Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
2.3 KiB

  1. /*++
  2. Copyright (C) 2000 Microsoft Corporation
  3. Module Name:
  4. dpapistb.cpp
  5. Abstract:
  6. RPC Proxy Stub to handle downlevel requests to the services.exe
  7. pipe
  8. Author:
  9. petesk 3/1/00
  10. Revisions:
  11. --*/
  12. #define _CRYPT32_ // use correct Dll Linkage
  13. #include <nt.h>
  14. #include <ntrtl.h>
  15. #include <nturtl.h>
  16. #include <windows.h>
  17. #include <wincrypt.h>
  18. // midl generated files
  19. #include "dpapiprv.h"
  20. #include "keyrpc.h"
  21. DWORD
  22. s_BackuprKey(
  23. /* [in] */ handle_t h,
  24. /* [in] */ GUID __RPC_FAR *pguidActionAgent,
  25. /* [in] */ BYTE __RPC_FAR *pDataIn,
  26. /* [in] */ DWORD cbDataIn,
  27. /* [size_is][size_is][out] */ BYTE __RPC_FAR *__RPC_FAR *ppDataOut,
  28. /* [out] */ DWORD __RPC_FAR *pcbDataOut,
  29. /* [in] */ DWORD dwParam
  30. )
  31. {
  32. RPC_BINDING_HANDLE hProxy = NULL;
  33. WCHAR *pStringBinding = NULL;
  34. RPC_SECURITY_QOS RpcQos;
  35. RPC_STATUS RpcStatus = RPC_S_OK;
  36. RpcStatus = RpcImpersonateClient(h);
  37. if (RPC_S_OK != RpcStatus)
  38. {
  39. return RpcStatus;
  40. }
  41. RpcStatus = RpcStringBindingComposeW(
  42. NULL,
  43. DPAPI_LOCAL_PROT_SEQ,
  44. NULL,
  45. DPAPI_LOCAL_ENDPOINT,
  46. NULL,
  47. &pStringBinding);
  48. if (RPC_S_OK != RpcStatus)
  49. {
  50. goto error;
  51. }
  52. RpcStatus = RpcBindingFromStringBindingW(
  53. pStringBinding,
  54. &hProxy);
  55. if (NULL != pStringBinding)
  56. {
  57. RpcStringFreeW(&pStringBinding);
  58. }
  59. if (RPC_S_OK != RpcStatus)
  60. {
  61. goto error;
  62. }
  63. RpcStatus = RpcEpResolveBinding(
  64. hProxy,
  65. BackupKey_v1_0_c_ifspec);
  66. if (RPC_S_OK != RpcStatus)
  67. {
  68. goto error;
  69. }
  70. __try
  71. {
  72. RpcStatus = BackuprKey(
  73. hProxy,
  74. (GUID*)pguidActionAgent,
  75. pDataIn,
  76. cbDataIn,
  77. ppDataOut,
  78. pcbDataOut,
  79. dwParam
  80. );
  81. }
  82. __except ( EXCEPTION_EXECUTE_HANDLER )
  83. {
  84. RpcStatus = _exception_code();
  85. }
  86. error:
  87. if(hProxy)
  88. {
  89. RpcBindingFree(&hProxy);
  90. }
  91. RpcRevertToSelf();
  92. return RpcStatus;
  93. }