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.

98 lines
2.3 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1999
  5. //
  6. // File: certxds.cpp
  7. //
  8. // Contents: Cert Server Exit Module implementation
  9. //
  10. //---------------------------------------------------------------------------
  11. #include "pch.cpp"
  12. #pragma hdrstop
  13. #include "exit.h"
  14. #include "module.h"
  15. CComModule _Module;
  16. BEGIN_OBJECT_MAP(ObjectMap)
  17. OBJECT_ENTRY(CLSID_CCertExit, CCertExit)
  18. OBJECT_ENTRY(CLSID_CCertManageExitModule, CCertManageExitModule)
  19. END_OBJECT_MAP()
  20. HINSTANCE g_hInstance = NULL;
  21. /////////////////////////////////////////////////////////////////////////////
  22. // DLL Entry Point
  23. extern "C"
  24. BOOL WINAPI
  25. DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  26. {
  27. switch (dwReason)
  28. {
  29. case DLL_PROCESS_ATTACH:
  30. _Module.Init(ObjectMap, hInstance);
  31. g_hInstance = hInstance;
  32. DisableThreadLibraryCalls(hInstance);
  33. break;
  34. case DLL_PROCESS_DETACH:
  35. _Module.Term();
  36. break;
  37. }
  38. return(TRUE); // ok
  39. }
  40. /////////////////////////////////////////////////////////////////////////////
  41. // Used to determine whether the DLL can be unloaded by OLE
  42. STDAPI
  43. DllCanUnloadNow(void)
  44. {
  45. return(_Module.GetLockCount() == 0? S_OK : S_FALSE);
  46. }
  47. /////////////////////////////////////////////////////////////////////////////
  48. // Returns a class factory to create an object of the requested type
  49. STDAPI
  50. DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  51. {
  52. HRESULT hr;
  53. hr = _Module.GetClassObject(rclsid, riid, ppv);
  54. if (S_OK == hr && NULL != *ppv)
  55. {
  56. myRegisterMemFree(*ppv, CSM_NEW | CSM_GLOBALDESTRUCTOR);
  57. }
  58. return(hr);
  59. }
  60. /////////////////////////////////////////////////////////////////////////////
  61. // DllRegisterServer - Adds entries to the system registry
  62. STDAPI
  63. DllRegisterServer(void)
  64. {
  65. // registers object, typelib and all interfaces in typelib
  66. return(_Module.RegisterServer(TRUE));
  67. }
  68. /////////////////////////////////////////////////////////////////////////////
  69. // DllUnregisterServer - Removes entries from the system registry
  70. STDAPI
  71. DllUnregisterServer(void)
  72. {
  73. _Module.UnregisterServer();
  74. return(S_OK);
  75. }