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.

158 lines
3.5 KiB

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