Files
isaac-port/scripts/ApplyDb.java
T
shweetandClaude Opus 5.5 ad8f933086 Salvage Repentance+ 1.9.7.17 decompilation toolkit, notes and name database
Ghidra 12.2 project and full dump of isaac-ng.exe v1.9.7.17, query scripts, notes
indexed by entity, anm2/rooms reimplementations, and db/ (names + fields) that
build.sh re-applies. Fixes awk numeric address comparison in find.sh/decompile.sh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 13:08:19 -04:00

33 lines
1.5 KiB
Java

// Applies db/names.tsv (address, Qualified::Name, note) as forced renames with a "DB: note" comment. Arg: names.tsv
import ghidra.app.script.GhidraScript;
import ghidra.program.model.address.*;
import ghidra.program.model.listing.*;
import ghidra.program.model.symbol.*;
import java.nio.file.*;
public class ApplyDb extends GhidraScript {
public void run() throws Exception {
SymbolTable st = currentProgram.getSymbolTable();
int n = 0;
for (String line : Files.readAllLines(Paths.get(getScriptArgs()[0]))) {
if (line.isBlank() || line.startsWith("#")) continue;
String[] c = line.split("\t", 3);
Address a = toAddr(c[0]);
Function fn = getFunctionAt(a);
if (fn == null) { disassemble(a); fn = createFunction(a, null); }
if (fn == null) { println("ApplyDb: no function at " + c[0]); continue; }
String[] parts = c[1].split("::");
Namespace ns = currentProgram.getGlobalNamespace();
for (int k = 0; k < parts.length - 1; k++) {
Namespace n2 = st.getNamespace(parts[k], ns);
ns = n2 != null ? n2 : st.createNameSpace(ns, parts[k], SourceType.USER_DEFINED);
}
fn.setParentNamespace(ns);
fn.setName(parts[parts.length - 1], SourceType.USER_DEFINED);
fn.setComment("DB: " + (c.length > 2 ? c[2] : ""));
n++;
}
println("ApplyDb: " + n + " names");
}
}