Uh oh!
There was an error while loading. Please reload this page.
forked from Vector35/binaryninja-api
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemangle.cpp
More file actions
Latest commit
90 lines (76 loc) · 2.74 KB
/
Copy pathdemangle.cpp
File metadata and controls
90 lines (76 loc) · 2.74 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
#include"binaryninjaapi.h"
#include<string>
usingnamespacestd;
namespaceBinaryNinja {
boolDemangleMS(Architecture* arch, const std::string& mangledName, Ref<Type>& outType, QualifiedName& outVarName,
BinaryView* view)
{
constbool simplify = Settings::Instance()->Get<bool>("analysis.types.templateSimplifier", view);
returnDemangleMS(arch, mangledName, outType, outVarName, simplify);
}
boolDemangleMS(Architecture* arch, const std::string& mangledName, Ref<Type>& outType, QualifiedName& outVarName,
constbool simplify)
{
BNType* localType = nullptr;
char** localVarName = nullptr;
size_t localSize = 0;
if (!BNDemangleMS(arch->GetObject(), mangledName.c_str(), &localType, &localVarName, &localSize, simplify))
returnfalse;
outType = localType ? newType(localType) : nullptr;
for (size_t i = 0; i < localSize; i++)
{
outVarName.push_back(localVarName[i]);
}
BNFreeDemangledName(&localVarName, localSize);
returntrue;
}
boolDemangleGNU3(Ref<Architecture> arch, const std::string& mangledName, Ref<Type>& outType, QualifiedName& outVarName,
BinaryView* view)
{
constbool simplify = Settings::Instance()->Get<bool>("analysis.types.templateSimplifier", view);
returnDemangleGNU3(arch, mangledName, outType, outVarName, simplify);
}
boolDemangleGNU3(Ref<Architecture> arch, const std::string& mangledName, Ref<Type>& outType, QualifiedName& outVarName,
constbool simplify)
{
BNType* localType;
char** localVarName = nullptr;
size_t localSize = 0;
if (!BNDemangleGNU3(arch->GetObject(), mangledName.c_str(), &localType, &localVarName, &localSize, simplify))
returnfalse;
outType = localType ? newType(localType) : nullptr;
outVarName.clear();
for (size_t i = 0; i < localSize; i++)
{
outVarName.push_back(localVarName[i]);
}
BNFreeDemangledName(&localVarName, localSize);
returntrue;
}
boolIsGNU3MangledString(const std::string& mangledName)
{
returnBNIsGNU3MangledString(mangledName.c_str());
}
string SimplifyToString(const string& input)
{
returnBNRustSimplifyStrToStr(input.c_str());
}
string SimplifyToString(const QualifiedName& input)
{
returnBNRustSimplifyStrToStr(input.GetString().c_str());
}
QualifiedName SimplifyToQualifiedName(const string& input, bool simplify)
{
BNQualifiedName name = BNRustSimplifyStrToFQN(input.c_str(), simplify);
QualifiedName result = QualifiedName::FromAPIObject(&name);
BNFreeQualifiedName(&name);
return result;
}
QualifiedName SimplifyToQualifiedName(const QualifiedName& input)
{
BNQualifiedName name = BNRustSimplifyStrToFQN(input.GetString().c_str(), true);
QualifiedName result = QualifiedName::FromAPIObject(&name);
BNFreeQualifiedName(&name);
return result;
}
} // namespace BinaryNinja