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(); ~VMTHook();
void Set(ptr_t inst, uint32_t offset = 0); void Set(ptr_t inst, uint32_t offset = 0);
void Release(); 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 HookMethod(ptr_t func, uint32_t idx, ptr_t *backup);
void *GetMethod(uint32_t idx) const; void *GetMethod(uint32_t idx) const;
void Apply(); void Apply();

View File

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

View File

@ -164,4 +164,8 @@ struct offsets
{ {
return PlatformOffset(2, undefined, undefined); 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(); g_pPlayerResource = new TFPlayerResource();
#if ENABLE_VISUALS #if ENABLE_VISUALS
hooks::panel.Set(g_IPanel); hooks::panel.Set(g_IPanel);
hooks::panel.HookMethod((void *) PaintTraverse_hook, hooks::panel.HookMethod(hooked_methods::methods::PaintTraverse,
offsets::PaintTraverse()); offsets::PaintTraverse(), &hooked_methods::original::PaintTraverse);
hooks::panel.Apply(); hooks::panel.Apply();
#endif #endif
uintptr_t *clientMode = 0; uintptr_t *clientMode = 0;
@ -304,32 +304,27 @@ free(logname);*/
usleep(10000); usleep(10000);
} }
hooks::clientmode.Set((void *) clientMode); hooks::clientmode.Set((void *) clientMode);
hooks::clientmode.HookMethod((void *) CreateMove_hook, hooks::clientmode.HookMethod(HOOK_ARGS(CreateMove));
offsets::CreateMove());
#if ENABLE_VISUALS #if ENABLE_VISUALS
hooks::clientmode.HookMethod((void *) OverrideView_hook, hooks::clientmode.HookMethod(HOOK_ARGS(OverrideView));
offsets::OverrideView());
#endif #endif
hooks::clientmode.HookMethod((void *) LevelInit_hook, offsets::LevelInit()); hooks::clientmode.HookMethod(HOOK_ARGS(LevelInit));
hooks::clientmode.HookMethod((void *) LevelShutdown_hook, hooks::clientmode.HookMethod(HOOK_ARGS(LevelShutdown));
offsets::LevelShutdown());
hooks::clientmode.Apply(); hooks::clientmode.Apply();
hooks::clientmode4.Set((void *) (clientMode), 4); hooks::clientmode4.Set((void *) (clientMode), 4);
hooks::clientmode4.HookMethod((void *) FireGameEvent_hook, hooks::clientmode4.HookMethod(HOOK_ARGS(FireGameEvent));
offsets::FireGameEvent());
hooks::clientmode4.Apply(); hooks::clientmode4.Apply();
hooks::client.Set(g_IBaseClient); hooks::client.Set(g_IBaseClient);
#if ENABLE_VISUALS #if ENABLE_VISUALS
hooks::client.HookMethod((void *) FrameStageNotify_hook, hooks::client.HookMethod(HOOK_ARGS(FrameStageNotify));
offsets::FrameStageNotify());
#endif #endif
hooks::client.HookMethod((void *) DispatchUserMessage_hook, hooks::client.HookMethod(HOOK_ARGS(DispatchUserMessage);
offsets::DispatchUserMessage());
#if ENABLE_VISUALS #if ENABLE_VISUALS
hooks::vstd.Set((void *) g_pUniformStream); hooks::vstd.Set((void *) g_pUniformStream);
hooks::vstd.HookMethod((void *) RandomInt_hook, offsets::RandomInt()); hooks::vstd.HookMethod(HOOK_ARGS(RandomInt));
hooks::vstd.Apply(); hooks::vstd.Apply();
#endif #endif
@ -356,28 +351,24 @@ free(logname);*/
} }
#endif #endif
#if ENABLE_VISUALS #if ENABLE_VISUALS
hooks::client.HookMethod((void *) IN_KeyEvent_hook, offsets::IN_KeyEvent()); hooks::client.HookMethod(HOOK_ARGS(IN_KeyEvent));
#endif #endif
hooks::client.Apply(); hooks::client.Apply();
hooks::input.Set(g_IInput); hooks::input.Set(g_IInput);
hooks::input.HookMethod((void *) GetUserCmd_hook, offsets::GetUserCmd()); hooks::input.HookMethod(HOOK_ARGS(GetUserCmd));
hooks::input.Apply(); hooks::input.Apply();
#ifndef HOOK_DME_DISABLED #ifndef HOOK_DME_DISABLED
#if ENABLE_VISUALS #if ENABLE_VISUALS
hooks::modelrender.Set(g_IVModelRender); hooks::modelrender.Set(g_IVModelRender);
hooks::modelrender.HookMethod((void *) DrawModelExecute_hook, hooks::modelrender.HookMethod(HOOK_ARGS(DrawModelExecute));
offsets::DrawModelExecute());
hooks::modelrender.Apply(); hooks::modelrender.Apply();
hooks::enginevgui.Set(g_IEngineVGui); hooks::enginevgui.Set(g_IEngineVGui);
hooks::enginevgui.HookMethod( hooks::enginevgui.HookMethod(HOOK_ARGS(Paint));
(void *) Paint_hook,
offsets::PlatformOffset(14, offsets::undefined, offsets::undefined));
hooks::enginevgui.Apply(); hooks::enginevgui.Apply();
#endif #endif
#endif #endif
hooks::steamfriends.Set(g_ISteamFriends); hooks::steamfriends.Set(g_ISteamFriends);
hooks::steamfriends.HookMethod((void *) GetFriendPersonaName_hook, hooks::steamfriends.HookMethod(HOOK_ARGS(GetFriendPersonaName));
offsets::GetFriendPersonaName());
hooks::steamfriends.Apply(); hooks::steamfriends.Apply();
// logging::Info("After hacking: %s", g_ISteamFriends->GetPersonaName()); // logging::Info("After hacking: %s", g_ISteamFriends->GetPersonaName());
// Sadly, it doesn't work as expected :( // 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]; user_data_s &data = peer->memory->peer_user_data[peer->client_id];
data.friendid = g_ISteamUser->GetSteamID().GetAccountID(); data.friendid = g_ISteamUser->GetSteamID().GetAccountID();
data.ts_injected = time_injected; data.ts_injected = time_injected;
strncpy(data.name, GetFriendPersonaName_hook(g_ISteamFriends, strncpy(data.name, hooked_methods::methods::GetFriendPersonaName(g_ISteamFriends,
g_ISteamUser->GetSteamID()), g_ISteamUser->GetSteamID()),
sizeof(data.name)); sizeof(data.name));
} }