// Apply exact cross-platform Function ID matches to the stripped Windows DLL. // @category Iggy import ghidra.app.script.GhidraScript; import ghidra.program.model.address.Address; import ghidra.program.model.listing.Function; import ghidra.program.model.symbol.SourceType; import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.InvalidInputException; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; public class ApplyFunctionMap extends GhidraScript { @Override protected void run() throws Exception { String[] args = getScriptArgs(); if (args.length != 1) { throw new IllegalArgumentException("expected function map TSV"); } int applied = 0; try (BufferedReader reader = new BufferedReader(new FileReader(new File(args[0])))) { String line = reader.readLine(); while ((line = reader.readLine()) != null) { String[] fields = line.split("\\t", -1); if (fields.length < 3) { continue; } Address address = toAddr(fields[0]); Function function = currentProgram.getFunctionManager().getFunctionAt(address); if (function == null || !function.getName().startsWith("FUN_")) { continue; } String originalName = fields[2]; String safeName = originalName.replace("::", "__") .replaceAll("[^A-Za-z0-9_$]", "_"); if (safeName.isEmpty() || Character.isDigit(safeName.charAt(0))) { safeName = "recovered_" + safeName; } try { function.setName(safeName, SourceType.IMPORTED); } catch (DuplicateNameException exception) { function.setName(safeName + "_" + fields[0], SourceType.IMPORTED); } catch (InvalidInputException exception) { printerr("Could not apply " + originalName + " at " + fields[0]); continue; } function.setComment("Recovered Durango symbol: " + originalName); applied++; } } println("Applied " + applied + " exact Durango function names to " + currentProgram.getName()); } }