Source code of Windows XP (NT5)
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.

161 lines
4.3 KiB

  1. /*++
  2. Module Name:
  3. Rms.cpp
  4. Abstract:
  5. DLL main for Rms
  6. Author:
  7. Ran Kalach [rankala] 14-June-1999
  8. Revision History:
  9. --*/
  10. // Rms.cpp : Implementation of DLL Exports.
  11. // Note: Currently, Rms proxy/stub is compiled into a different DLL.
  12. // Below is relevant information if it is decided to merge the two DLLs.
  13. // Note: Proxy/Stub Information
  14. // To merge the proxy/stub code into the object DLL, add the file
  15. // dlldatax.c to the project. Make sure precompiled headers
  16. // are turned off for this file, and add _MERGE_PROXYSTUB to the
  17. // defines for the project.
  18. //
  19. // If you are not running WinNT4.0 or Win95 with DCOM, then you
  20. // need to remove the following define from dlldatax.c
  21. // #define _WIN32_WINNT 0x0400
  22. //
  23. // Further, if you are running MIDL without /Oicf switch, you also
  24. // need to remove the following define from dlldatax.c.
  25. // #define USE_STUBLESS_PROXY
  26. //
  27. // Modify the custom build rule for rmsint.idl by adding the following
  28. // files to the Outputs.
  29. // rmsint_p.c
  30. // dlldata.c
  31. // To build a separate proxy/stub DLL,
  32. // run nmake -f rmsps.mk in the project directory.
  33. #include "stdafx.h"
  34. #include "initguid.h"
  35. #include "RmsServr.h"
  36. #include "RmsLibry.h"
  37. #include "RmsDrCls.h"
  38. #include "RmsCartg.h"
  39. #include "RmsDrive.h"
  40. #include "RmsSSlot.h"
  41. #include "RmsChngr.h"
  42. #include "RmsIPort.h"
  43. #include "RmsMdSet.h"
  44. #include "RmsReqst.h"
  45. #include "RmsPartn.h"
  46. #include "RmsClien.h"
  47. #include "RmsNTMS.h"
  48. #ifdef _MERGE_PROXYSTUB
  49. extern "C" HINSTANCE hProxyDll;
  50. #endif
  51. CComModule _Module;
  52. BEGIN_OBJECT_MAP(ObjectMap)
  53. OBJECT_ENTRY(CLSID_CRmsServer, CRmsServer)
  54. OBJECT_ENTRY(CLSID_CRmsLibrary, CRmsLibrary)
  55. OBJECT_ENTRY(CLSID_CRmsDriveClass, CRmsDriveClass)
  56. OBJECT_ENTRY(CLSID_CRmsCartridge, CRmsCartridge)
  57. OBJECT_ENTRY(CLSID_CRmsDrive, CRmsDrive)
  58. OBJECT_ENTRY(CLSID_CRmsStorageSlot, CRmsStorageSlot)
  59. OBJECT_ENTRY(CLSID_CRmsMediumChanger, CRmsMediumChanger)
  60. OBJECT_ENTRY(CLSID_CRmsIEPort, CRmsIEPort)
  61. OBJECT_ENTRY(CLSID_CRmsMediaSet, CRmsMediaSet)
  62. OBJECT_ENTRY(CLSID_CRmsRequest, CRmsRequest)
  63. OBJECT_ENTRY(CLSID_CRmsPartition, CRmsPartition)
  64. OBJECT_ENTRY(CLSID_CRmsClient, CRmsClient)
  65. OBJECT_ENTRY(CLSID_CRmsNTMS, CRmsNTMS)
  66. END_OBJECT_MAP()
  67. /////////////////////////////////////////////////////////////////////////////
  68. // DLL Entry Point
  69. extern "C"
  70. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  71. {
  72. lpReserved;
  73. #ifdef _MERGE_PROXYSTUB
  74. if (!PrxDllMain(hInstance, dwReason, lpReserved))
  75. return FALSE;
  76. #endif
  77. if (dwReason == DLL_PROCESS_ATTACH)
  78. {
  79. _Module.Init(ObjectMap, hInstance);
  80. DisableThreadLibraryCalls(hInstance);
  81. }
  82. else if (dwReason == DLL_PROCESS_DETACH)
  83. _Module.Term();
  84. return TRUE; // ok
  85. }
  86. /////////////////////////////////////////////////////////////////////////////
  87. // Used to determine whether the DLL can be unloaded by OLE
  88. STDAPI DllCanUnloadNow(void)
  89. {
  90. #ifdef _MERGE_PROXYSTUB
  91. if (PrxDllCanUnloadNow() != S_OK)
  92. return S_FALSE;
  93. #endif
  94. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  95. }
  96. /////////////////////////////////////////////////////////////////////////////
  97. // Returns a class factory to create an object of the requested type
  98. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  99. {
  100. #ifdef _MERGE_PROXYSTUB
  101. if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  102. return S_OK;
  103. #endif
  104. return _Module.GetClassObject(rclsid, riid, ppv);
  105. }
  106. /////////////////////////////////////////////////////////////////////////////
  107. // DllRegisterServer - Adds entries to the system registry
  108. STDAPI DllRegisterServer(void)
  109. {
  110. #ifdef _MERGE_PROXYSTUB
  111. HRESULT hRes = PrxDllRegisterServer();
  112. if (FAILED(hRes))
  113. return hRes;
  114. #endif
  115. // registers object, typelib and all interfaces in typelib
  116. CoInitialize( 0 );
  117. HRESULT hr = _Module.RegisterServer( FALSE );
  118. CoUninitialize( );
  119. return( hr );
  120. }
  121. /////////////////////////////////////////////////////////////////////////////
  122. // DllUnregisterServer - Removes entries from the system registry
  123. STDAPI DllUnregisterServer(void)
  124. {
  125. #ifdef _MERGE_PROXYSTUB
  126. PrxDllUnregisterServer();
  127. #endif
  128. CoInitialize( 0 );
  129. _Module.UnregisterServer();
  130. CoUninitialize( );
  131. return( S_OK );
  132. }