Leaked source code of windows server 2003
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.

93 lines
2.4 KiB

  1. /*++
  2. Copyright (c) 1996, 1997 Microsoft Corporation
  3. Module Name:
  4. certprot.cpp
  5. Abstract:
  6. This module contains routines associated with server side
  7. I_CertProtectFunctions operations.
  8. Author:
  9. Phil Hallin (philh) 19-Nov-97
  10. --*/
  11. #include <windows.h>
  12. #include <wincrypt.h>
  13. #include "cerrpc.h" // header file generated by MIDL compiler
  14. #include "certprot.h"
  15. ///////////////////////////////////////////////////////////////////////
  16. // LPC-exposed functions
  17. //
  18. // these functions return a DWORD equivalent to GetLastError().
  19. // the client side stub code will check if the return code is not
  20. // ERROR_SUCCESS, and if this is the case, the client stub will return
  21. // FALSE and SetLastError() to this DWORD.
  22. //
  23. DWORD s_SSCertProtectFunction(
  24. /* [in] */ handle_t h,
  25. /* [in] */ DWORD dwFuncId,
  26. /* [in] */ DWORD dwFlags,
  27. /* [in] */ LPCWSTR pwszIn,
  28. /* [size_is][in] */ BYTE __RPC_FAR *pbIn,
  29. /* [in] */ DWORD cbIn,
  30. /* [size_is][size_is][out] */ BYTE __RPC_FAR *__RPC_FAR *ppbOut,
  31. /* [out] */ DWORD __RPC_FAR *pcbOut)
  32. {
  33. DWORD dwRet;
  34. __try {
  35. {
  36. HINSTANCE hCrypt32Dll;
  37. PFN_CERT_SRV_PROTECT_FUNCTION pfnCertSrvProtectFunction;
  38. *ppbOut = NULL;
  39. *pcbOut = 0;
  40. hCrypt32Dll = LoadLibraryW(L"crypt32.dll");
  41. if (hCrypt32Dll == NULL) {
  42. dwRet = GetLastError();
  43. goto Ret;
  44. }
  45. if (NULL == (pfnCertSrvProtectFunction =
  46. (PFN_CERT_SRV_PROTECT_FUNCTION) GetProcAddress(
  47. hCrypt32Dll, "I_CertSrvProtectFunction")))
  48. dwRet = ERROR_PROC_NOT_FOUND;
  49. else
  50. dwRet = pfnCertSrvProtectFunction(
  51. h,
  52. dwFuncId,
  53. dwFlags,
  54. pwszIn,
  55. pbIn,
  56. cbIn,
  57. ppbOut,
  58. pcbOut,
  59. midl_user_allocate,
  60. midl_user_free
  61. );
  62. FreeLibrary(hCrypt32Dll);
  63. goto Ret;
  64. }
  65. } __except( EXCEPTION_EXECUTE_HANDLER ) {
  66. dwRet = GetExceptionCode();
  67. // TODO: for NT, convert exception code to winerror.
  68. // for 95, just override to access violation.
  69. }
  70. Ret:
  71. return dwRet;
  72. }