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.

122 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. WinNT4SP5VersionLie.cpp
  5. Abstract:
  6. This DLL APIHooks GetVersion and GetVersionEx so that they return Windows NT
  7. Service Pack 5 version credentials. Applications often check to ensure that
  8. they are running on a certain Win NTsystem, even though the current system
  9. is of higher build then the one they are checking for.
  10. Notes:
  11. This is a general purpose shim.
  12. History:
  13. 11/10/1999 v-johnwh Created
  14. --*/
  15. #include "precomp.h"
  16. #include "LegalStr.h"
  17. IMPLEMENT_SHIM_BEGIN(WinNT4SP5VersionLie)
  18. #include "ShimHookMacro.h"
  19. APIHOOK_ENUM_BEGIN
  20. APIHOOK_ENUM_ENTRY(GetVersionExA)
  21. APIHOOK_ENUM_ENTRY(GetVersionExW)
  22. APIHOOK_ENUM_ENTRY(GetVersion)
  23. APIHOOK_ENUM_END
  24. /*++
  25. This stub function fixes up the OSVERSIONINFO structure that is
  26. returned to the caller with Windows NT Service Pack 5 credentials.
  27. --*/
  28. BOOL
  29. APIHOOK(GetVersionExA)(LPOSVERSIONINFOA lpVersionInformation)
  30. {
  31. BOOL bReturn = FALSE;
  32. if (ORIGINAL_API(GetVersionExA)(lpVersionInformation)) {
  33. // Fixup the structure with the NT data
  34. lpVersionInformation->dwMajorVersion = 4;
  35. lpVersionInformation->dwMinorVersion = 0;
  36. lpVersionInformation->dwBuildNumber = 1381;
  37. lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
  38. strcpy(lpVersionInformation->szCSDVersion, "Service Pack 5");
  39. DPFN( eDbgLevelInfo, "GetVersionExA called. return NT4 SP5\n");
  40. bReturn = TRUE;
  41. }
  42. return bReturn;
  43. }
  44. /*++
  45. This stub function fixes up the OSVERSIONINFO structure that is returned to
  46. the caller with Win NT Service Pack 5 credentials. This is the
  47. wide-character version of GetVersionExW.
  48. --*/
  49. BOOL
  50. APIHOOK(GetVersionExW)(LPOSVERSIONINFOW lpVersionInformation)
  51. {
  52. BOOL bReturn = FALSE;
  53. if (ORIGINAL_API(GetVersionExW)(lpVersionInformation)) {
  54. // Fixup the structure with the Win NT Service Pack 5 data
  55. lpVersionInformation->dwMajorVersion = 4;
  56. lpVersionInformation->dwMinorVersion = 0;
  57. lpVersionInformation->dwBuildNumber = 1381;
  58. lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
  59. wcscpy( lpVersionInformation->szCSDVersion, L"Service Pack 5" );
  60. DPFN( eDbgLevelInfo, "GetVersionExW called. return NT4 SP5\n");
  61. bReturn = TRUE;
  62. }
  63. return bReturn;
  64. }
  65. /*++
  66. This stub function returns Windows NT 4.0 credentials.
  67. --*/
  68. DWORD
  69. APIHOOK(GetVersion)()
  70. {
  71. DPFN( eDbgLevelInfo, "GetVersion called. return NT4 SP5\n");
  72. return (DWORD) 0x05650004;
  73. }
  74. /*++
  75. Register hooked functions
  76. --*/
  77. HOOK_BEGIN
  78. APIHOOK_ENTRY(KERNEL32.DLL, GetVersionExA )
  79. APIHOOK_ENTRY(KERNEL32.DLL, GetVersionExW )
  80. APIHOOK_ENTRY(KERNEL32.DLL, GetVersion )
  81. HOOK_END
  82. IMPLEMENT_SHIM_END