Last active
July 17, 2021 05:20
-
-
Save maxton/4c9222d97880b483a5b7a3292fd6a165 to your computer and use it in GitHub Desktop.
Ghidra script to export .map files for the Xenia debugger. Load maps by launching Xenia with the --load_module_map="C:\path\to\ghidra.map" argument.
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
//Saves function names and addresses for Xenia | |
//@author Maxton | |
//@category Functions | |
//@keybinding | |
//@menupath File.Export Xenia Map File... | |
//@toolbar | |
import java.io.File; | |
import java.io.FileOutputStream; | |
import java.io.PrintWriter; | |
import ghidra.app.script.GhidraScript; | |
import ghidra.program.model.address.Address; | |
import ghidra.program.model.listing.*; | |
public class ExportXeniaMap extends GhidraScript { | |
@Override | |
public void run() throws Exception { | |
File outputFile = askFile("Choose Map File Name", "Save"); | |
PrintWriter pWriter = new PrintWriter(new FileOutputStream(outputFile)); | |
pWriter.println("Program map file for Xenia"); | |
pWriter.println(" Address (the map parser looks for this line before loading functions)"); | |
Listing listing = currentProgram.getListing(); | |
FunctionIterator iter = listing.getFunctions(true); | |
while (iter.hasNext() && !monitor.isCancelled()) { | |
Function f = iter.next(); | |
String fName = f.getName(true); | |
Address entry = f.getEntryPoint(); | |
if (entry == null) { | |
// Skip writing anything if the entry is null | |
} | |
else { | |
// Line is [ws][ignore][ws][name][ws][hex addr][ws][(f)][ws][library] | |
pWriter.println(" . " + fName + " " + entry + " f ?"); | |
} | |
} | |
pWriter.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment