Skip to content

Commit

Permalink
Explorer 32px Icons 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aubymori committed Nov 5, 2023
1 parent b84239f commit 79a7332
Showing 1 changed file with 158 additions and 0 deletions.
158 changes: 158 additions & 0 deletions mods/explorer-32px-icons.wh.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
// ==WindhawkMod==
// @id explorer-32px-icons
// @name Explorer 32px Icons
// @description Makes the "Medium icons" view in Explorer 32px again
// @version 1.0.0
// @author aubymori
// @github https://github.com/aubymori
// @include *
// ==/WindhawkMod==

// ==WindhawkModReadme==
/*
# Explorer 32px Icons
Beginning with Windows Vista, the "Medium icons" view (previous just "Icons") uses
icons that are 48 pixels in size, instead of the previous 32 pixel size. This mod
restores the 32 pixel size.
## YOU MUST BE USING AT LEAST WINDHAWK 1.4, OR ELSE EVERY 32-BIT APP WILL CRASH!
# IMPORTANT
You **must** be using Explorer with the SysListView32 view enabled for this mod to work.
The default DirectUI view will not work.
**Before**:
![Before](https://raw.githubusercontent.com/aubymori/images/main/explorer-32px-icons-before.png)
**After**:
![After](https://raw.githubusercontent.com/aubymori/images/main/explorer-32px-icons-after.png)
*/
// ==/WindhawkModReadme==

#include <windhawk_utils.h>

/* FOLDERVIEWMODE enum */
#include <shobjidl.h>

/* All of these symbols use the same calling convention,
but it varies between x86 and x86-64 */
#ifdef _WIN64
#define CALCON __cdecl
#define SCALCON L"__cdecl"
#else
#define CALCON __thiscall
#define SCALCON L"__thiscall"
#endif

/* Makes "Medium icons" set 32px icons. */
typedef void (* CALCON CDefView__SwitchToViewModeAndIconSize_t)(void *, FOLDERVIEWMODE, int);
CDefView__SwitchToViewModeAndIconSize_t CDefView__SwitchToViewModeAndIconSize_orig;
void CALCON CDefView__SwitchToViewModeAndIconSize_hook(
void *pThis,
FOLDERVIEWMODE mode,
int size
)
{
if (mode == FVM_THUMBNAIL && size == 48)
{
size = 32;
}

return CDefView__SwitchToViewModeAndIconSize_orig(
pThis, mode, size
);
}

/* Make 32px icons display labels below. */
typedef void (* CALCON CListViewHost__SwitchToViewModeAndIconSizeWorker_t)(void *, FOLDERVIEWMODE, FOLDERVIEWMODE, UINT);
CListViewHost__SwitchToViewModeAndIconSizeWorker_t CListViewHost__SwitchToViewModeAndIconSizeWorker_orig;
void CALCON CListViewHost__SwitchToViewModeAndIconSizeWorker_hook(
void *pThis,
FOLDERVIEWMODE prevMode,
FOLDERVIEWMODE newMode,
UINT size
)
{
if (newMode == FVM_SMALLICON && size == 32)
{
newMode = FVM_ICON;
}

return CListViewHost__SwitchToViewModeAndIconSizeWorker_orig(
pThis, prevMode, newMode, size
);
}

/* Make "Medium icons" selected when icons are 32px */
typedef UINT (*CALCON CDefView_GetMenuIDFromViewModeAndIconSize_t)(void *, FOLDERVIEWMODE, UINT, int);
CDefView_GetMenuIDFromViewModeAndIconSize_t CDefView_GetMenuIDFromViewModeAndIconSize_orig;
UINT CALCON CDefView_GetMenuIDFromViewModeAndIconSize_hook(
void *pThis,
FOLDERVIEWMODE mode,
UINT size,
int i1
)
{
if (mode == FVM_SMALLICON && size == 32)
{
return 28750;
}

return CDefView_GetMenuIDFromViewModeAndIconSize_orig(
pThis, mode, size, i1
);
}

BOOL Wh_ModInit(void)
{
HMODULE hShell32 = LoadLibraryW(L"shell32.dll");
if (!hShell32)
{
Wh_Log(L"Failed to load shell32.dll");
return FALSE;
}

WindhawkUtils::SYMBOL_HOOK hooks[] = {
{
{
L"private: void "
SCALCON
L" CDefView::_SwitchToViewModeAndIconSize(enum FOLDERVIEWMODE,int)"
},
(void **)&CDefView__SwitchToViewModeAndIconSize_orig,
(void *)CDefView__SwitchToViewModeAndIconSize_hook,
false
},
{
{
L"private: void "
SCALCON
L" CListViewHost::_SwitchToViewModeAndIconSizeWorker(enum FOLDERVIEWMODE,enum FOLDERVIEWMODE,unsigned int)"
},
(void **)&CListViewHost__SwitchToViewModeAndIconSizeWorker_orig,
(void *)CListViewHost__SwitchToViewModeAndIconSizeWorker_hook,
false
},
{
{
L"private: unsigned int "
SCALCON
L" CDefView::GetMenuIDFromViewModeAndIconSize(unsigned int,unsigned int,int)"
},
(void **)&CDefView_GetMenuIDFromViewModeAndIconSize_orig,
(void *)CDefView_GetMenuIDFromViewModeAndIconSize_hook,
false
}
};

if (!HookSymbols(hShell32, hooks, ARRAYSIZE(hooks)))
{
Wh_Log(L"Failed to hook one or more symbol functions");
return FALSE;
}

return TRUE;
}

0 comments on commit 79a7332

Please sign in to comment.