diff --git a/mods/explorer-frame-classic.wh.cpp b/mods/explorer-frame-classic.wh.cpp index 156caa62..d8e7c364 100644 --- a/mods/explorer-frame-classic.wh.cpp +++ b/mods/explorer-frame-classic.wh.cpp @@ -2,7 +2,7 @@ // @id explorer-frame-classic // @name Classic Explorer navigation bar // @description Restores the classic Explorer navigation bar to the version before the Windows 11 "Moments 4" update -// @version 1.0.4 +// @version 1.0.5 // @author m417z // @github https://github.com/m417z // @twitter https://twitter.com/m417z @@ -537,6 +537,26 @@ bool HandleNavigationBarControl(IUnknown* navigationBarControl) { return true; } +using XamlIslandViewAdapter_GetScaledXamlIslandLogicalHeight_t = + int(WINAPI*)(PVOID pThis); +XamlIslandViewAdapter_GetScaledXamlIslandLogicalHeight_t + XamlIslandViewAdapter_GetScaledXamlIslandLogicalHeight_Original; +int WINAPI +XamlIslandViewAdapter_GetScaledXamlIslandLogicalHeight_Hook(PVOID pThis) { + Wh_Log(L">"); + + int ret = + XamlIslandViewAdapter_GetScaledXamlIslandLogicalHeight_Original(pThis); + + if (g_settings.explorerStyle == ExplorerStyle::classicNavigationBar) { + int retNew = MulDiv(ret, 96, 136); + Wh_Log(L"%d -> %d", ret, retNew); + return retNew; + } + + return ret; +} + using Feature_NavigationBarControl_OnApplyTemplate_t = HRESULT(WINAPI*)(PVOID pThis); Feature_NavigationBarControl_OnApplyTemplate_t @@ -607,8 +627,6 @@ HRESULT WINAPI CoCreateInstance_Hook(REFCLSID rclsid, DWORD dwClsContext, REFIID riid, LPVOID* ppv) { - Wh_Log(L">"); - constexpr winrt::guid CLSID_XamlIslandViewAdapter{ 0x6480100B, 0x5A83, @@ -617,6 +635,8 @@ HRESULT WINAPI CoCreateInstance_Hook(REFCLSID rclsid, if (IsEqualCLSID(rclsid, CLSID_XamlIslandViewAdapter) && g_settings.explorerStyle == ExplorerStyle::classicRibbonUI) { + Wh_Log(L">"); + return REGDB_E_CLASSNOTREG; } @@ -628,7 +648,7 @@ bool HookExplorerFrameSymbols() { HMODULE module = LoadLibrary(L"explorerframe.dll"); if (!module) { Wh_Log(L"Couldn't load explorerframe.dll"); - return FALSE; + return false; } WindhawkUtils::SYMBOL_HOOK explorerFrameDllHooks[] = { @@ -650,6 +670,26 @@ bool HookExplorerFrameSymbols() { ARRAYSIZE(explorerFrameDllHooks)); } +bool HookWindowsUIFileExplorerSymbols() { + HMODULE module = LoadLibrary(L"Windows.UI.FileExplorer.dll"); + if (!module) { + Wh_Log(L"Couldn't load Windows.UI.FileExplorer.dll"); + return false; + } + + // Windows.UI.FileExplorer.dll + WindhawkUtils::SYMBOL_HOOK hooks[] = { + { + {LR"(private: int __cdecl XamlIslandViewAdapter::GetScaledXamlIslandLogicalHeight(void))"}, + (void**)&XamlIslandViewAdapter_GetScaledXamlIslandLogicalHeight_Original, + (void*)XamlIslandViewAdapter_GetScaledXamlIslandLogicalHeight_Hook, + true, + }, + }; + + return HookSymbols(module, hooks, ARRAYSIZE(hooks)); +} + bool HookFileExplorerExtensionsSymbols() { WCHAR path[MAX_PATH]; if (!GetWindowsDirectory(path, ARRAYSIZE(path))) { @@ -702,6 +742,10 @@ BOOL Wh_ModInit() { return FALSE; } + if (!HookWindowsUIFileExplorerSymbols()) { + return FALSE; + } + if (!HookFileExplorerExtensionsSymbols()) { return FALSE; }