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.

170 lines
3.5 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. Win98VersionLie.cpp
  5. Abstract:
  6. This DLL hooks GetVersion and GetVersionEx so that they return Windows 98
  7. version credentials. Applications often check to ensure that they are
  8. running on a Win9x system, even though they will run OK on an NT based
  9. system.
  10. Notes:
  11. This is a general purpose shim.
  12. History:
  13. 11/08/2000 v-hyders Created
  14. --*/
  15. #include "precomp.h"
  16. #include "LegalStr.h"
  17. IMPLEMENT_SHIM_BEGIN(Win98VersionLie)
  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. BOOL g_bCheckSafeDisc = FALSE;
  25. /*++
  26. This stub function fixes up the OSVERSIONINFO structure that is
  27. returned to the caller with Windows 98 credentials.
  28. --*/
  29. BOOL
  30. APIHOOK(GetVersionExA)(
  31. OUT LPOSVERSIONINFOA lpVersionInformation
  32. )
  33. {
  34. if (g_bCheckSafeDisc && bIsSafeDisc2()) {
  35. return ORIGINAL_API(GetVersionExA)(lpVersionInformation);
  36. } else {
  37. BOOL bReturn = FALSE;
  38. if (ORIGINAL_API(GetVersionExA)(lpVersionInformation)) {
  39. LOGN(eDbgLevelInfo, "[GetVersionExA] called. return Win98");
  40. //
  41. // Fixup the structure with the Win98 data.
  42. //
  43. lpVersionInformation->dwMajorVersion = 4;
  44. lpVersionInformation->dwMinorVersion = 10;
  45. lpVersionInformation->dwBuildNumber = 0x040A08AE;
  46. lpVersionInformation->dwPlatformId = 1;
  47. *lpVersionInformation->szCSDVersion = '\0';
  48. bReturn = TRUE;
  49. }
  50. return bReturn;
  51. }
  52. }
  53. /*++
  54. This stub function fixes up the OSVERSIONINFO structure that is
  55. returned to the caller with Windows 98 credentials. This is the
  56. wide-character version of GetVersionExW.
  57. --*/
  58. BOOL
  59. APIHOOK(GetVersionExW)(
  60. OUT LPOSVERSIONINFOW lpVersionInformation
  61. )
  62. {
  63. if (g_bCheckSafeDisc && bIsSafeDisc2()) {
  64. return ORIGINAL_API(GetVersionExW)(lpVersionInformation);
  65. } else {
  66. BOOL bReturn = FALSE;
  67. if (ORIGINAL_API(GetVersionExW)(lpVersionInformation)) {
  68. LOGN(eDbgLevelInfo, "[GetVersionExW] called. return Win98");
  69. //
  70. // Fixup the structure with the Win98 data.
  71. //
  72. lpVersionInformation->dwMajorVersion = 4;
  73. lpVersionInformation->dwMinorVersion = 10;
  74. lpVersionInformation->dwBuildNumber = 0x040A08AE;
  75. lpVersionInformation->dwPlatformId = 1;
  76. *lpVersionInformation->szCSDVersion = '\0';
  77. bReturn = TRUE;
  78. }
  79. return bReturn;
  80. }
  81. }
  82. /*++
  83. This stub function returns Windows 98 credentials.
  84. --*/
  85. DWORD
  86. APIHOOK(GetVersion)(
  87. void
  88. )
  89. {
  90. if (g_bCheckSafeDisc && bIsSafeDisc2()) {
  91. return ORIGINAL_API(GetVersion)();
  92. } else {
  93. LOGN(eDbgLevelInfo, "[GetVersion] Return Win98");
  94. return (DWORD) 0xC0000A04;
  95. }
  96. }
  97. /*++
  98. Register hooked functions
  99. --*/
  100. BOOL
  101. NOTIFY_FUNCTION(
  102. DWORD fdwReason
  103. )
  104. {
  105. if (fdwReason == DLL_PROCESS_ATTACH)
  106. {
  107. g_bCheckSafeDisc = COMMAND_LINE && (_stricmp(COMMAND_LINE, "Detect_SafeDisc") == 0);
  108. if (g_bCheckSafeDisc && bIsSafeDisc1())
  109. {
  110. LOGN(eDbgLevelWarning, "SafeDisc 1.x detected: ignoring shim");
  111. return FALSE;
  112. }
  113. }
  114. return TRUE;
  115. }
  116. HOOK_BEGIN
  117. CALL_NOTIFY_FUNCTION
  118. APIHOOK_ENTRY(KERNEL32.DLL, GetVersionExA)
  119. APIHOOK_ENTRY(KERNEL32.DLL, GetVersionExW)
  120. APIHOOK_ENTRY(KERNEL32.DLL, GetVersion)
  121. HOOK_END
  122. IMPLEMENT_SHIM_END