Skip to content

Commit

Permalink
Symbols: Update explorer.exe symbols reading for 26244+
Browse files Browse the repository at this point in the history
  • Loading branch information
Amrsatrio committed Jul 3, 2024
1 parent 62dcb98 commit 9844324
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 19 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
67 changes: 58 additions & 9 deletions ExplorerPatcher/dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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];
Expand All @@ -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)();
Expand All @@ -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");
Expand All @@ -11908,6 +11952,7 @@ void PrepareAlternateTaskbarImplementation(symbols_addr* symbols_PTRS, const WCH
}

wprintf(L"[TB] Using '%s'\n", pszTaskbarDll);
return hMyTaskbar;
}
#endif
#endif
Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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");

Expand Down
6 changes: 6 additions & 0 deletions ExplorerPatcher/hooking.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 15 additions & 9 deletions ExplorerPatcher/symbols.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 9844324

Please sign in to comment.