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.

129 lines
3.2 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. 02/14/2002 mnikkel Converted to use strsafe.h
  15. --*/
  16. #include "precomp.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. #ifndef ARRAYSIZE
  25. #define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
  26. #endif
  27. /*++
  28. This stub function fixes up the OSVERSIONINFO structure that is
  29. returned to the caller with Windows NT Service Pack 5 credentials.
  30. --*/
  31. BOOL
  32. APIHOOK(GetVersionExA)(LPOSVERSIONINFOA lpVersionInformation)
  33. {
  34. BOOL bReturn = FALSE;
  35. if (ORIGINAL_API(GetVersionExA)(lpVersionInformation)) {
  36. // Fixup the structure with the NT data
  37. lpVersionInformation->dwMajorVersion = 4;
  38. lpVersionInformation->dwMinorVersion = 0;
  39. lpVersionInformation->dwBuildNumber = 1381;
  40. lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
  41. //szCSDVersion is 128 TCHAR, our string fits with no problems.
  42. StringCchCopyA(lpVersionInformation->szCSDVersion,
  43. ARRAYSIZE(lpVersionInformation->szCSDVersion), "Service Pack 5");
  44. DPFN( eDbgLevelInfo, "GetVersionExA called. return NT4 SP5\n");
  45. bReturn = TRUE;
  46. }
  47. return bReturn;
  48. }
  49. /*++
  50. This stub function fixes up the OSVERSIONINFO structure that is returned to
  51. the caller with Win NT Service Pack 5 credentials. This is the
  52. wide-character version of GetVersionExW.
  53. --*/
  54. BOOL
  55. APIHOOK(GetVersionExW)(LPOSVERSIONINFOW lpVersionInformation)
  56. {
  57. BOOL bReturn = FALSE;
  58. if (ORIGINAL_API(GetVersionExW)(lpVersionInformation)) {
  59. // Fixup the structure with the Win NT Service Pack 5 data
  60. lpVersionInformation->dwMajorVersion = 4;
  61. lpVersionInformation->dwMinorVersion = 0;
  62. lpVersionInformation->dwBuildNumber = 1381;
  63. lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
  64. //szCSDVersion is 128 TCHAR, our string fits with no problems.
  65. StringCchCopyW(lpVersionInformation->szCSDVersion,
  66. ARRAYSIZE(lpVersionInformation->szCSDVersion), L"Service Pack 5");
  67. DPFN( eDbgLevelInfo, "GetVersionExW called. return NT4 SP5\n");
  68. bReturn = TRUE;
  69. }
  70. return bReturn;
  71. }
  72. /*++
  73. This stub function returns Windows NT 4.0 credentials.
  74. --*/
  75. DWORD
  76. APIHOOK(GetVersion)()
  77. {
  78. DPFN( eDbgLevelInfo, "GetVersion called. return NT4 SP5\n");
  79. return (DWORD) 0x05650004;
  80. }
  81. /*++
  82. Register hooked functions
  83. --*/
  84. HOOK_BEGIN
  85. APIHOOK_ENTRY(KERNEL32.DLL, GetVersionExA )
  86. APIHOOK_ENTRY(KERNEL32.DLL, GetVersionExW )
  87. APIHOOK_ENTRY(KERNEL32.DLL, GetVersion )
  88. HOOK_END
  89. IMPLEMENT_SHIM_END