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.

127 lines
3.4 KiB

  1. // script.cpp : Implementation of DLL Exports.
  2. // Note: Proxy/Stub Information
  3. // To merge the proxy/stub code into the object DLL, add the file
  4. // dlldatax.c to the project. Make sure precompiled headers
  5. // are turned off for this file, and add _MERGE_PROXYSTUB to the
  6. // defines for the project.
  7. //
  8. // If you are not running WinNT4.0 or Win95 with DCOM, then you
  9. // need to remove the following define from dlldatax.c
  10. // #define _WIN32_WINNT 0x0400
  11. //
  12. // Further, if you are running MIDL without /Oicf switch, you also
  13. // need to remove the following define from dlldatax.c.
  14. // #define USE_STUBLESS_PROXY
  15. //
  16. // Modify the custom build rule for script.idl by adding the following
  17. // files to the Outputs.
  18. // script_p.c
  19. // dlldata.c
  20. // To build a separate proxy/stub DLL,
  21. // run nmake -f scriptps.mk in the project directory.
  22. #include "stdafx.h"
  23. #include "resource.h"
  24. #include "script.h"
  25. #include "dlldatax.h"
  26. #include "script_i.c"
  27. #include <iadmw.h>
  28. #include "LogScripting.h"
  29. #ifdef _MERGE_PROXYSTUB
  30. extern "C" HINSTANCE hProxyDll;
  31. #endif
  32. CHAR g_szModuleName[] = "LogScript";
  33. CComModule _Module;
  34. BEGIN_OBJECT_MAP(ObjectMap)
  35. OBJECT_ENTRY(CLSID_LogScripting, CLogScripting)
  36. END_OBJECT_MAP()
  37. DECLARE_DEBUG_PRINTS_OBJECT( );
  38. /////////////////////////////////////////////////////////////////////////////
  39. // DLL Entry Point
  40. extern "C"
  41. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  42. {
  43. lpReserved;
  44. #ifdef _MERGE_PROXYSTUB
  45. if (!PrxDllMain(hInstance, dwReason, lpReserved))
  46. return FALSE;
  47. #endif
  48. if (dwReason == DLL_PROCESS_ATTACH)
  49. {
  50. _Module.Init(ObjectMap, hInstance);
  51. DisableThreadLibraryCalls(hInstance);
  52. CREATE_DEBUG_PRINT_OBJECT(g_szModuleName);
  53. LOAD_DEBUG_FLAGS_FROM_REG_STR("System\\CurrentControlSet\\Services\\InetInfo\\Parameters", 0);
  54. }
  55. else if (dwReason == DLL_PROCESS_DETACH)
  56. {
  57. DELETE_DEBUG_PRINT_OBJECT();
  58. _Module.Term();
  59. }
  60. return TRUE; // ok
  61. }
  62. /////////////////////////////////////////////////////////////////////////////
  63. // Used to determine whether the DLL can be unloaded by OLE
  64. STDAPI DllCanUnloadNow(void)
  65. {
  66. #ifdef _MERGE_PROXYSTUB
  67. if (PrxDllCanUnloadNow() != S_OK)
  68. return S_FALSE;
  69. #endif
  70. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  71. }
  72. /////////////////////////////////////////////////////////////////////////////
  73. // Returns a class factory to create an object of the requested type
  74. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  75. {
  76. #ifdef _MERGE_PROXYSTUB
  77. if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  78. return S_OK;
  79. #endif
  80. return _Module.GetClassObject(rclsid, riid, ppv);
  81. }
  82. /////////////////////////////////////////////////////////////////////////////
  83. // DllRegisterServer - Adds entries to the system registry
  84. STDAPI DllRegisterServer(void)
  85. {
  86. #ifdef _MERGE_PROXYSTUB
  87. HRESULT hRes = PrxDllRegisterServer();
  88. if (FAILED(hRes))
  89. return hRes;
  90. #endif
  91. // registers object, typelib and all interfaces in typelib
  92. return _Module.RegisterServer(TRUE);
  93. }
  94. /////////////////////////////////////////////////////////////////////////////
  95. // DllUnregisterServer - Removes entries from the system registry
  96. STDAPI DllUnregisterServer(void)
  97. {
  98. #ifdef _MERGE_PROXYSTUB
  99. PrxDllUnregisterServer();
  100. #endif
  101. _Module.UnregisterServer();
  102. return S_OK;
  103. }