MCPcopy Create free account
hub / github.com/clienthax/Ps3GhidraScripts / FnidUtils

Class FnidUtils

ghidra_scripts/FnidUtils.java:13–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11import java.util.stream.Collectors;
12
13class FnidUtils {
14
15 private static final String NIDS_PATH = "nids.txt";
16 private static HashMap<String, String> fnids = null;
17
18 public static String getNameForFnid(GhidraScript script, String moduleName, int fnid) throws Exception {
19
20 if(fnids == null) {
21 loadFnids(script);
22 }
23
24 if(moduleName.equals("NONAME")) {
25 moduleName = "";
26 }
27
28 final String fnidHex = String.format("0x%08X", fnid);
29 String name = fnids.get(fnidHex);
30 if(name == null) {
31 script.printf("Missing fnid, module: %s %s\n", moduleName, fnidHex);
32 return moduleName+"_"+fnidHex;
33 }
34
35 return name;
36 }
37
38 private static void loadFnids(GhidraScript script) throws Exception {
39 fnids = new HashMap<>();
40 File file = new File(Ps3ElfUtils.getExtensionInstallDataPath("Ps3GhidraScripts"), "data/"+NIDS_PATH);
41 if (!file.exists()) {
42 file = script.askFile("Locate nids.txt", "Load");
43 }
44
45 List<String> list = FileUtils.readLines(file);
46 for (String s : list) {
47 final String[] split = s.split(" ");
48 fnids.put(split[0], split[1]);
49 }
50 }
51
52}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected