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.

148 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name :
  4. isplat.cxx
  5. Abstract:
  6. This module defines functions for determining platform types
  7. Author:
  8. Johnson Apacible (johnsona) 19-Nov-1996
  9. Murali Krishnan (MuraliK) 17-Apr-1997
  10. Added CriticalSectionWith SpinCount stuff (moved to locks.cxx)
  11. --*/
  12. #include "precomp.hxx"
  13. #include <inetsvcs.h>
  14. #define DLL_IMPLEMENTATION
  15. #define IMPLEMENTATION_EXPORT
  16. #include <locks.h>
  17. typedef
  18. BOOLEAN
  19. (NTAPI *GET_PRODUCT_TYPE)(
  20. PNT_PRODUCT_TYPE
  21. );
  22. extern "C"
  23. PLATFORM_TYPE
  24. IISGetPlatformType(
  25. VOID
  26. )
  27. /*++
  28. This function consults the registry and determines the platform type
  29. for this machine.
  30. Arguments:
  31. None
  32. Returns:
  33. Platform type
  34. --*/
  35. {
  36. PLATFORM_TYPE pt;
  37. LONG result;
  38. HKEY keyHandle;
  39. WCHAR productType[30];
  40. DWORD type;
  41. BOOL isNt = TRUE;
  42. OSVERSIONINFO osInfo;
  43. //
  44. // See if the platform type has already been discovered.
  45. //
  46. if ( g_PlatformType != PtInvalid ) {
  47. return(g_PlatformType);
  48. }
  49. //
  50. // see if this is win95
  51. //
  52. osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  53. if ( GetVersionEx( &osInfo ) ) {
  54. isNt = (osInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
  55. } else {
  56. IIS_PRINTF((buff,"GetVersionEx failed with %d\n",
  57. GetLastError()));
  58. }
  59. if ( isNt ) {
  60. HINSTANCE hNtdll;
  61. NT_PRODUCT_TYPE ntType;
  62. GET_PRODUCT_TYPE pfnGetProductType;
  63. //
  64. // Get the product type from the system
  65. //
  66. pt = PtNtWorkstation;
  67. hNtdll = LoadLibrary("ntdll.dll");
  68. if ( hNtdll != NULL ) {
  69. pfnGetProductType = (GET_PRODUCT_TYPE)
  70. GetProcAddress(hNtdll, "RtlGetNtProductType");
  71. if ( (pfnGetProductType != NULL) &&
  72. pfnGetProductType( &ntType ) ) {
  73. if ( (ntType == NtProductLanManNt) ||
  74. (ntType == NtProductServer) ) {
  75. pt = PtNtServer;
  76. }
  77. }
  78. FreeLibrary( hNtdll );
  79. }
  80. } else {
  81. pt = PtWindows95;
  82. }
  83. g_PlatformType = pt;
  84. return(pt);
  85. } // IISGetPlatformType
  86. // Thunking wrapper for ::SetCriticalSectionSpinCount that will work on
  87. // systems that don't have this API in kernel32
  88. DWORD
  89. IISSetCriticalSectionSpinCount(
  90. LPCRITICAL_SECTION lpCriticalSection,
  91. DWORD dwSpinCount)
  92. {
  93. return CCritSec::SetSpinCount(lpCriticalSection, dwSpinCount);
  94. }
  95. // Thunking wrapper for ::InitializeCriticalSectionAndSpinCount that will
  96. // work on systems that don't have this API in kernel32. Sets the spin count
  97. // to the IIS default, IIS_DEFAULT_CS_SPIN_COUNT, which is defined in
  98. // <pudebug.h>
  99. VOID
  100. IISInitializeCriticalSection(
  101. LPCRITICAL_SECTION lpCriticalSection)
  102. {
  103. InitializeCriticalSection(lpCriticalSection);
  104. CCritSec::SetSpinCount(lpCriticalSection, IIS_DEFAULT_CS_SPIN_COUNT);
  105. }