Skip to content

Commit

Permalink
Windows 7 Alt+Tab Loader 1.0.3: Remove dead WindhawkUtils namespace (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aubymori authored Aug 14, 2024
1 parent 6deadd9 commit c541b56
Showing 1 changed file with 1 addition and 91 deletions.
92 changes: 1 addition & 91 deletions mods/win7-alttab-loader.wh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @id win7-alttab-loader
// @name Windows 7 Alt+Tab Loader
// @description Loads Windows 7 Alt+Tab on Windows 10.
// @version 1.0.2
// @version 1.0.3
// @author aubymori
// @github https://github.com/aubymori
// @include explorer.exe
Expand Down Expand Up @@ -207,96 +207,6 @@ inline BOOL VnPatchDelayIAT(HMODULE hMod, PSTR libName, PSTR funcName, uintptr_t
return FALSE;
}

#include <initializer_list>
namespace YukisCoffee::WindhawkUtils
{
struct SymbolHooks
{
PCWSTR symbolName;
void *hookFunction;
void **pOriginalFunction;
};

bool hookWithSymbols(HMODULE module, std::initializer_list<SymbolHooks> hooks, PCWSTR server = NULL)
{
WH_FIND_SYMBOL symbol;
HANDLE findSymbol;

if (!module)
{
Wh_Log(L"Loaded invalid module");
return false;
}

// These functions are terribly named, which is why I wrote this wrapper
// in the first place.
findSymbol = Wh_FindFirstSymbol(module, server, &symbol);

if (findSymbol)
{
do
{
for (SymbolHooks hook : hooks)
{
// If the symbol is unknown, then learn it.
if (!*hook.pOriginalFunction && 0 == wcscmp(symbol.symbol, hook.symbolName))
{
if (hook.hookFunction)
{
// This is unsafe if you make any typo at all.
Wh_SetFunctionHook(
symbol.address,
hook.hookFunction,
hook.pOriginalFunction
);

Wh_Log(
L"Installed hook for symbol %s at %p.",
hook.symbolName,
symbol.address
);
}
else
{
*hook.pOriginalFunction = symbol.address;

Wh_Log(
L"Found symbol %s for %p.",
hook.symbolName,
symbol.address
);
}
}
}
}
while (Wh_FindNextSymbol(findSymbol, &symbol));

Wh_FindCloseSymbol(findSymbol);
}
else
{
Wh_Log(L"Unable to find symbols for module.");
return false;
}

// If a requested symbol is not found at all, then error as such.
for (SymbolHooks hook : hooks)
{
if (!*hook.pOriginalFunction)
{
Wh_Log(
L"Original function for symbol hook %s not found.",
hook.symbolName
);

return false;
}
}

return true;
}
}

//=========================================================================================================================================
// ALT TAB:
//
Expand Down

0 comments on commit c541b56

Please sign in to comment.