-
Notifications
You must be signed in to change notification settings - Fork 283
Expand file tree
/
Copy pathmicrosoft.h
More file actions
80 lines (63 loc) · 1.97 KB
/
microsoft.h
File metadata and controls
80 lines (63 loc) · 1.97 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
#pragma once
#include "binaryninjaapi.h"
#include "rtti.h"
namespace BinaryNinja::RTTI::Microsoft {
struct BaseClassArray
{
uint32_t length;
std::vector<uint64_t> descriptors;
BaseClassArray(BinaryView *view, uint64_t address, uint32_t length);
};
struct ClassHierarchyDescriptor
{
uint32_t signature;
uint32_t attributes;
uint32_t numBaseClasses;
int32_t pBaseClassArray;
ClassHierarchyDescriptor(BinaryView *view, uint64_t address);
};
struct BaseClassDescriptor
{
int32_t pTypeDescriptor;
uint32_t numContainedBases;
int32_t where_mdisp;
int32_t where_pdisp;
int32_t where_vdisp;
uint32_t attributes;
int32_t pClassHierarchyDescriptor;
BaseClassDescriptor(BinaryView *view, uint64_t address);
};
struct TypeDescriptor
{
uint64_t pVFTable;
uint64_t spare;
std::string name;
TypeDescriptor(BinaryView *view, uint64_t address);
};
struct CompleteObjectLocator
{
uint32_t signature;
uint32_t offset;
uint32_t cdOffset;
int32_t pTypeDescriptor;
int32_t pClassHierarchyDescriptor;
// Only on 64 bit
int32_t pSelf;
CompleteObjectLocator(BinaryView *view, uint64_t address);
};
class MicrosoftRTTIProcessor : public RTTIProcessor
{
bool allowMangledClassNames;
bool allowAnonymousClassNames;
bool checkWritableRData;
bool virtualFunctionTableSweep;
// This will process a CHD and store all `BaseClassInfo` in `classInfo`.
std::vector<BaseClassInfo> ProcessClassHierarchyDescriptor(uint64_t address, CompleteObjectLocator &coLocator, const ClassInfo &classInfo);
std::optional<ClassInfo> ProcessRTTI(uint64_t objectAddr) override;
std::optional<VirtualFunctionTableInfo> ProcessVFT(uint64_t vftAddr, ClassInfo &classInfo, std::optional<BaseClassInfo> baseClassInfo) override;
public:
explicit MicrosoftRTTIProcessor(const Ref<BinaryView> &view, bool useMangled = true, bool checkRData = true, bool vftSweep = true, bool allowAnonymous = true);
void ProcessRTTI() override;
void ProcessVFT() override;
};
}