mirror of
https://codeberg.org/KeybadeBlox/JSRF-Decompilation.git
synced 2026-02-20 10:17:03 +03:00
Begin enhanced export Ghidra script
This commit is contained in:
parent
c38d9b5628
commit
43f4d10461
1 changed files with 65 additions and 0 deletions
65
ghidra/ghidra_scripts/EnhancedExport.java
Normal file
65
ghidra/ghidra_scripts/EnhancedExport.java
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
// TODO
|
||||
//
|
||||
// @category Export
|
||||
|
||||
import ghidra.app.script.GhidraScript;
|
||||
import ghidra.program.flatapi.FlatProgramAPI;
|
||||
import ghidra.program.model.listing.Data;
|
||||
import ghidra.program.model.listing.Function;
|
||||
import ghidra.program.model.symbol.SourceType;
|
||||
import ghidra.program.model.symbol.Symbol;
|
||||
import ghidra.program.model.symbol.SymbolIterator;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
public class EnhancedExport extends GhidraScript{
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
final FileWriter out = new FileWriter(askFile("Specify output file", "OK"));
|
||||
|
||||
final SymbolIterator iter = currentProgram.getSymbolTable()
|
||||
.getPrimarySymbolIterator(true);
|
||||
while (iter.hasNext() && !monitor.isCancelled()) {
|
||||
final Symbol s = iter.next();
|
||||
if (s.getSource() != SourceType.USER_DEFINED) continue;
|
||||
|
||||
final Object obj = s.getObject();
|
||||
if (obj != null) switch (obj) {
|
||||
case Data d:
|
||||
out.write(
|
||||
"0x" + s.getAddress().toString() + "\t" +
|
||||
"d" + "\t" +
|
||||
d.getDataType().getDisplayName() + "\t" +
|
||||
s.getName(true) + "\n"
|
||||
);
|
||||
break;
|
||||
|
||||
case Function f:
|
||||
out.write(
|
||||
"0x" + s.getAddress().toString() + "\t" +
|
||||
"f" + "\t" +
|
||||
f.getSignature(true).getReturnType()
|
||||
.getDisplayName() + "\t" +
|
||||
f.getCallingConventionName() + "\t" +
|
||||
f.getName(true) +
|
||||
String.join(
|
||||
"\t",
|
||||
Arrays.stream(f.getSignature(true).getArguments())
|
||||
.map(arg -> "\t" +
|
||||
arg.getDataType().getDisplayName() + "\t" +
|
||||
arg.getName()
|
||||
).toArray(String[]::new)
|
||||
) +
|
||||
(f.hasVarArgs() ? "\t..." : "") + "\n"
|
||||
);
|
||||
break;
|
||||
|
||||
default: {}
|
||||
}
|
||||
}
|
||||
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue