HOOK_ARGS

This commit is contained in:
Jenny White 2018-04-29 08:31:25 +03:00
parent 80cdf85450
commit 6303ca8b6b
5 changed files with 29 additions and 26 deletions

View File

@ -37,6 +37,11 @@ public:
~VMTHook();
void Set(ptr_t inst, uint32_t offset = 0);
void Release();
template<typename T>
inline void HookMethod(T func, uint32_t idx, T *backup)
{
HookMethod(ptr_t(func), idx, (ptr_t *)(backup));
}
void HookMethod(ptr_t func, uint32_t idx, ptr_t *backup);
void *GetMethod(uint32_t idx) const;
void Apply();

View File

@ -23,6 +23,9 @@ struct SDL_Window;
types::name original::name{ nullptr }; \
rtype name(__VA_ARGS__)
#define HOOK_ARGS(name) \
hooked_methods::methods::name, offsets::name(), &hooked_methods::original::name
namespace hooked_methods
{
// ClientMode

View File

@ -164,4 +164,8 @@ struct offsets
{
return PlatformOffset(2, undefined, undefined);
}
static constexpr uint32_t Paint()
{
return PlatformOffset(14, undefined, undefined);
}
};

View File

@ -290,8 +290,8 @@ free(logname);*/
g_pPlayerResource = new TFPlayerResource();
#if ENABLE_VISUALS
hooks::panel.Set(g_IPanel);
hooks::panel.HookMethod((void *) PaintTraverse_hook,
offsets::PaintTraverse());
hooks::panel.HookMethod(hooked_methods::methods::PaintTraverse,
offsets::PaintTraverse(), &hooked_methods::original::PaintTraverse);
hooks::panel.Apply();
#endif
uintptr_t *clientMode = 0;
@ -304,32 +304,27 @@ free(logname);*/
usleep(10000);
}
hooks::clientmode.Set((void *) clientMode);
hooks::clientmode.HookMethod((void *) CreateMove_hook,
offsets::CreateMove());
hooks::clientmode.HookMethod(HOOK_ARGS(CreateMove));
#if ENABLE_VISUALS
hooks::clientmode.HookMethod((void *) OverrideView_hook,
offsets::OverrideView());
hooks::clientmode.HookMethod(HOOK_ARGS(OverrideView));
#endif
hooks::clientmode.HookMethod((void *) LevelInit_hook, offsets::LevelInit());
hooks::clientmode.HookMethod((void *) LevelShutdown_hook,
offsets::LevelShutdown());
hooks::clientmode.HookMethod(HOOK_ARGS(LevelInit));
hooks::clientmode.HookMethod(HOOK_ARGS(LevelShutdown));
hooks::clientmode.Apply();
hooks::clientmode4.Set((void *) (clientMode), 4);
hooks::clientmode4.HookMethod((void *) FireGameEvent_hook,
offsets::FireGameEvent());
hooks::clientmode4.HookMethod(HOOK_ARGS(FireGameEvent));
hooks::clientmode4.Apply();
hooks::client.Set(g_IBaseClient);
#if ENABLE_VISUALS
hooks::client.HookMethod((void *) FrameStageNotify_hook,
offsets::FrameStageNotify());
hooks::client.HookMethod(HOOK_ARGS(FrameStageNotify));
#endif
hooks::client.HookMethod((void *) DispatchUserMessage_hook,
offsets::DispatchUserMessage());
hooks::client.HookMethod(HOOK_ARGS(DispatchUserMessage);
#if ENABLE_VISUALS
hooks::vstd.Set((void *) g_pUniformStream);
hooks::vstd.HookMethod((void *) RandomInt_hook, offsets::RandomInt());
hooks::vstd.HookMethod(HOOK_ARGS(RandomInt));
hooks::vstd.Apply();
#endif
@ -356,28 +351,24 @@ free(logname);*/
}
#endif
#if ENABLE_VISUALS
hooks::client.HookMethod((void *) IN_KeyEvent_hook, offsets::IN_KeyEvent());
hooks::client.HookMethod(HOOK_ARGS(IN_KeyEvent));
#endif
hooks::client.Apply();
hooks::input.Set(g_IInput);
hooks::input.HookMethod((void *) GetUserCmd_hook, offsets::GetUserCmd());
hooks::input.HookMethod(HOOK_ARGS(GetUserCmd));
hooks::input.Apply();
#ifndef HOOK_DME_DISABLED
#if ENABLE_VISUALS
hooks::modelrender.Set(g_IVModelRender);
hooks::modelrender.HookMethod((void *) DrawModelExecute_hook,
offsets::DrawModelExecute());
hooks::modelrender.HookMethod(HOOK_ARGS(DrawModelExecute));
hooks::modelrender.Apply();
hooks::enginevgui.Set(g_IEngineVGui);
hooks::enginevgui.HookMethod(
(void *) Paint_hook,
offsets::PlatformOffset(14, offsets::undefined, offsets::undefined));
hooks::enginevgui.HookMethod(HOOK_ARGS(Paint));
hooks::enginevgui.Apply();
#endif
#endif
hooks::steamfriends.Set(g_ISteamFriends);
hooks::steamfriends.HookMethod((void *) GetFriendPersonaName_hook,
offsets::GetFriendPersonaName());
hooks::steamfriends.HookMethod(HOOK_ARGS(GetFriendPersonaName));
hooks::steamfriends.Apply();
// logging::Info("After hacking: %s", g_ISteamFriends->GetPersonaName());
// Sadly, it doesn't work as expected :(

View File

@ -261,7 +261,7 @@ void StoreClientData()
user_data_s &data = peer->memory->peer_user_data[peer->client_id];
data.friendid = g_ISteamUser->GetSteamID().GetAccountID();
data.ts_injected = time_injected;
strncpy(data.name, GetFriendPersonaName_hook(g_ISteamFriends,
strncpy(data.name, hooked_methods::methods::GetFriendPersonaName(g_ISteamFriends,
g_ISteamUser->GetSteamID()),
sizeof(data.name));
}