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.

173 lines
4.5 KiB

  1. /*++
  2. Module Name:
  3. fsa.cpp
  4. Abstract:
  5. DLL main for Fsa
  6. Author:
  7. Ran Kalach [rankala] 28-July-1999
  8. Revision History:
  9. --*/
  10. // fsa.cpp : Implementation of DLL Exports.
  11. // Note: Currently, Fsa 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 ...int.idl by adding the following
  28. // files to the Outputs.
  29. // ...
  30. // dlldata.c
  31. // To build a separate proxy/stub DLL,
  32. // run nmake -f ...ps.mk in the project directory.
  33. #include "stdafx.h"
  34. #include "initguid.h"
  35. #include "fsa.h"
  36. #include "fsafltr.h"
  37. #include "fsaftclt.h"
  38. #include "fsaftrcl.h"
  39. #include "fsaitem.h"
  40. #include "fsaprem.h"
  41. #include "fsaunmdb.h"
  42. #include "fsarcvy.h"
  43. #include "fsarsc.h"
  44. #include "fsasrvr.h"
  45. #include "fsatrunc.h"
  46. #include "fsapost.h"
  47. #include "task.h"
  48. #include <stdio.h>
  49. #ifdef _MERGE_PROXYSTUB
  50. extern "C" HINSTANCE hProxyDll;
  51. #endif
  52. CComModule _Module;
  53. BEGIN_OBJECT_MAP(ObjectMap)
  54. OBJECT_ENTRY(CLSID_CFsaFilterClientNTFS, CFsaFilterClient)
  55. OBJECT_ENTRY(CLSID_CFsaFilterNTFS, CFsaFilter)
  56. OBJECT_ENTRY(CLSID_CFsaFilterRecallNTFS, CFsaFilterRecall)
  57. OBJECT_ENTRY(CLSID_CFsaPostIt, CFsaPostIt)
  58. OBJECT_ENTRY(CLSID_CFsaPremigratedDb, CFsaPremigratedDb)
  59. OBJECT_ENTRY(CLSID_CFsaPremigratedRec, CFsaPremigratedRec)
  60. OBJECT_ENTRY(CLSID_CFsaRecoveryRec, CFsaRecoveryRec)
  61. OBJECT_ENTRY(CLSID_CFsaResourceNTFS, CFsaResource)
  62. OBJECT_ENTRY(CLSID_CFsaScanItemNTFS, CFsaScanItem)
  63. OBJECT_ENTRY(CLSID_CFsaServerNTFS, CFsaServer)
  64. OBJECT_ENTRY(CLSID_CFsaTruncatorNTFS, CFsaTruncator)
  65. OBJECT_ENTRY(CLSID_CFsaUnmanageDb, CFsaUnmanageDb)
  66. OBJECT_ENTRY(CLSID_CFsaUnmanageRec, CFsaUnmanageRec)
  67. END_OBJECT_MAP()
  68. /////////////////////////////////////////////////////////////////////////////
  69. // DLL Entry Point
  70. extern "C"
  71. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  72. {
  73. lpReserved;
  74. #ifdef _MERGE_PROXYSTUB
  75. if (!PrxDllMain(hInstance, dwReason, lpReserved))
  76. return FALSE;
  77. #endif
  78. if (dwReason == DLL_PROCESS_ATTACH)
  79. {
  80. _Module.Init(ObjectMap, hInstance);
  81. DisableThreadLibraryCalls(hInstance);
  82. }
  83. else if (dwReason == DLL_PROCESS_DETACH)
  84. _Module.Term();
  85. return TRUE; // ok
  86. }
  87. /////////////////////////////////////////////////////////////////////////////
  88. // Used to determine whether the DLL can be unloaded by OLE
  89. STDAPI DllCanUnloadNow(void)
  90. {
  91. #ifdef _MERGE_PROXYSTUB
  92. if (PrxDllCanUnloadNow() != S_OK)
  93. return S_FALSE;
  94. #endif
  95. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  96. }
  97. /////////////////////////////////////////////////////////////////////////////
  98. // Returns a class factory to create an object of the requested type
  99. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  100. {
  101. #ifdef _MERGE_PROXYSTUB
  102. if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  103. return S_OK;
  104. #endif
  105. return _Module.GetClassObject(rclsid, riid, ppv);
  106. }
  107. /////////////////////////////////////////////////////////////////////////////
  108. // DllRegisterServer - Adds entries to the system registry
  109. STDAPI DllRegisterServer(void)
  110. {
  111. HRESULT hr;
  112. #ifdef _MERGE_PROXYSTUB
  113. HRESULT hRes = PrxDllRegisterServer();
  114. if (FAILED(hRes))
  115. return hRes;
  116. #endif
  117. // registers object, typelib and all interfaces in typelib
  118. hr = CoInitialize( 0 );
  119. if (SUCCEEDED(hr)) {
  120. hr = _Module.RegisterServer( FALSE );
  121. CoUninitialize( );
  122. }
  123. return( hr );
  124. }
  125. /////////////////////////////////////////////////////////////////////////////
  126. // DllUnregisterServer - Removes entries from the system registry
  127. STDAPI DllUnregisterServer(void)
  128. {
  129. HRESULT hr;
  130. #ifdef _MERGE_PROXYSTUB
  131. PrxDllUnregisterServer();
  132. #endif
  133. hr = CoInitialize( 0 );
  134. if (SUCCEEDED(hr)) {
  135. _Module.UnregisterServer();
  136. CoUninitialize( );
  137. hr = S_OK;
  138. }
  139. return(hr);
  140. }