-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatahook.h
More file actions
87 lines (73 loc) · 1.42 KB
/
datahook.h
File metadata and controls
87 lines (73 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#pragma once
#include <Windows.h>
#include <cstdint>
#include <iostream>
#include <d3d9.h>
#include <D3dx9.h>
#include "sig.h"
class VirtProt
{
private:
uintptr_t* m_pAddress;
size_t m_length;
uint32_t m_old;
public:
VirtProt()
{
}
~VirtProt()
{
}
int ChangeProtection(uintptr_t* base, size_t len, uint32_t flags);
};
class DataHook
{
private:
uintptr_t* m_classbase;
size_t m_vftsize;
uintptr_t* m_newvft;
uintptr_t* m_oldvft;
uintptr_t* m_oldendscene;
uintptr_t* m_newendscene;
uintptr_t m_searchbase;
bool m_allocated;
public:
DataHook();
DataHook(uintptr_t* base);
~DataHook();
int InitDataHook();
int PrintMbi(uintptr_t* address);
size_t VftLength (uintptr_t* vftbl_start);
uintptr_t* SearchFreePage (uintptr_t* vtable, const size_t vmt_size);
bool CheckDataProtection(uintptr_t address, const size_t vmt_size);
bool HookSetup(uintptr_t* base);
bool IsTableHooked();
int VftHook()
{
if (m_newvft != nullptr && (!IsTableHooked()))
{
**(uintptr_t***)(m_classbase) = &m_newvft[1];
}
return 1;
}
int VftUnhook()
{
if (m_oldvft != nullptr && IsTableHooked())
{
**(uintptr_t***)(m_classbase) = m_oldvft;
}
return 1;
}
uintptr_t* GetClassBase()
{
return m_classbase;
}
uintptr_t* GetOldEndScene()
{
return m_oldendscene;
}
uintptr_t* GetNewEndScene()
{
return m_newendscene;
}
};