Ghidra is a software reverse engineering (SRE) framework
Updated help to show again when the user clicks in a find results table
dragonmacherfb36c9a5de3b
diff --git a/Ghidra/Features/Base/src/main/help/help/topics/AutoAnalysisPlugin/AutoAnalysis.htm b/Ghidra/Features/Base/src/main/help/help/topics/AutoAnalysisPlugin/AutoAnalysis.htmindex defc2b3767..7101d52a49 100644--- a/Ghidra/Features/Base/src/main/help/help/topics/AutoAnalysisPlugin/AutoAnalysis.htm+++ b/Ghidra/Features/Base/src/main/help/help/topics/AutoAnalysisPlugin/AutoAnalysis.htm@@ -392,6 +392,8 @@<H3><A name="Demangler_Analyzer"></A>Demangler Analyzer</H3>+ <H3>Demangler GNU or Demangeler Microsoft</H3>+<BLOCKQUOTE><P>This analyzer examines the name of the newly created function. If the name appears to bea <I>GCC v3</I> or <I>Microsoft Visual Studio</I> mangled symbol, then it will demangle the@@ -577,25 +579,14 @@<P><U>Started By:</U> Importing or adding to a program, Auto Analyze command</P></BLOCKQUOTE>- <H3><A name="Format_String_Analyzer"></A>Format String Analyzer</H3>- <BLOCKQUOTE>- <P>This analyzer detects variadic function calls in the bodies of each function that intersect- the current selection. It then parses their format string arguments to infer the correct function- call signatures. Currently, this analyzer only supports printf, scanf, and their variants (e.g., snprintf, fscanf).- If the current selection is empty, it searches through every function within the binary. Once- the signatures are inferred, they are overridden.</P>-- <P><U>Started By:</U> Importing or adding to a program, Auto Analyze command</P>-- </BLOCKQUOTE>- <H3><A name="Image"></A>Image Analyzer</H3>+ <H3><A name="Image"></A>Embedded Media Analyzer</H3><BLOCKQUOTE>- <P>This analyzer searches the program for images. If a valid image is found an appropriate- image data type is applied at that location with the corresponding visual representation of- the image. Also, a bookmark is added to indicate an image.</P>+ <P>Finds embedded media data types (e.g., png, gif, jpeg, wav). If a valid image is found an+ appropriate image data type is applied at that location with the corresponding visual+ representation of image. Also, a bookmark is added to indicate an image.</P><P><U>Started By</U>: Importing or adding to a program, Auto Analyze command</P></BLOCKQUOTE>@@ -727,6 +718,22 @@<P><U>Started By</U>: Auto Analyze command</P></BLOCKQUOTE>++ <H3><A name="Format_String_Analyzer"></A>Format String Analyzer</H3>+ <H3>(Variadic Function Signature Override)</H3>++ <BLOCKQUOTE>+ <P>This analyzer detects variadic function calls in the bodies of each function that intersect+ the current selection. It then parses their format string arguments to infer the correct function+ call signatures. Currently, this analyzer only supports printf, scanf, and their variants (e.g., snprintf, fscanf).+ If the current selection is empty, it searches through every function within the binary. Once+ the signatures are inferred, they are overridden.</P>++ <P><U>Started By:</U> Importing or adding to a program, Auto Analyze command</P>++ </BLOCKQUOTE>++</BLOCKQUOTE><P class="providedbyplugin">Provided by: <I>AutoAnalysisPlugin</I><BR>diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/EmbeddedMediaAnalyzer.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/EmbeddedMediaAnalyzer.javaindex 334acc3a1f..8ae2a5233a 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/EmbeddedMediaAnalyzer.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/EmbeddedMediaAnalyzer.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.@@ -35,11 +35,12 @@ import ghidra.util.task.TaskMonitor;public class EmbeddedMediaAnalyzer extends AbstractAnalyzer {private static final String NAME = "Embedded Media";private static final String DESCRIPTION =- "Finds embedded media data types (ie png, gif, jpeg, wav)";+ "Finds embedded media data types (e.g., png, gif, jpeg, wav)";private static final String OPTION_NAME_CREATE_BOOKMARKS = "Create Analysis Bookmarks";private static final String OPTION_DESCRIPTION_CREATE_BOOKMARKS =- "If checked, an analysis bookmark will be created at each location where embedded media data is identified.";+ "If checked, an analysis bookmark will be created at each location where embedded media " ++ "data is identified.";private static final boolean OPTION_DEFAULT_CREATE_BOOKMARKS_ENABLED = true;private boolean createBookmarksEnabled = OPTION_DEFAULT_CREATE_BOOKMARKS_ENABLED;@@ -101,14 +102,16 @@ public class EmbeddedMediaAnalyzer extends AbstractAnalyzer {private void addByteSearchPattern(MemoryBytePatternSearcher searcher, Program program,List<Address> foundMedia, DataType mediaDT, String mediaName, byte[] bytes,byte[] mask) {+if (bytes == null) {return;}GenericMatchAction<DataType> action = new GenericMatchAction<DataType>(mediaDT) {+@Override- public void apply(Program prog, Address addr, Match match) {- //See if it is already an applied media data type+ public void apply(Program prog, Address addr, Match<Pattern> match) {+ // See if it is already an applied media data typeif (!program.getListing().isUndefined(addr, addr)) {return;}@@ -117,23 +120,26 @@ public class EmbeddedMediaAnalyzer extends AbstractAnalyzer {CreateDataCmd cmd = new CreateDataCmd(addr, mediaDT);if (cmd.applyTo(program)) {if (createBookmarksEnabled) {- program.getBookmarkManager().setBookmark(addr, BookmarkType.ANALYSIS,- "Embedded Media", "Found " + mediaName + " Embedded Media");+ program.getBookmarkManager()+ .setBookmark(addr, BookmarkType.ANALYSIS,+ "Embedded Media", "Found " + mediaName + " Embedded Media");}foundMedia.add(addr);}++ // If media does not apply correctly then it is not really that media data type+ // or there is other data in the way.}- //If media does not apply correctly then it is not really a that media data type or there is other data in the waycatch (Exception e) {- // Not a valid embedded media or no room to apply it so just ignore it and skip it+ // Not a valid embedded media or no room to apply it so just ignore it and skip+}}};- GenericByteSequencePattern<DataType> genericByteMatchPattern =- new GenericByteSequencePattern<DataType>(bytes, mask, action);-- searcher.addPattern(genericByteMatchPattern);+ GenericByteSequencePattern<DataType> pattern =+ new GenericByteSequencePattern<>(bytes, mask, action);+ searcher.addPattern(pattern);}@Overridediff --git a/Ghidra/Features/Base/src/main/java/ghidra/util/bytesearch/DummyMatchAction.java b/Ghidra/Features/Base/src/main/java/ghidra/util/bytesearch/DummyMatchAction.javaindex e8e58e4c37..f49b5ce1ac 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/util/bytesearch/DummyMatchAction.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/util/bytesearch/DummyMatchAction.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.@@ -25,7 +25,8 @@ import ghidra.xml.XmlPullParser;public class DummyMatchAction implements MatchAction {@Override- public void apply(Program program, Address addr, Match match) {+ public void apply(Program program, Address addr, Match<Pattern> match) {+ // stub}@Overridediff --git a/Ghidra/Features/Base/src/main/java/ghidra/util/bytesearch/GenericMatchAction.java b/Ghidra/Features/Base/src/main/java/ghidra/util/bytesearch/GenericMatchAction.javaindex 3b337c6fed..6ab762067a 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/util/bytesearch/GenericMatchAction.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/util/bytesearch/GenericMatchAction.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.@@ -21,7 +21,7 @@ package ghidra.util.bytesearch;* The associated value can be retrieved when the sequence is matched.** @param <T> - object to attach to match sequence, generally used to specify- * a specialized momento to be used by the action when it is "applied".+ * a specialized memento to be used by the action when it is "applied".*/public class GenericMatchAction<T> extends DummyMatchAction {T matchValue;diff --git a/Ghidra/Features/Base/src/main/java/ghidra/util/bytesearch/MatchAction.java b/Ghidra/Features/Base/src/main/java/ghidra/util/bytesearch/MatchAction.javaindex 94d43bcec5..e69d724d61 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/util/bytesearch/MatchAction.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/util/bytesearch/MatchAction.java@@ -20,14 +20,14 @@ import ghidra.program.model.listing.Program;import ghidra.xml.XmlPullParser;/**- * Interface for a match action to be taken for the Program@Address for a ditted bit seqence pattern+ * Interface for a match action to be taken for the Program@Address for a ditted bit sequence pattern*/public interface MatchAction {/*** Apply the match action to the program at the address.** @param program program in which the match occurred- * @param addr where the match occured+ * @param addr where the match occurred* @param match information about the match that occurred*/public void apply(Program program, Address addr, Match<Pattern> match);diff --git a/Ghidra/Framework/Docking/src/main/java/docking/help/HelpManager.java b/Ghidra/Framework/Docking/src/main/java/docking/help/HelpManager.javaindex d4ffc93dc3..a3c87507f8 100644--- a/Ghidra/Framework/Docking/src/main/java/docking/help/HelpManager.java+++ b/Ghidra/Framework/Docking/src/main/java/docking/help/HelpManager.java@@ -102,6 +102,11 @@ public class HelpManager implements HelpService {Help.installHelpService(this);}+ @Override+ public boolean isShowing() {+ return mainHB.isDisplayed();+ }+@Overridepublic boolean helpExists() {return isValidHelp && hasMergedHelpSets;diff --git a/Ghidra/Framework/Docking/src/main/java/docking/help/HelpViewSearcher.java b/Ghidra/Framework/Docking/src/main/java/docking/help/HelpViewSearcher.javaindex 77196d8968..09e2962dd0 100644--- a/Ghidra/Framework/Docking/src/main/java/docking/help/HelpViewSearcher.java+++ b/Ghidra/Framework/Docking/src/main/java/docking/help/HelpViewSearcher.java@@ -39,6 +39,8 @@ import generic.util.WindowUtilities;import ghidra.util.exception.AssertException;import ghidra.util.task.TaskMonitor;import ghidra.util.worker.Worker;+import help.Help;+import help.HelpService;/*** Enables the Find Dialog for searching through the current page of a help document.@@ -273,6 +275,12 @@ class HelpViewSearcher {@Overridepublic void activate() {++ HelpService help = Help.getHelpService();+ if (!help.isShowing()) {+ help.showHelp(searchUrl);+ }+//// When we activate, a new page load may get triggered. When that happens the caret// position will get moved by the help viewer. We will put back the last active searchdiff --git a/Ghidra/Framework/Help/src/main/java/docking/DefaultHelpService.java b/Ghidra/Framework/Help/src/main/java/docking/DefaultHelpService.javaindex 993d23009d..846301e6e0 100644--- a/Ghidra/Framework/Help/src/main/java/docking/DefaultHelpService.java+++ b/Ghidra/Framework/Help/src/main/java/docking/DefaultHelpService.java@@ -33,6 +33,11 @@ public class DefaultHelpService implements HelpService {}}+ @Override+ public boolean isShowing() {+ return false;+ }+@Overridepublic void showHelp(java.net.URL url) {// no-opdiff --git a/Ghidra/Framework/Help/src/main/java/help/HelpService.java b/Ghidra/Framework/Help/src/main/java/help/HelpService.javaindex d6aff75c31..64af48df5e 100644--- a/Ghidra/Framework/Help/src/main/java/help/HelpService.java+++ b/Ghidra/Framework/Help/src/main/java/help/HelpService.java@@ -28,6 +28,11 @@ public interface HelpService {public static final String DUMMY_HELP_SET_NAME = "Dummy_HelpSet.hs";+ /**+ * {@return true if the main help window is showing}+ */+ public boolean isShowing();+/*** Display the Help content identified by the help object.*