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.9 KiB

  1. //---------------------------------------------------------------------------
  2. // File: H245Main.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 "precomp.h"
  16. #define H245DLL_EXPORT
  17. #include "h245com.h"
  18. #if defined(_DEBUG) || defined(PCS_COMPLIANCE)
  19. #include "interop.h"
  20. #include "h245plog.h"
  21. LPInteropLogger H245Logger = NULL;
  22. #endif // (PCS_COMPLIANCE)
  23. extern CRITICAL_SECTION TimerLock;
  24. extern CRITICAL_SECTION InstanceCreateLock;
  25. extern CRITICAL_SECTION InstanceLocks[MAXINST];
  26. extern struct InstanceStruct * InstanceTable[MAXINST];
  27. BOOL H245SysInit()
  28. {
  29. register unsigned int uIndex;
  30. /* initialize memory resources */
  31. H245TRACE(0, 0, "***** Loading H.245 DLL %s - %s",
  32. __DATE__, __TIME__);
  33. #if defined(_DEBUG) || defined(PCS_COMPLIANCE)
  34. H245Logger = InteropLoad(H245LOG_PROTOCOL);
  35. #endif // (PCS_COMPLIANCE)
  36. InitializeCriticalSection(&TimerLock);
  37. InitializeCriticalSection(&InstanceCreateLock);
  38. for (uIndex = 0; uIndex < MAXINST; ++uIndex)
  39. {
  40. InitializeCriticalSection(&InstanceLocks[uIndex]);
  41. }
  42. return TRUE;
  43. }
  44. VOID H245SysDeInit()
  45. {
  46. register unsigned int uIndex;
  47. H245TRACE(0, 0, "***** Unloading H.245 DLL");
  48. for (uIndex = 0; uIndex < MAXINST; ++uIndex)
  49. {
  50. if (InstanceTable[uIndex])
  51. {
  52. register struct InstanceStruct *pInstance = InstanceLock(uIndex + 1);
  53. if (pInstance)
  54. {
  55. H245TRACE(uIndex+1,0,"DLLMain: Calling H245ShutDown");
  56. H245ShutDown(uIndex + 1);
  57. InstanceUnlock_ProcessDetach(pInstance,TRUE);
  58. }
  59. }
  60. ASSERT(InstanceTable[uIndex] == NULL);
  61. DeleteCriticalSection(&InstanceLocks[uIndex]);
  62. }
  63. DeleteCriticalSection(&InstanceCreateLock);
  64. DeleteCriticalSection(&TimerLock);
  65. #if defined(_DEBUG) || defined(PCS_COMPLIANCE)
  66. if (H245Logger)
  67. {
  68. H245TRACE(0, 4, "Unloading interop logger");
  69. InteropUnload(H245Logger);
  70. H245Logger = NULL;
  71. }
  72. #endif // (PCS_COMPLIANCE)
  73. }
  74. #if(0)
  75. //---------------------------------------------------------------------------
  76. // Function: dllmain
  77. //
  78. // Description: DLL entry/exit points.
  79. //
  80. // Inputs:
  81. // hInstDll : DLL instance.
  82. // fdwReason : Reason the main function is called.
  83. // lpReserved : Reserved.
  84. //
  85. // Return: TRUE : OK
  86. // FALSE : Error, DLL won't load
  87. //---------------------------------------------------------------------------
  88. BOOL WINAPI DllMain (HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved)
  89. {
  90. extern CRITICAL_SECTION TimerLock;
  91. extern CRITICAL_SECTION InstanceCreateLock;
  92. extern CRITICAL_SECTION InstanceLocks[MAXINST];
  93. extern struct InstanceStruct * InstanceTable[MAXINST];
  94. register unsigned int uIndex;
  95. switch (fdwReason)
  96. {
  97. case DLL_PROCESS_ATTACH:
  98. DBG_INIT_MEMORY_TRACKING(hInstDll);
  99. /* initialize memory resources */
  100. H245TRACE(0, 0, "***** Loading H.245 DLL %s - %s",
  101. __DATE__, __TIME__);
  102. #if defined(_DEBUG) || defined(PCS_COMPLIANCE)
  103. H245Logger = InteropLoad(H245LOG_PROTOCOL);
  104. #endif // (PCS_COMPLIANCE)
  105. InitializeCriticalSection(&TimerLock);
  106. InitializeCriticalSection(&InstanceCreateLock);
  107. for (uIndex = 0; uIndex < MAXINST; ++uIndex)
  108. {
  109. InitializeCriticalSection(&InstanceLocks[uIndex]);
  110. }
  111. break;
  112. case DLL_PROCESS_DETACH:
  113. /* release memory resources */
  114. H245TRACE(0, 0, "***** Unloading H.245 DLL");
  115. H245TRACE(0, 0, "***** fProcessDetach = TRUE");
  116. for (uIndex = 0; uIndex < MAXINST; ++uIndex)
  117. {
  118. if (InstanceTable[uIndex])
  119. {
  120. register struct InstanceStruct *pInstance = InstanceLock(uIndex + 1);
  121. if (pInstance)
  122. {
  123. H245TRACE(uIndex+1,0,"DLLMain: Calling H245ShutDown");
  124. H245ShutDown(uIndex + 1);
  125. InstanceUnlock_ProcessDetach(pInstance,TRUE);
  126. }
  127. }
  128. ASSERT(InstanceTable[uIndex] == NULL);
  129. DeleteCriticalSection(&InstanceLocks[uIndex]);
  130. }
  131. DeleteCriticalSection(&InstanceCreateLock);
  132. DeleteCriticalSection(&TimerLock);
  133. #if defined(_DEBUG) || defined(PCS_COMPLIANCE)
  134. if (H245Logger)
  135. {
  136. H245TRACE(0, 4, "Unloading interop logger");
  137. InteropUnload(H245Logger);
  138. H245Logger = NULL;
  139. }
  140. #endif // (PCS_COMPLIANCE)
  141. DBG_CHECK_MEMORY_TRACKING(hInstDll);
  142. break;
  143. }
  144. return TRUE;
  145. }
  146. #endif // if(0)