Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef176d4
commit 2d511d4
Showing
7 changed files
with
95 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "ghidra/ghidra"] | ||
path = ghidra/ghidra | ||
url = https://github.com/thestr4ng3r/ghidra.git | ||
[submodule "third-party/pugixml"] | ||
path = third-party/pugixml | ||
url = https://github.com/zeux/pugixml.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
#include "CodeXMLParse.h" | ||
#include <funcdata.hh> | ||
#include <r_util.h> | ||
#include <pugixml.hpp> | ||
#include <sstream> | ||
#include <string> | ||
|
||
static void ParseNode(pugi::xml_node node, Funcdata *func, std::ostream &stream, RAnnotatedCode *code) | ||
{ | ||
if(node.type() == pugi::xml_node_type::node_pcdata) | ||
{ | ||
stream << node.value(); | ||
return; | ||
} | ||
|
||
if(strcmp(node.name(), "break") == 0) | ||
{ | ||
stream << "\n"; | ||
stream << std::string(node.attribute("indent").as_uint(0), ' '); | ||
} | ||
|
||
for(pugi::xml_node child : node) | ||
ParseNode(child, func, stream, code); | ||
} | ||
|
||
R_API RAnnotatedCode *ParseCodeXML(Funcdata *func, const char *xml) | ||
{ | ||
pugi::xml_document doc; | ||
if(!doc.load_string(xml, pugi::parse_default | pugi::parse_ws_pcdata)) | ||
return nullptr; | ||
|
||
std::stringstream ss; | ||
RAnnotatedCode *code = r_annotated_code_new(nullptr); | ||
if(!code) | ||
return nullptr; | ||
|
||
ParseNode(doc.child("function"), func, ss, code); | ||
|
||
std::string str = ss.str(); | ||
code->code = reinterpret_cast<char *>(r_malloc(str.length() + 1)); | ||
if(!code->code) | ||
{ | ||
r_annotated_code_free(code); | ||
return nullptr; | ||
} | ||
memcpy(code->code, str.c_str(), str.length()); | ||
code->code[str.length()] = '\0'; | ||
return code; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
#ifndef R2GHIDRA_CODEXMLPARSE_H | ||
#define R2GHIDRA_CODEXMLPARSE_H | ||
|
||
#include "AnnotatedCode.h" | ||
|
||
class Funcdata; | ||
|
||
R_API RAnnotatedCode *ParseCodeXML(Funcdata *func, const char *xml); | ||
|
||
#endif //R2GHIDRA_CODEXMLPARSE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
add_library(pugixml STATIC | ||
pugixml/src/pugiconfig.hpp | ||
pugixml/src/pugixml.cpp | ||
pugixml/src/pugixml.hpp) | ||
target_include_directories(pugixml PUBLIC pugixml/src) | ||
set_target_properties(pugixml PROPERTIES POSITION_INDEPENDENT_CODE ON) | ||
|