From 6bc2ea5d2b0b6fbfe2ba62cdb425d6dc0992b10f Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Mon, 20 Mar 2023 23:58:32 +0200 Subject: [PATCH] All: Fix crash when attempting to hook function on older OS builds `RtlQueryFeatureConfiguration` is not available on old Windows 10 builds, like 17763 (LTSC 2019). Related issue: https://github.com/valinet/ExplorerPatcher/discussions/1142 --- ExplorerPatcher/dllmain.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 5b85cd6c0..eff4795cf 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -10161,15 +10161,17 @@ DWORD Inject(BOOL bIsExplorer) } RtlQueryFeatureConfigurationFunc = GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "RtlQueryFeatureConfiguration"); - rv = funchook_prepare( - funchook, - (void**)&RtlQueryFeatureConfigurationFunc, - RtlQueryFeatureConfigurationHook - ); - if (rv != 0) - { - FreeLibraryAndExitThread(hModule, rv); - return FALSE; + if (RtlQueryFeatureConfigurationFunc) { + rv = funchook_prepare( + funchook, + (void**)&RtlQueryFeatureConfigurationFunc, + RtlQueryFeatureConfigurationHook + ); + if (rv != 0) + { + FreeLibraryAndExitThread(hModule, rv); + return FALSE; + } } printf("Setup ntdll functions done\n");