From 9844324b5e25b6449bc9e4b2572782c1bcd8fd83 Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Thu, 4 Jul 2024 06:10:23 +0700 Subject: [PATCH] Symbols: Update explorer.exe symbols reading for 26244+ --- CHANGELOG.md | 2 +- ExplorerPatcher/dllmain.c | 67 +++++++++++++++++++++++++++++++++------ ExplorerPatcher/hooking.h | 6 ++++ ExplorerPatcher/symbols.c | 24 ++++++++------ 4 files changed, 80 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91cc369cb..c86dcc192 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ Tested on OS builds 22621.3296, 22621.3447, 22621.3527, 22635.3566, 26058.1000, ##### 3 -* All: Updated some patterns to work with 22635.3430+ (Beta) and recent 24H2 builds. (b51ef38) +* All: Updated some patterns to work with 22635.3430+ (Beta) and recent 24H2 builds. (6d22947) * This should fix the Windows 10 start menu crashing and Win+X not working on both aforementioned builds when symbols are not yet downloaded. ##### 4 diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index dc4598026..5dd58e76d 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -1861,6 +1861,18 @@ void UpdateStartMenuPositioning(LPARAM loIsShouldInitializeArray_hiIsShouldRoIni } } } + +__declspec(dllexport) unsigned __int64 FindTaskbarLayoutTokenByHMONITOR(HMONITOR hMonitor) +{ + for (DWORD i = 0; i < dwMonitorCount; i++) + { + if (hMonitorList[i].hMonitor == hMonitor) + { + return hMonitorList[i].token; + } + } + return 0; +} #else void UpdateStartMenuPositioning(LPARAM loIsShouldInitializeArray_hiIsShouldRoInitialize) {} #endif @@ -11480,10 +11492,16 @@ BOOL FixStartMenuAnimation(LPMODULEINFO mi) } // ### CStartExperienceManager::Hide() - // ``` - // 74 ?? ?? 03 00 00 00 44 88 - // ^^ Turn jz into jmp - // ``` + // * Pattern 1, mov [rbx+2A3h], r12b: + // ``` + // 74 ?? ?? 03 00 00 00 44 88 + // ^^ Turn jz into jmp + // ``` + // * Pattern 2, mov byte ptr [rbx+2A3h], 1: + // ``` + // 74 ?? ?? 03 00 00 00 C6 83 + // ^^ Turn jz into jmp + // ``` // Perform on exactly two matches PBYTE matchHideA = FindPattern( mi->lpBaseOfDll, @@ -11507,6 +11525,31 @@ BOOL FixStartMenuAnimation(LPMODULEINFO mi) } } + if (!matchHideA || !matchHideB) + { + matchHideA = FindPattern( + mi->lpBaseOfDll, + mi->SizeOfImage, + "\x74\x00\x00\x03\x00\x00\x00\xC6\x83", + "x??xxxxxx" + ); + matchHideB = NULL; + if (matchHideA) + { + printf("[SMA] matchHideA in CStartExperienceManager::Hide() = %llX\n", matchHideA - (PBYTE)mi->lpBaseOfDll); + matchHideB = FindPattern( + matchHideA + 14, + mi->SizeOfImage - (matchHideA + 14 - (PBYTE)mi->lpBaseOfDll), + "\x74\x00\x00\x03\x00\x00\x00\xC6\x83", + "x??xxxxxx" + ); + if (matchHideB) + { + printf("[SMA] matchHideB in CStartExperienceManager::Hide() = %llX\n", matchHideB - (PBYTE)mi->lpBaseOfDll); + } + } + } + if (!matchVtable || !matchSingleViewShellExperienceFields || !matchAnimationHelperFields @@ -11859,11 +11902,11 @@ const WCHAR* GetTaskbarDllChecked(symbols_addr* symbols_PTRS) return pszTaskbarDll; } -void PrepareAlternateTaskbarImplementation(symbols_addr* symbols_PTRS, const WCHAR* pszTaskbarDll) +HMODULE PrepareAlternateTaskbarImplementation(symbols_addr* symbols_PTRS, const WCHAR* pszTaskbarDll) { if (!symbols_PTRS || !pszTaskbarDll) { - return; + return NULL; } wchar_t szPath[MAX_PATH]; @@ -11875,7 +11918,7 @@ void PrepareAlternateTaskbarImplementation(symbols_addr* symbols_PTRS, const WCH if (!hMyTaskbar) { wprintf(L"[TB] '%s' not found\n", pszTaskbarDll); - return; + return NULL; } typedef DWORD (*GetVersion_t)(); @@ -11884,7 +11927,8 @@ void PrepareAlternateTaskbarImplementation(symbols_addr* symbols_PTRS, const WCH if (version != 2) { wprintf(L"[TB] '%s' with version %d is not compatible\n", pszTaskbarDll, version); - return; + FreeLibrary(hMyTaskbar); + return NULL; } explorer_TrayUI_CreateInstanceFunc = GetProcAddress(hMyTaskbar, "EP_TrayUI_CreateInstance"); @@ -11908,6 +11952,7 @@ void PrepareAlternateTaskbarImplementation(symbols_addr* symbols_PTRS, const WCH } wprintf(L"[TB] Using '%s'\n", pszTaskbarDll); + return hMyTaskbar; } #endif #endif @@ -12764,7 +12809,7 @@ DWORD Inject(BOOL bIsExplorer) VnPatchIAT(hTwinuiPcshell, "API-MS-WIN-CORE-REGISTRY-L1-1-0.DLL", "RegGetValueW", twinuipcshell_RegGetValueW); #if WITH_ALT_TASKBAR_IMPL - PrepareAlternateTaskbarImplementation(&symbols_PTRS, pszTaskbarDll); + HMODULE hMyTaskbar = PrepareAlternateTaskbarImplementation(&symbols_PTRS, pszTaskbarDll); #endif printf("Setup twinui.pcshell functions done\n"); @@ -13151,6 +13196,10 @@ DWORD Inject(BOOL bIsExplorer) VnPatchDelayIAT(hExplorer, "ext-ms-win-rtcore-ntuser-window-ext-l1-1-0.dll", "GetClientRect", TaskbarCenter_GetClientRectHook); +#if WITH_ALT_TASKBAR_IMPL + if (hMyTaskbar) + VnPatchIAT(hMyTaskbar, "USER32.dll", "GetClientRect", TaskbarCenter_GetClientRectHook); +#endif VnPatchIAT(hExplorer, "SHCORE.dll", (LPCSTR)190, TaskbarCenter_SHWindowsPolicy); printf("Initialized taskbar centering module.\n"); diff --git a/ExplorerPatcher/hooking.h b/ExplorerPatcher/hooking.h index e47dc2cdc..39e0df9e6 100644 --- a/ExplorerPatcher/hooking.h +++ b/ExplorerPatcher/hooking.h @@ -96,8 +96,14 @@ extern "C" #endif #if HOW_TO_HOOK == HOOK_WITH_FUNCHOOK +#ifdef __cplusplus +inline +#endif funchook_t* funchook; #elif HOW_TO_HOOK == HOOK_WITH_DETOURS +#ifdef __cplusplus +inline +#endif void* funchook; #endif diff --git a/ExplorerPatcher/symbols.c b/ExplorerPatcher/symbols.c index 8704a73cb..3c240fc4e 100644 --- a/ExplorerPatcher/symbols.c +++ b/ExplorerPatcher/symbols.c @@ -8,6 +8,9 @@ const char* explorer_SN[EXPLORER_SB_CNT] = { EXPLORER_SB_4, EXPLORER_SB_5 }; +const char* explorer_SN_26244[1] = { + EXPLORER_SB_4, +}; const char* twinui_pcshell_SN[TWINUI_PCSHELL_SB_CNT] = { TWINUI_PCSHELL_SB_0, TWINUI_PCSHELL_SB_1, @@ -113,16 +116,19 @@ static BOOL ProcessExplorerSymbols(const char* pszSettingsPath, DWORD* pOffsets) } printf("[Symbols] Reading symbols...\n"); - if (VnGetSymbols( - pszSettingsPath, - pOffsets, - explorer_SN, - EXPLORER_SB_CNT - )) + if (VnGetSymbols(pszSettingsPath, pOffsets, explorer_SN, ARRAYSIZE(explorer_SN)) != 0) { - printf("[Symbols] Failure in reading symbols for \"%s\".\n", explorer_sb_dll); - if (hKey) RegCloseKey(hKey); - return FALSE; + DWORD offsets26244[ARRAYSIZE(explorer_SN_26244)]; + if (VnGetSymbols(pszSettingsPath, offsets26244, explorer_SN_26244, ARRAYSIZE(explorer_SN_26244)) == 0) + { + pOffsets[4] = offsets26244[0]; + } + else + { + printf("[Symbols] Failure in reading symbols for \"%s\".\n", explorer_sb_dll); + if (hKey) RegCloseKey(hKey); + return FALSE; + } } RegSetValueExW(hKey, TEXT(EXPLORER_SB_0), 0, REG_DWORD, &pOffsets[0], sizeof(DWORD));