From bb1288d9b05e329f3d85134b4803a2d6eaa06e05 Mon Sep 17 00:00:00 2001 From: Ethan Messinger-Arns Date: Mon, 2 Oct 2023 21:39:27 -0700 Subject: [PATCH 1/2] Replaced deprecated API --- ghidra_scripts/FnidUtils.java | 7 +------ ghidra_scripts/Ps3ElfUtils.java | 10 ++++------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/ghidra_scripts/FnidUtils.java b/ghidra_scripts/FnidUtils.java index 3f8ae45..991a3f4 100644 --- a/ghidra_scripts/FnidUtils.java +++ b/ghidra_scripts/FnidUtils.java @@ -1,14 +1,9 @@ import ghidra.app.script.GhidraScript; -import ghidra.framework.Application; -import ghidra.framework.plugintool.dialog.ExtensionDetails; -import ghidra.framework.plugintool.dialog.ExtensionUtils; import org.apache.commons.io.FileUtils; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.stream.Collectors; class FnidUtils { @@ -42,7 +37,7 @@ private static void loadFnids(GhidraScript script) throws Exception { file = script.askFile("Locate nids.txt", "Load"); } - List list = FileUtils.readLines(file); + List list = FileUtils.readLines(file,"ascii"); for (String s : list) { final String[] split = s.split(" "); fnids.put(split[0], split[1]); diff --git a/ghidra_scripts/Ps3ElfUtils.java b/ghidra_scripts/Ps3ElfUtils.java index 4c2ce3e..6d3b26c 100644 --- a/ghidra_scripts/Ps3ElfUtils.java +++ b/ghidra_scripts/Ps3ElfUtils.java @@ -1,7 +1,6 @@ import ghidra.app.script.GhidraScript; -import ghidra.framework.plugintool.dialog.ExtensionDetails; -import ghidra.framework.plugintool.dialog.ExtensionException; -import ghidra.framework.plugintool.dialog.ExtensionUtils; +import ghidra.framework.project.extensions.ExtensionDetails; +import ghidra.framework.project.extensions.ExtensionUtils; import ghidra.program.model.address.Address; import ghidra.program.model.data.ArrayDataType; import ghidra.program.model.data.DataType; @@ -10,7 +9,6 @@ import ghidra.program.model.listing.Program; import ghidra.program.model.mem.MemoryBlock; -import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -160,13 +158,13 @@ public void applyDataForce(DataType data, String name, Address address) throws E public static String getExtensionInstallDataPath(String extensionName) { final List ps3GhidraScripts; try { - ps3GhidraScripts = ExtensionUtils.getInstalledExtensions(false) + ps3GhidraScripts = ExtensionUtils.getInstalledExtensions() .stream() .filter(extension -> extension.getName().equals(extensionName)) .collect(Collectors.toList()); final ExtensionDetails extensionDetails = ps3GhidraScripts.get(0); return extensionDetails.getInstallPath(); - } catch (ExtensionException e) { + } catch (Exception e) { e.printStackTrace(); } From 94c50e5e07783f19343c7a4c3f70ecab680fdde2 Mon Sep 17 00:00:00 2001 From: Ethan Messinger-Arns Date: Mon, 2 Oct 2023 21:49:10 -0700 Subject: [PATCH 2/2] Better charset recognition method --- ghidra_scripts/FnidUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ghidra_scripts/FnidUtils.java b/ghidra_scripts/FnidUtils.java index 991a3f4..f64b095 100644 --- a/ghidra_scripts/FnidUtils.java +++ b/ghidra_scripts/FnidUtils.java @@ -2,6 +2,7 @@ import org.apache.commons.io.FileUtils; import java.io.File; +import java.nio.charset.Charset; import java.util.HashMap; import java.util.List; @@ -37,7 +38,7 @@ private static void loadFnids(GhidraScript script) throws Exception { file = script.askFile("Locate nids.txt", "Load"); } - List list = FileUtils.readLines(file,"ascii"); + List list = FileUtils.readLines(file,Charset.defaultCharset()); for (String s : list) { final String[] split = s.split(" "); fnids.put(split[0], split[1]);