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.

162 lines
4.1 KiB

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