Skip to content

Ghidra is a software reverse engineering (SRE) framework

Fixed tools unable to restore Listing location information; fixed warning getting printed to console for non-Java binaries

dragonmacher83d85daabc15
diff --git a/Ghidra/Configurations/Public_Release/src/main/resources/defaultTools/CodeBrowser.tool b/Ghidra/Configurations/Public_Release/src/main/resources/defaultTools/CodeBrowser.tool
index 559279c039..ffcede31e1 100644
--- a/Ghidra/Configurations/Public_Release/src/main/resources/defaultTools/CodeBrowser.tool
+++ b/Ghidra/Configurations/Public_Release/src/main/resources/defaultTools/CodeBrowser.tool
@@ -34,7 +34,7 @@
<SPLIT_NODE WIDTH="1386" HEIGHT="638" DIVIDER_LOCATION="705" ORIENTATION="VERTICAL">
<SPLIT_NODE WIDTH="1399" HEIGHT="642" DIVIDER_LOCATION="679" ORIENTATION="HORIZONTAL">
<COMPONENT_NODE TOP_INFO="0">
- <COMPONENT_INFO NAME="CodeBrowserPlugin" OWNER="CodeBrowserPlugin" TITLE="Listing: " ACTIVE="true" GROUP="Core" INSTANCE_ID="3207819926581772881" />
+ <COMPONENT_INFO NAME="Listing" OWNER="CodeBrowserPlugin" TITLE="Listing: " ACTIVE="true" GROUP="Core" INSTANCE_ID="3207819926581772881" />
</COMPONENT_NODE>
<COMPONENT_NODE TOP_INFO="0">
<COMPONENT_INFO NAME="Decompiler" OWNER="DecompilePlugin" TITLE="Decompile" ACTIVE="true" GROUP="Default" INSTANCE_ID="3207819926581772879" />
diff --git a/Ghidra/Features/Base/src/test/resources/defaultTools/TestCodeBrowser.tool b/Ghidra/Features/Base/src/test/resources/defaultTools/TestCodeBrowser.tool
index ece29faf92..1c0956fa0d 100644
--- a/Ghidra/Features/Base/src/test/resources/defaultTools/TestCodeBrowser.tool
+++ b/Ghidra/Features/Base/src/test/resources/defaultTools/TestCodeBrowser.tool
@@ -31,7 +31,7 @@
</SPLIT_NODE>
<SPLIT_NODE WIDTH="996" HEIGHT="491" DIVIDER_LOCATION="622" ORIENTATION="HORIZONTAL">
<COMPONENT_NODE TOP_INFO="0">
- <COMPONENT_INFO NAME="CodeBrowserPlugin" OWNER="CodeBrowserPlugin" TITLE="Listing: WinHelloCPP.exe" ACTIVE="false" GROUP="Default" INSTANCE_ID="2978368332383876916" />
+ <COMPONENT_INFO NAME="Listing" OWNER="CodeBrowserPlugin" TITLE="Listing: WinHelloCPP.exe" ACTIVE="false" GROUP="Default" INSTANCE_ID="2978368332383876916" />
</COMPONENT_NODE>
<COMPONENT_NODE TOP_INFO="0">
<COMPONENT_INFO NAME="Decompiler" OWNER="DecompilePlugin" TITLE="Decompiler" ACTIVE="false" GROUP="Default" INSTANCE_ID="2999653489311119725" />
@@ -43,9 +43,6 @@
</COMPONENT_NODE>
</SPLIT_NODE>
<SPLIT_NODE WIDTH="100" HEIGHT="100" DIVIDER_LOCATION="0" ORIENTATION="VERTICAL">
- <COMPONENT_NODE TOP_INFO="0">
- <COMPONENT_INFO NAME="CodeBrowserPlugin" OWNER="CodeBrowserPlugin" TITLE="Listing: WinHelloCPP.exe" ACTIVE="true" GROUP="Core" INSTANCE_ID="2999653489311119722" />
- </COMPONENT_NODE>
<COMPONENT_NODE TOP_INFO="0">
<COMPONENT_INFO NAME="Bookmarks" OWNER="BookmarkPlugin" TITLE="Bookmarks" ACTIVE="false" GROUP="Core.Bookmarks" INSTANCE_ID="2999653489311119724" />
</COMPONENT_NODE>
diff --git a/Ghidra/Features/VersionTracking/src/main/resources/Version Tracking (DESTINATION TOOL).tool b/Ghidra/Features/VersionTracking/src/main/resources/Version Tracking (DESTINATION TOOL).tool
index 1430f66a81..127a0cfae3 100644
--- a/Ghidra/Features/VersionTracking/src/main/resources/Version Tracking (DESTINATION TOOL).tool
+++ b/Ghidra/Features/VersionTracking/src/main/resources/Version Tracking (DESTINATION TOOL).tool
@@ -34,11 +34,7 @@
<SPLIT_NODE WIDTH="1475" HEIGHT="596" DIVIDER_LOCATION="632" ORIENTATION="HORIZONTAL">
<SPLIT_NODE WIDTH="950" HEIGHT="985" DIVIDER_LOCATION="894" ORIENTATION="HORIZONTAL">
<COMPONENT_NODE TOP_INFO="0">
- <COMPONENT_INFO NAME="CodeBrowserPlugin" OWNER="CodeBrowserPlugin" TITLE="Listing: notepad.exe.2" ACTIVE="true" GROUP="" INSTANCE_ID="2777482860928188961" />
- <COMPONENT_INFO NAME="Test Listing" OWNER="Test Listing" TITLE="Test Listing" ACTIVE="false" GROUP="" INSTANCE_ID="2733632016422332683" />
- </COMPONENT_NODE>
- <COMPONENT_NODE TOP_INFO="0">
- <COMPONENT_INFO NAME="CodeBrowserPlugin" OWNER="CodeBrowserPlugin" TITLE="[Listing: notepad.exe]" ACTIVE="false" GROUP="disconnected" INSTANCE_ID="2738354194536315852" />
+ <COMPONENT_INFO NAME="Listing" OWNER="CodeBrowserPlugin" TITLE="Listing: notepad.exe.2" ACTIVE="true" GROUP="" INSTANCE_ID="2777482860928188961" />
</COMPONENT_NODE>
</SPLIT_NODE>
<SPLIT_NODE WIDTH="355" HEIGHT="1097" DIVIDER_LOCATION="542" ORIENTATION="VERTICAL">
diff --git a/Ghidra/Features/VersionTracking/src/main/resources/Version Tracking (SOURCE TOOL).tool b/Ghidra/Features/VersionTracking/src/main/resources/Version Tracking (SOURCE TOOL).tool
index 93b45c3ee0..3d7385fbdf 100644
--- a/Ghidra/Features/VersionTracking/src/main/resources/Version Tracking (SOURCE TOOL).tool
+++ b/Ghidra/Features/VersionTracking/src/main/resources/Version Tracking (SOURCE TOOL).tool
@@ -34,11 +34,7 @@
<SPLIT_NODE WIDTH="1475" HEIGHT="551" DIVIDER_LOCATION="632" ORIENTATION="HORIZONTAL">
<SPLIT_NODE WIDTH="950" HEIGHT="985" DIVIDER_LOCATION="894" ORIENTATION="HORIZONTAL">
<COMPONENT_NODE TOP_INFO="0">
- <COMPONENT_INFO NAME="CodeBrowserPlugin" OWNER="CodeBrowserPlugin" TITLE="Listing: WallaceSrc" ACTIVE="true" GROUP="" INSTANCE_ID="2769903913093334120" />
- <COMPONENT_INFO NAME="Test Listing" OWNER="Test Listing" TITLE="Test Listing" ACTIVE="false" GROUP="" INSTANCE_ID="2733632016422332683" />
- </COMPONENT_NODE>
- <COMPONENT_NODE TOP_INFO="0">
- <COMPONENT_INFO NAME="CodeBrowserPlugin" OWNER="CodeBrowserPlugin" TITLE="[Listing: notepad.exe]" ACTIVE="false" GROUP="disconnected" INSTANCE_ID="2738354194536315852" />
+ <COMPONENT_INFO NAME="Listing" OWNER="CodeBrowserPlugin" TITLE="Listing: WallaceSrc" ACTIVE="true" GROUP="" INSTANCE_ID="2769903913093334120" />
</COMPONENT_NODE>
</SPLIT_NODE>
<SPLIT_NODE WIDTH="355" HEIGHT="1097" DIVIDER_LOCATION="542" ORIENTATION="VERTICAL">
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/ComponentNode.java b/Ghidra/Framework/Docking/src/main/java/docking/ComponentNode.java
index f285aae562..b26fd303f3 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/ComponentNode.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/ComponentNode.java
@@ -35,6 +35,10 @@ import ghidra.util.SystemUtilities;
* is active, then this node will create a tabbedPane object to contain the active components.
*/
class ComponentNode extends Node {
+
+ private static final String OLD_LISTING_NAME = "CodeBrowserPlugin";
+ private static final String NEW_LISTING_NAME = "Listing";
+
private ComponentPlaceholder top;
private List<ComponentPlaceholder> windowPlaceholders;
private JComponent comp;
@@ -69,6 +73,7 @@ class ComponentNode extends Node {
* @param elem the xml element describing the configuration of this node.
* @param mgr the docking windows manager
* @param parent the parent node for this node.
+ * @param restoredPlaceholders the list into which any restored placeholders will be placed
*/
ComponentNode(Element elem, DockingWindowManager mgr, Node parent,
List<ComponentPlaceholder> restoredPlaceholders) {
@@ -90,13 +95,10 @@ class ComponentNode extends Node {
group = ComponentProvider.DEFAULT_WINDOW_GROUP;
}
- // SCR #4120 - Ignore old, buggy child nodes that had too long titles. This
- // will cleanup slow loading XML project files.
- if (name.length() > 100) {
- name = name.substring(0, 100);
- }
- if (title.length() > 100) {
- title = title.substring(0, 100);
+ // TODO remove this in a few major releases after 9.1; this prevents existing tools
+ // from losing layout positioning information due to a recent rename
+ if (OLD_LISTING_NAME.equals(name)) {
+ name = NEW_LISTING_NAME;
}
boolean isActive = Boolean.valueOf(e.getAttributeValue("ACTIVE")).booleanValue();
@@ -232,9 +234,6 @@ class ComponentNode extends Node {
}
}
- /**
- * Returns the number of ComponentWindowingPlaceholder objects being managed by this node.
- */
int getComponentCount() {
return windowPlaceholders.size();
}
diff --git a/Ghidra/Processors/JVM/src/main/java/ghidra/javaclass/format/JavaClassUtil.java b/Ghidra/Processors/JVM/src/main/java/ghidra/javaclass/format/JavaClassUtil.java
index fc7070d398..36e99207b1 100644
--- a/Ghidra/Processors/JVM/src/main/java/ghidra/javaclass/format/JavaClassUtil.java
+++ b/Ghidra/Processors/JVM/src/main/java/ghidra/javaclass/format/JavaClassUtil.java
@@ -30,14 +30,17 @@ public class JavaClassUtil {
public final static boolean isClassFile(Program program) {
+ AddressFactory factory = program.getAddressFactory();
byte[] bytes = new byte[4];
try {
- Address address = program.getAddressFactory().getAddressSpace(
- JavaLoader.CONSTANT_POOL).getMinAddress();
- program.getMemory().getBytes(address, bytes);
+ AddressSpace space = factory.getAddressSpace(JavaLoader.CONSTANT_POOL);
+ if (space != null) {
+ Address address = space.getMinAddress();
+ program.getMemory().getBytes(address, bytes);
+ }
}
catch (Exception e) {
- Msg.info(JavaClassUtil.class, e.getLocalizedMessage());
+ Msg.error(JavaClassUtil.class, "Exception reading program bytes: " + e.getMessage(), e);
return false;
}
return Arrays.equals(bytes, JavaClassConstants.MAGIC_BYTES);