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.

116 lines
2.7 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1999
  5. //
  6. // File: certenc.cpp
  7. //
  8. // Contents: Cert Server encode/decode support
  9. //
  10. //---------------------------------------------------------------------------
  11. #include "pch.cpp"
  12. #pragma hdrstop
  13. #include "celib.h"
  14. #include "resource.h"
  15. #include "certenc.h"
  16. #include "adate.h"
  17. #include "along.h"
  18. #include "astring.h"
  19. #include "crldist.h"
  20. #include "altname.h"
  21. #include "bitstr.h"
  22. CComModule _Module;
  23. HMODULE g_hModule;
  24. BEGIN_OBJECT_MAP(ObjectMap)
  25. OBJECT_ENTRY(CLSID_CCertEncodeDateArray, CCertEncodeDateArray)
  26. OBJECT_ENTRY(CLSID_CCertEncodeLongArray, CCertEncodeLongArray)
  27. OBJECT_ENTRY(CLSID_CCertEncodeStringArray, CCertEncodeStringArray)
  28. OBJECT_ENTRY(CLSID_CCertEncodeCRLDistInfo, CCertEncodeCRLDistInfo)
  29. OBJECT_ENTRY(CLSID_CCertEncodeAltName, CCertEncodeAltName)
  30. OBJECT_ENTRY(CLSID_CCertEncodeBitString, CCertEncodeBitString)
  31. END_OBJECT_MAP()
  32. /////////////////////////////////////////////////////////////////////////////
  33. // DLL Entry Point
  34. extern "C"
  35. BOOL WINAPI
  36. DllMain(
  37. HINSTANCE hInstance,
  38. DWORD dwReason,
  39. VOID * /* lpReserved */ )
  40. {
  41. g_hModule = hInstance;
  42. if (DLL_PROCESS_ATTACH == dwReason)
  43. {
  44. ceInitErrorMessageText(
  45. hInstance,
  46. IDS_E_UNEXPECTED,
  47. IDS_UNKNOWN_ERROR_CODE);
  48. _Module.Init(ObjectMap, hInstance);
  49. DisableThreadLibraryCalls(hInstance);
  50. }
  51. if (DLL_PROCESS_DETACH == dwReason)
  52. {
  53. _Module.Term();
  54. }
  55. return(TRUE);
  56. }
  57. /////////////////////////////////////////////////////////////////////////////
  58. // Used to determine whether the DLL can be unloaded by OLE
  59. STDAPI
  60. DllCanUnloadNow(VOID)
  61. {
  62. HRESULT hr;
  63. hr = 0 == _Module.GetLockCount()? S_OK : S_FALSE;
  64. return(hr);
  65. }
  66. /////////////////////////////////////////////////////////////////////////////
  67. // Returns a class factory to create an object of the requested type
  68. STDAPI
  69. DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  70. {
  71. HRESULT hr;
  72. hr = _Module.GetClassObject(rclsid, riid, ppv);
  73. return(hr);
  74. }
  75. /////////////////////////////////////////////////////////////////////////////
  76. // DllRegisterServer - Adds entries to the system registry
  77. STDAPI
  78. DllRegisterServer(VOID)
  79. {
  80. HRESULT hr;
  81. // registers object, typelib and all interfaces in typelib
  82. hr = _Module.RegisterServer(TRUE);
  83. return(hr);
  84. }
  85. /////////////////////////////////////////////////////////////////////////////
  86. // DllUnregisterServer - Removes entries from the system registry
  87. STDAPI
  88. DllUnregisterServer(VOID)
  89. {
  90. _Module.UnregisterServer();
  91. return(S_OK);
  92. }