3 #include "../Include/WinHeaders.h"
8 #include <unordered_map>
27 PathNode( TraceState _action, uintptr_t _arg = 0 )
38 typedef std::unordered_map<uintptr_t, std::pair<uintptr_t, bool>> mapHooks;
39 typedef std::vector<PathNode> vecState;
43 uintptr_t targetPtr = 0;
44 uintptr_t origPtrVal = 0;
45 uintptr_t checkIP = 0;
46 uintptr_t breakValue = 0;
47 uintptr_t stateIdx = 0;
49 TraceState state = TS_Start;
64 for (
auto& item : hooks)
65 item.second.second =
false;
73 typedef std::map<uintptr_t, HookContext> mapContext;
74 typedef std::vector <std::pair<uintptr_t, uintptr_t>> vecStackFrames;
89 BLACKBONE_API
bool ApplyHook(
void* targetFunc,
92 const HookContext::vecState& tracePath = HookContext::vecState(),
100 BLACKBONE_API
bool RemoveHook(
void* targetFunc );
113 static LONG __stdcall VecHandler( PEXCEPTION_POINTERS ExceptionInfo );
114 LONG VecHandlerP( PEXCEPTION_POINTERS ExceptionInfo );
124 size_t StackBacktrace( uintptr_t ip, uintptr_t sp, vecStackFrames& results, uintptr_t depth = 10 );
130 inline void BreakOnReturn( uintptr_t sp );
139 bool CheckBranching(
const HookContext& ctx, uintptr_t ip, uintptr_t sp );
146 void HandleBranch(
HookContext& ctx, PCONTEXT exptContex );
154 bool RestorePtr(
const HookContext& ctx, PEXCEPTION_POINTERS ExceptionInfo );
157 PVOID _pExptHandler =
nullptr;
158 mapContext _contexts;
159 uintptr_t _breakPtr = 0x2000;
BLACKBONE_API bool RemoveHook(void *targetFunc)
Remove existing hook
Definition: TraceHook.cpp:98
BLACKBONE_API bool ApplyHook(void *targetFunc, void *hookFunc, void *ptrAddress, const HookContext::vecState &tracePath=HookContext::vecState(), void *checkIP=0)
Setup hook
Definition: TraceHook.cpp:50
void reset()
Reset tracing state
Definition: TraceHook.h:57
Definition: TraceHook.h:22
Hook-related data
Definition: TraceHook.h:36
Definition: TraceHook.h:69
Definition: AsmHelper32.cpp:6