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.

200 lines
4.8 KiB

  1. //---------------------------------------------------------------------------
  2. // File: RRCMMAIN.C
  3. //
  4. // This file contains the DLL's entry and exit points.
  5. //
  6. // INTEL Corporation Proprietary Information
  7. // This listing is supplied under the terms of a license agreement with
  8. // Intel Corporation and may not be copied nor disclosed except in
  9. // accordance with the terms of that agreement.
  10. // Copyright (c) 1995 Intel Corporation.
  11. //---------------------------------------------------------------------------
  12. #ifndef STRICT
  13. #define STRICT
  14. #endif
  15. #include "stdafx.h"
  16. #include "windows.h"
  17. #include <confdbg.h>
  18. #include <memtrack.h>
  19. // Note: Proxy/Stub Information
  20. // To build a separate proxy/stub DLL,
  21. // run nmake -f mpps.mk in the project directory.
  22. #include "resource.h"
  23. #include "initguid.h"
  24. #include "irtp.h"
  25. #include "irtp_i.c"
  26. //#include <cmmstrm.h>
  27. #include "RTPSess.h"
  28. #include "thread.h"
  29. CComModule _Module;
  30. CRITICAL_SECTION g_CritSect;
  31. BEGIN_OBJECT_MAP(ObjectMap)
  32. OBJECT_ENTRY(CLSID_RTP, CRTP)
  33. END_OBJECT_MAP()
  34. #if (defined(_DEBUG) || defined(PCS_COMPLIANCE))
  35. //INTEROP
  36. #include "interop.h"
  37. #include "rtpplog.h"
  38. #endif
  39. #ifdef ISRDBG
  40. #include "isrg.h"
  41. WORD ghISRInst = 0;
  42. #endif
  43. #if (defined(_DEBUG) || defined(PCS_COMPLIANCE))
  44. //INTEROP
  45. LPInteropLogger RTPLogger;
  46. #endif
  47. #if defined(__cplusplus)
  48. extern "C"
  49. {
  50. #endif // (__cplusplus)
  51. extern DWORD deleteRTP (HINSTANCE);
  52. extern DWORD initRTP (HINSTANCE);
  53. #if defined(__cplusplus)
  54. }
  55. #endif // (__cplusplus)
  56. #ifdef _DEBUG
  57. HDBGZONE ghDbgZoneRRCM = NULL;
  58. static PTCHAR _rgZones[] = {
  59. TEXT("RRCM"),
  60. TEXT("Trace"),
  61. TEXT("Error"),
  62. };
  63. #endif /* DEBUG */
  64. //---------------------------------------------------------------------------
  65. // Function: dllmain
  66. //
  67. // Description: DLL entry/exit points.
  68. //
  69. // Inputs:
  70. // hInstDll : DLL instance.
  71. // fdwReason : Reason the main function is called.
  72. // lpReserved : Reserved.
  73. //
  74. // Return: TRUE : OK
  75. // FALSE : Error, DLL won't load
  76. //---------------------------------------------------------------------------
  77. BOOL WINAPI DllMain (HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved)
  78. {
  79. BOOL status = TRUE;
  80. switch (fdwReason)
  81. {
  82. case DLL_PROCESS_ATTACH:
  83. // The DLL is being loaded for the first time by a given process.
  84. // Perform per-process initialization here. If the initialization
  85. // is successful, return TRUE; if unsuccessful, return FALSE.
  86. #ifdef ISRDBG
  87. ISRREGISTERMODULE(&ghISRInst, "RRCM", "RTP/RTCP");
  88. #endif
  89. DBGINIT(&ghDbgZoneRRCM, _rgZones);
  90. DBG_INIT_MEMORY_TRACKING(hInstDll);
  91. #if (defined(_DEBUG) || defined(PCS_COMPLIANCE))
  92. //INTEROP
  93. RTPLogger = InteropLoad(RTPLOG_PROTOCOL);
  94. #endif
  95. _Module.Init(ObjectMap, hInstDll);
  96. DisableThreadLibraryCalls(hInstDll);
  97. //LogInit();
  98. InitializeCriticalSection(&g_CritSect);
  99. // initialize RTP/RTCP
  100. status = (initRTP (hInstDll) == FALSE) ? TRUE:FALSE;
  101. break;
  102. case DLL_PROCESS_DETACH:
  103. // The DLL is being unloaded by a given process. Do any
  104. // per-process clean up here.The return value is ignored.
  105. // delete RTP resource
  106. deleteRTP (hInstDll);
  107. _Module.Term();
  108. //LogClose();
  109. DeleteCriticalSection(&g_CritSect);
  110. #if (defined(_DEBUG) || defined(PCS_COMPLIANCE))
  111. //INTEROP
  112. if (RTPLogger)
  113. InteropUnload(RTPLogger);
  114. #endif
  115. DBG_CHECK_MEMORY_TRACKING(hInstDll);
  116. DBGDEINIT(&ghDbgZoneRRCM);
  117. break;
  118. case DLL_THREAD_ATTACH:
  119. // A thread is being created in a process that has already loaded
  120. // this DLL. Perform any per-thread initialization here.
  121. break;
  122. case DLL_THREAD_DETACH:
  123. // A thread is exiting cleanly in a process that has already
  124. // loaded this DLL. Perform any per-thread clean up here.
  125. break;
  126. }
  127. return (status);
  128. }
  129. /////////////////////////////////////////////////////////////////////////////
  130. // Used to determine whether the DLL can be unloaded by OLE
  131. STDAPI DllCanUnloadNow(void)
  132. {
  133. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  134. }
  135. /////////////////////////////////////////////////////////////////////////////
  136. // Returns a class factory to create an object of the requested type
  137. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  138. {
  139. return _Module.GetClassObject(rclsid, riid, ppv);
  140. }
  141. /////////////////////////////////////////////////////////////////////////////
  142. // DllRegisterServer - Adds entries to the system registry
  143. STDAPI DllRegisterServer(void)
  144. {
  145. // registers object, typelib and all interfaces in typelib
  146. return _Module.RegisterServer(FALSE);
  147. }
  148. /////////////////////////////////////////////////////////////////////////////
  149. // DllUnregisterServer - Removes entries from the system registry
  150. STDAPI DllUnregisterServer(void)
  151. {
  152. _Module.UnregisterServer();
  153. return S_OK;
  154. }
  155. // [EOF]