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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
#include "binaryninjaapi.h"
using namespace BinaryNinja;
using namespace std;
bool Setting::ProcessMainSettingsFile()
{
return BNProcessMainSettingsFile();
}
bool Setting::GetBool(const std::string& pluginName, const std::string& name, bool defaultValue)
{
return BNSettingGetBool(pluginName.c_str(), name.c_str(), defaultValue);
}
uint64_t Setting::GetInteger(const std::string& pluginName, const std::string& name, uint64_t defaultValue)
{
return BNSettingGetInteger(pluginName.c_str(), name.c_str(), defaultValue);
}
std::string Setting::GetString(const std::string& pluginName, const std::string& name, const std::string& defaultValue)
{
return BNSettingGetString(pluginName.c_str(), name.c_str(), defaultValue.c_str());
}
double Setting::GetDouble(const std::string& pluginName, const std::string& name, double defaultValue)
{
return BNSettingGetDouble(pluginName.c_str(), name.c_str(), defaultValue);
}
std::vector<uint64_t> Setting::GetIntegerList(const std::string& pluginName, const std::string& name, const std::vector<uint64_t>& defaultValue)
{
uint64_t* buffer = new uint64_t[defaultValue.size()];
memcpy(&buffer[0], &defaultValue[0], sizeof(uint64_t) * defaultValue.size());
size_t size = defaultValue.size();
uint64_t* outBuffer = BNSettingGetIntegerList(pluginName.c_str(), name.c_str(), buffer, &size);
if (buffer == outBuffer)
return defaultValue;
vector<uint64_t> out(buffer, buffer + size);
delete[] buffer;
return out;
}
std::vector<std::string> Setting::GetStringList(const std::string& pluginName, const std::string& name, const std::vector<std::string>& defaultValue)
{
char** buffer = new char*[defaultValue.size()];
for (size_t i = 0; i < defaultValue.size(); i++)
buffer[i] = BNAllocString(defaultValue[i].c_str());
size_t size = defaultValue.size();
const char** outBuffer = BNSettingGetStringList(pluginName.c_str(), name.c_str(), (const char**)buffer, &size);
if (buffer == outBuffer)
return defaultValue;
vector<string> out;
for (size_t i = 0; i < size; i++)
out.push_back(string(outBuffer[i]));
for (size_t i = 0; i < defaultValue.size(); i++)
BNFreeString(buffer[i]);
delete[] buffer;
return out;
}
bool Setting::IsPresent(const std::string& pluginName, const std::string& name)
{
return BNSettingIsPresent(pluginName.c_str(), name.c_str());
}
bool Setting::IsBool(const std::string& pluginName, const std::string& name)
{
return BNSettingIsBool(pluginName.c_str(), name.c_str());
}
bool Setting::IsInteger(const std::string& pluginName, const std::string& name)
{
return BNSettingIsInteger(pluginName.c_str(), name.c_str());
}
bool Setting::IsString(const std::string& pluginName, const std::string& name)
{
return BNSettingIsString(pluginName.c_str(), name.c_str());
}
bool Setting::IsIntegerList(const std::string& pluginName, const std::string& name)
{
return BNSettingIsIntegerList(pluginName.c_str(), name.c_str());
}
bool Setting::IsStringList(const std::string& pluginName, const std::string& name)
{
return BNSettingIsStringList(pluginName.c_str(), name.c_str());
}
bool Setting::IsDouble(const std::string& pluginName, const std::string& name)
{
return BNSettingIsDouble(pluginName.c_str(), name.c_str());
}
bool CoreSetting::GetBool(const std::string& name, bool defaultValue)
{
return BNSettingGetBool("core", name.c_str(), defaultValue);
}
uint64_t CoreSetting::GetInteger(const std::string& name, uint64_t defaultValue)
{
return BNSettingGetInteger("core", name.c_str(), defaultValue);
}
std::string CoreSetting::GetString(const std::string& name, const std::string& defaultValue)
{
return Setting::GetString("core", name.c_str(), defaultValue);
}
double CoreSetting::GetDouble(const std::string& name, double defaultValue)
{
return BNSettingGetDouble("core", name.c_str(), defaultValue);
}
std::vector<uint64_t> CoreSetting::GetIntegerList(const std::string& name, const std::vector<uint64_t>& defaultValue)
{
return Setting::GetIntegerList("core", name.c_str(), defaultValue);
}
std::vector<std::string> CoreSetting::GetStringList(const std::string& name, const std::vector<std::string>& defaultValue)
{
return Setting::GetStringList("core", name.c_str(), defaultValue);
}
bool CoreSetting::IsPresent(const std::string& name)
{
return BNSettingIsPresent("core", name.c_str());
}
bool CoreSetting::IsBool(const std::string& name)
{
return BNSettingIsBool("core", name.c_str());
}
bool CoreSetting::IsInteger(const std::string& name)
{
return BNSettingIsInteger("core", name.c_str());
}
bool CoreSetting::IsString(const std::string& name)
{
return BNSettingIsString("core", name.c_str());
}
bool CoreSetting::IsIntegerList(const std::string& name)
{
return BNSettingIsIntegerList("core", name.c_str());
}
bool CoreSetting::IsStringList(const std::string& name)
{
return BNSettingIsStringList("core", name.c_str());
}
bool CoreSetting::IsDouble(const std::string& name)
{
return BNSettingIsDouble("core", name.c_str());
}
|