diff options
| author | Valentin Popov <valentin@popov.link> | 2026-07-18 19:40:17 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-07-18 19:40:17 +0300 |
| commit | d31d1f8eab7a2c79e349748939de01895af5de7e (patch) | |
| tree | 89546aab24629deebaf88c3694e49ef2a547a3e2 /tools/ghidra/FindAiScriptLoaderReferences.java | |
| parent | a7b434aeb2e1c79131e4919f6b0cbf66cdc06599 (diff) | |
| download | fparkan-d31d1f8eab7a2c79e349748939de01895af5de7e.tar.xz fparkan-d31d1f8eab7a2c79e349748939de01895af5de7e.zip | |
feat(script): decode compiled package framing
Diffstat (limited to 'tools/ghidra/FindAiScriptLoaderReferences.java')
| -rw-r--r-- | tools/ghidra/FindAiScriptLoaderReferences.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/ghidra/FindAiScriptLoaderReferences.java b/tools/ghidra/FindAiScriptLoaderReferences.java new file mode 100644 index 0000000..5aae152 --- /dev/null +++ b/tools/ghidra/FindAiScriptLoaderReferences.java @@ -0,0 +1,29 @@ +// Locates callers that reference the stable AI script-loader literals. +// Run through Ghidra headless analysis; the original PE is read only. +import ghidra.app.script.GhidraScript; +import ghidra.program.model.address.Address; +import ghidra.program.model.listing.Function; +import ghidra.program.model.mem.Memory; +import ghidra.program.model.symbol.Reference; +import ghidra.program.model.symbol.ReferenceManager; + +public class FindAiScriptLoaderReferences extends GhidraScript { + private static final String[] NEEDLES = {".scr", "MISSIONS\\SCRIPTS\\"}; + + @Override + public void run() throws Exception { + Memory memory = currentProgram.getMemory(); + ReferenceManager references = currentProgram.getReferenceManager(); + for (String needle : NEEDLES) { + byte[] bytes = (needle + "\0").getBytes("US-ASCII"); + Address address = memory.findBytes(memory.getMinAddress(), memory.getMaxAddress(), bytes, null, true, monitor); + println("===== " + needle + " ====="); + if (address == null) { println("missing"); continue; } + println("literal=" + address); + for (Reference reference : references.getReferencesTo(address)) { + Function caller = currentProgram.getFunctionManager().getFunctionContaining(reference.getFromAddress()); + println("reference=" + reference.getFromAddress() + " caller=" + (caller == null ? "missing" : caller.getEntryPoint())); + } + } + } +} |
