[STORAHCI] Merge Storport Miniport driver by Aman Priyadarshi in GSoC.
[reactos.git] / reactos / dll / appcompat / shims / layer / versionlie.inl
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Shim library
4 * FILE: dll/appcompat/shims/layer/versionlie.inl
5 * PURPOSE: Version lie implementation helper
6 * PROGRAMMER: Mark Jansen
7 */
8
9
10 #include <setup_shim.inl>
11
12 DWORD WINAPI SHIM_OBJ_NAME(APIHook_GetVersion)()
13 {
14 return VERSION_INFO.FullVersion;
15 }
16
17 BOOL WINAPI SHIM_OBJ_NAME(APIHook_GetVersionExA)(LPOSVERSIONINFOEXA lpOsVersionInfo)
18 {
19 if (CALL_SHIM(0, GETVERSIONEXAPROC)(lpOsVersionInfo))
20 {
21 return FakeVersion(lpOsVersionInfo, &VERSION_INFO);
22 }
23 return FALSE;
24 }
25
26 /* We do not care about the actual type, FakeVersion will correctly handle it either way */
27 BOOL WINAPI SHIM_OBJ_NAME(APIHook_GetVersionExW)(LPOSVERSIONINFOEXA lpOsVersionInfo)
28 {
29 if (CALL_SHIM(1, GETVERSIONEXAPROC)(lpOsVersionInfo))
30 {
31 return FakeVersion(lpOsVersionInfo, &VERSION_INFO);
32 }
33 return FALSE;
34 }
35
36 /* We do not care about the actual type, FakeVersion will correctly handle it either way */
37 BOOL WINAPI SHIM_OBJ_NAME(APIHook_RtlGetVersion)(LPOSVERSIONINFOEXA lpOsVersionInfo)
38 {
39 if (CALL_SHIM(3, GETVERSIONEXAPROC)(lpOsVersionInfo))
40 {
41 return FakeVersion(lpOsVersionInfo, &VERSION_INFO);
42 }
43 return FALSE;
44 }
45
46 BOOL WINAPI SHIM_OBJ_NAME(Notify)(DWORD fdwReason, PVOID ptr)
47 {
48 if (fdwReason == SHIM_NOTIFY_ATTACH && VERSION_INFO.wServicePackMajor)
49 {
50 static CONST WCHAR szServicePack[] = {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','%','u',0};
51 HRESULT hr = StringCbPrintfA(VERSION_INFO.szCSDVersionA, sizeof(VERSION_INFO.szCSDVersionA),
52 "Service Pack %u", VERSION_INFO.wServicePackMajor);
53 if (FAILED(hr))
54 return FALSE;
55 hr = StringCbPrintfW(VERSION_INFO.szCSDVersionW, sizeof(VERSION_INFO.szCSDVersionW),
56 szServicePack, VERSION_INFO.wServicePackMajor);
57 if (FAILED(hr))
58 return FALSE;
59 }
60 return TRUE;
61 }
62
63
64 #define SHIM_NUM_HOOKS 4
65 #define SHIM_SETUP_HOOKS \
66 SHIM_HOOK(0, "KERNEL32.DLL", "GetVersionExA", SHIM_OBJ_NAME(APIHook_GetVersionExA)) \
67 SHIM_HOOK(1, "KERNEL32.DLL", "GetVersionExW", SHIM_OBJ_NAME(APIHook_GetVersionExW)) \
68 SHIM_HOOK(2, "KERNEL32.DLL", "GetVersion", SHIM_OBJ_NAME(APIHook_GetVersion)) \
69 SHIM_HOOK(3, "NTDLL.DLL", "RtlGetVersion", SHIM_OBJ_NAME(APIHook_RtlGetVersion))
70 #define SHIM_NOTIFY_FN SHIM_OBJ_NAME(Notify)
71
72 #include <implement_shim.inl>
73
74 #undef VERSION_INFO
75