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.

169 lines
3.7 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. IMPLEMENT_SHIM_BEGIN(Win98VersionLie)
  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. BOOL g_bCheckSafeDisc = FALSE;
  24. /*++
  25. This stub function fixes up the OSVERSIONINFO structure that is
  26. returned to the caller with Windows 98 credentials.
  27. --*/
  28. BOOL
  29. APIHOOK(GetVersionExA)(
  30. OUT LPOSVERSIONINFOA lpVersionInformation
  31. )
  32. {
  33. if (g_bCheckSafeDisc && bIsSafeDisc2()) {
  34. return ORIGINAL_API(GetVersionExA)(lpVersionInformation);
  35. } else {
  36. BOOL bReturn = FALSE;
  37. if (ORIGINAL_API(GetVersionExA)(lpVersionInformation)) {
  38. LOGN(eDbgLevelInfo, "[GetVersionExA] called. return Win98");
  39. //
  40. // Fixup the structure with the Win98 data.
  41. //
  42. lpVersionInformation->dwMajorVersion = 4;
  43. lpVersionInformation->dwMinorVersion = 10;
  44. lpVersionInformation->dwBuildNumber = 0x040A08AE;
  45. lpVersionInformation->dwPlatformId = 1;
  46. *lpVersionInformation->szCSDVersion = '\0';
  47. bReturn = TRUE;
  48. }
  49. return bReturn;
  50. }
  51. }
  52. /*++
  53. This stub function fixes up the OSVERSIONINFO structure that is
  54. returned to the caller with Windows 98 credentials. This is the
  55. wide-character version of GetVersionExW.
  56. --*/
  57. BOOL
  58. APIHOOK(GetVersionExW)(
  59. OUT LPOSVERSIONINFOW lpVersionInformation
  60. )
  61. {
  62. if (g_bCheckSafeDisc && bIsSafeDisc2()) {
  63. return ORIGINAL_API(GetVersionExW)(lpVersionInformation);
  64. } else {
  65. BOOL bReturn = FALSE;
  66. if (ORIGINAL_API(GetVersionExW)(lpVersionInformation)) {
  67. LOGN(eDbgLevelInfo, "[GetVersionExW] called. return Win98");
  68. //
  69. // Fixup the structure with the Win98 data.
  70. //
  71. lpVersionInformation->dwMajorVersion = 4;
  72. lpVersionInformation->dwMinorVersion = 10;
  73. lpVersionInformation->dwBuildNumber = 0x040A08AE;
  74. lpVersionInformation->dwPlatformId = 1;
  75. *lpVersionInformation->szCSDVersion = '\0';
  76. bReturn = TRUE;
  77. }
  78. return bReturn;
  79. }
  80. }
  81. /*++
  82. This stub function returns Windows 98 credentials.
  83. --*/
  84. DWORD
  85. APIHOOK(GetVersion)(
  86. void
  87. )
  88. {
  89. if (g_bCheckSafeDisc && bIsSafeDisc2()) {
  90. return ORIGINAL_API(GetVersion)();
  91. } else {
  92. LOGN(eDbgLevelInfo, "[GetVersion] Return Win98");
  93. return (DWORD) 0xC0000A04;
  94. }
  95. }
  96. /*++
  97. Register hooked functions
  98. --*/
  99. BOOL
  100. NOTIFY_FUNCTION(
  101. DWORD fdwReason
  102. )
  103. {
  104. if (fdwReason == DLL_PROCESS_ATTACH)
  105. {
  106. g_bCheckSafeDisc = COMMAND_LINE && (_stricmp(COMMAND_LINE, "Detect_SafeDisc") == 0);
  107. if (g_bCheckSafeDisc && bIsSafeDisc1())
  108. {
  109. LOGN(eDbgLevelWarning, "SafeDisc 1.x detected: ignoring shim");
  110. return FALSE;
  111. }
  112. }
  113. return TRUE;
  114. }
  115. HOOK_BEGIN
  116. CALL_NOTIFY_FUNCTION
  117. APIHOOK_ENTRY(KERNEL32.DLL, GetVersionExA)
  118. APIHOOK_ENTRY(KERNEL32.DLL, GetVersionExW)
  119. APIHOOK_ENTRY(KERNEL32.DLL, GetVersion)
  120. HOOK_END
  121. IMPLEMENT_SHIM_END