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.

171 lines
4.3 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. #include "StrSafe.h"
  17. IMPLEMENT_SHIM_BEGIN(Win2000SP1VersionLie)
  18. #include "ShimHookMacro.h"
  19. #define SIZE(x) sizeof(x)/sizeof(x[0])
  20. APIHOOK_ENUM_BEGIN
  21. APIHOOK_ENUM_ENTRY(GetVersionExA)
  22. APIHOOK_ENUM_ENTRY(GetVersionExW)
  23. APIHOOK_ENUM_ENTRY(GetVersion)
  24. APIHOOK_ENUM_END
  25. /*++
  26. This stub function fixes up the OSVERSIONINFO structure that is
  27. returned to the caller with Windows 2000 SP1 credentials.
  28. --*/
  29. BOOL
  30. APIHOOK(GetVersionExA)(
  31. OUT LPOSVERSIONINFOA lpVersionInformation
  32. )
  33. {
  34. BOOL bReturn = FALSE;
  35. if (ORIGINAL_API(GetVersionExA)(lpVersionInformation)) {
  36. LOGN(
  37. eDbgLevelInfo,
  38. "[GetVersionExA] called. return Win2k SP1");
  39. //
  40. // Fixup the structure with the Win2k data.
  41. //
  42. lpVersionInformation->dwMajorVersion = 5;
  43. lpVersionInformation->dwMinorVersion = 0;
  44. lpVersionInformation->dwBuildNumber = 2195;
  45. lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
  46. //strcpy(lpVersionInformation->szCSDVersion, "Service Pack 1");
  47. StringCbCopyExA(lpVersionInformation->szCSDVersion,
  48. SIZE(lpVersionInformation->szCSDVersion),
  49. "Service Pack 1", NULL , NULL, STRSAFE_NULL_ON_FAILURE);
  50. if (lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA))
  51. {
  52. // We are here as we are passed a OSVERSIONINFOEX structure.
  53. // Set the major and minor service pack numbers.
  54. ((LPOSVERSIONINFOEXA)lpVersionInformation)->wServicePackMajor = 1;
  55. ((LPOSVERSIONINFOEXA)lpVersionInformation)->wServicePackMinor = 0;
  56. }
  57. bReturn = TRUE;
  58. }
  59. return bReturn;
  60. }
  61. /*++
  62. This stub function fixes up the OSVERSIONINFO structure that is
  63. returned to the caller with Windows 95 credentials. This is the
  64. wide-character version of GetVersionExW.
  65. --*/
  66. BOOL
  67. APIHOOK(GetVersionExW)(
  68. OUT LPOSVERSIONINFOW lpVersionInformation
  69. )
  70. {
  71. BOOL bReturn = FALSE;
  72. if (ORIGINAL_API(GetVersionExW)(lpVersionInformation)) {
  73. LOGN(
  74. eDbgLevelInfo,
  75. "[GetVersionExW] called. return Win2k SP1");
  76. //
  77. // Fixup the structure with the Win2k data.
  78. //
  79. lpVersionInformation->dwMajorVersion = 5;
  80. lpVersionInformation->dwMinorVersion = 0;
  81. lpVersionInformation->dwBuildNumber = 2195;
  82. lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
  83. //wcscpy(lpVersionInformation->szCSDVersion, L"Service Pack 1");
  84. StringCbCopyExW(lpVersionInformation->szCSDVersion,
  85. SIZE(lpVersionInformation->szCSDVersion),
  86. L"Service Pack 1", NULL , NULL, STRSAFE_NULL_ON_FAILURE);
  87. if (lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXW))
  88. {
  89. // We are here as we are passed a OSVERSIONINFOEX structure.
  90. // Set the major and minor service pack numbers.
  91. ((LPOSVERSIONINFOEXW)lpVersionInformation)->wServicePackMajor = 1;
  92. ((LPOSVERSIONINFOEXW)lpVersionInformation)->wServicePackMinor = 0;
  93. }
  94. bReturn = TRUE;
  95. }
  96. return bReturn;
  97. }
  98. /*++
  99. This stub function returns Windows 95 credentials.
  100. --*/
  101. DWORD
  102. APIHOOK(GetVersion)(
  103. void
  104. )
  105. {
  106. LOGN(
  107. eDbgLevelInfo,
  108. "[GetVersion] called. return Win2k SP1");
  109. return (DWORD)0x08930005;
  110. }
  111. /*++
  112. Register hooked functions
  113. --*/
  114. HOOK_BEGIN
  115. APIHOOK_ENTRY(KERNEL32.DLL, GetVersionExA)
  116. APIHOOK_ENTRY(KERNEL32.DLL, GetVersionExW)
  117. APIHOOK_ENTRY(KERNEL32.DLL, GetVersion)
  118. HOOK_END
  119. IMPLEMENT_SHIM_END