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.

153 lines
3.5 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. Win2000VersionLie.cpp
  5. Abstract:
  6. This DLL hooks GetVersion and GetVersionEx so that they return Windows 2000
  7. version credentials.
  8. Notes:
  9. This is a general purpose shim.
  10. History:
  11. 03/13/2000 clupu Created
  12. --*/
  13. #include "precomp.h"
  14. IMPLEMENT_SHIM_BEGIN(Win2000VersionLie)
  15. #include "ShimHookMacro.h"
  16. APIHOOK_ENUM_BEGIN
  17. APIHOOK_ENUM_ENTRY(GetVersionExA)
  18. APIHOOK_ENUM_ENTRY(GetVersionExW)
  19. APIHOOK_ENUM_ENTRY(GetVersion)
  20. APIHOOK_ENUM_END
  21. /*++
  22. This stub function fixes up the OSVERSIONINFO structure that is
  23. returned to the caller with Windows 95 credentials.
  24. --*/
  25. BOOL
  26. APIHOOK(GetVersionExA)(
  27. OUT LPOSVERSIONINFOA lpVersionInformation
  28. )
  29. {
  30. BOOL bReturn = FALSE;
  31. if (ORIGINAL_API(GetVersionExA)(lpVersionInformation)) {
  32. LOGN(
  33. eDbgLevelInfo,
  34. "[GetVersionExA] called. return Win2k.");
  35. //
  36. // Fixup the structure with the Win2k data.
  37. //
  38. lpVersionInformation->dwMajorVersion = 5;
  39. lpVersionInformation->dwMinorVersion = 0;
  40. lpVersionInformation->dwBuildNumber = 2195;
  41. lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
  42. *lpVersionInformation->szCSDVersion = '\0';
  43. if( lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA) )
  44. {
  45. // We are here as we are passed a OSVERSIONINFOEX structure.
  46. // Set the major and minor service pack numbers.
  47. ((LPOSVERSIONINFOEXA)lpVersionInformation)->wServicePackMajor = 0;
  48. ((LPOSVERSIONINFOEXA)lpVersionInformation)->wServicePackMinor = 0;
  49. }
  50. bReturn = TRUE;
  51. }
  52. return bReturn;
  53. }
  54. /*++
  55. This stub function fixes up the OSVERSIONINFO structure that is
  56. returned to the caller with Windows 95 credentials. This is the
  57. wide-character version of GetVersionExW.
  58. --*/
  59. BOOL
  60. APIHOOK(GetVersionExW)(
  61. OUT LPOSVERSIONINFOW lpVersionInformation
  62. )
  63. {
  64. BOOL bReturn = FALSE;
  65. if (ORIGINAL_API(GetVersionExW)(lpVersionInformation)) {
  66. LOGN(
  67. eDbgLevelInfo,
  68. "[GetVersionExW] called. return Win2k.");
  69. //
  70. // Fixup the structure with the Win2k data.
  71. //
  72. lpVersionInformation->dwMajorVersion = 5;
  73. lpVersionInformation->dwMinorVersion = 0;
  74. lpVersionInformation->dwBuildNumber = 2195;
  75. lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
  76. *lpVersionInformation->szCSDVersion = L'\0';
  77. if( lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXW) )
  78. {
  79. // We are here as we are passed a OSVERSIONINFOEX structure.
  80. // Set the major and minor service pack numbers.
  81. ((LPOSVERSIONINFOEXW)lpVersionInformation)->wServicePackMajor = 0;
  82. ((LPOSVERSIONINFOEXW)lpVersionInformation)->wServicePackMinor = 0;
  83. }
  84. bReturn = TRUE;
  85. }
  86. return bReturn;
  87. }
  88. /*++
  89. This stub function returns Windows 95 credentials.
  90. --*/
  91. DWORD
  92. APIHOOK(GetVersion)(
  93. void
  94. )
  95. {
  96. LOGN(
  97. eDbgLevelInfo,
  98. "[GetVersion] called. return Win2k.");
  99. return (DWORD)0x08930005;
  100. }
  101. /*++
  102. Register hooked functions
  103. --*/
  104. HOOK_BEGIN
  105. APIHOOK_ENTRY(KERNEL32.DLL, GetVersionExA)
  106. APIHOOK_ENTRY(KERNEL32.DLL, GetVersionExW)
  107. APIHOOK_ENTRY(KERNEL32.DLL, GetVersion)
  108. HOOK_END
  109. IMPLEMENT_SHIM_END