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.

157 lines
3.9 KiB

  1. /*
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. */
  4. // wavemsp.cpp : Implementation of DLL Exports.
  5. // Note: Proxy/Stub Information
  6. // To merge the proxy/stub code into the object DLL, add the file
  7. // dlldatax.c to the project. Make sure precompiled headers
  8. // are turned off for this file, and add _MERGE_PROXYSTUB to the
  9. // defines for the project.
  10. //
  11. // If you are not running WinNT4.0 or Win95 with DCOM, then you
  12. // need to remove the following define from dlldatax.c
  13. // #define _WIN32_WINNT 0x0400
  14. //
  15. // Further, if you are running MIDL without /Oicf switch, you also
  16. // need to remove the following define from dlldatax.c.
  17. // #define USE_STUBLESS_PROXY
  18. //
  19. // Modify the custom build rule for wavemsp.idl by adding the following
  20. // files to the Outputs.
  21. // wavemsp_p.c
  22. // dlldata.c
  23. // To build a separate proxy/stub DLL,
  24. // run nmake -f wavemspps.mk in the project directory.
  25. #include "stdafx.h"
  26. #include "resource.h"
  27. #include "initguid.h"
  28. #include "wavemsp_i.c"
  29. //
  30. // For the ntbuild environment we need to include this file to get the base
  31. // class implementations.
  32. #ifdef _ATL_STATIC_REGISTRY
  33. #include <statreg.h>
  34. #include <statreg.cpp>
  35. #endif
  36. #include <atlimpl.cpp>
  37. #ifdef _MERGE_PROXYSTUB
  38. extern "C" HINSTANCE hProxyDll;
  39. #endif
  40. #ifdef DEBUG_HEAPS
  41. #include <crtdbg.h>
  42. #endif // DEBUG_HEAPS
  43. CComModule _Module;
  44. BEGIN_OBJECT_MAP(ObjectMap)
  45. OBJECT_ENTRY(CLSID_WaveMSP, CWaveMSP)
  46. END_OBJECT_MAP()
  47. /////////////////////////////////////////////////////////////////////////////
  48. // DLL Entry Point
  49. extern "C"
  50. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  51. {
  52. lpReserved;
  53. #ifdef _MERGE_PROXYSTUB
  54. if (!PrxDllMain(hInstance, dwReason, lpReserved))
  55. {
  56. return FALSE;
  57. }
  58. #endif
  59. if (dwReason == DLL_PROCESS_ATTACH)
  60. {
  61. #ifdef DEBUG_HEAPS
  62. // ZoltanS: turn on leak detection on process exit
  63. _CrtSetDbgFlag( _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF );
  64. // ZoltanS: force a memory leak
  65. char * leak = new char [ 1977 ];
  66. sprintf(leak, "wavemsp.dll NORMAL leak");
  67. leak = NULL;
  68. #endif // DEBUG_HEAPS
  69. _Module.Init(ObjectMap, hInstance);
  70. DisableThreadLibraryCalls(hInstance);
  71. // Register for trace output.
  72. MSPLOGREGISTER(_T("wavemsp"));
  73. }
  74. else if (dwReason == DLL_PROCESS_DETACH)
  75. {
  76. // Deregister for trace output.
  77. MSPLOGDEREGISTER();
  78. _Module.Term();
  79. }
  80. return TRUE; // ok
  81. }
  82. /////////////////////////////////////////////////////////////////////////////
  83. // Used to determine whether the DLL can be unloaded by OLE
  84. STDAPI DllCanUnloadNow(void)
  85. {
  86. #ifdef _MERGE_PROXYSTUB
  87. if (PrxDllCanUnloadNow() != S_OK)
  88. return S_FALSE;
  89. #endif
  90. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  91. }
  92. /////////////////////////////////////////////////////////////////////////////
  93. // Returns a class factory to create an object of the requested type
  94. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  95. {
  96. #ifdef _MERGE_PROXYSTUB
  97. if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  98. return S_OK;
  99. #endif
  100. return _Module.GetClassObject(rclsid, riid, ppv);
  101. }
  102. /////////////////////////////////////////////////////////////////////////////
  103. // DllRegisterServer - Adds entries to the system registry
  104. STDAPI DllRegisterServer(void)
  105. {
  106. #ifdef _MERGE_PROXYSTUB
  107. HRESULT hRes = PrxDllRegisterServer();
  108. if (FAILED(hRes))
  109. return hRes;
  110. #endif
  111. // registers object, typelib and all interfaces in typelib
  112. return _Module.RegisterServer(TRUE);
  113. }
  114. /////////////////////////////////////////////////////////////////////////////
  115. // DllUnregisterServer - Removes entries from the system registry
  116. STDAPI DllUnregisterServer(void)
  117. {
  118. #ifdef _MERGE_PROXYSTUB
  119. PrxDllUnregisterServer();
  120. #endif
  121. _Module.UnregisterServer();
  122. return S_OK;
  123. }