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.

103 lines
2.6 KiB

  1. //--------------------------------------------------------------
  2. // Copyright (C) Microsoft Corporation, 1996 - 1999
  3. //
  4. // File: cryptext.cpp
  5. //
  6. // Contents: Implements
  7. // 1) DllMain, DLLCanUnloadNow, and DLLGetClassObject
  8. // 2) the class factory code
  9. //
  10. // Note: Proxy/Stub Information
  11. // To build a separate proxy/stub DLL,
  12. // run nmake -f cryptextps.mk in the project directory.
  13. //
  14. // History: 16-09-1997 xiaohs created
  15. //
  16. //--------------------------------------------------------------
  17. #include "stdafx.h"
  18. #include <shlobj.h>
  19. #include "initguid.h"
  20. #include "cryptext.h"
  21. #include "cryptext_i.c"
  22. #include "private.h"
  23. #include "CryptPKO.h"
  24. #include "CryptSig.h"
  25. HINSTANCE g_hmodThisDll = NULL; // Handle to this DLL itself.
  26. CComModule _Module;
  27. BEGIN_OBJECT_MAP(ObjectMap)
  28. OBJECT_ENTRY(CLSID_CryptPKO, CCryptPKO)
  29. OBJECT_ENTRY(CLSID_CryptSig, CCryptSig)
  30. END_OBJECT_MAP()
  31. /////////////////////////////////////////////////////////////////////////////
  32. // DLL Entry Point
  33. extern "C"
  34. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  35. {
  36. if (dwReason == DLL_PROCESS_ATTACH)
  37. {
  38. _Module.Init(ObjectMap, hInstance);
  39. DisableThreadLibraryCalls(hInstance);
  40. g_hmodThisDll=hInstance;
  41. }
  42. else if (dwReason == DLL_PROCESS_DETACH)
  43. _Module.Term();
  44. return TRUE; // ok
  45. }
  46. /////////////////////////////////////////////////////////////////////////////
  47. // Used to determine whether the DLL can be unloaded by OLE
  48. STDAPI DllCanUnloadNow(void)
  49. {
  50. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  51. }
  52. /////////////////////////////////////////////////////////////////////////////
  53. // Returns a class factory to create an object of the requested type
  54. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  55. {
  56. return _Module.GetClassObject(rclsid, riid, ppv);
  57. }
  58. /////////////////////////////////////////////////////////////////////////////
  59. // DllRegisterServer - Adds entries to the system registry
  60. STDAPI DllRegisterServer(void)
  61. {
  62. HRESULT hr=S_OK;
  63. // registers object, typelib and all interfaces in typelib
  64. if(S_OK !=(hr= _Module.RegisterServer(TRUE)))
  65. return hr;
  66. //register the entries for the MIME handler
  67. return RegisterMimeHandler();
  68. }
  69. /////////////////////////////////////////////////////////////////////////////
  70. // DllUnregisterServer - Removes entries from the system registry
  71. STDAPI DllUnregisterServer(void)
  72. {
  73. UnregisterMimeHandler();
  74. _Module.UnregisterServer();
  75. return S_OK;
  76. }