2016-05-28 17:55:56 +00:00
|
|
|
/*
|
2017-09-08 20:29:16 +00:00
|
|
|
* PROJECT: ReactOS 'Layers' Shim library
|
|
|
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
|
|
|
* PURPOSE: Version lie implementation helper
|
|
|
|
* COPYRIGHT: Copyright 2016,2017 Mark Jansen (mark.jansen@reactos.org)
|
2016-05-28 17:55:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <setup_shim.inl>
|
|
|
|
|
|
|
|
DWORD WINAPI SHIM_OBJ_NAME(APIHook_GetVersion)()
|
|
|
|
{
|
|
|
|
return VERSION_INFO.FullVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI SHIM_OBJ_NAME(APIHook_GetVersionExA)(LPOSVERSIONINFOEXA lpOsVersionInfo)
|
|
|
|
{
|
|
|
|
if (CALL_SHIM(0, GETVERSIONEXAPROC)(lpOsVersionInfo))
|
|
|
|
{
|
|
|
|
return FakeVersion(lpOsVersionInfo, &VERSION_INFO);
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We do not care about the actual type, FakeVersion will correctly handle it either way */
|
|
|
|
BOOL WINAPI SHIM_OBJ_NAME(APIHook_GetVersionExW)(LPOSVERSIONINFOEXA lpOsVersionInfo)
|
|
|
|
{
|
|
|
|
if (CALL_SHIM(1, GETVERSIONEXAPROC)(lpOsVersionInfo))
|
|
|
|
{
|
|
|
|
return FakeVersion(lpOsVersionInfo, &VERSION_INFO);
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We do not care about the actual type, FakeVersion will correctly handle it either way */
|
|
|
|
BOOL WINAPI SHIM_OBJ_NAME(APIHook_RtlGetVersion)(LPOSVERSIONINFOEXA lpOsVersionInfo)
|
|
|
|
{
|
|
|
|
if (CALL_SHIM(3, GETVERSIONEXAPROC)(lpOsVersionInfo))
|
|
|
|
{
|
|
|
|
return FakeVersion(lpOsVersionInfo, &VERSION_INFO);
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2016-12-16 19:18:26 +00:00
|
|
|
BOOL WINAPI SHIM_OBJ_NAME(Notify)(DWORD fdwReason, PVOID ptr)
|
2016-05-28 17:55:56 +00:00
|
|
|
{
|
2016-12-16 19:18:26 +00:00
|
|
|
if (fdwReason == SHIM_NOTIFY_ATTACH && VERSION_INFO.wServicePackMajor)
|
2016-05-28 17:55:56 +00:00
|
|
|
{
|
2016-05-31 18:02:54 +00:00
|
|
|
static CONST WCHAR szServicePack[] = {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','%','u',0};
|
2016-05-28 17:55:56 +00:00
|
|
|
HRESULT hr = StringCbPrintfA(VERSION_INFO.szCSDVersionA, sizeof(VERSION_INFO.szCSDVersionA),
|
|
|
|
"Service Pack %u", VERSION_INFO.wServicePackMajor);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return FALSE;
|
2016-07-13 18:10:37 +00:00
|
|
|
hr = StringCbPrintfW(VERSION_INFO.szCSDVersionW, sizeof(VERSION_INFO.szCSDVersionW),
|
2016-05-31 18:02:54 +00:00
|
|
|
szServicePack, VERSION_INFO.wServicePackMajor);
|
2016-05-28 17:55:56 +00:00
|
|
|
if (FAILED(hr))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define SHIM_NUM_HOOKS 4
|
|
|
|
#define SHIM_SETUP_HOOKS \
|
|
|
|
SHIM_HOOK(0, "KERNEL32.DLL", "GetVersionExA", SHIM_OBJ_NAME(APIHook_GetVersionExA)) \
|
|
|
|
SHIM_HOOK(1, "KERNEL32.DLL", "GetVersionExW", SHIM_OBJ_NAME(APIHook_GetVersionExW)) \
|
|
|
|
SHIM_HOOK(2, "KERNEL32.DLL", "GetVersion", SHIM_OBJ_NAME(APIHook_GetVersion)) \
|
|
|
|
SHIM_HOOK(3, "NTDLL.DLL", "RtlGetVersion", SHIM_OBJ_NAME(APIHook_RtlGetVersion))
|
|
|
|
#define SHIM_NOTIFY_FN SHIM_OBJ_NAME(Notify)
|
|
|
|
|
|
|
|
#include <implement_shim.inl>
|
|
|
|
|
|
|
|
#undef VERSION_INFO
|
2016-05-31 18:02:54 +00:00
|
|
|
|