Commit ·
b5c89ee
1
Parent(s): 9446bbb
minor
Browse files
main.py
CHANGED
|
@@ -146,7 +146,7 @@ This is a space to experiment with GhidraFunctionCPPExporter, a Ghidra scripts t
|
|
| 146 |
fm = program.getFunctionManager()
|
| 147 |
func = fm.getFunctionAt(program.getAddressFactory().getAddress(hex(selected_fun)))
|
| 148 |
listing = program.getListing()
|
| 149 |
-
|
| 150 |
|
| 151 |
|
| 152 |
o = subprocess.run(["/code/GhidraFunctionCPPExporter/export.bash", state['file'], "base_name", "file", "address_set_str", hex(selected_fun), "output_dir", TEMP_DIR], shell=False, capture_output=True, encoding="utf8")
|
|
@@ -158,11 +158,11 @@ This is a space to experiment with GhidraFunctionCPPExporter, a Ghidra scripts t
|
|
| 158 |
raise Exception(f"Ghidra export failed with return code {o.returncode}: {o.stderr}")
|
| 159 |
|
| 160 |
with open(os.path.join(TEMP_DIR, "file.c"), "r") as f:
|
| 161 |
-
|
| 162 |
|
| 163 |
return {
|
| 164 |
-
disassembly: gr.Textbox(value=
|
| 165 |
-
original_decompile: gr.Textbox(value=
|
| 166 |
}
|
| 167 |
|
| 168 |
demo.queue()
|
|
|
|
| 146 |
fm = program.getFunctionManager()
|
| 147 |
func = fm.getFunctionAt(program.getAddressFactory().getAddress(hex(selected_fun)))
|
| 148 |
listing = program.getListing()
|
| 149 |
+
disassembly_str = "\n".join([i.toString() for i in listing.getInstructions(func.getBody(), True)])
|
| 150 |
|
| 151 |
|
| 152 |
o = subprocess.run(["/code/GhidraFunctionCPPExporter/export.bash", state['file'], "base_name", "file", "address_set_str", hex(selected_fun), "output_dir", TEMP_DIR], shell=False, capture_output=True, encoding="utf8")
|
|
|
|
| 158 |
raise Exception(f"Ghidra export failed with return code {o.returncode}: {o.stderr}")
|
| 159 |
|
| 160 |
with open(os.path.join(TEMP_DIR, "file.c"), "r") as f:
|
| 161 |
+
decompile_str = f.read()
|
| 162 |
|
| 163 |
return {
|
| 164 |
+
disassembly: gr.Textbox(value=disassembly_str),
|
| 165 |
+
original_decompile: gr.Textbox(value=decompile_str),
|
| 166 |
}
|
| 167 |
|
| 168 |
demo.queue()
|