diff options
| author | Rusty Wagner <rusty@vector35.com> | 2017-06-23 18:36:37 -0400 |
|---|---|---|
| committer | Rusty Wagner <rusty@vector35.com> | 2017-06-23 18:36:37 -0400 |
| commit | c51f3bed6bdef577253feee0e85a71fda1931bd7 (patch) | |
| tree | 1cf26ff28e0b9bfb6bfbed044ba7ca520d63f862 /demangle.cpp | |
| parent | 4b988c0d24c8d8c8dc67485f3aaeb7106eb4af18 (diff) | |
| parent | cca0fe6ea60eb7f6b35cc433a6fff96cc65b3ff8 (diff) | |
Merge branch 'dev'
Diffstat (limited to 'demangle.cpp')
| -rw-r--r-- | demangle.cpp | 70 |
1 files changed, 39 insertions, 31 deletions
diff --git a/demangle.cpp b/demangle.cpp index a12303ca..c3867aed 100644 --- a/demangle.cpp +++ b/demangle.cpp @@ -1,43 +1,51 @@ #include "binaryninjaapi.h" -using namespace BinaryNinja; using namespace std; -bool DemangleMS(Architecture* arch, - const std::string& mangledName, - Type** outType, - std::vector<std::string>& outVarName) +namespace BinaryNinja { - BNType* localType = (*outType)->GetObject(); - char** localVarName = nullptr; - size_t localSize = 0; - if (!BNDemangleMS(arch->GetObject(), mangledName.c_str(), &localType, &localVarName, &localSize)) - return false; - for (size_t i = 0; i < localSize; i++) + bool DemangleMS(Architecture* arch, + const std::string& mangledName, + Type** outType, + QualifiedName& outVarName) { - outVarName.push_back(localVarName[i]); - BNFreeString(localVarName[i]); + 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; } - delete [] localVarName; - return true; -} -bool DemangleGNU3(Architecture* arch, - const std::string& mangledName, - Type** outType, - std::vector<std::string>& outVarName) -{ - BNType* localType = (*outType)->GetObject(); - char** localVarName = nullptr; - size_t localSize = 0; - if (!BNDemangleGNU3(arch->GetObject(), mangledName.c_str(), &localType, &localVarName, &localSize)) - return false; - for (size_t i = 0; i < localSize; i++) + bool DemangleGNU3(Ref<Architecture> arch, + const std::string& mangledName, + Type** outType, + QualifiedName& outVarName) { - outVarName.push_back(localVarName[i]); - BNFreeString(localVarName[i]); + 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; } - delete [] localVarName; - return true; } |
