BlackBone
Windows memory hacking library
 All Classes Functions
RemoteLocalHook.h
1 #pragma once
2 
3 #include "../../Config.h"
4 #include "../../Asm/AsmHelper.h"
5 #include "../../Include/Types.h"
6 
7 #include <unordered_map>
8 
9 namespace blackbone
10 {
11 
15 struct HookCtx32
16 {
17  uint32_t codeSize; // Size of saved code
18  uint8_t original_code[29]; // Original function code
19  uint8_t jmp_code[5]; // Jump instruction
20 };
21 
22 struct HookCtx64
23 {
24  uint64_t dst_ptr; // Target address
25  uint32_t codeSize; // Size of saved code
26  uint8_t original_code[32]; // Original function code
27  uint8_t far_jmp[6]; // Far jump code
28 };
29 
30 union HookCtx
31 {
32  HookCtx32 hook32;
33  HookCtx64 hook64;
34 };
35 
36 
41 {
42  typedef std::unordered_map<ptr_t, HookCtx> mapCtx;
43 
44 public:
45  RemoteLocalHook( class Process& process );
46  ~RemoteLocalHook();
47 
48  NTSTATUS SetHook( ptr_t address, asmjit::Assembler& hook );
49 
50  NTSTATUS Restore( ptr_t address );
51 
52 private:
53  RemoteLocalHook( const RemoteLocalHook& ) = delete;
54  RemoteLocalHook& operator = (const RemoteLocalHook&) = delete;
55 
56 private:
57  class Process& _process;
58  mapCtx _hooks;
59 };
60 
61 }
Definition: RemoteLocalHook.h:30
In-process remote hook
Definition: RemoteLocalHook.h:40
Definition: Process.h:80
Hook data, sizeof = 0x50 bytes
Definition: RemoteLocalHook.h:15
Definition: RemoteLocalHook.h:22
Definition: AsmHelper32.cpp:6