diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 1908573..9b58640 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -9658,10 +9658,20 @@ INT64 twinui_pcshell_IsUndockedAssetAvailableHook(INT a1, INT64 a2, INT64 a3, co // else, show Windows 11 style basically else { - return twinui_pcshell_IsUndockedAssetAvailableFunc(a1, a2, a3, a4); + if (twinui_pcshell_IsUndockedAssetAvailableFunc) + return twinui_pcshell_IsUndockedAssetAvailableFunc(a1, a2, a3, a4); + return 1; } } +INT64(*twinui_pcshell_CMultitaskingViewManager__CreateDCompMTVHostFunc)(INT64 a1, unsigned int a2, INT64 a3, INT64 a4, INT64* a5); +INT64(*twinui_pcshell_CMultitaskingViewManager__CreateXamlMTVHostFunc)(INT64 a1, unsigned int a2, INT64 a3, INT64 a4, INT64* a5); +INT64 twinui_pcshell_CMultitaskingViewManager__CreateXamlMTVHostHook(INT64 a1, unsigned int a2, INT64 a3, INT64 a4, INT64* a5) +{ + if (!twinui_pcshell_IsUndockedAssetAvailableHook(a2, 0, 0, 0, NULL)) return twinui_pcshell_CMultitaskingViewManager__CreateDCompMTVHostFunc(a1, a2, a3, a4, a5); + return twinui_pcshell_CMultitaskingViewManager__CreateXamlMTVHostFunc(a1, a2, a3, a4, a5); +} + BOOL IsDebuggerPresentHook() { return FALSE; @@ -10180,17 +10190,37 @@ DWORD Inject(BOOL bIsExplorer) if (symbols_PTRS.twinui_pcshell_PTRS[7] && symbols_PTRS.twinui_pcshell_PTRS[7] != 0xFFFFFFFF) { - twinui_pcshell_IsUndockedAssetAvailableFunc = (INT64(*)(void*, POINT*)) - ((uintptr_t)hTwinuiPcshell + symbols_PTRS.twinui_pcshell_PTRS[7]); - rv = funchook_prepare( - funchook, - (void**)&twinui_pcshell_IsUndockedAssetAvailableFunc, - twinui_pcshell_IsUndockedAssetAvailableHook - ); - if (rv != 0) + if (IsWindows11Version22H2OrHigher()) { - FreeLibraryAndExitThread(hModule, rv); - return rv; + twinui_pcshell_CMultitaskingViewManager__CreateDCompMTVHostFunc = (INT64(*)(void*, POINT*)) + ((uintptr_t)hTwinuiPcshell + symbols_PTRS.twinui_pcshell_PTRS[TWINUI_PCSHELL_SB_CNT - 1]); + twinui_pcshell_CMultitaskingViewManager__CreateXamlMTVHostFunc = (INT64(*)(void*, POINT*)) + ((uintptr_t)hTwinuiPcshell + symbols_PTRS.twinui_pcshell_PTRS[7]); + rv = funchook_prepare( + funchook, + (void**)&twinui_pcshell_CMultitaskingViewManager__CreateXamlMTVHostFunc, + twinui_pcshell_CMultitaskingViewManager__CreateXamlMTVHostHook + ); + if (rv != 0) + { + FreeLibraryAndExitThread(hModule, rv); + return rv; + } + } + else + { + twinui_pcshell_IsUndockedAssetAvailableFunc = (INT64(*)(void*, POINT*)) + ((uintptr_t)hTwinuiPcshell + symbols_PTRS.twinui_pcshell_PTRS[7]); + rv = funchook_prepare( + funchook, + (void**)&twinui_pcshell_IsUndockedAssetAvailableFunc, + twinui_pcshell_IsUndockedAssetAvailableHook + ); + if (rv != 0) + { + FreeLibraryAndExitThread(hModule, rv); + return rv; + } } } diff --git a/ExplorerPatcher/symbols.c b/ExplorerPatcher/symbols.c index bcebccc..7e7d46d 100644 --- a/ExplorerPatcher/symbols.c +++ b/ExplorerPatcher/symbols.c @@ -246,6 +246,16 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params) VirtualProtect(twinui_pcshell_SN, sizeof(twinui_pcshell_SN), flOldProtect, &flOldProtect); } } + if (IsWindows11Version22H2OrHigher()) + { + DWORD flOldProtect = 0; + if (VirtualProtect(twinui_pcshell_SN, sizeof(twinui_pcshell_SN), PAGE_EXECUTE_READWRITE, &flOldProtect)) + { + twinui_pcshell_SN[7] = "CMultitaskingViewManager::_CreateXamlMTVHost"; + twinui_pcshell_SN[TWINUI_PCSHELL_SB_CNT - 1] = "CMultitaskingViewManager::_CreateDCompMTVHost"; + VirtualProtect(twinui_pcshell_SN, sizeof(twinui_pcshell_SN), flOldProtect, &flOldProtect); + } + } if (VnGetSymbols( szSettingsPath, symbols_PTRS.twinui_pcshell_PTRS, @@ -1124,6 +1134,17 @@ BOOL LoadSymbols(symbols_addr* symbols_PTRS, HMODULE hModule) &(symbols_PTRS->twinui_pcshell_PTRS[7]), &dwSize ); + if (IsWindows11Version22H2OrHigher()) + { + RegQueryValueExW( + hKey, + TEXT(TWINUI_PCSHELL_SB_LAST), + 0, + NULL, + &(symbols_PTRS->twinui_pcshell_PTRS[TWINUI_PCSHELL_SB_CNT - 1]), + &dwSize + ); + } RegCloseKey(hKey); if (IsWindows11()) diff --git a/ExplorerPatcher/symbols.h b/ExplorerPatcher/symbols.h index a6aa5e1..d70b55c 100644 --- a/ExplorerPatcher/symbols.h +++ b/ExplorerPatcher/symbols.h @@ -19,6 +19,7 @@ #define TWINUI_PCSHELL_SB_6 "CLauncherTipContextMenu::ShowLauncherTipContextMenu" #define TWINUI_PCSHELL_SB_7 "IsUndockedAssetAvailable" #define TWINUI_PCSHELL_SB_8 "winrt::Windows::Internal::Shell::implementation::MeetAndChatManager::OnMessage" // should be always last +#define TWINUI_PCSHELL_SB_LAST TWINUI_PCSHELL_SB_8 #define TWINUI_PCSHELL_SB_CNT 9 #define STARTDOCKED_SB_NAME "StartDocked" #define STARTDOCKED_SB_0 "StartDocked::LauncherFrame::ShowAllApps" // UNUSED