summaryrefslogtreecommitdiff
path: root/demangle.cpp
diff options
context:
space:
mode:
authorPeter LaFosse <peter@vector35.com>2017-05-14 09:41:28 -0400
committerPeter LaFosse <peter@vector35.com>2017-05-14 10:11:50 -0400
commit2111f1f77241c938b30bd3cf2851919094429dd6 (patch)
treea0201812b8409528b64549295b1fed6bad19e93b /demangle.cpp
parent12d16ae11dd2c0524a36c59c5b025c38edb4135b (diff)
Expose some core API's for the demangling and type creation
Diffstat (limited to 'demangle.cpp')
-rw-r--r--demangle.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/demangle.cpp b/demangle.cpp
index 70a2fe08..677998d2 100644
--- a/demangle.cpp
+++ b/demangle.cpp
@@ -1,18 +1,22 @@
#include "binaryninjaapi.h"
-using namespace BinaryNinja;
using namespace std;
+namespace BinaryNinja
+{
bool DemangleMS(Architecture* arch,
const std::string& mangledName,
Type** outType,
QualifiedName& outVarName)
{
- BNType* localType = (*outType)->GetObject();
+ 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]);
@@ -23,16 +27,19 @@ bool DemangleMS(Architecture* arch,
}
-bool DemangleGNU3(Architecture* arch,
+bool DemangleGNU3(Ref<Architecture> arch,
const std::string& mangledName,
Type** outType,
QualifiedName& outVarName)
{
- BNType* localType = (*outType)->GetObject();
+ 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]);
@@ -41,3 +48,4 @@ bool DemangleGNU3(Architecture* arch,
delete [] localVarName;
return true;
}
+} \ No newline at end of file