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.

169 lines
3.5 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name :
  4. ulw3.cxx
  5. Abstract:
  6. W3 Handler Driver
  7. Author:
  8. Bilal Alam (balam) 13-Dec-1999
  9. Environment:
  10. Win32 - User Mode
  11. Project:
  12. ULW3.DLL
  13. --*/
  14. /************************************************************
  15. * Include Headers
  16. ************************************************************/
  17. #include "precomp.hxx"
  18. /************************************************************
  19. * Declarations
  20. ************************************************************/
  21. // BUGBUG
  22. #undef INET_INFO_KEY
  23. #undef INET_INFO_PARAMETERS_KEY
  24. #define W3_TRACE_MOF_FILE L"W3CoreMofResource"
  25. #define W3_IMAGE_PATH L"w3core.dll"
  26. //
  27. // Configuration parameters registry key.
  28. //
  29. #define INET_INFO_KEY \
  30. "System\\CurrentControlSet\\Services\\w3svc"
  31. #define INET_INFO_PARAMETERS_KEY \
  32. INET_INFO_KEY "\\Parameters"
  33. const CHAR g_pszWpRegLocation[] =
  34. INET_INFO_PARAMETERS_KEY "\\w3core";
  35. DECLARE_DEBUG_PRINTS_OBJECT();
  36. DECLARE_DEBUG_VARIABLE();
  37. DECLARE_PLATFORM_TYPE();
  38. /************************************************************
  39. * Type Definitions
  40. ************************************************************/
  41. W3_SERVER * g_pW3Server = NULL;
  42. CEtwTracer * g_pEtwTracer = NULL;
  43. HRESULT
  44. UlW3Start(
  45. INT argc,
  46. LPWSTR argv[],
  47. BOOL fCompatibilityMode
  48. )
  49. /*++
  50. Description:
  51. Perform one time initialization, including ULATQ setup.
  52. Wait on shutdown. Then clean up.
  53. Assumes that this startup thread is CoInitialized MTA.
  54. --*/
  55. {
  56. HRESULT hr = NO_ERROR;
  57. CREATE_DEBUG_PRINT_OBJECT("w3core");
  58. if (!VALID_DEBUG_PRINT_OBJECT())
  59. {
  60. return E_FAIL;
  61. }
  62. LOAD_DEBUG_FLAGS_FROM_REG_STR( g_pszWpRegLocation, DEBUG_ERROR );
  63. INITIALIZE_PLATFORM_TYPE();
  64. DBG_ASSERT( g_pW3Server == NULL );
  65. //
  66. // First initialize tracing stuff so initialization of W3_SERVER has
  67. // access to the object
  68. //
  69. g_pEtwTracer = new CEtwTracer;
  70. if ( g_pEtwTracer == NULL )
  71. {
  72. hr = HRESULT_FROM_WIN32( ERROR_NOT_ENOUGH_MEMORY );
  73. goto Finished;
  74. }
  75. hr = g_pEtwTracer->Register( &IISControlGuid,
  76. W3_IMAGE_PATH,
  77. W3_TRACE_MOF_FILE );
  78. if ( FAILED( hr ) )
  79. {
  80. goto Finished;
  81. }
  82. //
  83. // Create the global W3_SERVER object
  84. //
  85. g_pW3Server = new W3_SERVER( fCompatibilityMode );
  86. if ( g_pW3Server == NULL )
  87. {
  88. hr = HRESULT_FROM_WIN32( ERROR_NOT_ENOUGH_MEMORY );
  89. goto Finished;
  90. }
  91. //
  92. // Do global initialization (but no listen)
  93. //
  94. hr = g_pW3Server->Initialize( argc, argv );
  95. if ( FAILED( hr ) )
  96. {
  97. goto Finished;
  98. }
  99. //
  100. // Start listening
  101. //
  102. hr = g_pW3Server->StartListen();
  103. if ( FAILED( hr ) )
  104. {
  105. goto Finished;
  106. }
  107. Finished:
  108. //
  109. // Cleanup
  110. //
  111. if ( g_pW3Server != NULL )
  112. {
  113. g_pW3Server->Terminate( hr );
  114. delete g_pW3Server;
  115. g_pW3Server = NULL;
  116. }
  117. if ( g_pEtwTracer != NULL )
  118. {
  119. g_pEtwTracer->UnRegister();
  120. delete g_pEtwTracer;
  121. g_pEtwTracer = NULL;
  122. }
  123. DELETE_DEBUG_PRINT_OBJECT();
  124. return hr;
  125. }