Source code of Windows XP (NT5)
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.

203 lines
2.9 KiB

  1. /*
  2. * dllinit.c - Initialization and termination routines.
  3. */
  4. /* Headers
  5. **********/
  6. #include "project.h"
  7. #pragma hdrstop
  8. #include "..\core\init.h"
  9. #include "server.h"
  10. #include "cnrlink.h"
  11. /* Module Prototypes
  12. ********************/
  13. PRIVATE_CODE BOOL MyAttachProcess(HMODULE);
  14. PRIVATE_CODE BOOL MyDetachProcess(HMODULE);
  15. /* Global Variables
  16. *******************/
  17. /* serialization control structure */
  18. /* note no thread attach or thread detach procs here so we can optimize... */
  19. PUBLIC_DATA CSERIALCONTROL g_cserctrl =
  20. {
  21. MyAttachProcess,
  22. MyDetachProcess,
  23. NULL,
  24. NULL
  25. };
  26. #ifdef DEBUG
  27. /* .ini file name and section used by inifile.c!SetIniSwitches() */
  28. PUBLIC_DATA LPCTSTR GpcszIniFile = TEXT("rover.ini");
  29. PUBLIC_DATA LPCTSTR GpcszIniSection = TEXT("LinkInfoDebugOptions");
  30. /* module name used by debug.c!SpewOut() */
  31. PUBLIC_DATA LPCTSTR GpcszSpewModule = TEXT("LinkInfo");
  32. #endif
  33. /***************************** Private Functions *****************************/
  34. #pragma warning(disable:4100) /* "unreferenced formal parameter" warning */
  35. /*
  36. ** MyAttachProcess()
  37. **
  38. **
  39. **
  40. ** Arguments:
  41. **
  42. ** Returns:
  43. **
  44. ** Side Effects: none
  45. */
  46. PRIVATE_CODE BOOL MyAttachProcess(HMODULE hmod)
  47. {
  48. BOOL bResult;
  49. ASSERT(IS_VALID_HANDLE(hmod, MODULE));
  50. DebugEntry(MyAttachProcess);
  51. // Don't care about thread attach/detach.
  52. DisableThreadLibraryCalls(hmod);
  53. bResult = ProcessInitServerModule();
  54. DebugExitBOOL(MyAttachProcess, bResult);
  55. return(bResult);
  56. }
  57. /*
  58. ** MyDetachProcess()
  59. **
  60. **
  61. **
  62. ** Arguments:
  63. **
  64. ** Returns:
  65. **
  66. ** Side Effects: none
  67. */
  68. PRIVATE_CODE BOOL MyDetachProcess(HMODULE hmod)
  69. {
  70. BOOL bResult = TRUE;
  71. ASSERT(IS_VALID_HANDLE(hmod, MODULE));
  72. DebugEntry(MyDetachProcess);
  73. ProcessExitServerModule();
  74. DebugExitBOOL(MyDetachProcess, bResult);
  75. return(bResult);
  76. }
  77. #pragma warning(default:4100) /* "unreferenced formal parameter" warning */
  78. /****************************** Public Functions *****************************/
  79. #ifdef DEBUG
  80. /*
  81. ** SetAllIniSwitches()
  82. **
  83. **
  84. **
  85. ** Arguments:
  86. **
  87. ** Returns:
  88. **
  89. ** Side Effects: none
  90. */
  91. PUBLIC_CODE BOOL SetAllIniSwitches(void)
  92. {
  93. BOOL bResult;
  94. bResult = SetDebugModuleIniSwitches();
  95. bResult |= SetSerialModuleIniSwitches();
  96. bResult |= SetMemoryManagerModuleIniSwitches();
  97. return(bResult);
  98. }
  99. #endif
  100. /*
  101. ** InitializeDLL()
  102. **
  103. **
  104. **
  105. ** Arguments:
  106. **
  107. ** Returns:
  108. **
  109. ** Side Effects: none
  110. */
  111. PUBLIC_CODE BOOL InitializeDLL(void)
  112. {
  113. BOOL bResult;
  114. DebugEntry(InitializeDLL);
  115. bResult = InitMemoryManagerModule();
  116. #ifdef DEBUG
  117. if (bResult)
  118. {
  119. SpewHeapSummary(0);
  120. }
  121. #endif
  122. DebugExitBOOL(InitializeDLL, bResult);
  123. return(bResult);
  124. }
  125. /*
  126. ** TerminateDLL()
  127. **
  128. **
  129. **
  130. ** Arguments:
  131. **
  132. ** Returns: TRUE
  133. **
  134. ** Side Effects: none
  135. */
  136. PUBLIC_CODE BOOL TerminateDLL(void)
  137. {
  138. BOOL bResult;
  139. DebugEntry(TerminateDLL);
  140. ExitMemoryManagerModule();
  141. bResult = TRUE;
  142. DebugExitBOOL(TerminateDLL, bResult);
  143. return(bResult);
  144. }