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.

190 lines
4.2 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1994-1996 **/
  4. /**********************************************************************/
  5. /*
  6. dllmain.cxx
  7. Library initialization for isatq.dll --
  8. Internet Information Services - ATQ dll.
  9. FILE HISTORY:
  10. MuraliK 08-Apr-1996 Created.
  11. */
  12. #include "isatq.hxx"
  13. #include <inetinfo.h>
  14. /************************************************************
  15. * Globals
  16. ************************************************************/
  17. #ifdef _NO_TRACING_
  18. DECLARE_DEBUG_VARIABLE();
  19. #else
  20. #include <initguid.h>
  21. #ifndef _EXEXPRESS
  22. DEFINE_GUID(IisAtqGuid,
  23. 0x784d8904, 0xaa8c, 0x11d2, 0x92, 0x5e, 0x00, 0xc0, 0x4f, 0x72, 0xd9, 0x0e);
  24. #else
  25. DEFINE_GUID(IisKAtqGuid,
  26. 0x784d8915, 0xaa8c, 0x11d2, 0x92, 0x5e, 0x00, 0xc0, 0x4f, 0x72, 0xd9, 0x0e);
  27. #endif
  28. #endif
  29. DECLARE_DEBUG_PRINTS_OBJECT();
  30. DECLARE_PLATFORM_TYPE();
  31. const CHAR g_pszAtqRegLocation[] =
  32. INET_INFO_PARAMETERS_KEY /* string concatenation */
  33. #ifndef _EXEXPRESS
  34. TEXT("\\isatq");
  35. #else
  36. TEXT("\\ksatq");
  37. #endif
  38. //
  39. // is winsock initialized?
  40. //
  41. BOOL g_fSocketsInitialized = FALSE;
  42. /************************************************************
  43. * Functions
  44. ************************************************************/
  45. extern "C"
  46. BOOL WINAPI
  47. DllMain( HINSTANCE hDll, DWORD dwReason, LPVOID lpvReserved )
  48. {
  49. BOOL fReturn = TRUE;
  50. switch ( dwReason )
  51. {
  52. case DLL_PROCESS_ATTACH: {
  53. RECT rect;
  54. #ifdef _NO_TRACING_
  55. #ifndef _EXEXPRESS
  56. CREATE_DEBUG_PRINT_OBJECT( "isatq");
  57. #else
  58. CREATE_DEBUG_PRINT_OBJECT( "ksatq");
  59. #endif
  60. #else
  61. #ifndef _EXEXPRESS
  62. CREATE_DEBUG_PRINT_OBJECT( "isatq", IisAtqGuid);
  63. #else
  64. CREATE_DEBUG_PRINT_OBJECT( "ksatq", IisKAtqGuid);
  65. #endif
  66. #endif
  67. if ( !VALID_DEBUG_PRINT_OBJECT()) {
  68. return ( FALSE);
  69. }
  70. #ifdef _NO_TRACING_
  71. LOAD_DEBUG_FLAGS_FROM_REG_STR( g_pszAtqRegLocation, DEBUG_ERROR );
  72. #endif
  73. //
  74. // Initialize sockets
  75. //
  76. {
  77. DWORD dwError = NO_ERROR;
  78. WSADATA wsaData;
  79. INT serr;
  80. //
  81. // Connect to WinSock 2.0
  82. //
  83. serr = WSAStartup( MAKEWORD( 2, 0), &wsaData);
  84. if( serr != 0 ) {
  85. DBGPRINTF((DBG_CONTEXT,"WSAStartup failed with %d\n",serr));
  86. return(FALSE);
  87. }
  88. g_fSocketsInitialized = TRUE;
  89. }
  90. //
  91. // Initialize the platform type
  92. //
  93. INITIALIZE_PLATFORM_TYPE();
  94. ATQ_ASSERT(IISIsValidPlatform());
  95. //
  96. // Call a windows API that will cause windows server side thread to
  97. // be created for tcpsvcs.exe. This prevents a severe winsrv memory
  98. // leak when spawning processes and
  99. // gives a perf boost so the windows
  100. // console isn't brought up and torn down each time. :(
  101. //
  102. if ( !TsIsWindows95() ) {
  103. (VOID) AdjustWindowRectEx( &rect,
  104. 0,
  105. FALSE,
  106. 0 );
  107. // fReturn already init to TRUE
  108. }
  109. INITIALIZE_CRITICAL_SECTION( &g_csInitTermLock );
  110. DisableThreadLibraryCalls( hDll );
  111. break;
  112. }
  113. case DLL_PROCESS_DETACH:
  114. if ( lpvReserved != NULL) {
  115. //
  116. // Only Cleanup if there is a FreeLibrary() call.
  117. //
  118. break;
  119. }
  120. DeleteCriticalSection( &g_csInitTermLock );
  121. //
  122. // Cleanup sockets
  123. //
  124. if ( g_fSocketsInitialized ) {
  125. INT serr = WSACleanup();
  126. if ( serr != 0) {
  127. DBGPRINTF((DBG_CONTEXT,"WSACleanup failed with %d\n",
  128. WSAGetLastError()));
  129. }
  130. g_fSocketsInitialized = FALSE;
  131. }
  132. DELETE_DEBUG_PRINT_OBJECT();
  133. break;
  134. case DLL_THREAD_ATTACH:
  135. case DLL_THREAD_DETACH:
  136. default:
  137. break ;
  138. }
  139. return ( fReturn);
  140. } // main()