1/* 2 * PROJECT: ReactOS 'Layers' Shim library 3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) 4 * PURPOSE: Version lie implementation helper 5 * COPYRIGHT: Copyright 2016,2017 Mark Jansen (mark.jansen@reactos.org) 6 */ 7 8#include <setup_shim.inl> 9 10DWORD WINAPI SHIM_OBJ_NAME(APIHook_GetVersion)() 11{ 12 return VERSION_INFO.FullVersion; 13} 14 15BOOL WINAPI SHIM_OBJ_NAME(APIHook_GetVersionExA)(LPOSVERSIONINFOEXA lpOsVersionInfo) 16{ 17 if (CALL_SHIM(0, GETVERSIONEXAPROC)(lpOsVersionInfo)) 18 { 19 return FakeVersion(lpOsVersionInfo, &VERSION_INFO); 20 } 21 return FALSE; 22} 23 24/* We do not care about the actual type, FakeVersion will correctly handle it either way */ 25BOOL WINAPI SHIM_OBJ_NAME(APIHook_GetVersionExW)(LPOSVERSIONINFOEXA lpOsVersionInfo) 26{ 27 if (CALL_SHIM(1, GETVERSIONEXAPROC)(lpOsVersionInfo)) 28 { 29 return FakeVersion(lpOsVersionInfo, &VERSION_INFO); 30 } 31 return FALSE; 32} 33 34#ifndef STATUS_INVALID_PARAMETER 35#define STATUS_INVALID_PARAMETER 0xC000000DL 36#define STATUS_SUCCESS 0 37#endif 38 39/* We do not care about the actual type, FakeVersion will correctly handle it either way */ 40DWORD WINAPI SHIM_OBJ_NAME(APIHook_RtlGetVersion)(LPOSVERSIONINFOEXA lpOsVersionInfo) 41{ 42 if (CALL_SHIM(3, GETVERSIONEXAPROC)(lpOsVersionInfo) == STATUS_SUCCESS) 43 { 44 return FakeVersion(lpOsVersionInfo, &VERSION_INFO) ? STATUS_SUCCESS : STATUS_INVALID_PARAMETER; 45 } 46 return STATUS_INVALID_PARAMETER; 47} 48 49BOOL WINAPI SHIM_OBJ_NAME(Notify)(DWORD fdwReason, PVOID ptr) 50{ 51 if (fdwReason == SHIM_NOTIFY_ATTACH && VERSION_INFO.wServicePackMajor) 52 { 53 static CONST WCHAR szServicePack[] = {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','%','u',0}; 54 HRESULT hr = StringCbPrintfA(VERSION_INFO.szCSDVersionA, sizeof(VERSION_INFO.szCSDVersionA), 55 "Service Pack %u", VERSION_INFO.wServicePackMajor); 56 if (FAILED(hr)) 57 return FALSE; 58 hr = StringCbPrintfW(VERSION_INFO.szCSDVersionW, sizeof(VERSION_INFO.szCSDVersionW), 59 szServicePack, VERSION_INFO.wServicePackMajor); 60 if (FAILED(hr)) 61 return FALSE; 62 } 63 return TRUE; 64} 65 66 67#define SHIM_NUM_HOOKS 4 68#define SHIM_SETUP_HOOKS \ 69 SHIM_HOOK(0, "KERNEL32.DLL", "GetVersionExA", SHIM_OBJ_NAME(APIHook_GetVersionExA)) \ 70 SHIM_HOOK(1, "KERNEL32.DLL", "GetVersionExW", SHIM_OBJ_NAME(APIHook_GetVersionExW)) \ 71 SHIM_HOOK(2, "KERNEL32.DLL", "GetVersion", SHIM_OBJ_NAME(APIHook_GetVersion)) \ 72 SHIM_HOOK(3, "NTDLL.DLL", "RtlGetVersion", SHIM_OBJ_NAME(APIHook_RtlGetVersion)) 73#define SHIM_NOTIFY_FN SHIM_OBJ_NAME(Notify) 74 75#include <implement_shim.inl> 76 77#undef VERSION_INFO 78 79