Hide Navigation Bar & Classic Explorer Toolbars
Nov 27, 2023 19:36:24 GMT -8
Post by Cynosphere on Nov 27, 2023 19:36:24 GMT -8
This is a combined post for both of these mods because these mods are meant to supersede my Classic Theme Explorer mod. You likely noticed that there is no address bar mod, that's because ClassicExplorer does a better job at reimplementing the address bar than trying to hack in functionality to the old address bar.
The mods are split for the future, as I most likely will eventually PR these to Windhawk's mod repo.
Hide Navigation Bar
// ==WindhawkMod==
// @id hide-navigation-bar
// @name Hide Navigation Bar
// @description Hide navigation bar by removing it entirely
// @version 0.1
// @author Cynosphere
// @github https://github.com/Cynosphere
// @homepage https://c7.pm
// @include explorer.exe
// @compilerOptions -lcomdlg32
// ==/WindhawkMod==
// ==WindhawkModReadme==
/*
# Hide Navigation Bar
*/
// ==/WindhawkModReadme==
#include <windhawk_utils.h>
#ifdef _WIN64
# define THISCALL __cdecl
# define STHISCALL L"__cdecl"
#else
# define THISCALL __thiscall
# define STHISCALL L"__thiscall"
#endif
typedef long (THISCALL *CNavBar__CreateBar_t)(void *);
CNavBar__CreateBar_t CNavBar__CreateBar_orig;
long THISCALL CNavBar__CreateBar_hook(void *pThis) {
return 0;
}
BOOL Wh_ModInit() {
HMODULE hExplorerFrame = LoadLibraryW(L"ExplorerFrame.dll");
if (!hExplorerFrame)
{
Wh_Log(L"Failed to load ExplorerFrame.dll");
return FALSE;
}
const WindhawkUtils::SYMBOL_HOOK hooks[] = {
{
{
L"protected: long "
STHISCALL
L" CNavBar::_CreateBar(void)"
},
&CNavBar__CreateBar_orig,
CNavBar__CreateBar_hook,
false
}
};
if (!WindhawkUtils::HookSymbols(
hExplorerFrame,
hooks,
ARRAYSIZE(hooks)
))
{
Wh_Log(L"Failed to hook CAddressBand::_CreateAddressBand");
return FALSE;
}
return TRUE;
}
Classic Explorer Toolbars
// ==WindhawkMod==
// @id classic-explorer-toolbars
// @name Classic Explorer Toolbars
// @description Restyles Explorer toolbars to fit in with classic theme
// @version 1.0.1
// @author Cynosphere
// @github https://github.com/Cynosphere
// @homepage https://c7.pm
// @include explorer.exe
// @compilerOptions -lcomdlg32
// ==/WindhawkMod==
// ==WindhawkModReadme==
/*
# Classic Explorer Toolbars
Restyles Explorer toolbars to fit in with classic theme
## Changelog
**1.0.1** (2023/12/10)
- Fix applying to taskbar
**1.0.0** (2023/11/27)
- Initial release
*/
// ==/WindhawkModReadme==
#include <windhawk_utils.h>
#ifdef _WIN64
# define THISCALL __cdecl
# define STHISCALL L"__cdecl"
#else
# define THISCALL __thiscall
# define STHISCALL L"__thiscall"
#endif
typedef long (THISCALL *BandSite__Initialize_t)(int* pThis, HWND hWnd);
BandSite__Initialize_t CBandSite__Initialize_orig;
long THISCALL CBandSite__Initialize_hook(int* pThis, HWND hWnd) {
long ret = CBandSite__Initialize_orig(pThis, hWnd);
// FIXME: pointer math bad!
HWND barHwnd = *((HWND *)pThis + 17);
if (barHwnd) {
HWND parentHwnd = GetParent(barHwnd);
WCHAR lpParCls[256];
GetClassNameW(parentHwnd, lpParCls, 256);
if (!wcscmp(lpParCls, L"WorkerW")) {
LONG style = GetWindowLongPtrW(barHwnd, GWL_STYLE);
style |= RBS_BANDBORDERS;
style |= WS_BORDER;
SetWindowLongPtrW(barHwnd, GWL_STYLE, style);
}
}
return ret;
}
BOOL Wh_ModInit() {
HMODULE hExplorerFrame = LoadLibraryW(L"ExplorerFrame.dll");
if (!hExplorerFrame)
{
Wh_Log(L"Failed to load ExplorerFrame.dll");
return FALSE;
}
const WindhawkUtils::SYMBOL_HOOK hooks[] = {
{
{
L"protected: virtual long "
STHISCALL
L" CBandSite::_Initialize(struct HWND__ *)"
},
&CBandSite__Initialize_orig,
CBandSite__Initialize_hook,
false
}
};
if (!WindhawkUtils::HookSymbols(
hExplorerFrame,
hooks,
ARRAYSIZE(hooks)
))
{
Wh_Log(L"Failed to hook CBandSite::_Initialize");
return FALSE;
}
return TRUE;
}
Caveats
- Aerexplorer's Control Panel unification causes neither of these mods (all mods targeting Explorer to be more specific) to run on first window open. (creating the factory Explorer process Control Panel uses)
- Classic Explorer Toolbar uses pointer math to get ReBarWindow32. If someone smarter knows a way to avoid this without enumerating over every child please let me know.
- The above also means that I have no idea if the mod works on any other Windows version other than 22H2 19045.3693.