From 23a4190018f14c5bb257279d3be967586660a0b0 Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Sat, 18 Mar 2023 00:43:13 +0200 Subject: [PATCH] All: Infrastructure for reporting which OS features are enabled --- ExplorerPatcher/dllmain.c | 37 +++++++++++++++++++++++++++++++++++++ ExplorerPatcher/osutility.h | 8 ++++++++ 2 files changed, 45 insertions(+) diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index affa4d6..090650e 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -50,6 +50,7 @@ HANDLE hServiceWindowThread = NULL; RTL_OSVERSIONINFOW global_rovi; DWORD32 global_ubr; #endif +#include #define WINX_ADJUST_X 5 #define WINX_ADJUST_Y 5 @@ -9583,6 +9584,29 @@ HWND user32_NtUserFindWindowExHook(HWND hWndParent, HWND hWndChildAfter, LPCWSTR #pragma endregion +#pragma region "Infrastructure for reporting which OS features are enabled" +#pragma pack(push, 1) +struct RTL_FEATURE_CONFIGURATION { + unsigned int featureId; + unsigned __int32 group : 4; + unsigned __int32 enabledState : 2; + unsigned __int32 enabledStateOptions : 1; + unsigned __int32 unused1 : 1; + unsigned __int32 variant : 6; + unsigned __int32 variantPayloadKind : 2; + unsigned __int32 unused2 : 16; + unsigned int payload; +}; +#pragma pack(pop) + +int (*RtlQueryFeatureConfigurationFunc)(UINT32 featureId, int sectionType, INT64* changeStamp, struct RTL_FEATURE_CONFIGURATION* buffer); +int RtlQueryFeatureConfigurationHook(UINT32 featureId, int sectionType, INT64* changeStamp, struct RTL_FEATURE_CONFIGURATION* buffer) { + int rv = RtlQueryFeatureConfigurationFunc(featureId, sectionType, changeStamp, buffer); + return rv; +} +#pragma endregion + + DWORD InjectBasicFunctions(BOOL bIsExplorer, BOOL bInstall) { //Sleep(150); @@ -10127,6 +10151,19 @@ DWORD Inject(BOOL bIsExplorer) printf("Loaded symbols\n"); } + RtlQueryFeatureConfigurationFunc = GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "RtlQueryFeatureConfiguration"); + rv = funchook_prepare( + funchook, + (void**)&RtlQueryFeatureConfigurationFunc, + RtlQueryFeatureConfigurationHook + ); + if (rv != 0) + { + FreeLibraryAndExitThread(hModule, rv); + return FALSE; + } + printf("Setup ntdll functions done\n"); + HANDLE hUser32 = LoadLibraryW(L"user32.dll"); CreateWindowInBand = GetProcAddress(hUser32, "CreateWindowInBand"); diff --git a/ExplorerPatcher/osutility.h b/ExplorerPatcher/osutility.h index d2ae7d2..a67f9df 100644 --- a/ExplorerPatcher/osutility.h +++ b/ExplorerPatcher/osutility.h @@ -69,4 +69,12 @@ inline BOOL IsWindows11BuildHigherThan25158() if (global_rovi.dwBuildNumber > 25158) return TRUE; return FALSE; } + +inline BOOL IsWindows11Version22H2Build1413OrHigher() +{ + if (IsWindows11BuildHigherThan25158()) return TRUE; + if (!global_rovi.dwMajorVersion) global_ubr = VnGetOSVersionAndUBR(&global_rovi); + if (global_ubr >= 1413) return TRUE; + return FALSE; +} #endif \ No newline at end of file