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.

102 lines
2.9 KiB

  1. // dllmain.cpp : Implementation of DLL Exports.
  2. // Note: Proxy/Stub Information
  3. // To build a separate proxy/stub DLL,
  4. // run nmake -f imsgps.mk in the project directory.
  5. #include "stdafx.h"
  6. #include "resource.h"
  7. #include "initguid.h"
  8. #include "filehc.h"
  9. #include "mailmsg.h"
  10. #include "seo.h"
  11. #include "ntfs.h"
  12. CComModule _Module;
  13. BEGIN_OBJECT_MAP(ObjectMap)
  14. OBJECT_ENTRY(CLSID_NtfsStoreDriver, CNtfsStoreDriver)
  15. OBJECT_ENTRY(CLSID_NtfsEnumMessages, CNtfsEnumMessages)
  16. OBJECT_ENTRY(CLSID_NtfsPropertyStream, CNtfsPropertyStream)
  17. END_OBJECT_MAP()
  18. /////////////////////////////////////////////////////////////////////////////
  19. // DLL Entry Point
  20. extern "C"
  21. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  22. {
  23. if (dwReason == DLL_PROCESS_ATTACH)
  24. {
  25. TrHeapCreate();
  26. _Module.Init(ObjectMap, hInstance);
  27. DisableThreadLibraryCalls(hInstance);
  28. //Initialize the critical section used to control access to the
  29. //global ntfsstore driver instance list
  30. InitializeCriticalSection(&CNtfsStoreDriver::sm_csLockInstList);
  31. //Init the head of the list
  32. InitializeListHead(&CNtfsStoreDriver::sm_ListHead);
  33. // initialize eventlogging
  34. CNtfsStoreDriver::g_pEventLog = new CEventLogWrapper();
  35. if (CNtfsStoreDriver::g_pEventLog)
  36. CNtfsStoreDriver::g_pEventLog->Initialize("smtpsvc");
  37. }
  38. else if (dwReason == DLL_PROCESS_DETACH)
  39. {
  40. _Module.Term();
  41. if (CNtfsStoreDriver::g_pEventLog)
  42. {
  43. delete CNtfsStoreDriver::g_pEventLog;
  44. CNtfsStoreDriver::g_pEventLog = NULL;
  45. }
  46. TrHeapDestroy();
  47. DeleteCriticalSection(&CNtfsStoreDriver::sm_csLockInstList);
  48. }
  49. return TRUE; // ok
  50. }
  51. /////////////////////////////////////////////////////////////////////////////
  52. // Used to determine whether the DLL can be unloaded by OLE
  53. STDAPI DllCanUnloadNow(void)
  54. {
  55. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  56. }
  57. /////////////////////////////////////////////////////////////////////////////
  58. // Returns a class factory to create an object of the requested type
  59. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  60. {
  61. return _Module.GetClassObject(rclsid, riid, ppv);
  62. }
  63. /////////////////////////////////////////////////////////////////////////////
  64. // DllRegisterServer - Adds entries to the system registry
  65. STDAPI DllRegisterServer(void)
  66. {
  67. // registers object, typelib and all interfaces in typelib
  68. return _Module.RegisterServer(TRUE);
  69. }
  70. /////////////////////////////////////////////////////////////////////////////
  71. // DllUnregisterServer - Removes entries from the system registry
  72. STDAPI DllUnregisterServer(void)
  73. {
  74. _Module.UnregisterServer();
  75. return S_OK;
  76. }