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.

158 lines
3.8 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved.
  3. Module Name:
  4. Mover.cpp
  5. Abstract:
  6. Data Mover defines
  7. Author:
  8. Brian Dodd [brian] 01-Apr-1997
  9. Revision History:
  10. --*/
  11. // Mover.cpp : Implementation of DLL Exports.
  12. // Note: Proxy/Stub Information
  13. // To merge the proxy/stub code into the object DLL, add the file
  14. // dlldatax.c to the project. Make sure precompiled headers
  15. // are turned off for this file, and add _MERGE_PROXYSTUB to the
  16. // defines for the project.
  17. //
  18. // If you are not running WinNT4.0 or Win95 with DCOM, then you
  19. // need to remove the following define from dlldatax.c
  20. // #define _WIN32_WINNT 0x0400
  21. //
  22. // Further, if you are running MIDL without /Oicf switch, you also
  23. // need to remove the following define from dlldatax.c.
  24. // #define USE_STUBLESS_PROXY
  25. //
  26. // Modify the custom build rule for Mover.idl by adding the following
  27. // files to the Outputs.
  28. // Mover_p.c
  29. // dlldata.c
  30. // To build a separate proxy/stub DLL,
  31. // run nmake -f Moverps.mk in the project directory.
  32. #include "stdafx.h"
  33. #include "resource.h"
  34. #include "initguid.h"
  35. #include "Mover.h"
  36. #include "dlldatax.h"
  37. #include "NtTapeIo.h"
  38. #include "NtFileIo.h"
  39. #include "FilterIo.h"
  40. #ifdef _MERGE_PROXYSTUB
  41. extern "C" HINSTANCE hProxyDll;
  42. #endif
  43. CComModule _Module;
  44. BEGIN_OBJECT_MAP(ObjectMap)
  45. OBJECT_ENTRY(CLSID_CNtTapeIo, CNtTapeIo)
  46. OBJECT_ENTRY(CLSID_CNtFileIo, CNtFileIo)
  47. OBJECT_ENTRY(CLSID_CFilterIo, CFilterIo)
  48. END_OBJECT_MAP()
  49. /////////////////////////////////////////////////////////////////////////////
  50. // DLL Entry Point
  51. extern "C"
  52. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  53. {
  54. lpReserved;
  55. #ifdef _MERGE_PROXYSTUB
  56. if (!PrxDllMain(hInstance, dwReason, lpReserved))
  57. return FALSE;
  58. #endif
  59. if (dwReason == DLL_PROCESS_ATTACH)
  60. {
  61. _Module.Init(ObjectMap, hInstance);
  62. DisableThreadLibraryCalls(hInstance);
  63. }
  64. else if (dwReason == DLL_PROCESS_DETACH)
  65. _Module.Term();
  66. return TRUE; // ok
  67. }
  68. /////////////////////////////////////////////////////////////////////////////
  69. // Used to determine whether the DLL can be unloaded by OLE
  70. STDAPI DllCanUnloadNow(void)
  71. {
  72. #ifdef _MERGE_PROXYSTUB
  73. if (PrxDllCanUnloadNow() != S_OK)
  74. return S_FALSE;
  75. #endif
  76. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  77. }
  78. /////////////////////////////////////////////////////////////////////////////
  79. // Returns a class factory to create an object of the requested type
  80. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  81. {
  82. #ifdef _MERGE_PROXYSTUB
  83. if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  84. return S_OK;
  85. #endif
  86. return _Module.GetClassObject(rclsid, riid, ppv);
  87. }
  88. /////////////////////////////////////////////////////////////////////////////
  89. // DllRegisterServer - Adds entries to the system registry
  90. STDAPI DllRegisterServer(void)
  91. {
  92. HRESULT hr;
  93. #ifdef _MERGE_PROXYSTUB
  94. HRESULT hRes = PrxDllRegisterServer();
  95. if (FAILED(hRes))
  96. return hRes;
  97. #endif
  98. // registers object, typelib and all interfaces in typelib
  99. hr = CoInitialize( 0 );
  100. if (SUCCEEDED(hr)) {
  101. hr = _Module.RegisterServer( FALSE );
  102. CoUninitialize( );
  103. }
  104. return( hr );
  105. }
  106. /////////////////////////////////////////////////////////////////////////////
  107. // DllUnregisterServer - Removes entries from the system registry
  108. STDAPI DllUnregisterServer(void)
  109. {
  110. HRESULT hr;
  111. #ifdef _MERGE_PROXYSTUB
  112. PrxDllUnregisterServer();
  113. #endif
  114. hr = CoInitialize( 0 );
  115. if (SUCCEEDED(hr)) {
  116. _Module.UnregisterServer();
  117. CoUninitialize( );
  118. hr = S_OK;
  119. }
  120. return( hr );
  121. }