Ghidra is a software reverse engineering (SRE) framework
GP-4820 Changed to allow bookmarks to be placed on interior data.
ghidragon4f25ad1cef86
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/bookmark/AddBookmarkAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/bookmark/AddBookmarkAction.javaindex fd483ffdbf..2a0e8ddb82 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/bookmark/AddBookmarkAction.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/bookmark/AddBookmarkAction.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.@@ -58,10 +58,6 @@ class AddBookmarkAction extends DockingAction {plugin.showAddBookmarkDialog(getAddress(context), getProgram(context));}- /**- *- * @see docking.DockingAction#isEnabledForContext(java.lang.Object)- */@Overridepublic boolean isEnabledForContext(ActionContext context) {if (context == null) {diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/bookmark/BookmarkPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/bookmark/BookmarkPlugin.javaindex c7f8b1f0b1..7ca56f797a 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/bookmark/BookmarkPlugin.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/bookmark/BookmarkPlugin.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.@@ -413,16 +413,27 @@ public class BookmarkPlugin extends ProgramPlugin implements PopupActionProviderif (program != currentProgram) {return;}- Listing listing = currentProgram.getListing();- CodeUnit currCU = listing.getCodeUnitContaining(address);- if (currCU == null) {+ CodeUnit cu = getLowestLevelCodeUnit(program, address);+ if (cu == null) {return;}boolean hasSelection = currentSelection != null && !currentSelection.isEmpty();- CreateBookmarkDialog createDialog = new CreateBookmarkDialog(this, currCU, hasSelection);+ CreateBookmarkDialog createDialog = new CreateBookmarkDialog(this, cu, hasSelection);tool.showDialog(createDialog);}+ CodeUnit getLowestLevelCodeUnit(Program program, Address address) {+ Listing listing = program.getListing();+ CodeUnit cu = listing.getCodeUnitContaining(address);+ if (cu instanceof Data data) {+ Data subData = data.getPrimitiveAt((int) address.subtract(cu.getMinAddress()));+ if (subData != null) {+ return subData;+ }+ }+ return cu;+ }+/*** Called when a new bookmark is to be added; called from the add bookmark dialog*@@ -433,7 +444,7 @@ public class BookmarkPlugin extends ProgramPlugin implements PopupActionProvider*/public void setNote(Address addr, String category, String comment) {- CompoundCmd cmd = new CompoundCmd("Set Note Bookmark");+ CompoundCmd<Program> cmd = new CompoundCmd<>("Set Note Bookmark");if (addr != null) {// Add address specified within bookmarkdiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/listingpanel/ProgramBigListingModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/listingpanel/ProgramBigListingModel.javaindex ca0ae5dbbe..6140eb79c2 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/listingpanel/ProgramBigListingModel.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/listingpanel/ProgramBigListingModel.java@@ -195,6 +195,7 @@ public class ProgramBigListingModel implements ListingModel, FormatModelListenerif (format != null) {format.addLayouts(list, 0, new DataProxy(this, program, d));}+ indexSize = d.getLength();}dataList = null;}