diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeManagerDB.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeManagerDB.java index 73d45f4e85..81310f47f5 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeManagerDB.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeManagerDB.java @@ -1111,7 +1111,9 @@ abstract public class DataTypeManagerDB implements DataTypeManager { } else { buildSortedDataTypeList(); - Iterator it = sortedDataTypes.iterator(); + // make copy of sortedDataTypes list before iterating as dt.dataTypeReplaced may + // call back into this class and cause a modification to the sortedDataTypes list. + Iterator it = new ArrayList<>(sortedDataTypes).iterator(); while (it.hasNext()) { DataType dt = it.next(); dt.dataTypeReplaced(existingDt, newDt); diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/DynamicHash.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/DynamicHash.java index 75cc6157e6..8fb24b73e1 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/DynamicHash.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/DynamicHash.java @@ -118,8 +118,8 @@ public class DynamicHash { reg = SimpleCRC32.hashOneByte(reg, slot); reg = SimpleCRC32.hashOneByte(reg, transtable[op.getOpcode()]); long val = op.getSeqnum().getTarget().getOffset(); - int sz = op.getSeqnum().getTarget().getPointerSize(); - for (int i = 0; i < sz; ++i) { + int sz = op.getSeqnum().getTarget().getSize(); + for (int i = 0; i < sz; i += 8) { reg = SimpleCRC32.hashOneByte(reg, (int) val); val >>= 8; } diff --git a/Ghidra/Framework/Utility/src/main/java/ghidra/GhidraLauncher.java b/Ghidra/Framework/Utility/src/main/java/ghidra/GhidraLauncher.java index c21a749dd7..381dc1ad25 100644 --- a/Ghidra/Framework/Utility/src/main/java/ghidra/GhidraLauncher.java +++ b/Ghidra/Framework/Utility/src/main/java/ghidra/GhidraLauncher.java @@ -56,7 +56,7 @@ public class GhidraLauncher { addExternalJarPaths(classpathList, layout.getApplicationRootDirs()); } else { - addPatchPaths(classpathList, layout.getApplicationRootDirs()); + addPatchPaths(classpathList, layout.getApplicationInstallationDir()); addModuleJarPaths(classpathList, layout.getModules()); } classpathList = orderClasspath(classpathList); @@ -79,25 +79,16 @@ public class GhidraLauncher { } /** - * Add bin patch directories and lib patch jars to the given path list. This should be done + * Add patch jars to the given path list. This should be done * first so they take precedence in the classpath. * * @param pathList The list of paths to add to. * @param appRootDirs The application root directories to search. */ - private static void addPatchPaths(List pathList, Collection appRootDirs) { - - for (ResourceFile rootDir : appRootDirs) { - - ResourceFile dir = new ResourceFile(rootDir, "bin"); - if (dir.exists()) { - pathList.add(dir.getAbsolutePath()); - } - - ResourceFile debugLibDir = new ResourceFile(rootDir, "lib"); - if (debugLibDir.exists()) { - pathList.addAll(findJarsInDir(debugLibDir)); - } + private static void addPatchPaths(List pathList, ResourceFile installDir) { + ResourceFile patchDir = new ResourceFile(installDir, "Ghidra/patch"); + if (patchDir.exists()) { + pathList.addAll(findJarsInDir(patchDir)); } } diff --git a/GhidraBuild/patch/README.txt b/GhidraBuild/patch/README.txt new file mode 100644 index 0000000000..c80aadd7a0 --- /dev/null +++ b/GhidraBuild/patch/README.txt @@ -0,0 +1,3 @@ +Drop jar files in this directory to apply patches to an installation of Ghidra. Any jar files +found in this directory will be placed at the front of the classpath, allowing them to override +any existing classes in any module. \ No newline at end of file diff --git a/GhidraBuild/patch/certification.local.manifest b/GhidraBuild/patch/certification.local.manifest new file mode 100644 index 0000000000..6018e9ca9f --- /dev/null +++ b/GhidraBuild/patch/certification.local.manifest @@ -0,0 +1,2 @@ +##VERSION: 2.0 +README.txt||GHIDRA||||END| diff --git a/gradleScripts/distribution.gradle b/gradleScripts/distribution.gradle index 15260c088c..10b6289462 100644 --- a/gradleScripts/distribution.gradle +++ b/gradleScripts/distribution.gradle @@ -394,7 +394,14 @@ task assembleCommon (type: Copy) { into "Ghidra" filter (ConcatFilter, prepend: buildDateFile) } - + + //////////////// + // Patch Readme + //////////////// + from (ROOT_PROJECT_DIR + "/GhidraBuild/patch") { + into "Ghidra/patch" + } + ///////////////// // GLOBALS /////////////////