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.

183 lines
6.2 KiB

  1. // job.cpp : Implementation of DLL Exports.
  2. // You will need the NT SUR Beta 2 SDK or VC 4.2 in order to build this
  3. // project. This is because you will need MIDL 3.00.15 or higher and new
  4. // headers and libs. If you have VC 4.2 installed, then everything should
  5. // already be configured correctly.
  6. // Note: Proxy/Stub Information
  7. // To merge the proxy/stub code into the object DLL, add the file
  8. // dlldatax.c to the project. Make sure precompiled headers
  9. // are turned off for this file, and add _MERGE_PROXYSTUB to the
  10. // defines for the project.
  11. //
  12. // Modify the custom build rule for job.idl by adding the following
  13. // files to the Outputs. You can select all of the .IDL files by
  14. // expanding each project and holding Ctrl while clicking on each of them.
  15. // job_p.c
  16. // dlldata.c
  17. // To build a separate proxy/stub DLL,
  18. // run nmake -f jobps.mak in the project directory.
  19. #include "stdafx.h"
  20. #include "resource.h"
  21. #include "initguid.h"
  22. #include "wsb.h"
  23. #include "fsa.h"
  24. #include "job.h"
  25. #include "task.h"
  26. #include "hsmcrit.h"
  27. #include "hsmactn.h"
  28. #include "hsmacrsc.h"
  29. #include "hsmjob.h"
  30. #include "hsmjobcx.h"
  31. #include "hsmjobdf.h"
  32. #include "hsmjobwi.h"
  33. #include "hsmphase.h"
  34. #include "hsmpolcy.h"
  35. #include "hsmrule.h"
  36. #include "hsmrlstk.h"
  37. #include "hsmscan.h"
  38. #include "hsmsess.h"
  39. #include "hsmsesst.h"
  40. #include "dlldatax.h"
  41. #ifdef _MERGE_PROXYSTUB
  42. extern "C" HINSTANCE hProxyDll;
  43. #endif
  44. CComModule _Module;
  45. BEGIN_OBJECT_MAP(ObjectMap)
  46. OBJECT_ENTRY(CLSID_CHsmActionCopy, CHsmActionCopy)
  47. OBJECT_ENTRY(CLSID_CHsmActionDelete, CHsmActionDelete)
  48. OBJECT_ENTRY(CLSID_CHsmActionManage, CHsmActionManage)
  49. OBJECT_ENTRY(CLSID_CHsmActionMigrate, CHsmActionMigrate)
  50. OBJECT_ENTRY(CLSID_CHsmActionMove, CHsmActionMove)
  51. OBJECT_ENTRY(CLSID_CHsmActionOnResourcePreUnmanage, CHsmActionOnResourcePreUnmanage)
  52. OBJECT_ENTRY(CLSID_CHsmActionOnResourcePostUnmanage, CHsmActionOnResourcePostUnmanage)
  53. OBJECT_ENTRY(CLSID_CHsmActionOnResourcePreScanUnmanage, CHsmActionOnResourcePreScanUnmanage)
  54. OBJECT_ENTRY(CLSID_CHsmActionOnResourcePostValidate, CHsmActionOnResourcePostValidate)
  55. OBJECT_ENTRY(CLSID_CHsmActionOnResourcePreValidate, CHsmActionOnResourcePreValidate)
  56. OBJECT_ENTRY(CLSID_CHsmActionRecall, CHsmActionRecall)
  57. OBJECT_ENTRY(CLSID_CHsmActionRecycle, CHsmActionRecycle)
  58. OBJECT_ENTRY(CLSID_CHsmActionTruncate, CHsmActionTruncate)
  59. OBJECT_ENTRY(CLSID_CHsmActionUnmanage, CHsmActionUnmanage)
  60. OBJECT_ENTRY(CLSID_CHsmActionValidate, CHsmActionValidate)
  61. OBJECT_ENTRY(CLSID_CHsmCritAccessTime, CHsmCritAccessTime)
  62. OBJECT_ENTRY(CLSID_CHsmCritAlways, CHsmCritAlways)
  63. OBJECT_ENTRY(CLSID_CHsmCritCompressed, CHsmCritCompressed)
  64. OBJECT_ENTRY(CLSID_CHsmCritLinked, CHsmCritLinked)
  65. OBJECT_ENTRY(CLSID_CHsmCritMbit, CHsmCritMbit)
  66. OBJECT_ENTRY(CLSID_CHsmCritManageable, CHsmCritManageable)
  67. OBJECT_ENTRY(CLSID_CHsmCritMigrated, CHsmCritMigrated)
  68. OBJECT_ENTRY(CLSID_CHsmCritPremigrated, CHsmCritPremigrated)
  69. OBJECT_ENTRY(CLSID_CHsmCritGroup, CHsmCritGroup)
  70. OBJECT_ENTRY(CLSID_CHsmCritLogicalSize, CHsmCritLogicalSize)
  71. OBJECT_ENTRY(CLSID_CHsmCritModifyTime, CHsmCritModifyTime)
  72. OBJECT_ENTRY(CLSID_CHsmCritOwner, CHsmCritOwner)
  73. OBJECT_ENTRY(CLSID_CHsmCritPhysicalSize, CHsmCritPhysicalSize)
  74. OBJECT_ENTRY(CLSID_CHsmJob, CHsmJob)
  75. OBJECT_ENTRY(CLSID_CHsmJobContext, CHsmJobContext)
  76. OBJECT_ENTRY(CLSID_CHsmJobDef, CHsmJobDef)
  77. OBJECT_ENTRY(CLSID_CHsmJobWorkItem, CHsmJobWorkItem)
  78. OBJECT_ENTRY(CLSID_CHsmPhase, CHsmPhase)
  79. OBJECT_ENTRY(CLSID_CHsmPolicy, CHsmPolicy)
  80. OBJECT_ENTRY(CLSID_CHsmRule, CHsmRule)
  81. OBJECT_ENTRY(CLSID_CHsmRuleStack, CHsmRuleStack)
  82. OBJECT_ENTRY(CLSID_CHsmScanner, CHsmScanner)
  83. OBJECT_ENTRY(CLSID_CHsmSession, CHsmSession)
  84. OBJECT_ENTRY(CLSID_CHsmSessionTotals, CHsmSessionTotals)
  85. END_OBJECT_MAP()
  86. /////////////////////////////////////////////////////////////////////////////
  87. // DLL Entry Point
  88. extern "C"
  89. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  90. {
  91. lpReserved;
  92. #ifdef _MERGE_PROXYSTUB
  93. if (!PrxDllMain(hInstance, dwReason, lpReserved))
  94. return FALSE;
  95. #endif
  96. if (dwReason == DLL_PROCESS_ATTACH)
  97. {
  98. _Module.Init(ObjectMap, hInstance);
  99. DisableThreadLibraryCalls(hInstance);
  100. }
  101. else if (dwReason == DLL_PROCESS_DETACH)
  102. _Module.Term();
  103. return TRUE; // ok
  104. }
  105. /////////////////////////////////////////////////////////////////////////////
  106. // Used to determine whether the DLL can be unloaded by OLE
  107. STDAPI DllCanUnloadNow(void)
  108. {
  109. #ifdef _MERGE_PROXYSTUB
  110. if (PrxDllCanUnloadNow() != S_OK)
  111. return S_FALSE;
  112. #endif
  113. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  114. }
  115. /////////////////////////////////////////////////////////////////////////////
  116. // Returns a class factory to create an object of the requested type
  117. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  118. {
  119. #ifdef _MERGE_PROXYSTUB
  120. if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  121. return S_OK;
  122. #endif
  123. return _Module.GetClassObject(rclsid, riid, ppv);
  124. }
  125. /////////////////////////////////////////////////////////////////////////////
  126. // DllRegisterServer - Adds entries to the system registry
  127. STDAPI DllRegisterServer(void)
  128. {
  129. HRESULT hr;
  130. #ifdef _MERGE_PROXYSTUB
  131. HRESULT hRes = PrxDllRegisterServer();
  132. if (FAILED(hRes))
  133. return hRes;
  134. #endif
  135. // registers object, typelib and all interfaces in typelib
  136. // Not registering the Type Library right now
  137. hr = CoInitialize( 0 );
  138. if (SUCCEEDED(hr)) {
  139. hr = _Module.RegisterServer( FALSE );
  140. CoUninitialize( );
  141. }
  142. return( hr );
  143. }
  144. /////////////////////////////////////////////////////////////////////////////
  145. // DllUnregisterServer - Removes entries from the system registry
  146. STDAPI DllUnregisterServer(void)
  147. {
  148. HRESULT hr;
  149. #ifdef _MERGE_PROXYSTUB
  150. PrxDllUnregisterServer();
  151. #endif
  152. hr = CoInitialize( 0 );
  153. if (SUCCEEDED(hr)) {
  154. _Module.UnregisterServer();
  155. CoUninitialize( );
  156. hr = S_OK;
  157. }
  158. return( hr );
  159. }