forked from Vector35/binaryninja-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demangle.cpp
51 lines (47 loc) · 1.22 KB
/
demangle.cpp
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
#include "binaryninjaapi.h"
using namespace std;
namespace BinaryNinja
{
bool DemangleMS(Architecture* arch,
const std::string& mangledName,
Type** outType,
QualifiedName& outVarName)
{
BNType* localType = nullptr;
char** localVarName = nullptr;
size_t localSize = 0;
if (!BNDemangleMS(arch->GetObject(), mangledName.c_str(), &localType, &localVarName, &localSize))
return false;
if (!localType)
return false;
*outType = new Type(localType);
for (size_t i = 0; i < localSize; i++)
{
outVarName.push_back(localVarName[i]);
BNFreeString(localVarName[i]);
}
delete [] localVarName;
return true;
}
bool DemangleGNU3(Ref<Architecture> arch,
const std::string& mangledName,
Type** outType,
QualifiedName& outVarName)
{
BNType* localType;
char** localVarName = nullptr;
size_t localSize = 0;
if (!BNDemangleGNU3(arch->GetObject(), mangledName.c_str(), &localType, &localVarName, &localSize))
return false;
if (!localType)
return false;
*outType = new Type(localType);
for (size_t i = 0; i < localSize; i++)
{
outVarName.push_back(localVarName[i]);
BNFreeString(localVarName[i]);
}
delete [] localVarName;
return true;
}
}