Skip to content

Commit

Permalink
Classic Explorer navigation bar v1.0.5
Browse files Browse the repository at this point in the history
* Fixed incorrect height if the `FileExplorerTabLineFix` (51960011) Windows flag is set.
  • Loading branch information
m417z committed Oct 18, 2024
1 parent f467a93 commit d287d0a
Showing 1 changed file with 47 additions and 3 deletions.
50 changes: 47 additions & 3 deletions mods/explorer-frame-classic.wh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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;
}

Expand Down Expand Up @@ -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))) {
Expand Down Expand Up @@ -702,6 +742,10 @@ BOOL Wh_ModInit() {
return FALSE;
}

if (!HookWindowsUIFileExplorerSymbols()) {
return FALSE;
}

if (!HookFileExplorerExtensionsSymbols()) {
return FALSE;
}
Expand Down

0 comments on commit d287d0a

Please sign in to comment.