add empty hook implementations
This commit is contained in:
parent
51c596a6eb
commit
80cdf85450
@ -37,7 +37,7 @@ public:
|
||||
~VMTHook();
|
||||
void Set(ptr_t inst, uint32_t offset = 0);
|
||||
void Release();
|
||||
void HookMethod(ptr_t func, uint32_t idx);
|
||||
void HookMethod(ptr_t func, uint32_t idx, ptr_t *backup);
|
||||
void *GetMethod(uint32_t idx) const;
|
||||
void Apply();
|
||||
|
||||
|
@ -14,93 +14,55 @@ union SDL_Event;
|
||||
struct SDL_Window;
|
||||
#endif
|
||||
|
||||
#define DECLARE_HOOKED_METHOD(name, rtype, ...) \
|
||||
namespace types { using name = rtype(*)(__VA_ARGS__); } \
|
||||
namespace methods { rtype name(__VA_ARGS__); } \
|
||||
namespace original { extern types::name name; }
|
||||
|
||||
#define DEFINE_HOOKED_METHOD(name, rtype, ...) \
|
||||
types::name original::name{ nullptr }; \
|
||||
rtype name(__VA_ARGS__)
|
||||
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
namespace types
|
||||
{
|
||||
// ClientMode
|
||||
using CreateMove = bool(*)(void *, float, CUserCmd *);
|
||||
using LevelInit = void(*)(void *, const char *);
|
||||
using LevelShutdown = void(*)(void *);
|
||||
DECLARE_HOOKED_METHOD(CreateMove, bool, void *, float, CUserCmd *);
|
||||
DECLARE_HOOKED_METHOD(LevelInit, void, void *, const char *);
|
||||
DECLARE_HOOKED_METHOD(LevelShutdown, void, void *);
|
||||
// ClientMode + 4
|
||||
using FireGameEvent = void(*)(void *_this, IGameEvent *event);
|
||||
DECLARE_HOOKED_METHOD(FireGameEvent, void, void *, IGameEvent *);
|
||||
// IBaseClient
|
||||
using DispatchUserMessage = bool(*)(void *, int, bf_read &);
|
||||
using IN_KeyEvent = int(*)(void *, int, int, const char *);
|
||||
DECLARE_HOOKED_METHOD(DispatchUserMessage, bool, void *, int, bf_read &);
|
||||
DECLARE_HOOKED_METHOD(IN_KeyEvent, int, void *, int, ButtonCode_t, const char *);
|
||||
// IInput
|
||||
using GetUserCmd = CUserCmd *(*)(IInput *, int);
|
||||
DECLARE_HOOKED_METHOD(GetUserCmd, CUserCmd *, IInput *, int);
|
||||
// INetChannel
|
||||
using SendNetMsg = bool(*)(INetChannel *, INetMessage &, bool, bool);
|
||||
using CanPacket = bool(*)(INetChannel *);
|
||||
using Shutdown = void(*)(INetChannel *, const char *);
|
||||
DECLARE_HOOKED_METHOD(SendNetMsg, bool, INetChannel *, INetMessage &, bool, bool);
|
||||
DECLARE_HOOKED_METHOD(CanPacket, bool, INetChannel *);
|
||||
DECLARE_HOOKED_METHOD(Shutdown, void, INetChannel *, const char *);
|
||||
// ISteamFriends
|
||||
using GetFriendPersonaName = const char *(*)(ISteamFriends *, CSteamID);
|
||||
DECLARE_HOOKED_METHOD(GetFriendPersonaName, const char *, ISteamFriends *, CSteamID);
|
||||
// IEngineVGui
|
||||
using Paint = void(*)(IEngineVGui *, PaintMode_t);
|
||||
DECLARE_HOOKED_METHOD(Paint, void, IEngineVGui *, PaintMode_t);
|
||||
|
||||
#if ENABLE_VISUALS
|
||||
// ClientMode
|
||||
using OverrideView = void(*)(void *, CViewSetup *);
|
||||
DECLARE_HOOKED_METHOD(OverrideView, void, void *, CViewSetup *);
|
||||
// IVModelRender
|
||||
using DrawModelExecute = void(*)(IVModelRender *, const DrawModelState_t &,
|
||||
const ModelRenderInfo_t &, matrix3x4_t *);
|
||||
DECLARE_HOOKED_METHOD(DrawModelExecute, void, IVModelRender *, const DrawModelState_t &,
|
||||
const ModelRenderInfo_t &, matrix3x4_t *);
|
||||
// IStudioRender
|
||||
using BeginFrame = void(*)(IStudioRender *);
|
||||
DECLARE_HOOKED_METHOD(BeginFrame, void, IStudioRender *);
|
||||
// IBaseClient
|
||||
using FrameStageNotify = void(*)(void *, int);
|
||||
DECLARE_HOOKED_METHOD(FrameStageNotify, void, void *, ClientFrameStage_t);
|
||||
// vgui::IPanel
|
||||
using PaintTraverse = void(*)(vgui::IPanel *, unsigned int, bool, bool);
|
||||
DECLARE_HOOKED_METHOD(PaintTraverse, void, vgui::IPanel *, unsigned int, bool, bool);
|
||||
// SDL
|
||||
using SDL_GL_SwapWindow = void(*)(SDL_Window *window);
|
||||
using SDL_PollEvent = int(*)(SDL_Event *event);
|
||||
DECLARE_HOOKED_METHOD(SDL_GL_SwapWindow, void, SDL_Window *);
|
||||
DECLARE_HOOKED_METHOD(SDL_PollEvent, int, SDL_Event *);
|
||||
// IUniformRandomStream
|
||||
using RandomInt = int(*)(void *, int, int);
|
||||
DECLARE_HOOKED_METHOD(RandomInt, int, IUniformRandomStream *, int, int);
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace methods
|
||||
{
|
||||
// ClientMode
|
||||
bool CreateMove(void *, float, CUserCmd *);
|
||||
void LevelInit(void *, const char *);
|
||||
void LevelShutdown(void *);
|
||||
// ClientMode + 4
|
||||
void FireGameEvent(void *_this, IGameEvent *event);
|
||||
// IBaseClient
|
||||
bool DispatchUserMessage(void *, int, bf_read &);
|
||||
int IN_KeyEvent(void *, int, int, const char *);
|
||||
// IInput
|
||||
CUserCmd *GetUserCmd(IInput *, int);
|
||||
// INetChannel
|
||||
bool SendNetMsg(INetChannel *, INetMessage &, bool, bool);
|
||||
bool CanPacket(INetChannel *);
|
||||
void Shutdown(INetChannel *, const char *);
|
||||
// ISteamFriends
|
||||
const char *GetFriendPersonaName(ISteamFriends *_this, CSteamID steamID);
|
||||
// IEngineVGui
|
||||
void Paint(IEngineVGui *_this, PaintMode_t mode);
|
||||
|
||||
#if ENABLE_VISUALS
|
||||
// ClientMode
|
||||
void OverrideView(void *, CViewSetup *);
|
||||
// IVModelRender
|
||||
void DrawModelExecute(IVModelRender *_this, const DrawModelState_t &state,
|
||||
const ModelRenderInfo_t &info, matrix3x4_t *matrix);
|
||||
// IStudioRender
|
||||
void BeginFrame(IStudioRender *);
|
||||
// IBaseClient
|
||||
void FrameStageNotify(void *, int);
|
||||
// vgui::IPanel
|
||||
void PaintTraverse(vgui::IPanel *, unsigned int, bool, bool);
|
||||
// SDL
|
||||
void SDL_GL_SwapWindow(SDL_Window *window);
|
||||
int SDL_PollEvent(SDL_Event *event);
|
||||
// IUniformRandomStream
|
||||
int RandomInt(void *, int, int);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -77,11 +77,13 @@ void *VMTHook::GetMethod(uint32_t idx) const
|
||||
return vtable_original[idx];
|
||||
}
|
||||
|
||||
void VMTHook::HookMethod(ptr_t func, uint32_t idx)
|
||||
void VMTHook::HookMethod(ptr_t func, uint32_t idx, ptr_t *backup)
|
||||
{
|
||||
logging::Info(
|
||||
"Hooking method %d of vtable 0x%08x, replacing 0x%08x with 0x%08x", idx,
|
||||
vtable_original, GetMethod(idx), func);
|
||||
if (backup)
|
||||
*backup = vtable_hooked[2 + idx];
|
||||
vtable_hooked[2 + idx] = func;
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,21 @@
|
||||
target_sources(cathook PRIVATE
|
||||
"${CMAKE_CURRENT_LIST_DIR}/CanPacket.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/CreateMove.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/DispatchUserMessage.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/FireGameEvent.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/GetFriendPersonaName.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/GetUserCmd.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/IN_KeyEvent.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/LevelInit.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/LevelShutdown.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/nographics.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/others.cpp")
|
||||
"${CMAKE_CURRENT_LIST_DIR}/others.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Paint.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/PaintTraverse.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/sdl.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/SendNetMsg.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Shutdown.cpp")
|
||||
|
||||
if(EnableVisuals)
|
||||
target_sources(cathook PRIVATE
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Paint.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/PaintTraverse.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/sdl.cpp")
|
||||
add_subdirectory(visual)
|
||||
endif()
|
@ -3,4 +3,14 @@
|
||||
Copyright (c) 2018 nullworks. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "HookedMethods.hpp"
|
||||
#include "HookedMethods.hpp"
|
||||
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
DEFINE_HOOKED_METHOD(CanPacket, bool, INetChannel *this_)
|
||||
{
|
||||
return original::CanPacket(this_);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,18 @@
|
||||
|
||||
#include <link.h>
|
||||
|
||||
#include "HookedMethods.hpp"
|
||||
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time, CUserCmd *cmd)
|
||||
{
|
||||
return original::CreateMove(this_, input_sample_time, cmd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class CMoveData;
|
||||
namespace engine_prediction
|
||||
{
|
||||
|
@ -3,4 +3,14 @@
|
||||
Copyright (c) 2018 nullworks. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "HookedMethods.hpp"
|
||||
#include "HookedMethods.hpp"
|
||||
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
DEFINE_HOOKED_METHOD(DispatchUserMessage, bool, void * this_, int type, bf_read &buffer)
|
||||
{
|
||||
return original::DispatchUserMessage(this_, type, buffer);
|
||||
}
|
||||
|
||||
}
|
@ -3,4 +3,14 @@
|
||||
Copyright (c) 2018 nullworks. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "HookedMethods.hpp"
|
||||
#include "HookedMethods.hpp"
|
||||
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
DEFINE_HOOKED_METHOD(FireGameEvent, void, void *this_, IGameEvent *event)
|
||||
{
|
||||
return original::FireGameEvent(this_, event);
|
||||
}
|
||||
|
||||
}
|
@ -3,4 +3,14 @@
|
||||
Copyright (c) 2018 nullworks. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "HookedMethods.hpp"
|
||||
#include "HookedMethods.hpp"
|
||||
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
DEFINE_HOOKED_METHOD(GetFriendPersonaName, const char *, ISteamFriends *this_, CSteamID steam_id)
|
||||
{
|
||||
return original::GetFriendPersonaName(this_, steam_id);
|
||||
}
|
||||
|
||||
}
|
@ -3,4 +3,14 @@
|
||||
Copyright (c) 2018 nullworks. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "HookedMethods.hpp"
|
||||
#include "HookedMethods.hpp"
|
||||
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
DEFINE_HOOKED_METHOD(GetUserCmd, CUserCmd *, IInput *this_, int sequence_number)
|
||||
{
|
||||
return original::GetUserCmd(this_, sequence_number);
|
||||
}
|
||||
|
||||
}
|
@ -3,4 +3,14 @@
|
||||
Copyright (c) 2018 nullworks. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "HookedMethods.hpp"
|
||||
#include "HookedMethods.hpp"
|
||||
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
DEFINE_HOOKED_METHOD(IN_KeyEvent, int, void *this_, int eventcode, ButtonCode_t keynum, const char *binding)
|
||||
{
|
||||
return original::IN_KeyEvent(this_, eventcode, keynum, binding);
|
||||
}
|
||||
|
||||
}
|
@ -3,4 +3,14 @@
|
||||
Copyright (c) 2018 nullworks. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "HookedMethods.hpp"
|
||||
#include "HookedMethods.hpp"
|
||||
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
DEFINE_HOOKED_METHOD(LevelInit, void, void *this_, const char *name)
|
||||
{
|
||||
return original::LevelInit(this_, name);
|
||||
}
|
||||
|
||||
}
|
@ -3,4 +3,14 @@
|
||||
Copyright (c) 2018 nullworks. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "HookedMethods.hpp"
|
||||
#include "HookedMethods.hpp"
|
||||
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
DEFINE_HOOKED_METHOD(LevelShutdown, void, void *this_)
|
||||
{
|
||||
return original::LevelShutdown(this_);
|
||||
}
|
||||
|
||||
}
|
@ -9,6 +9,16 @@
|
||||
#include "hitrate.hpp"
|
||||
#include "hack.hpp"
|
||||
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
DEFINE_HOOKED_METHOD(Paint, void, IEngineVGui *this_, PaintMode_t mode)
|
||||
{
|
||||
return original::Paint(this_, mode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static CatVar cursor_fix_experimental(CV_SWITCH, "experimental_cursor_fix", "1",
|
||||
"Cursor fix");
|
||||
|
||||
|
@ -3,4 +3,14 @@
|
||||
Copyright (c) 2018 nullworks. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "HookedMethods.hpp"
|
||||
#include "HookedMethods.hpp"
|
||||
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
DEFINE_HOOKED_METHOD(SendNetMsg, bool, INetChannel *this_, INetMessage &message, bool force_reliable, bool voice)
|
||||
{
|
||||
return original::SendNetMsg(this_, message, force_reliable, voice);
|
||||
}
|
||||
|
||||
}
|
@ -3,4 +3,14 @@
|
||||
Copyright (c) 2018 nullworks. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "HookedMethods.hpp"
|
||||
#include "HookedMethods.hpp"
|
||||
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
DEFINE_HOOKED_METHOD(Shutdown, void, INetChannel *this_, const char *reason)
|
||||
{
|
||||
return original::Shutdown(this_, reason);
|
||||
}
|
||||
|
||||
}
|
@ -3,4 +3,14 @@
|
||||
Copyright (c) 2018 nullworks. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "HookedMethods.hpp"
|
||||
#include "HookedMethods.hpp"
|
||||
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
DEFINE_HOOKED_METHOD(BeginFrame, void, IStudioRender *this_)
|
||||
{
|
||||
return original::BeginFrame(this_);
|
||||
}
|
||||
|
||||
}
|
9
src/hooks/visual/CMakeLists.txt
Normal file
9
src/hooks/visual/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
target_sources(cathook PRIVATE
|
||||
"${CMAKE_CURRENT_LIST_DIR}/BeginFrame.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/DrawModelExecute.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/FrameStageNotify.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/OverrideView.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/PaintTraverse.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/RandomInt.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/SDL_GL_SwapWindow.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/SDL_PollEvent.cpp")
|
@ -3,4 +3,15 @@
|
||||
Copyright (c) 2018 nullworks. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "HookedMethods.hpp"
|
||||
#include "HookedMethods.hpp"
|
||||
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
DEFINE_HOOKED_METHOD(DrawModelExecute, void, IVModelRender *this_, const DrawModelState_t &state,
|
||||
const ModelRenderInfo_t &info, matrix3x4_t *bone)
|
||||
{
|
||||
return original::DrawModelExecute(this_, state, info, bone);
|
||||
}
|
||||
|
||||
}
|
@ -3,4 +3,14 @@
|
||||
Copyright (c) 2018 nullworks. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "HookedMethods.hpp"
|
||||
#include "HookedMethods.hpp"
|
||||
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
DEFINE_HOOKED_METHOD(FrameStageNotify, void, void *this_, ClientFrameStage_t stage)
|
||||
{
|
||||
return original::FrameStageNotify(this_, stage);
|
||||
}
|
||||
|
||||
}
|
@ -3,4 +3,14 @@
|
||||
Copyright (c) 2018 nullworks. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "HookedMethods.hpp"
|
||||
#include "HookedMethods.hpp"
|
||||
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
DEFINE_HOOKED_METHOD(OverrideView, void, void *this_, CViewSetup *setup)
|
||||
{
|
||||
return original::OverrideView(this_, setup);
|
||||
}
|
||||
|
||||
}
|
@ -3,4 +3,14 @@
|
||||
Copyright (c) 2018 nullworks. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "HookedMethods.hpp"
|
||||
#include "HookedMethods.hpp"
|
||||
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
DEFINE_HOOKED_METHOD(PaintTraverse, void, vgui::IPanel *this_, unsigned int panel, bool force, bool allow_force)
|
||||
{
|
||||
return original::PaintTraverse(this_, panel, force, allow_force);
|
||||
}
|
||||
|
||||
}
|
@ -3,4 +3,14 @@
|
||||
Copyright (c) 2018 nullworks. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "HookedMethods.hpp"
|
||||
#include "HookedMethods.hpp"
|
||||
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
DEFINE_HOOKED_METHOD(RandomInt, int, IUniformRandomStream *this_, int min, int max)
|
||||
{
|
||||
return original::RandomInt(this_, min, max);
|
||||
}
|
||||
|
||||
}
|
@ -3,4 +3,14 @@
|
||||
Copyright (c) 2018 nullworks. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "HookedMethods.hpp"
|
||||
#include "HookedMethods.hpp"
|
||||
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
DEFINE_HOOKED_METHOD(SDL_GL_SwapWindow, void, SDL_Window *window)
|
||||
{
|
||||
return original::SDL_GL_SwapWindow(window);
|
||||
}
|
||||
|
||||
}
|
@ -3,4 +3,14 @@
|
||||
Copyright (c) 2018 nullworks. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "HookedMethods.hpp"
|
||||
#include "HookedMethods.hpp"
|
||||
|
||||
namespace hooked_methods
|
||||
{
|
||||
|
||||
DEFINE_HOOKED_METHOD(SDL_PollEvent, int, SDL_Event *event)
|
||||
{
|
||||
return original::SDL_PollEvent(event);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user