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.

156 lines
4.8 KiB

  1. /*---------------------------------------------------------------------------
  2. File: WorkerObjects.cpp
  3. Comments: Library of COM objects to perform DCT tasks
  4. This file was mostly generated by the ATL wizard.
  5. (c) Copyright 1999, Mission Critical Software, Inc., All Rights Reserved
  6. Proprietary and confidential to Mission Critical Software, Inc.
  7. REVISION LOG ENTRY
  8. Revision By: Christy Boles
  9. Revised on 02/18/99 11:34:16
  10. ---------------------------------------------------------------------------
  11. */// WorkerObjects.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 WorkerObjects.idl by adding the following
  27. // files to the Outputs.
  28. // WorkerObjects_p.c
  29. // dlldata.c
  30. // To build a separate proxy/stub DLL,
  31. // run nmake -f WorkerObjectsps.mk in the project directory.
  32. #include "stdafx.h"
  33. #include "resource.h"
  34. #include <initguid.h>
  35. #include "WorkObj.h"
  36. #include "dlldatax.h"
  37. #include "WorkObj_i.c"
  38. #include "AcctRepl.h"
  39. #include "PwdAge.h"
  40. #include "Reboot.h"
  41. #include "ChDom.h"
  42. #include "Rename.h"
  43. #include "StatObj.h"
  44. #include "UserRts.h"
  45. #include "SecTrans.h"
  46. #include "Checker.h"
  47. #include "PlugInfo.h"
  48. #include "ResStr.h"
  49. StringLoader gString;
  50. #ifdef _MERGE_PROXYSTUB
  51. extern "C" HINSTANCE hProxyDll;
  52. #endif
  53. CComModule _Module;
  54. BEGIN_OBJECT_MAP(ObjectMap)
  55. OBJECT_ENTRY(CLSID_AcctRepl, CAcctRepl)
  56. OBJECT_ENTRY(CLSID_ComputerPwdAge, CComputerPwdAge)
  57. OBJECT_ENTRY(CLSID_RebootComputer, CRebootComputer)
  58. OBJECT_ENTRY(CLSID_ChangeDomain, CChangeDomain)
  59. OBJECT_ENTRY(CLSID_RenameComputer, CRenameComputer)
  60. OBJECT_ENTRY(CLSID_StatusObj, CStatusObj)
  61. OBJECT_ENTRY(CLSID_UserRights, CUserRights)
  62. OBJECT_ENTRY(CLSID_SecTranslator, CSecTranslator)
  63. OBJECT_ENTRY(CLSID_AccessChecker, CAccessChecker)
  64. OBJECT_ENTRY(CLSID_PlugInInfo, CPlugInInfo)
  65. END_OBJECT_MAP()
  66. /////////////////////////////////////////////////////////////////////////////
  67. // DLL Entry Point
  68. extern "C"
  69. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  70. {
  71. lpReserved;
  72. #ifdef _MERGE_PROXYSTUB
  73. if (!PrxDllMain(hInstance, dwReason, lpReserved))
  74. return FALSE;
  75. #endif
  76. if (dwReason == DLL_PROCESS_ATTACH)
  77. {
  78. ATLTRACE(_T("{McsDctWorkerObjects.dll}DllMain(hInstance=0x%08lX, dwReason=DLL_PROCESS_ATTACH,...)\n"), hInstance);
  79. _Module.Init(ObjectMap, hInstance, &LIBID_MCSDCTWORKEROBJECTSLib);
  80. DisableThreadLibraryCalls(hInstance);
  81. _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF);
  82. }
  83. else if (dwReason == DLL_PROCESS_DETACH)
  84. {
  85. ATLTRACE(_T("{McsDctWorkerObjects.dll}DllMain(hInstance=0x%08lX, dwReason=DLL_PROCESS_DETACH,...)\n"), hInstance);
  86. _Module.Term();
  87. }
  88. return TRUE; // ok
  89. }
  90. /////////////////////////////////////////////////////////////////////////////
  91. // Used to determine whether the DLL can be unloaded by OLE
  92. STDAPI DllCanUnloadNow(void)
  93. {
  94. #ifdef _MERGE_PROXYSTUB
  95. if (PrxDllCanUnloadNow() != S_OK)
  96. return S_FALSE;
  97. #endif
  98. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  99. }
  100. /////////////////////////////////////////////////////////////////////////////
  101. // Returns a class factory to create an object of the requested type
  102. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  103. {
  104. #ifdef _MERGE_PROXYSTUB
  105. if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  106. return S_OK;
  107. #endif
  108. return _Module.GetClassObject(rclsid, riid, ppv);
  109. }
  110. /////////////////////////////////////////////////////////////////////////////
  111. // DllRegisterServer - Adds entries to the system registry
  112. STDAPI DllRegisterServer(void)
  113. {
  114. #ifdef _MERGE_PROXYSTUB
  115. HRESULT hRes = PrxDllRegisterServer();
  116. if (FAILED(hRes))
  117. return hRes;
  118. #endif
  119. // registers object, typelib and all interfaces in typelib
  120. return _Module.RegisterServer(TRUE);
  121. }
  122. /////////////////////////////////////////////////////////////////////////////
  123. // DllUnregisterServer - Removes entries from the system registry
  124. STDAPI DllUnregisterServer(void)
  125. {
  126. #ifdef _MERGE_PROXYSTUB
  127. PrxDllUnregisterServer();
  128. #endif
  129. return _Module.UnregisterServer(TRUE);
  130. }