This repository was archived by the owner on Jul 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathCustomTypes.cpp
More file actions
103 lines (84 loc) · 1.87 KB
/
Copy pathCustomTypes.cpp
File metadata and controls
103 lines (84 loc) · 1.87 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
* Copyright (c) 2022 Jon Palmisciano. All rights reserved.
*
* Use of this source code is governed by the BSD 3-Clause license; the full
* terms of the license can be found in the LICENSE.txt file.
*/
#include "CustomTypes.h"
constexpr const char* AllTypesSource = R"(
struct tptr_t {
uint64_t raw;
};
struct fptr_t {
uint64_t raw;
};
struct rptr_t {
int32_t raw;
};
typedef void* id;
typedef char* SEL;
typedef char BOOL;
typedef int64_t NSInteger;
typedef uint64_t NSUInteger;
typedef double CGFloat;
struct CFString {
const tptr_t isa;
uint64_t flags;
const tptr_t data;
uint64_t size;
};
struct objc_method_entry_t {
rptr_t name;
rptr_t types;
rptr_t imp;
};
struct objc_method_t {
tptr_t name;
tptr_t types;
tptr_t imp;
};
struct objc_method_list_t {
uint32_t obsolete;
uint32_t count;
};
struct objc_class_ro_t {
uint32_t flags;
uint32_t start;
uint32_t size;
uint32_t reserved;
const tptr_t ivar_layout;
const tptr_t name;
const tptr_t methods;
const tptr_t protocols;
const tptr_t vars;
const tptr_t weak_ivar_layout;
const tptr_t properties;
};
struct objc_class_t {
const tptr_t isa;
const tptr_t super;
void* cache;
void* vtable;
const fptr_t data;
};
struct objc_category_t {
const char* name;
void* class;
const tptr_t instance_methods;
const tptr_t class_methods;
const tptr_t protocols;
const tptr_t instance_properties;
}
)";
namespace CustomTypes {
using namespace BinaryNinja;
void defineAll(Ref<BinaryView> bv)
{
std::map<QualifiedName, Ref<Type>> types, variables, functions;
std::string errors;
bv->GetDefaultPlatform()->ParseTypesFromSource(AllTypesSource,
"ObjectiveNinja.h", types, variables, functions, errors);
for (const auto& [name, type] : types)
bv->DefineUserType(name, type);
}
}