ReactOS 0.4.16-dev-329-g9223134
versionlie.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS 'Layers' Shim library
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Version lie shims
5 * COPYRIGHT: Copyright 2016,2017 Mark Jansen (mark.jansen@reactos.org)
6 */
7
8#define WIN32_NO_STATUS
9#include <windef.h>
10#include <winbase.h>
11#include <shimlib.h>
12#include <strsafe.h>
13
14/* Generic version info to use with the shims */
15typedef struct VersionLieInfo
16{
24 char szCSDVersionA[20];
27
28VersionLieInfo g_Win95 = { 0xC3B60004, 4, 0, 950, VER_PLATFORM_WIN32_WINDOWS, 0, 0 };
29VersionLieInfo g_WinNT4SP5 = { 0x05650004, 4, 0, 1381, VER_PLATFORM_WIN32_NT, 5, 0 };
30VersionLieInfo g_Win98 = { 0xC0000A04, 4, 10, 0x040A08AE, VER_PLATFORM_WIN32_WINDOWS, 0, 0 };
31
32VersionLieInfo g_Win2000 = { 0x08930005, 5, 0, 2195, VER_PLATFORM_WIN32_NT, 0, 0 };
33VersionLieInfo g_Win2000SP1 = { 0x08930005, 5, 0, 2195, VER_PLATFORM_WIN32_NT, 1, 0 };
34VersionLieInfo g_Win2000SP2 = { 0x08930005, 5, 0, 2195, VER_PLATFORM_WIN32_NT, 2, 0 };
35VersionLieInfo g_Win2000SP3 = { 0x08930005, 5, 0, 2195, VER_PLATFORM_WIN32_NT, 3, 0 };
36
37VersionLieInfo g_WinXP = { 0x0a280105, 5, 1, 2600, VER_PLATFORM_WIN32_NT, 0, 0 };
38VersionLieInfo g_WinXPSP1 = { 0x0a280105, 5, 1, 2600, VER_PLATFORM_WIN32_NT, 1, 0 };
39VersionLieInfo g_WinXPSP2 = { 0x0a280105, 5, 1, 2600, VER_PLATFORM_WIN32_NT, 2, 0 };
40VersionLieInfo g_WinXPSP3 = { 0x0a280105, 5, 1, 2600, VER_PLATFORM_WIN32_NT, 3, 0 };
41
42VersionLieInfo g_Win2k3RTM = { 0x0ece0205, 5, 2, 3790, VER_PLATFORM_WIN32_NT, 0, 0 };
43VersionLieInfo g_Win2k3SP1 = { 0x0ece0205, 5, 2, 3790, VER_PLATFORM_WIN32_NT, 1, 0 };
44
45VersionLieInfo g_WinVistaRTM = { 0x17700006, 6, 0, 6000, VER_PLATFORM_WIN32_NT, 0, 0 };
46VersionLieInfo g_WinVistaSP1 = { 0x17710006, 6, 0, 6001, VER_PLATFORM_WIN32_NT, 1, 0 };
47VersionLieInfo g_WinVistaSP2 = { 0x17720006, 6, 0, 6002, VER_PLATFORM_WIN32_NT, 2, 0 };
48
49VersionLieInfo g_Win7RTM = { 0x1db00106, 6, 1, 7600, VER_PLATFORM_WIN32_NT, 0, 0 };
50VersionLieInfo g_Win7SP1 = { 0x1db10106, 6, 1, 7601, VER_PLATFORM_WIN32_NT, 1, 0 };
51
52VersionLieInfo g_Win8RTM = { 0x23f00206, 6, 2, 9200, VER_PLATFORM_WIN32_NT, 0, 0 };
53VersionLieInfo g_Win81RTM = { 0x25800306, 6, 3, 9600, VER_PLATFORM_WIN32_NT, 0, 0 };
54
55VersionLieInfo g_Win10RTM = { 0x47ba000a, 10, 0, 18362, VER_PLATFORM_WIN32_NT, 0, 0 };
56
57VersionLieInfo g_Win2k16RTM = { 0x3fab000a, 10, 0, 16299, VER_PLATFORM_WIN32_NT, 0, 0 };
58VersionLieInfo g_Win2k19RTM = { 0x4563000a, 10, 0, 17763, VER_PLATFORM_WIN32_NT, 0, 0 };
59
60/* Fill the OSVERSIONINFO[EX][W|A] struct with the info from the generic VersionLieInfo */
61
63{
64 if (pResult->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA) || pResult->dwOSVersionInfoSize == sizeof(OSVERSIONINFOA) ||
65 pResult->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXW) || pResult->dwOSVersionInfoSize == sizeof(OSVERSIONINFOW))
66 {
67 pResult->dwMajorVersion = pFake->dwMajorVersion;
68 pResult->dwMinorVersion = pFake->dwMinorVersion;
69 pResult->dwBuildNumber = pFake->dwBuildNumber;
70 pResult->dwPlatformId = pFake->dwPlatformId;
71 if (pResult->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA) || pResult->dwOSVersionInfoSize == sizeof(OSVERSIONINFOA))
72 {
73 if (FAILED(StringCbCopyA(pResult->szCSDVersion, sizeof(pResult->szCSDVersion), pFake->szCSDVersionA)))
74 return FALSE;
76 {
77 pResult->wServicePackMajor = pFake->wServicePackMajor;
78 pResult->wServicePackMinor = pFake->wServicePackMinor;
79 }
80 }
81 else
82 {
83 LPOSVERSIONINFOEXW pResultW = (LPOSVERSIONINFOEXW)pResult;
84 if (FAILED(StringCbCopyW(pResultW->szCSDVersion, sizeof(pResultW->szCSDVersion), pFake->szCSDVersionW)))
85 return FALSE;
87 {
88 pResultW->wServicePackMajor = pFake->wServicePackMajor;
89 pResultW->wServicePackMinor = pFake->wServicePackMinor;
90 }
91 }
92 return TRUE;
93 }
94 return FALSE;
95}
96
98
99
100#define SHIM_NS Win95VersionLie
101#include <setup_shim.inl>
102
104{
105 return g_Win95.FullVersion;
106}
107
109{
110 if (CALL_SHIM(1, GETVERSIONEXAPROC)(lpOsVersionInfo))
111 {
112 return FakeVersion(lpOsVersionInfo, &g_Win95);
113 }
114 return FALSE;
115}
116
117/* We do not call about the actual type, FakeVersion will correctly handle it either way */
119{
120 if (CALL_SHIM(2, GETVERSIONEXAPROC)(lpOsVersionInfo))
121 {
122 return FakeVersion(lpOsVersionInfo, &g_Win95);
123 }
124 return FALSE;
125}
126
127#define SHIM_NUM_HOOKS 3
128#define SHIM_SETUP_HOOKS \
129 SHIM_HOOK(0, "KERNEL32.DLL", "GetVersion", SHIM_OBJ_NAME(APIHook_GetVersion)) \
130 SHIM_HOOK(1, "KERNEL32.DLL", "GetVersionExA", SHIM_OBJ_NAME(APIHook_GetVersionExA)) \
131 SHIM_HOOK(2, "KERNEL32.DLL", "GetVersionExW", SHIM_OBJ_NAME(APIHook_GetVersionExW))
132
133#include <implement_shim.inl>
134
135
136
137
138#define SHIM_NS Win98VersionLie
139#include <setup_shim.inl>
140
141DWORD WINAPI SHIM_OBJ_NAME(APIHook_GetVersion)()
142{
143 return g_Win98.FullVersion;
144}
145
146BOOL WINAPI SHIM_OBJ_NAME(APIHook_GetVersionExA)(LPOSVERSIONINFOEXA lpOsVersionInfo)
147{
148 if (CALL_SHIM(0, GETVERSIONEXAPROC)(lpOsVersionInfo))
149 {
150 return FakeVersion(lpOsVersionInfo, &g_Win98);
151 }
152 return FALSE;
153}
154
155/* We do not call about the actual type, FakeVersion will correctly handle it either way */
156BOOL WINAPI SHIM_OBJ_NAME(APIHook_GetVersionExW)(LPOSVERSIONINFOEXA lpOsVersionInfo)
157{
158 if (CALL_SHIM(1, GETVERSIONEXAPROC)(lpOsVersionInfo))
159 {
160 return FakeVersion(lpOsVersionInfo, &g_Win98);
161 }
162 return FALSE;
163}
164
165#define SHIM_NUM_HOOKS 3
166#define SHIM_SETUP_HOOKS \
167 SHIM_HOOK(2, "KERNEL32.DLL", "GetVersion", SHIM_OBJ_NAME(APIHook_GetVersion)) \
168 SHIM_HOOK(0, "KERNEL32.DLL", "GetVersionExA", SHIM_OBJ_NAME(APIHook_GetVersionExA)) \
169 SHIM_HOOK(1, "KERNEL32.DLL", "GetVersionExW", SHIM_OBJ_NAME(APIHook_GetVersionExW))
170
171#include <implement_shim.inl>
172
173
174
175#define SHIM_NS WinNT4SP5VersionLie
176#define VERSION_INFO g_WinNT4SP5
177#include "versionlie.inl"
178
179
180#define SHIM_NS Win2000VersionLie
181#define VERSION_INFO g_Win2000
182#include "versionlie.inl"
183
184#define SHIM_NS Win2000SP1VersionLie
185#define VERSION_INFO g_Win2000SP1
186#include "versionlie.inl"
187
188#define SHIM_NS Win2000SP2VersionLie
189#define VERSION_INFO g_Win2000SP2
190#include "versionlie.inl"
191
192#define SHIM_NS Win2000SP3VersionLie
193#define VERSION_INFO g_Win2000SP3
194#include "versionlie.inl"
195
196
197#define SHIM_NS WinXPVersionLie
198#define VERSION_INFO g_WinXP
199#include "versionlie.inl"
200
201#define SHIM_NS WinXPSP1VersionLie
202#define VERSION_INFO g_WinXPSP1
203#include "versionlie.inl"
204
205#define SHIM_NS WinXPSP2VersionLie
206#define VERSION_INFO g_WinXPSP2
207#include "versionlie.inl"
208
209#define SHIM_NS WinXPSP3VersionLie
210#define VERSION_INFO g_WinXPSP3
211#include "versionlie.inl"
212
213
214#define SHIM_NS Win2k3RTMVersionLie
215#define VERSION_INFO g_Win2k3RTM
216#include "versionlie.inl"
217
218#define SHIM_NS Win2k3SP1VersionLie
219#define VERSION_INFO g_Win2k3SP1
220#include "versionlie.inl"
221
222
223#define SHIM_NS VistaRTMVersionLie
224#define VERSION_INFO g_WinVistaRTM
225#include "versionlie.inl"
226
227#define SHIM_NS VistaSP1VersionLie
228#define VERSION_INFO g_WinVistaSP1
229#include "versionlie.inl"
230
231#define SHIM_NS VistaSP2VersionLie
232#define VERSION_INFO g_WinVistaSP2
233#include "versionlie.inl"
234
235
236#define SHIM_NS Win7RTMVersionLie
237#define VERSION_INFO g_Win7RTM
238#include "versionlie.inl"
239
240#define SHIM_NS Win7SP1VersionLie
241#define VERSION_INFO g_Win7SP1
242#include "versionlie.inl"
243
244
245#define SHIM_NS Win8RTMVersionLie
246#define VERSION_INFO g_Win8RTM
247#include "versionlie.inl"
248
249#define SHIM_NS Win81RTMVersionLie
250#define VERSION_INFO g_Win81RTM
251#include "versionlie.inl"
252
253
254#define SHIM_NS Win10RTMVersionLie
255#define VERSION_INFO g_Win10RTM
256#include "versionlie.inl"
257
258
259#define SHIM_NS Win2k16RTMVersionLie
260#define VERSION_INFO g_Win2k16RTM
261#include "versionlie.inl"
262
263
264#define SHIM_NS Win2k19RTMVersionLie
265#define VERSION_INFO g_Win2k19RTM
266#include "versionlie.inl"
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
VersionLieInfo g_Win8RTM
Definition: versionlie.c:52
struct VersionLieInfo VersionLieInfo
VersionLieInfo g_Win2000
Definition: versionlie.c:32
VersionLieInfo g_Win2k3SP1
Definition: versionlie.c:43
VersionLieInfo g_Win2000SP2
Definition: versionlie.c:34
VersionLieInfo g_WinNT4SP5
Definition: versionlie.c:29
VersionLieInfo g_WinVistaRTM
Definition: versionlie.c:45
VersionLieInfo g_WinXPSP1
Definition: versionlie.c:38
VersionLieInfo g_Win7SP1
Definition: versionlie.c:50
VersionLieInfo g_WinXP
Definition: versionlie.c:37
VersionLieInfo g_Win7RTM
Definition: versionlie.c:49
BOOL WINAPI SHIM_OBJ_NAME() APIHook_GetVersionExW(LPOSVERSIONINFOEXA lpOsVersionInfo)
Definition: versionlie.c:118
BOOL WINAPI SHIM_OBJ_NAME() APIHook_GetVersionExA(LPOSVERSIONINFOEXA lpOsVersionInfo)
Definition: versionlie.c:108
BOOL(WINAPI * GETVERSIONEXAPROC)(LPOSVERSIONINFOEXA)
Definition: versionlie.c:97
VersionLieInfo g_Win2000SP1
Definition: versionlie.c:33
VersionLieInfo g_Win81RTM
Definition: versionlie.c:53
VersionLieInfo g_Win95
Definition: versionlie.c:28
VersionLieInfo g_Win10RTM
Definition: versionlie.c:55
VersionLieInfo g_Win2k19RTM
Definition: versionlie.c:58
VersionLieInfo g_Win98
Definition: versionlie.c:30
VersionLieInfo g_Win2k16RTM
Definition: versionlie.c:57
VersionLieInfo g_Win2k3RTM
Definition: versionlie.c:42
VersionLieInfo g_WinXPSP2
Definition: versionlie.c:39
DWORD WINAPI SHIM_OBJ_NAME() APIHook_GetVersion()
Definition: versionlie.c:103
VersionLieInfo g_Win2000SP3
Definition: versionlie.c:35
VersionLieInfo g_WinVistaSP2
Definition: versionlie.c:47
VersionLieInfo g_WinXPSP3
Definition: versionlie.c:40
BOOL FakeVersion(LPOSVERSIONINFOEXA pResult, VersionLieInfo *pFake)
Definition: versionlie.c:62
VersionLieInfo g_WinVistaSP1
Definition: versionlie.c:46
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
#define FAILED(hr)
Definition: intsafe.h:51
#define VER_PLATFORM_WIN32_NT
Definition: rtltypes.h:238
#define VER_PLATFORM_WIN32_WINDOWS
Definition: rtltypes.h:237
#define BOOL
Definition: nt_native.h:43
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
STRSAFEAPI StringCbCopyA(STRSAFE_LPSTR pszDest, size_t cbDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:161
WORD dwPlatformId
Definition: versionlie.c:21
WORD wServicePackMinor
Definition: versionlie.c:23
char szCSDVersionA[20]
Definition: versionlie.c:24
DWORD dwBuildNumber
Definition: versionlie.c:20
WORD wServicePackMajor
Definition: versionlie.c:22
DWORD FullVersion
Definition: versionlie.c:17
WORD dwMajorVersion
Definition: versionlie.c:18
WCHAR szCSDVersionW[20]
Definition: versionlie.c:25
WORD dwMinorVersion
Definition: versionlie.c:19
ULONG dwMajorVersion
Definition: rtltypes.h:256
ULONG dwMinorVersion
Definition: rtltypes.h:257
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:255
ULONG dwBuildNumber
Definition: rtltypes.h:258
USHORT wServicePackMajor
Definition: rtltypes.h:261
CHAR szCSDVersion[128]
Definition: rtltypes.h:260
USHORT wServicePackMinor
Definition: rtltypes.h:262
ULONG dwPlatformId
Definition: rtltypes.h:259
WCHAR szCSDVersion[128]
Definition: rtltypes.h:274
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:269
USHORT wServicePackMinor
Definition: rtltypes.h:276
USHORT wServicePackMajor
Definition: rtltypes.h:275
#define WINAPI
Definition: msvc.h:6
struct _OSVERSIONINFOEXA * LPOSVERSIONINFOEXA
struct _OSVERSIONINFOEXW * LPOSVERSIONINFOEXW
__wchar_t WCHAR
Definition: xmlstorage.h:180