Ghidra is a software reverse engineering (SRE) framework
Fixed screenshots broken due to archive type change
dragonmachera0893d6c59f3
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/AbstractGhidraHeadedDebuggerTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/AbstractGhidraHeadedDebuggerTest.javaindex 18c2827ab3..38bb51f9ef 100644--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/AbstractGhidraHeadedDebuggerTest.java+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/AbstractGhidraHeadedDebuggerTest.java@@ -555,6 +555,9 @@ public abstract class AbstractGhidraHeadedDebuggerTestif (provider == null) {ctx = new DefaultActionContext();}+ else {+ ctx = provider.getActionContext(null);+ }ctx.setContextProvider(provider);diff --git a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/CommitDialog.png b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/CommitDialog.pngindex ed14f0cc2c..4c4ce221e7 100644Binary files a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/CommitDialog.png and b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/CommitDialog.png differdiff --git a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/DataTypeManager.png b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/DataTypeManager.pngindex 9c0184df11..350313c5c1 100644Binary files a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/DataTypeManager.png and b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/DataTypeManager.png differdiff --git a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/DisassociateDialog.png b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/DisassociateDialog.pngindex 906206d70f..6426868cbc 100644Binary files a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/DisassociateDialog.png and b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/DisassociateDialog.png differdiff --git a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/FavoriteDts.png b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/FavoriteDts.pngindex 5368f27b6c..5b7cb6a0dc 100644Binary files a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/FavoriteDts.png and b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/FavoriteDts.png differdiff --git a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/FindDataTypesBySize.png b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/FindDataTypesBySize.pngindex 13e21e5ed8..7fe6f46aa4 100644Binary files a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/FindDataTypesBySize.png and b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/FindDataTypesBySize.png differdiff --git a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/MergeErrorDialog.png b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/MergeErrorDialog.pngindex 5813d6e57f..307b4dc034 100644Binary files a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/MergeErrorDialog.png and b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/MergeErrorDialog.png differdiff --git a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/PreviewWindow.png b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/PreviewWindow.pngindex 9d79b7df64..7019669931 100644Binary files a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/PreviewWindow.png and b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/PreviewWindow.png differdiff --git a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/RevertDialog.png b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/RevertDialog.pngindex a897e616a2..0d78cd4f7b 100644Binary files a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/RevertDialog.png and b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/RevertDialog.png differdiff --git a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/SearchResults.png b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/SearchResults.pngindex bff1b63aab..0cab53ed93 100644Binary files a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/SearchResults.png and b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/SearchResults.png differdiff --git a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/UpdateDialog.png b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/UpdateDialog.pngindex bea0f431b6..4796fe421b 100644Binary files a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/UpdateDialog.png and b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/images/UpdateDialog.png differdiff --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.javaindex 0c55620640..c440262c29 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@@ -1283,14 +1283,16 @@ abstract public class DataTypeManagerDB implements DataTypeManager {resolvedDataType = resolveDataTypeNoSource(dataType);}else if (!sourceArchive.getSourceArchiveID().equals(getUniversalID()) &&- (sourceArchive.getArchiveType() == ArchiveType.PROGRAM ||- sourceArchive.getArchiveType() == ArchiveType.TEMPORARY)) {- // dataTypes from a program or temporary archive don't carry over their identity+ !sourceArchive.getArchiveType().isValidSourceArchive()) {++ // dataTypes from a invalid source (program, built-in, temporary) archive+ // don't carry over their identityresolvedDataType = resolveDataTypeNoSource(dataType);}else {resolvedDataType = resolveDataTypeWithSource(dataType);}+cacheResolvedDataType(dataType, resolvedDataType);if (resolvedDataType instanceof DataTypeDB) {setCachedEquivalence((DataTypeDB) resolvedDataType, dataType);@@ -4594,8 +4596,7 @@ abstract public class DataTypeManagerDB implements DataTypeManager {}}- private record DedupedConflicts(int processCnt, int replaceCnt) {- }+ private record DedupedConflicts(int processCnt, int replaceCnt) {}private DedupedConflicts doDedupeConflicts(DataType dataType) {diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/ArchiveType.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/ArchiveType.javaindex 020a0ebb6e..398de44892 100644--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/ArchiveType.java+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/ArchiveType.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -27,4 +27,11 @@ public enum ArchiveType {public boolean isBuiltIn() {return this == BUILT_IN;}++ /**+ * {@return true if this type is a valid type of source archive for adding types to the program}+ */+ public boolean isValidSourceArchive() {+ return this == FILE || this == PROJECT;+ }}diff --git a/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/DataTypeManagerPluginScreenShots.java b/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/DataTypeManagerPluginScreenShots.javaindex 58b9e4ecd5..290421e0a4 100644--- a/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/DataTypeManagerPluginScreenShots.java+++ b/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/DataTypeManagerPluginScreenShots.java@@ -79,17 +79,6 @@ public class DataTypeManagerPluginScreenShots extends GhidraScreenShotGeneratorcaptureIsolatedProvider(DataTypesProvider.class, 500, 400);}- @Test- public void testDataTypeTreeWithAssociations() {- DataTypesProvider provider = getProvider(DataTypesProvider.class);- GTree tree = (GTree) getInstanceField("archiveGTree", provider);- GTreeNode rootNode = tree.getViewRoot();- GTreeNode child = rootNode.getChild("WinHelloCPP.exe");- child = child.getChild("basetsd.h");- tree.expandPath(child);- captureIsolatedProvider(DataTypesProvider.class, 500, 400);- }-@Testpublic void testDisassociateDialog() {DataTypeManagerPlugin plugin = getPlugin(tool, DataTypeManagerPlugin.class);@@ -196,8 +185,8 @@ public class DataTypeManagerPluginScreenShots extends GhidraScreenShotGenerator@Testpublic void testFindDataTypes() {- performAction("Find Data Types", "DataTypeManagerPlugin", false);- JDialog d = waitForJDialog("Find Data Types");+ performAction("Find Data Types by Name", "DataTypeManagerPlugin", false);+ JDialog d = waitForJDialog("Find Data Types by Name");captureDialog();pressButtonByText(d, "Cancel");}@@ -260,7 +249,8 @@ public class DataTypeManagerPluginScreenShots extends GhidraScreenShotGeneratorcloseNonProgramArchives();closeProvider(DataTypesProvider.class);- runSwing(() -> performAction("Find Data Types", "DataTypeManagerPlugin", false), false);+ runSwing(() -> performAction("Find Data Types by Name", "DataTypeManagerPlugin", false),+ false);final DialogComponentProvider dialog = getDialog();runSwing(() -> {@@ -281,41 +271,26 @@ public class DataTypeManagerPluginScreenShots extends GhidraScreenShotGeneratorDataTypeManagerPlugin plugin = getPlugin(tool, DataTypeManagerPlugin.class);List<DataTypeSyncInfo> list = new ArrayList<>();Set<DataTypeSyncInfo> set = new HashSet<>();- createChangedDatatypesFromArchive(list, set);-- DataTypeManager dtm = program.getDataTypeManager();-- StandAloneDataTypeManager sourceDTM = new StandAloneDataTypeManager("MyArhcive");- StructureDataType sdt1 = new StructureDataType("MyDataType1", 0);- sdt1.add(new PointerDataType(new StringDataType()), "name", null);- sdt1.add(new IntegerDataType(), "age", null);- sdt1.add(new PointerDataType(new VoidDataType()), "data", null);-- StructureDataType sdt2 = new StructureDataType("MyDataType2", 0);- sdt2.add(new PointerDataType(new IntegerDataType()));- sdt2.add(new IntegerDataType());- sdt2.add(new WordDataType());+ StandAloneDataTypeManager sourceDtm = createChangedDatatypesFromArchive(list, set);- int id = sourceDTM.startTransaction("Test");- DataType dt1 = sourceDTM.addDataType(sdt1, null);- sourceDTM.endTransaction(id, true);+ DataType dt1 = sourceDtm.getDataType("/MyDataType1");- int txID = program.startTransaction("Test");- Structure struct = (Structure) dtm.addDataType(dt1, null);- program.endTransaction(txID, true);+ Structure struct = tx(program, () -> {+ DataTypeManager dtm = program.getDataTypeManager();+ return (Structure) dtm.addDataType(dt1, null);+ });- id = sourceDTM.startTransaction("Test2");- ((Structure) dt1).add(new IntegerDataType(), "id", null);- sourceDTM.endTransaction(id, true);+ tx(sourceDtm, () -> {+ ((Structure) dt1).add(new IntegerDataType(), "id", null);+ });- DataTypeSyncInfo sync1 = new DataTypeSyncInfo(struct, sourceDTM);+ DataTypeSyncInfo sync1 = new DataTypeSyncInfo(struct, sourceDtm);list.add(sync1);set.add(sync1);- final DataTypeSyncDialog dialog =+ DataTypeSyncDialog dialog =new DataTypeSyncDialog(plugin, "WinHelloCPP.exe", "MyArchive", list, set, "Update","Update DataType Changes From Archive \"MyArchive\" To \"WinHelloCpp.exe\" ");-showModalDialogInTool(dialog);runSwing(() -> {@@ -360,11 +335,18 @@ public class DataTypeManagerPluginScreenShots extends GhidraScreenShotGeneratorreturn null;// cannot get here}- private void createChangedDatatypesFromArchive(List<DataTypeSyncInfo> list,+ private StandAloneDataTypeManager createChangedDatatypesFromArchive(List<DataTypeSyncInfo> list,Set<DataTypeSyncInfo> set) {DataTypeManager dtm = program.getDataTypeManager();- StandAloneDataTypeManager sourceDTM = new StandAloneDataTypeManager("MyArhcive");+ StandAloneDataTypeManager sourceDtm = new StandAloneDataTypeManager("MyArhcive") {+ @Override+ public ArchiveType getType() {+ // Need to not be the default TEMPORARY type so that the universal ID of our data+ // types will be maintained. This is needed to associate the types.+ return ArchiveType.FILE;+ }+ };StructureDataType sdt1 = new StructureDataType("MyDataType1", 0);sdt1.add(new PointerDataType(new StringDataType()), "name", null);sdt1.add(new IntegerDataType(), "age", null);@@ -375,27 +357,26 @@ public class DataTypeManagerPluginScreenShots extends GhidraScreenShotGeneratorsdt2.add(new IntegerDataType());sdt2.add(new WordDataType());- int id = sourceDTM.startTransaction("Test");- DataType dt1 = sourceDTM.addDataType(sdt1, null);- DataType dt2 = sourceDTM.addDataType(sdt2, null);- sourceDTM.endTransaction(id, true);+ int id = sourceDtm.startTransaction("Test");+ DataType dt1 = sourceDtm.addDataType(sdt1, null);+ DataType dt2 = sourceDtm.addDataType(sdt2, null);+ sourceDtm.endTransaction(id, true);++ tx(program, () -> {- int txID = program.startTransaction("Test");- try {Structure struct = (Structure) dtm.addDataType(dt1, null);struct.add(new IntegerDataType(), "id", null);Structure struct2 = (Structure) dtm.addDataType(dt2, null);struct2.add(new IntegerDataType());- DataTypeSyncInfo sync1 = new DataTypeSyncInfo(struct, sourceDTM);- DataTypeSyncInfo sync2 = new DataTypeSyncInfo(struct2, sourceDTM);+ DataTypeSyncInfo sync1 = new DataTypeSyncInfo(struct, sourceDtm);+ DataTypeSyncInfo sync2 = new DataTypeSyncInfo(struct2, sourceDtm);list.add(sync1);list.add(sync2);set.add(sync1);- }- finally {- program.endTransaction(txID, true);- }+ });++ return sourceDtm;}private void showModalDialogInTool(final DialogComponentProvider dialog) {