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.

181 lines
4.1 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. DECLARE_DEBUG_PRINTS_OBJECT();
  18. DECLARE_PLATFORM_TYPE();
  19. const CHAR g_pszAtqRegLocation[] =
  20. INET_INFO_PARAMETERS_KEY /* string concatenation */
  21. #ifndef _EXEXPRESS
  22. TEXT("\\isatq");
  23. #else
  24. TEXT("\\ksatq");
  25. #endif
  26. const CHAR g_szModuleName[] =
  27. #ifndef _EXEXPRESS
  28. TEXT("\\isatq");
  29. #else
  30. TEXT("\\ksatq");
  31. #endif
  32. //
  33. // is winsock initialized?
  34. //
  35. BOOL g_fSocketsInitialized = FALSE;
  36. /************************************************************
  37. * Functions
  38. ************************************************************/
  39. extern "C"
  40. BOOL WINAPI
  41. DllMain( HINSTANCE hDll, DWORD dwReason, LPVOID lpvReserved )
  42. {
  43. BOOL fReturn = TRUE;
  44. switch ( dwReason )
  45. {
  46. case DLL_PROCESS_ATTACH: {
  47. RECT rect;
  48. CREATE_DEBUG_PRINT_OBJECT( g_szModuleName);
  49. if ( !VALID_DEBUG_PRINT_OBJECT()) {
  50. return ( FALSE);
  51. }
  52. LOAD_DEBUG_FLAGS_FROM_REG_STR( g_pszAtqRegLocation, 0 );
  53. //
  54. // Initialize sockets
  55. //
  56. {
  57. DWORD dwError = NO_ERROR;
  58. WSADATA wsaData;
  59. INT serr;
  60. //
  61. // Connect to WinSock 2.0
  62. //
  63. serr = WSAStartup( MAKEWORD( 2, 0), &wsaData);
  64. if( serr != 0 ) {
  65. DBGPRINTF((DBG_CONTEXT,"WSAStartup failed with %d\n",serr));
  66. return(FALSE);
  67. }
  68. g_fSocketsInitialized = TRUE;
  69. }
  70. //
  71. // Initialize the platform type
  72. //
  73. INITIALIZE_PLATFORM_TYPE();
  74. ATQ_ASSERT(IISIsValidPlatform());
  75. //
  76. // Call a windows API that will cause windows server side thread to
  77. // be created for tcpsvcs.exe. This prevents a severe winsrv memory
  78. // leak when spawning processes and
  79. // gives a perf boost so the windows
  80. // console isn't brought up and torn down each time. :(
  81. //
  82. (VOID) AdjustWindowRectEx( &rect,
  83. 0,
  84. FALSE,
  85. 0 );
  86. // fReturn already init to TRUE
  87. if ( !INITIALIZE_CRITICAL_SECTION( &g_csInitTermLock ) )
  88. {
  89. WSACleanup();
  90. return FALSE;
  91. }
  92. if ( !INITIALIZE_CRITICAL_SECTION( &AtqEndpointLock ) )
  93. {
  94. DeleteCriticalSection( &g_csInitTermLock );
  95. WSACleanup();
  96. return FALSE;
  97. }
  98. DisableThreadLibraryCalls( hDll );
  99. break;
  100. }
  101. case DLL_PROCESS_DETACH:
  102. if ( lpvReserved != NULL) {
  103. //
  104. // Only Cleanup if there is a FreeLibrary() call.
  105. //
  106. break;
  107. }
  108. DeleteCriticalSection( &AtqEndpointLock );
  109. DeleteCriticalSection( &g_csInitTermLock );
  110. //
  111. // Cleanup sockets
  112. //
  113. if ( g_fSocketsInitialized ) {
  114. INT serr = WSACleanup();
  115. if ( serr != 0) {
  116. DBGPRINTF((DBG_CONTEXT,"WSACleanup failed with %d\n",
  117. WSAGetLastError()));
  118. }
  119. g_fSocketsInitialized = FALSE;
  120. }
  121. DELETE_DEBUG_PRINT_OBJECT();
  122. break;
  123. case DLL_THREAD_ATTACH:
  124. case DLL_THREAD_DETACH:
  125. default:
  126. break ;
  127. }
  128. return ( fReturn);
  129. } // main()