diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 385782a424..2882356cb6 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -29,7 +29,8 @@ If applicable, please attach any files that caused problems or log files generat **Environment (please complete the following information):** - OS: [e.g. macOS 10.14.2] - Java Version: [e.g. 11.0] - - Ghidra Version: [e.g. 9.0] + - Ghidra Version: [e.g. 9.1.2] + - Ghidra Origin: [e.g. official ghidra-sre.org distro, third party distro, locally built] **Additional context** Add any other context about the problem here. diff --git a/Ghidra/Configurations/Public_Release/src/global/docs/ChangeHistory.html b/Ghidra/Configurations/Public_Release/src/global/docs/ChangeHistory.html index aabe465742..dc38d983fe 100644 --- a/Ghidra/Configurations/Public_Release/src/global/docs/ChangeHistory.html +++ b/Ghidra/Configurations/Public_Release/src/global/docs/ChangeHistory.html @@ -6,14 +6,61 @@
++Improvements
++
+- Analysis. Added check for vftable entries in
+.NEPsection and relaxed the requirement that the code must have a return. (GP-649)- Analysis. Corrected flaw in RTTI analyzer determination of size of vftables. (GP-688)
+- Basic Infrastructure. Updated TLS protocol preference to use the most preferred/recent version available to both sides of an SSL connection (e.g., TLSv1.3) instead of forcing use of TLSv1.2. (GP-622)
+- Build. Corrected build issues which had prevented users from building Ghidra on an Apple M1 (OS X, AARCH64 architecture). (GP-600, Issue #2653)
+- Demangler. Increased Gnu Demangler parsing performance by changing some regular expressions. (GP-705)
+- Eclipse Integration. Updated SleighEditor to support new endian tag on define token definitions. (GP-721)
+- GUI. Updated the Choose Data Type dialog to apply data types in the same manner as dragging types from the Data Types window. This provides users more control when choosing how to overwrite existing types. (GP-521)
+- Importer:ELF. Added support for ELF relocation
+R_X86_64_IRELATIVE. (GP-651, Issue #1189)- Importer:ELF. Sped up loading of ELF files with large symbol tables. (GP-697)
+
+Bugs
++
+- Analysis. The RTTI analyzer now runs prior to Reference analysis so that references into vftables are not turned into code or data before the vftables are created. (GP-517)
+- API.
+Funtion.getCalledFunctions(TaskMonitor)andFunction.getCallingFunctions(TaskMonitor)now support passingnullfor the task monitor parameter, which previously would have thrown an exception. (GP-589, Issue #2643)- Data Types. Corrected segmented 32-bit pointer datatype address generation for 16:16 x86 far pointers. (GP-534, Issue #2548)
+- Decompiler. Fixed Decompiler issue where, when a function name extends beyond the line limit, an end-of-line comment could wrap around to additional lines without including additional
+//comment indicators. (GP-473)- Decompiler. Corrected an exception that could occur when attempting to edit function signature from the Decompiler. (GP-597, Issue #2601)
+- Eclipse Integration. When installing the SleighEditor into Eclipse, the plugin will now show up under the Ghidra category. Previously the Group Items by Category option had to be turned off before the SleighEditor would appear as a visible entry. (GP-564)
+- Eclipse Integration. Fixed an issue with Eclipse PyDev breakpoints not catching. (GP-668, Issue #2713)
+- Eclipse Integration. Fixed an Eclipse GhidraDev exception that occurred when creating a new Ghidra scripting project if a ~/ghidra_scripts directory did not exist. (GP-669)
+- Emulator. Replaced Java floating point emulation to fix multiple rounding issues. (GP-357, Issue #2414)
+- Graphing. Fixed issue with graph filters not updating satellite view when changing edge filters. (GP-557)
+- Graphing. Fixed Function Graph keybindings that did not work when docked in the main Code Browser window. (GP-586, Issue #2641)
+- GUI. Fixed NPE due to using Go To action when there was no open program in the Listing. (GP-66)
+- GUI. Fixed bug in Reference Code Viewer options that caused an exception. (GP-620, Issue #2672)
+- Importer. Fixed exception caused when importing previously exported XML data where the bookmark override option was turned off. (GP-667)
+- Importer:ELF. Fixed a NullPointerException caused by importing an ELF with an uninitialized
+.gotsection. (GP-360, Issue #2416)- Importer:ELF. Added Support for ELF
+R_ARM_MOVW_ABS_NCandR_ARM_MOVT_ABS ELFRelocations for ARM. (GP-555, Issue #2510)- Importer:ELF. Corrected ELF processing of
+.init_arrayand.fini_arraywhich was incorrectly overadjusting entries for an image base change. (GP-699)- Importer:Mach-O. Corrected Mach-O fat-binary library import issue and resolved error related to unnamed Mach-O segment. (GP-652, Issue #2702)
+- Importer:Mach-O. Fixed an issue with DYLD Load Command data structures being created in the wrong locations. (GP-689, Issue #2624)
+- Importer:Mach-O. Fixed an exception that occurred when importing Mach-O files that define zero
+LC_BUILD_VERSIONtool entries. (GP-702, Issue #2192)- PDB. Fixed createPdbXmlFiles.bat to permit spaces in the path name of Ghidra installation folder and the batch argument name. (GP-575, Issue #2167)
+- PDB. Fix PDB Universal analyzer to set the run-once flag when finished. (GP-724)
+- Processors. Added missing
+RFEinstruction in MIPS up to version R3000. (GP-33, Issue #1766)- Processors. ARM instruction
+VMULnow decodes correctly. (GP-627, Issue #2677)- Processors. Added missing
+CFINVinstruction to AARCH64 processor specification and added definitions for locals in neon instructions. (GP-655, Issue #2710)- Scripting. Fixed analyzeHeadless
+-scriptPathoption that didn't work for Python and other non-Java scripts located in non-default directories. (GP-528, Issue #2561)- Scripting. Fixed concurrency issue with management of scripting bundle paths. (GP-576)
+- Scripting. Corrected handling for Ghidra Script files which are symlinks that were broken in Ghidra 9.2. (GP-650, Issue #2698)
+
@@ -24,6 +71,7 @@Bugs
- Graphing. Fixed issue with Graph filters not working and satellite view sometimes not matching graph. (GP-526)
-- Importer:MachO. MachO DYLD cache incorrect offset use has been fixed. (GP-550, Issue ##2560)
-- Listing. Fixed issue where Edit Label action (L key) did not work on primary function symbols. (GP-537)
+- Importer:Mach-O. Mach-O DYLD cache incorrect offset use has been fixed. (GP-550, Issue #2560)
+- Listing. Fixed issue where Edit Label action (L key) did not work on primary function symbols. (GP-537)
- Multi-User. Corrected Ghidra Server build issue for version 9.2.1 which had an improperly generated classpath.frag file. Issue caused server to fail startup with a ClassNotFoundException. (GP-542)
-- Processors. The V850 JMP instruction has been corrected not to use the PC in the address calculation (GP-548, Issue #2570)
+- Processors. The V850
JMPinstruction has been corrected not to use the PC in the address calculation. (GP-548, Issue #2570)- Processors. Removed erroneous VST4 variant, most likely from a copy/paste error. This fixes the ARM Thumb BL instruction disassembly with a negative offset. (GP-549, Issue #2559)
type_info vftable when it cannot be found with its mangled name. This will enable many more Windows programs to have their RTTI structures created that were unable to be parsed in previous Ghidra versions. (GP-141)gradle Decompiler:generateParsers task, which still requires bison and flex, must be used, explicitly, when changes are made to lex/yacc source files. (GP-467)0x1608 and 0x1609 with presumed class and struct types and follow-on application of these types. Also fixed up some fall-back data type logic and improved some warning messages to reflect the cause of the conditions. (GP-474, Issue #2523)longlong and double return values. Endianess ordering of r0/r1 was incorrect. (GP-512, Issue #2547)DUMPBIN /EXPORTS (see Ghidra/Features/Base/data/symbols/README.txt). (GT-3235)unique space are now always shown with the size of the access. Fixed bug which would cause the PCode emulator to reject valid pcode in rare instances. (GP-196)"Method is not Remote" errors. (GT-3521, Issue #1440)Method is not Remote errors. (GT-3521, Issue #1440)RSB.w instruction. (GT-3420, Issue #1365)@@ -331,7 +379,7 @@Improvements
-
- Importer:MachO. Improved import/load time of DYLD shared cache files. (GT-3261)
+- Importer:Mach-O. Improved import/load time of DYLD shared cache files. (GT-3261)
- Program API. Cached the addresses that correspond to executable memory to improve analysis performance. (GT-3260)
-i option. Corrected -ip option to strictly convey remote access hostname to clients. The updated server will only accept connections from Ghidra 9.1 and later clients due to the registry port now employing TLS. (GT-2685, Issue #101, #645)GhidraScript.askDomainFile() now correctly throws a CancelledException when the cancel button is clicked. (GT-2841)Bugs
-
- Multi-User:Ghidra Server. Corrected severe script error in svrAdmin.bat introduced with 9.0.3 build.
-- GUI. Restored the default 'p' key binding for creating pointers within the listing display.
+- Multi-User:Ghidra Server. Corrected severe script error in svrAdmin.bat introduced with 9.0.3 build. (GT-2874)
+- GUI. Restored the default 'p' key binding for creating pointers within the listing display. (GT-2854)
New Features
-
- GUI. Function tags are now viewable from Functions Window table using new column.
+- GUI. Function tags are now viewable from Functions Window table using new column. (GT-2114)
Improvements
-
- Decompiler. Improved modeling of CFG on Windows 10. (Issue #340)
-- Patcher. Renamed patch directory to /Ghidra/patch and added README.txt that explains how the patch directory is used.
-- Search. Updated the Decompiler Data Type Finder to find references to inside of nested array access in a line of Decompiler C output. (Issue #416)
-- Sleigh. Improved error reporting for SLEIGH compiler. (Issue #364)
+- Decompiler. Improved modeling of CFG on Windows 10. (GT-2755, Issue #340)
+- Patcher. Renamed patch directory to
+/Ghidra/patch and added README.txt that explains how the patch directory is used. (GT-2734) - Search. Updated the Decompiler Data Type Finder to find references inside of nested array access in a line of Decompiler C output. (GT-2756, Issue #416)
+- Sleigh. Improved error reporting for SLEIGH compiler. (GT-2820, Issue #364)
Bugs
-
- Analysis. Code that checks for thunks no longer throws an exception if the PC is not set for the processor.
-- Analysis. Made a fix to enable Apply button when changing tool options. (Issue #40)
-- Data Types. Fixed concurrent modification exception when replacing one datatype for another that results in some other datatype being renamed.
-- Decompiler. Fixed dynamic variables and equates in 16-bit x86 programs. (Issue #336)
-- Decompiler:Java. Fixed DEX decompilation regression issue. (Issue #350)
-- Eclipse Integration. Fixed exception in Eclipse GhidraDev plugin that occurred when performing certain actions on a Ghidra project that was imported from a previously exported Archive File. (Issues #283, #383)
+- Analysis. Code that checks for thunks no longer throws an exception if the PC is not set for the processor. (GT-2730)
+- Analysis. Made a fix to enable Apply button when changing tool options. (GT-2801, Issue #40)
+- Data Types. Fixed concurrent modification exception when replacing one datatype for another that results in some other datatype being renamed. (GT-2736)
+- Decompiler. Fixed dynamic variables and equates in 16-bit x86 programs. (GT-2745, Issue #336)
+- Decompiler:Java. Fixed DEX decompilation regression issue. (Issue #350, GT-2743)
+- Eclipse Integration. Fixed exception in Eclipse GhidraDev plugin that occurred when performing certain actions on a Ghidra project that was imported from a previously exported Archive File. (GT-2721, Issues #283, #383)
- GUI. Improved documentation on how to deal with HiDPI monitor issues in Linux. In the <ghidra_installation>/support/launch.properties file, change VMARGS=-Dsun.java2d.xrender from false to true.
-- Importer. Fixed an exception that occurred when batch importing APK files. (Issue #426)
-- Multi-User:Ghidra Server. Restored ability to execute svrAdmin script in development mode.
-- Processors. The 6502 Zero page indexed addressing has been corrected to only access the Zero page. (Issue #201)
-- Processors. The 68000 BCD arithmetic instructions now have pcode semantics that allow disassembly to continue. (Issue #227)
-- Search. Fixed NullPointerException in Decompiler Data Type Reference Finder. (Issue #407)
+- Importer. Fixed an exception that occurred when batch importing APK files. (GT-2767, Issue #426)
+- Multi-User:Ghidra Server. Restored ability to execute svrAdmin script in development mode. (GT-2740)
+- Processors. The 6502 Zero page indexed addressing has been corrected to only access the Zero page. (GT-2759, Issue #201)
+- Processors. The M68000 BCD arithmetic instructions now have pcode semantics that allow disassembly to continue. (GT-2807, Issue #227)
+- Search. Fixed NullPointerException in Decompiler Data Type Reference Finder. (GT-2754. Issue #407)
Bugs
-
- Analysis. Constant reference analysis boundary controls for speculative references has been fixed. Speculative references are references created from computed constants passed as parameters, stored to a location, or from indexed offsets from a register. (Issue #228)
-- Decompiler. Fixed rendering bug in the Decompiler when the "Find" dialog is closed. (Issue #282)
-- Decompiler. Fixed decompiler handling of Function Definition data types. (Issue #247)
-- Decompiler. Fixed "Free Varnode" exception in RuleConditionalMove. (Issue #294)
-- Diff. Fixed exceptions that can occur in the Diff View for programs with overlays.
-- Documentation. Corrected the spelling of "listener" throughout the source code. (Issue #235)
-- Exporter. Exporting a selection as Intel Hex will now allow a selection of any length. Previously this was restricted to multiples of 16 bytes. (Issue #260)
-- GUI. Fixed exception that occurs after disabling MyProgramChangesDisplayPlugin.
-- GUI. Updated the "Open Program" dialog to disallow file drop operations. (Issue #252) -
- Multi-User:Ghidra Server. Corrected bug introduced into ghidraSvr.bat which could prevent Ghidra Server startup (Issue #279)
-- Processors. The ARM Thumb CMP.W and LSL instructions have been changed to correctly decode. There are still issues to work out with Unpredictable execution when Rd is the PC. (Issue #280)
-- Scripting. MultiInstructionMemReference script has been corrected to consider input and output registers when placing a reference on an instruction.
+- Analysis. Constant reference analysis boundary controls for speculative references has been fixed. Speculative references are references created from computed constants passed as parameters, stored to a location, or from indexed offsets from a register. (GT-2723, Issue #228)
+- Decompiler. Fixed Decompiler handling of Function Definition data types. (GT-2704, Issue #247)
+- Decompiler. Fixed rendering bug in the Decompiler when the "Find" dialog is closed. (GT-2716, Issue #282)
+- Decompiler. Fixed "Free Varnode" exception in RuleConditionalMove. (GT-2726, Issue #294)
+- Diff. Fixed exceptions that can occur in the Diff View for programs with overlays. (GT-2706)
+- Documentation. Corrected the spelling of "listener" throughout the source code. (GT-2702, Issue #235)
+- Exporter. Exporting a selection as Intel Hex will now allow a selection of any length. Previously this was restricted to multiples of 16 bytes. (GT-2703, Issue #260)
+- GUI. Fixed exception that occurs after disabling MyProgramChangesDisplayPlugin. (GT-2712)
+- GUI. Updated the "Open Program" dialog to disallow file drop operations. (GT-2705, Issue #252)
+- Multi-User:Ghidra Server. Corrected bug introduced into ghidraSvr.bat which could prevent Ghidra Server startup. (GT-2717, Issue #279)
+- Processors. The ARM Thumb CMP.W and LSL instructions have been changed to correctly decode. There are still issues to work out with Unpredictable execution when Rd is the PC. (GT-2722, Issue #280)
+- Scripting. MultiInstructionMemReference script has been corrected to consider input and output registers when placing a reference on an instruction. (GT-2723)
Security
-
- Basic Infrastructure. Added a property to support/launch.properties to prevent log4j from using jansi.dll on Windows. (Issue #286)
+- Basic Infrastructure. Added a property to support/launch.properties to prevent log4j from using jansi.dll on Windows. (GT-2725, Issue #286)
New Features
-
- Scripting. Created a script to show all equates within the current selection. (Issue #111)
+- Scripting. Created ShowEquatesInSelectionScript to show all equates within the current selection. (GT-2651, Issue #111)
Improvements
-
- Basic Infrastructure. Updated commons-compress library to version 1.18. (Issue #171)
-- Eclipse Integration. Ghidra now connects to the Eclipse GhidraDev plugin on 127.0.0.1 rather than localhost.
-- GUI. Turned on font anti-aliasing by default for Linux. (Issue #212)
-- GUI. Fixed Options Dialog slow scrolling speed. (Issue #27)
-- Importer:ELF. Corrected bug in ELF loader which can improperly process the GOT, PLT and relocations - when multiple symbol tables exist within the ELF binary. (Issue #52)
-- Multi-User:Ghidra Server. Corrected the Ghidra Server service wrapper (YAJSW) configuration for - Mac OS X to prevent a startup timeout condition which could occur.
-- Processors. Added ARM/Thumb SRS instruction decodes for undefined modes. (Issue #216)
+- Basic Infrastructure. Updated commons-compress library to version 1.18. (GT-2657, Issue #171)
+- Eclipse Integration. Ghidra now connects to the Eclipse GhidraDev plugin on 127.0.0.1 rather than localhost. (GT-2691)
+- GUI. Turned on font anti-aliasing by default for Linux. (GT-2674, Issue #212)
+- GUI. Fixed Options Dialog slow scrolling speed. (GT-2679, Issue #27)
+- Importer:ELF. Corrected bug in ELF loader which can improperly process the GOT, PLT and relocations when multiple symbol tables exist within the ELF binary. (GT-2646, Issue #52)
+- Multi-User:Ghidra Server. Corrected the Ghidra Server service wrapper (YAJSW) configuration for Mac OS X to prevent a startup timeout condition which could occur. (GT-2637)
+- Processors. Added ARM/Thumb SRS instruction decodes for undefined modes. (GT-2676, Issue #216)
Bugs
-
- API. Fixed equals method on Varnode class. (Issue #97)
-- API. Fixed a bug in MaskImpl.comlementMask(). (Issue #187)
-- Basic Infrastructure. Fixed special character handling in idaxml.py. (Issue #75)
-- Basic Infrastructure. Ghidra now forces the locale to en_US by default. Only the en_US is currently supported. - This fixes certain unexpected exceptions. (Issue #209)
-- Diff. Fixed exceptions occasionally encountered when starting a Diff session. (Issue #211)
-- Documentation. Fixed javadoc search box redirecting to broken links. (Issue #129)
-- Function Graph. Fixed Function Graph exception when generating tooltip. (Issue #65)
-- GUI. Updated window placement to keep windows on screen. (Issue #41)
-- GUI. Add/Edit References dialog now restricts users to creating refs in valid memory address spaces.
-- GUI. Fixed exception when exiting Ghidra while a table is being edited. (Issue #51)
-- GUI. Fixed some touchpad scrolling issues. (Issue #2)
-- GUI. Fixed stack trace in the Data Type Manager's tooltip generation. (Issue #133)
-- GUI. User key binding settings for the Recently Used and Define Pointer actions no longer lost after re-launching tool. (Issue #152)
-- GUI. Toolbar buttons now respond to fast clicking.
-- Importer:MachO. The MachoLoader can now find import libraries found in Universal Binary files. (Issue #136)
-- Importer:PE. The PeLoader now correctly parses the GuardCFFunctionTable when entries are more than 4 bytes each. (Issue #220)
-- Multi-User:Ghidra Server. Removed support for native OS authentication from Ghidra Server (removed modes -a2 and -a3) - due to incompatibility with newer OS releases including Windows 10 and Windows Server 2016. Re-introduction of this will be - considered for a future release.
-- PDB. Corrected NPE error when processing PDB files. (Issues #138, #188)
-- Processors. Added missing PowerPC VLE conditional branch instructions: e_bdnz and e_bdz. (Issue #103)
-- Processors. Fixed instruction semantics for several instructions and added Control Flow Enforcement, NOP variants, CMP variants, UD1, and - prefixed call instructions to X86 processor specification. (Issues #22, #53, #158, #157)
-- Processors. The 68000 MOVE instruction now correctly sets the CF and VF flags. (Issue #163)
-- Processors. Added four missing MOVEM instruction variants to the 68000 processor. (Issue #219)
-- Processors. An incorrect usage of X instead of Y in indexed mode for the 6502 has been corrected.(Issue #201)
-- Processors. Added support for ARM Thumb half BL instruction on processor variants prior to v6. (Issue #39)
-- Scripting. Fixed a bug in ImportSymbolsScript.py that prevented it from running. (Issue #170)
+- API. Fixed equals method on Varnode class. (GT-2648, Issue #97)
+- API. Fixed a bug in MaskImpl.complementMask(). (GT-2694, Issue #187)
+- Basic Infrastructure. Fixed special character handling in idaxml.py. (GT-2669, Issue #75)
+- Basic Infrastructure. Ghidra now forces the locale to en_US by default. Only the en_US is currently supported. This fixes certain unexpected exceptions. (GT-2680, Issue #209)
+- Diff. Fixed exception occasionally encountered when starting a Diff session. (GT-2672, Issue #211)
+- Documentation. Fixed javadoc search box redirecting to broken links. (GT-2655, Issue #129)
+- Function Graph. Fixed Function Graph exception when generating tooltip. (GT-2650, Issue #65)
+- GUI. Updated window placement to keep windows on screen. (GT-1516, Issue #41)
+- GUI. Add/Edit References dialog now restricts users to creating refs in valid memory address spaces. (GT-2638)
+- GUI. Fixed exception when exiting Ghidra while a table is being edited. (GT-2642, Issue #51)
+- GUI. Fixed some touchpad scrolling issues. (GT-2647, Issue #2)
+- GUI. Fixed stack trace in the Data Type Manager's tooltip generation. (GT-2656, Issue #133)
+- GUI. User key binding settings for the Recently Used and Define Pointer actions no longer lost after re-launching tool. (GT-2659, Issue #152)
+- GUI. Toolbar buttons now respond to fast clicking. (GT-2689)
+- Importer:Mach-O. The Mach-O loader can now find import libraries found in Universal Binary files. (GT-2663, Issue #136)
+- Importer:PE. The PeLoader now correctly parses the GuardCFFunctionTable when table entries are more than 4 bytes each. (GT-2671, Issue #220)
+- Multi-User:Ghidra Server. Removed support for native OS authentication from Ghidra Server (removed modes -a2 and -a3) due to incompatibility with newer OS releases including Windows 10 and Windows Server 2016. Re-introduction of this will be considered for a future release. (GT-2653)
+- PDB. Corrected NPE error when processing PDB files. (GT-2673, Issues #138, #188)
+- Processors. Added missing PowerPC VLE conditional branch instructions: e_bdnz and e_bdz. (GT-2652, Issue #103)
+- Processors. Fixed instruction semantics for several instructions and added Control Flow Enforcement, NOP variants, CMP variants, UD1, and prefixed call instructions to X86 processor specification. (GT-2660, Issues #22, #53, #158, #157)
+- Processors. The M68000 MOVE instruction now correctly sets the CF and VF flags. (GT-2661, Issue #163)
+- Processors. Added four missing MOVEM instruction variants to the M68000 processor. (GT-2675, Issue #219)
+- Processors. An incorrect usage of X instead of Y in indexed mode for the 6502 has been corrected. (GT-2677, Issue #201)
+- Processors. PPC VLE now disassembles base PPC instructions that are valid in VLE mode. (GT-2681, Issue #127)
+- Processors. Added support for ARM Thumb half BL instruction on processor variants prior to v6. (GT-2684, Issue #39)
+- Scripting. Fixed a bug in ImportSymbolsScript.py that prevented it from running. (GT-2668, Issue #170)
diff --git a/Ghidra/Features/Base/data/PEFunctionsThatDoNotReturn b/Ghidra/Features/Base/data/PEFunctionsThatDoNotReturn index e8ed7404f4..51c5089410 100644 --- a/Ghidra/Features/Base/data/PEFunctionsThatDoNotReturn +++ b/Ghidra/Features/Base/data/PEFunctionsThatDoNotReturn @@ -1,7 +1,15 @@ +abort CxxThrowException CxxThrowException@8 CxxFrameHandler3 crtExitProcess ExitProcess +ExitThread exit +FreeLibraryAndExitThread +invalid_parameter_noinfo_noreturn +invoke_watson longjmp +quick_exit +RpcRaiseException +terminate diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/GoToAddressLabelPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/GoToAddressLabelPlugin.java index eef0b65f3c..b77dafd9f5 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/GoToAddressLabelPlugin.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/GoToAddressLabelPlugin.java @@ -17,6 +17,7 @@ package ghidra.app.plugin.core.navigation; import java.awt.event.KeyEvent; +import docking.ActionContext; import docking.action.*; import docking.tool.ToolConstants; import ghidra.GhidraOptions; @@ -29,7 +30,7 @@ import ghidra.app.util.HelpTopics; import ghidra.app.util.navigation.GoToAddressLabelDialog; import ghidra.framework.options.*; import ghidra.framework.plugintool.*; -import ghidra.framework.plugintool.util.*; +import ghidra.framework.plugintool.util.PluginStatus; import ghidra.util.HelpLocation; import ghidra.util.bean.opteditor.OptionsVetoException; @@ -91,11 +92,21 @@ public class GoToAddressLabelPlugin extends Plugin implements OptionsChangeListe public void actionPerformed(NavigatableActionContext context) { goToDialog.show(context.getNavigatable(), context.getAddress(), tool); } + + @Override + protected boolean isEnabledForContext(NavigatableActionContext context) { + return context.getProgram() != null; + } + + @Override + public boolean isAddToPopup(ActionContext context) { + return true; + } }; action.setHelpLocation(new HelpLocation(HelpTopics.NAVIGATION, action.getName())); - action.setMenuBarData(new MenuData( - new String[] { ToolConstants.MENU_NAVIGATION, "Go To..." }, null, "GoTo", - MenuData.NO_MNEMONIC, "2")); // second item in the menu + action.setMenuBarData( + new MenuData(new String[] { ToolConstants.MENU_NAVIGATION, "Go To..." }, null, "GoTo", + MenuData.NO_MNEMONIC, "2")); // second item in the menu action.setKeyBindingData(new KeyBindingData(KeyEvent.VK_G, 0)); @@ -144,10 +155,11 @@ public class GoToAddressLabelPlugin extends Plugin implements OptionsChangeListe * @param newValue new value of the option */ @Override - public void optionsChanged(ToolOptions options, String opName, Object oldValue, Object newValue) { + public void optionsChanged(ToolOptions options, String opName, Object oldValue, + Object newValue) { if (opName.equals(GhidraOptions.OPTION_MAX_GO_TO_ENTRIES)) { maximumGotoEntries = - options.getInt(GhidraOptions.OPTION_MAX_GO_TO_ENTRIES, DEFAULT_MAX_GOTO_ENTRIES); + options.getInt(GhidraOptions.OPTION_MAX_GO_TO_ENTRIES, DEFAULT_MAX_GOTO_ENTRIES); if (maximumGotoEntries <= 0) { throw new OptionsVetoException("Search limit must be greater than 0"); } @@ -155,7 +167,7 @@ public class GoToAddressLabelPlugin extends Plugin implements OptionsChangeListe } else if (opName.equals(GhidraOptions.OPTION_NUMERIC_FORMATTING)) { cStyleInput = - options.getBoolean(GhidraOptions.OPTION_NUMERIC_FORMATTING, DEFAULT_C_STYLE); + options.getBoolean(GhidraOptions.OPTION_NUMERIC_FORMATTING, DEFAULT_C_STYLE); goToDialog.setCStyleInput(cStyleInput); } else if (opName.equals(GO_TO_MEMORY)) { @@ -182,20 +194,20 @@ public class GoToAddressLabelPlugin extends Plugin implements OptionsChangeListe ToolOptions opt = tool.getOptions(ToolConstants.TOOL_OPTIONS); // descriptions opt.registerOption(GhidraOptions.OPTION_NUMERIC_FORMATTING, DEFAULT_C_STYLE, null, - "Interpret value entered in the Go To dialog as either hex, " - + "octal, or binary number."); + "Interpret value entered in the Go To dialog as either hex, " + + "octal, or binary number."); opt.registerOption(GhidraOptions.OPTION_MAX_GO_TO_ENTRIES, DEFAULT_MAX_GOTO_ENTRIES, null, - "Max number of entries remembered in the go to list."); + "Max number of entries remembered in the go to list."); opt.registerOption(GO_TO_MEMORY, DEFAULT_MEMORY, null, - "Remember the last successful go to input in the " - + "Go To dialog. If this option is enabled, then the " - + "Go To dialog will leave the last " - + "successful go to input in the combo box of the Go " - + "To dialog and will select the " + "value for easy paste replacement."); + "Remember the last successful go to input in the " + + "Go To dialog. If this option is enabled, then the " + + "Go To dialog will leave the last " + + "successful go to input in the combo box of the Go " + + "To dialog and will select the " + "value for easy paste replacement."); // options maximumGotoEntries = - opt.getInt(GhidraOptions.OPTION_MAX_GO_TO_ENTRIES, DEFAULT_MAX_GOTO_ENTRIES); + opt.getInt(GhidraOptions.OPTION_MAX_GO_TO_ENTRIES, DEFAULT_MAX_GOTO_ENTRIES); cStyleInput = opt.getBoolean(GhidraOptions.OPTION_NUMERIC_FORMATTING, DEFAULT_C_STYLE); goToDialog.setCStyleInput(cStyleInput); diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/FileHeader.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/FileHeader.java index 2a9cfebdd2..7d1dd90681 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/FileHeader.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/FileHeader.java @@ -22,6 +22,7 @@ import java.util.List; import ghidra.app.util.bin.StructConverter; import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader; +import ghidra.app.util.bin.format.pe.ImageRuntimeFunctionEntries._IMAGE_RUNTIME_FUNCTION_ENTRY; import ghidra.app.util.bin.format.pe.debug.DebugCOFFSymbol; import ghidra.app.util.bin.format.pe.debug.DebugCOFFSymbolAux; import ghidra.program.model.data.*; @@ -45,7 +46,7 @@ import ghidra.util.exception.DuplicateNameException; * WORD Characteristics; // MANDATORY * } IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER; * - * + * */ public class FileHeader implements StructConverter { /** @@ -55,128 +56,131 @@ public class FileHeader implements StructConverter { /** * The size of theSecurity
-
- Basic Infrastructure. Running Ghidra in debug mode no longer opens remotely accessible ports by default. (Issue #6)
-- GUI. The Defined Strings plugin no longer renders HTML in its table. (Issue #45)
-- Project Manager. Fixed an XXE vulnerability affecting projects and many other saved components. (Issue #71)
+- Basic Infrastructure. Running Ghidra in debug mode no longer opens remotely accessible ports by default. (GT-2641, Issue #6)
+- GUI. The Defined Strings plugin no longer renders HTML in its table. (GT-2686, Issue #45)
+- Project Manager. Fixed an XXE vulnerability affecting projects and many other saved components. (GT-2643, Issue #71)
IMAGE_FILE_HEADER in bytes.
*/
- public final static int IMAGE_SIZEOF_FILE_HEADER = 20;
+ public final static int IMAGE_SIZEOF_FILE_HEADER = 20;
/**
* Relocation info stripped from file.
*/
- public final static int IMAGE_FILE_RELOCS_STRIPPED = 0x0001;
- /**
- * File is executable (no unresolved externel references).
- */
- public final static int IMAGE_FILE_EXECUTABLE_IMAGE = 0x0002;
- /**
- * Line nunbers stripped from file.
- */
- public final static int IMAGE_FILE_LINE_NUMS_STRIPPED = 0x0004;
- /**
- * Local symbols stripped from file.
- */
- public final static int IMAGE_FILE_LOCAL_SYMS_STRIPPED = 0x0008;
- /**
- * Agressively trim working set
- */
- public final static int IMAGE_FILE_AGGRESIVE_WS_TRIM = 0x0010;
- /**
- * App can handle >2gb addresses
- */
- public final static int IMAGE_FILE_LARGE_ADDRESS_AWARE = 0x0020;
- /**
- * Bytes of machine word are reversed.
- */
- public final static int IMAGE_FILE_BYTES_REVERSED_LO = 0x0080;
- /**
- * 32 bit word machine.
- */
- public final static int IMAGE_FILE_32BIT_MACHINE = 0x0100;
- /**
- * Debugging info stripped from file in .DBG file
- */
- public final static int IMAGE_FILE_DEBUG_STRIPPED = 0x0200;
- /**
- * If Image is on removable media, copy and run from the swap file.
- */
- public final static int IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP = 0x0400;
- /**
- * If Image is on Net, copy and run from the swap file.
- */
- public final static int IMAGE_FILE_NET_RUN_FROM_SWAP = 0x0800;
- /**
- * System File.
- */
- public final static int IMAGE_FILE_SYSTEM = 0x1000;
- /**
- * File is a DLL.
- */
- public final static int IMAGE_FILE_DLL = 0x2000;
- /**
- * File should only be run on a UP machine
- */
- public final static int IMAGE_FILE_UP_SYSTEM_ONLY = 0x4000;
- /**
- * Bytes of machine word are reversed.
- */
- public final static int IMAGE_FILE_BYTES_REVERSED_HI = 0x8000;
+ public final static int IMAGE_FILE_RELOCS_STRIPPED = 0x0001;
+ /**
+ * File is executable (no unresolved externel references).
+ */
+ public final static int IMAGE_FILE_EXECUTABLE_IMAGE = 0x0002;
+ /**
+ * Line nunbers stripped from file.
+ */
+ public final static int IMAGE_FILE_LINE_NUMS_STRIPPED = 0x0004;
+ /**
+ * Local symbols stripped from file.
+ */
+ public final static int IMAGE_FILE_LOCAL_SYMS_STRIPPED = 0x0008;
+ /**
+ * Agressively trim working set
+ */
+ public final static int IMAGE_FILE_AGGRESIVE_WS_TRIM = 0x0010;
+ /**
+ * App can handle >2gb addresses
+ */
+ public final static int IMAGE_FILE_LARGE_ADDRESS_AWARE = 0x0020;
+ /**
+ * Bytes of machine word are reversed.
+ */
+ public final static int IMAGE_FILE_BYTES_REVERSED_LO = 0x0080;
+ /**
+ * 32 bit word machine.
+ */
+ public final static int IMAGE_FILE_32BIT_MACHINE = 0x0100;
+ /**
+ * Debugging info stripped from file in .DBG file
+ */
+ public final static int IMAGE_FILE_DEBUG_STRIPPED = 0x0200;
+ /**
+ * If Image is on removable media, copy and run from the swap file.
+ */
+ public final static int IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP = 0x0400;
+ /**
+ * If Image is on Net, copy and run from the swap file.
+ */
+ public final static int IMAGE_FILE_NET_RUN_FROM_SWAP = 0x0800;
+ /**
+ * System File.
+ */
+ public final static int IMAGE_FILE_SYSTEM = 0x1000;
+ /**
+ * File is a DLL.
+ */
+ public final static int IMAGE_FILE_DLL = 0x2000;
+ /**
+ * File should only be run on a UP machine.
+ */
+ public final static int IMAGE_FILE_UP_SYSTEM_ONLY = 0x4000;
+ /**
+ * Bytes of machine word are reversed.
+ */
+ public final static int IMAGE_FILE_BYTES_REVERSED_HI = 0x8000;
- public final static String [] CHARACTERISTICS = {
- "Relocation info stripped from file",
- "File is executable (i.e. no unresolved externel references)",
- "Line nunbers stripped from file",
- "Local symbols stripped from file",
- "Agressively trim working set",
- "App can handle >2gb addresses",
- "Bytes of machine word are reversed",
- "32 bit word machine",
- "Debugging info stripped from file in .DBG file",
- "If Image is on removable media, copy and run from the swap file",
- "If Image is on Net, copy and run from the swap file",
- "System file",
- "File is a DLL",
- "File should only be run on a UP machine",
- "Bytes of machine word are reversed"
- };
+ /**
+ * Magic value in LordPE's Symbol Table pointer field.
+ */
+ private final static int LORDPE_SYMBOL_TABLE = 0x726F4C5B;
+ /**
+ * Magic value in LordPE's Number of Symbols field.
+ */
+ private final static int LORDPE_NUMBER_OF_SYMBOLS = 0x5D455064;
- private short machine;
- private short numberOfSections;
- private int timeDateStamp;
- private int pointerToSymbolTable;
- private int numberOfSymbols;
- private short sizeOfOptionalHeader; // delta between start of OptionalHeader and start of section table
- private short characteristics;
+ public final static String[] CHARACTERISTICS = { "Relocation info stripped from file",
+ "File is executable (i.e. no unresolved externel references)",
+ "Line nunbers stripped from file", "Local symbols stripped from file",
+ "Agressively trim working set", "App can handle >2gb addresses",
+ "Bytes of machine word are reversed", "32 bit word machine",
+ "Debugging info stripped from file in .DBG file",
+ "If Image is on removable media, copy and run from the swap file",
+ "If Image is on Net, copy and run from the swap file", "System file", "File is a DLL",
+ "File should only be run on a UP machine", "Bytes of machine word are reversed" };
- private SectionHeader [] sectionHeaders;
- private ListIMAGE_NT_HEADERS32 and
- * IMAGE_NT_HEADERS64 structs as defined in
+ * IMAGE_NT_HEADERS64 structs as defined in
* winnt.h.
*
* typedef struct _IMAGE_NT_HEADERS {
@@ -39,8 +39,8 @@ import ghidra.util.task.TaskMonitorAdapter;
* IMAGE_OPTIONAL_HEADER32 OptionalHeader;
* };
*
- *
- *
+ *
+ *
*/
public class NTHeader implements StructConverter, OffsetValidator {
/**
@@ -82,8 +82,8 @@ public class NTHeader implements StructConverter, OffsetValidator {
public NTHeader() {
}
- private void initNTHeader(FactoryBundledWithBinaryReader reader, int index, SectionLayout layout,
- boolean advancedProcess, boolean parseCliHeaders)
+ private void initNTHeader(FactoryBundledWithBinaryReader reader, int index,
+ SectionLayout layout, boolean advancedProcess, boolean parseCliHeaders)
throws InvalidNTHeaderException, IOException {
this.reader = reader;
this.index = index;
@@ -172,9 +172,9 @@ public class NTHeader implements StructConverter, OffsetValidator {
//low alignment mode?
//
if (optionalHeader != null) {
- if (optionalHeader.getFileAlignment() == optionalHeader.getSectionAlignment()
- && optionalHeader.getSectionAlignment() < 800
- && optionalHeader.getFileAlignment() > 1) {
+ if (optionalHeader.getFileAlignment() == optionalHeader.getSectionAlignment() &&
+ optionalHeader.getSectionAlignment() < 800 &&
+ optionalHeader.getFileAlignment() > 1) {
return rva;
}
}
@@ -270,6 +270,7 @@ public class NTHeader implements StructConverter, OffsetValidator {
fileHeader.processSections(optionalHeader);
fileHeader.processSymbols();
+ fileHeader.processImageRuntimeFunctionEntries();
if (advancedProcess) {
optionalHeader.processDataDirectories(TaskMonitorAdapter.DUMMY_MONITOR);
@@ -278,7 +279,7 @@ public class NTHeader implements StructConverter, OffsetValidator {
void writeHeader(RandomAccessFile raf, DataConverter dc) throws IOException {
- raf.seek( index );
+ raf.seek(index);
raf.write(dc.getBytes(signature));
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/PeLoader.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/PeLoader.java
index f7f1141135..ad4317876c 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/PeLoader.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/PeLoader.java
@@ -28,6 +28,7 @@ import ghidra.app.util.bin.ByteProvider;
import ghidra.app.util.bin.format.mz.DOSHeader;
import ghidra.app.util.bin.format.pe.*;
import ghidra.app.util.bin.format.pe.ImageCor20Header.ImageCor20Flags;
+import ghidra.app.util.bin.format.pe.ImageRuntimeFunctionEntries._IMAGE_RUNTIME_FUNCTION_ENTRY;
import ghidra.app.util.bin.format.pe.PortableExecutable.SectionLayout;
import ghidra.app.util.bin.format.pe.debug.DebugCOFFSymbol;
import ghidra.app.util.bin.format.pe.debug.DebugDirectoryParser;
@@ -148,6 +149,7 @@ public class PeLoader extends AbstractPeDebugLoader {
processProperties(optionalHeader, program, monitor);
processComments(program.getListing(), monitor);
processSymbols(fileHeader, sectionToAddress, program, monitor, log);
+ processImageRuntimeFunctionEntries(fileHeader, program, monitor, log);
processEntryPoints(ntHeader, program, monitor);
String compiler = CompilerOpinion.getOpinion(pe, provider).toString();
@@ -248,24 +250,74 @@ public class PeLoader extends AbstractPeDebugLoader {
setComment(CodeUnit.EOL_COMMENT, start, section.getName());
start = start.add(dt.getLength());
}
-
-// for (int i = 0; i < datadirs.length; ++i) {
-// if (datadirs[i] == null || datadirs[i].getSize() == 0) {
-// continue;
-// }
-//
-// if (datadirs[i].hasParsedCorrectly()) {
-// start = datadirs[i].getMarkupAddress(program, true);
-// dt = datadirs[i].toDataType();
-// DataUtilities.createData(program, start, dt, true, DataUtilities.ClearDataMode.CHECK_FOR_SPACE);
-// }
-// }
}
catch (Exception e1) {
Msg.error(this, "Error laying down header structures " + e1);
}
}
+ private void processImageRuntimeFunctionEntries(FileHeader fileHeader, Program program,
+ TaskMonitor monitor, MessageLog log) {
+
+ // Check to see that we have exception data to process
+ SectionHeader irfeHeader = null;
+ for (SectionHeader header : fileHeader.getSectionHeaders()) {
+ if (header.getName().contains(".pdata")) {
+ irfeHeader = header;
+ break;
+ }
+ }
+
+ if (irfeHeader == null) {
+ return;
+ }
+
+ Address start = program.getImageBase().add(irfeHeader.getVirtualAddress());
+
+ List<_IMAGE_RUNTIME_FUNCTION_ENTRY> irfes = fileHeader.getImageRuntimeFunctionEntries();
+ if (irfes == null) {
+ return;
+ }
+
+ StructureDataType dt = new StructureDataType(".PDATA", 0);
+ dt.setCategoryPath(new CategoryPath("/PE"));
+
+ // Lay an array of RUNTIME_INFO structure out over the data
+ StructureDataType irfeStruct = new StructureDataType("_IMAGE_RUNTIME_FUNCTION_ENTRY", 0);
+ irfeStruct.add(ghidra.app.util.bin.StructConverter.IBO32, "BeginAddress", null);
+ irfeStruct.add(ghidra.app.util.bin.StructConverter.IBO32, "EndAddress", null);
+ irfeStruct.add(ghidra.app.util.bin.StructConverter.IBO32, "UnwindInfoAddressOrData", null);
+
+ ArrayDataType irfeArray =
+ new ArrayDataType(irfeStruct, irfes.size(), irfeStruct.getLength());
+
+ try {
+ DataUtilities.createData(program, start, irfeArray, irfeArray.getLength(), true,
+ DataUtilities.ClearDataMode.CHECK_FOR_SPACE);
+ }
+ catch (CodeUnitInsertionException e) {
+ return;
+ }
+
+ // Each RUNTIME_INFO contains an address to an UNWIND_INFO structure
+ // which also needs to be laid out. When they contain chaining data
+ // they're recursive but the toDataType() function handles that.
+ for (_IMAGE_RUNTIME_FUNCTION_ENTRY entry : irfes) {
+ if (entry.unwindInfoAddressOrData > 0) {
+ try {
+ dt = (StructureDataType) entry.unwindInfo.toDataType();
+ start = program.getImageBase().add(entry.unwindInfoAddressOrData);
+
+ DataUtilities.createData(program, start, dt, dt.getLength(), true,
+ DataUtilities.ClearDataMode.CHECK_FOR_SPACE);
+ }
+ catch (CodeUnitInsertionException | DuplicateNameException | IOException e) {
+ continue;
+ }
+ }
+ }
+ }
+
private void processSymbols(FileHeader fileHeader, MapWhile this dialog is showing all new exceptions will be added to the dialog. When - * this dialog is closed, this reference will be cleared. - * + * this dialog is closed, this reference will be cleared. + * *
Note: all use of this variable must be on the Swing thread to avoid thread
* visibility issues.
*/
@@ -62,23 +64,34 @@ public class DockingErrorDisplay implements ErrorDisplay {
Component parent, String title, Object message, Throwable throwable) {
int dialogType = OptionDialog.PLAIN_MESSAGE;
+
String messageString = message != null ? message.toString() : null;
- String rawMessage = HTMLUtilities.fromHTML(messageString);
+ if (messageString != null) {
+ // prevent excessive message degenerate cases
+ int maxChars = 1000;
+ String safeMessage = StringUtilities.trimMiddle(messageString, maxChars);
+
+ // wrap any poorly formatted text that gets displayed in the label; 80-100 chars is
+ // a reasonable line length based on historical print margins
+ messageString = WordUtils.wrap(safeMessage, 100, null, true);
+ }
+
+ String unformattedMessage = HTMLUtilities.fromHTML(messageString);
switch (messageType) {
case INFO:
dialogType = OptionDialog.INFORMATION_MESSAGE;
consoleDisplay.displayInfoMessage(errorLogger, originator, parent, title,
- rawMessage);
+ unformattedMessage);
break;
case WARNING:
case ALERT:
dialogType = OptionDialog.WARNING_MESSAGE;
consoleDisplay.displayWarningMessage(errorLogger, originator, parent, title,
- rawMessage, throwable);
+ unformattedMessage, throwable);
break;
case ERROR:
consoleDisplay.displayErrorMessage(errorLogger, originator, parent, title,
- rawMessage, throwable);
+ unformattedMessage, throwable);
dialogType = OptionDialog.ERROR_MESSAGE;
break;
}
@@ -93,8 +106,8 @@ public class DockingErrorDisplay implements ErrorDisplay {
return component;
}
- private void showDialog(final String title, final Throwable throwable,
- final int dialogType, final String messageString, final Component parent) {
+ private void showDialog(final String title, final Throwable throwable, final int dialogType,
+ final String messageString, final Component parent) {
Swing.runIfSwingOrRunLater(() -> {
@@ -108,8 +121,8 @@ public class DockingErrorDisplay implements ErrorDisplay {
});
}
- private void showDialogOnSwing(String title, Throwable throwable,
- int dialogType, String messageString, Component parent) {
+ private void showDialogOnSwing(String title, Throwable throwable, int dialogType,
+ String messageString, Component parent) {
if (activeDialog != null) {
activeDialog.addException(messageString, throwable);
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/DockingWindowManager.java b/Ghidra/Framework/Docking/src/main/java/docking/DockingWindowManager.java
index 4b7d9b4476..b85ab9ec69 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/DockingWindowManager.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/DockingWindowManager.java
@@ -1765,8 +1765,11 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
}
if (bestParent == null) {
- KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
- bestParent = kfm.getActiveWindow();
+ bestParent = getJavaActiveWindow();
+ }
+
+ if (bestParent != null && !bestParent.isShowing()) {
+ bestParent = null; // don't let non-showing windows be parents
}
return bestParent;
@@ -1775,8 +1778,7 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
private static Window getBestNonModalParent(DialogComponentProvider newProvider,
Window bestParent) {
- KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
- Window activeWindow = kfm.getActiveWindow();
+ Window activeWindow = getJavaActiveWindow();
if (!(activeWindow instanceof DockingDialog)) {
return bestParent;
}
@@ -1937,13 +1939,19 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
private static Window getJavaActiveWindow() {
KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
- return kfm.getActiveWindow();
+ Window activeWindow = kfm.getActiveWindow();
+ if (activeWindow == null) {
+ return null;
+ }
+ if (!activeWindow.isShowing()) {
+ return null; // don't let non-showing windows be considered active
+ }
+ return activeWindow;
}
private static Window getActiveNonTransientWindow() {
- KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
- Window bestWindow = kfm.getActiveWindow();
+ Window bestWindow = getJavaActiveWindow();
if (bestWindow instanceof DockingDialog) {
// We do not want Task Dialogs becoming parents, as they will get closed when the
// task is finished, closing any other child dialogs, which means that dialogs such
@@ -2172,6 +2180,34 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
objectUnderMouse = null;
}
+ /**
+ * Shows a popup menu over the given component. If this given component is not part of the
+ * docking windows hierarchy, then no action is taken.
+ *
+ * @param component the component
+ */
+ public static void showContextMenu(Component component) {
+
+ DockingWindowManager dwm = getInstance(component);
+ if (dwm == null) {
+ return;
+ }
+
+ DockableComponent dockableComponent = dwm.getDockableComponent(component);
+ if (dockableComponent == null) {
+ return;
+ }
+
+ Rectangle bounds = dockableComponent.getBounds();
+
+ bounds.x = 0;
+ bounds.y = 0;
+ int x = (int) bounds.getCenterX();
+ int y = (int) bounds.getCenterY();
+ PopupMenuContext popupContext = new PopupMenuContext(dockableComponent, new Point(x, y));
+ dockableComponent.showContextMenu(popupContext);
+ }
+
public void contextChanged(ComponentProvider provider) {
if (provider == null) {
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/ErrLogDialog.java b/Ghidra/Framework/Docking/src/main/java/docking/ErrLogDialog.java
index 0f02fc7c40..3eaf3c950d 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/ErrLogDialog.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/ErrLogDialog.java
@@ -43,7 +43,7 @@ import ghidra.util.table.column.GColumnRenderer;
import utilities.util.reflection.ReflectionUtilities;
/**
- * A dialog that takes error text and displays it with an option details button. If there is
+ * A dialog that takes error text and displays it with an option details button. If there is
* an {@link ErrorReporter}, then a button is provided to report the error.
*/
public class ErrLogDialog extends AbstractErrDialog {
@@ -149,7 +149,8 @@ public class ErrLogDialog extends AbstractErrDialog {
introPanel.add(
new GIconLabel(UIManager.getIcon("OptionPane.errorIcon"), SwingConstants.RIGHT),
BorderLayout.WEST);
- introPanel.add(new GHtmlLabel(HTMLUtilities.toHTML(message)) {
+ String html = HTMLUtilities.toHTML(message);
+ introPanel.add(new GHtmlLabel(html) {
@Override
public Dimension getPreferredSize() {
// rendering HTML the label can expand larger than the screen; keep it reasonable
@@ -387,6 +388,16 @@ public class ErrLogDialog extends AbstractErrDialog {
textDetails.scrollToBottom();
}
+ @Override
+ public Dimension getPreferredSize() {
+ Dimension size = super.getPreferredSize();
+
+ // Cap preferred width to something reasonable; most displays have more than 1000 width.
+ // Users can still resize as desired
+ size.width = Math.min(size.width, 1000);
+ return size;
+ }
+
void setError(ErrorEntry e) {
error = e;
setExceptionMessage(e.getDetailsText());
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/PopupActionManager.java b/Ghidra/Framework/Docking/src/main/java/docking/PopupActionManager.java
index af93a7677a..5a712f2b76 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/PopupActionManager.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/PopupActionManager.java
@@ -16,6 +16,7 @@
package docking;
import java.awt.Component;
+import java.awt.Point;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -67,28 +68,27 @@ public class PopupActionManager implements PropertyChangeListener {
}
}
- void popupMenu(ComponentPlaceholder info, MouseEvent e) {
+ void popupMenu(ComponentPlaceholder placeholder, PopupMenuContext popupContext) {
- if (e.isConsumed()) {
- return;
- }
- ComponentProvider popupProvider = info.getProvider();
- ActionContext actionContext = popupProvider.getActionContext(e);
+ MouseEvent event = popupContext.getEvent();
+ ComponentProvider popupProvider = placeholder.getProvider();
+ ActionContext actionContext = popupProvider.getActionContext(event);
if (actionContext == null) {
actionContext = new ActionContext();
}
- actionContext.setSourceObject(e.getSource());
- actionContext.setMouseEvent(e);
+ actionContext.setSourceObject(popupContext.getSource());
+ actionContext.setMouseEvent(event);
- Iteratortrue has
* been called.
- *
+ *
* @return true if {@link #setIndeterminate(boolean)} with a value of true has
* been called.
*/
@@ -280,7 +280,7 @@ public class TaskMonitorComponent extends JPanel implements TaskMonitor {
/**
* Set whether the progress bar should be visible
- *
+ *
* @param show true if the progress bar should be visible
*/
public synchronized void showProgress(boolean show) {
@@ -293,7 +293,7 @@ public class TaskMonitorComponent extends JPanel implements TaskMonitor {
/**
* Set the name of the task; the name shows up in the tool tip for
* the cancel button.
- *
+ *
* @param name the name of the task
*/
public void setTaskName(String name) {
@@ -303,7 +303,7 @@ public class TaskMonitorComponent extends JPanel implements TaskMonitor {
/**
* Set the visibility of the cancel button
- *
+ *
* @param visible if true, show the cancel button; false otherwise
*/
public void setCancelButtonVisibility(boolean visible) {
@@ -325,7 +325,7 @@ public class TaskMonitorComponent extends JPanel implements TaskMonitor {
/**
* Sets the visibility of the progress icon
- *
+ *
* @param visible if true, display the progress icon
*/
public void showProgressIcon(boolean visible) {
diff --git a/Ghidra/Framework/Docking/src/test.slow/java/docking/framework/SplashScreenTest.java b/Ghidra/Framework/Docking/src/test.slow/java/docking/framework/SplashScreenTest.java
index c3ef15bca8..0dbdf2655b 100644
--- a/Ghidra/Framework/Docking/src/test.slow/java/docking/framework/SplashScreenTest.java
+++ b/Ghidra/Framework/Docking/src/test.slow/java/docking/framework/SplashScreenTest.java
@@ -30,71 +30,43 @@ import docking.*;
import docking.test.AbstractDockingTest;
import docking.widgets.PasswordDialog;
import generic.test.category.NightlyCategory;
-import ghidra.util.Msg;
// The splash screen is sensitive to windows being activated/deactivated, so don't run
// when other test windows may be open
@Category(NightlyCategory.class)
public class SplashScreenTest extends AbstractDockingTest {
- private AboutDialog aboutDialog;
-
@After
public void tearDown() {
- Msg.debug(this, "tearDown() - open windows before closing");
- printOpenWindows();
-
runSwing(() -> SplashScreen.disposeSplashScreen());
-
- closeAllWindows();
- printOpenWindows();
-
- Msg.debug(this, "tearDown() - open windows after closing");
+ disposeAllWindows();
}
- @Test
- public void testShowInfoWindow() throws Exception {
- // no parent
- showModalInfoWindow(null);
-
- ensureInfoWindowVisible();
- hideInfoWindow();
-
- // not visible parent
- JFrame parentFrame = new JFrame("InfoWindowTest.testShowInfoWindow Frame");
- parentFrame.setBounds(-100, -100, 0, 0);
- showModalInfoWindow(parentFrame);
-
- ensureInfoWindowVisible();
- hideInfoWindow();
-
- // visible parent
- parentFrame.setVisible(true);
- showModalInfoWindow(parentFrame);
-
- ensureInfoWindowVisible();
- hideInfoWindow();
+ private void disposeAllWindows() {
+ for (Window window : getAllWindows()) {
+ runSwing(window::dispose);
+ }
}
@Test
public void testShowAndHideSplashScreen() {
showSplashScreen(true);
- ensureSpashScreenVisible(true);
+ assertSpashScreenVisible(true);
showSplashScreen(false);
- ensureSpashScreenVisible(false);
+ assertSpashScreenVisible(false);
showSplashScreen(true);
- ensureSpashScreenVisible(true);
+ assertSpashScreenVisible(true);
showSplashScreen(false);
- ensureSpashScreenVisible(false);
+ assertSpashScreenVisible(false);
}
@Test
public void testUpdateSplashScreenStatus() {
showSplashScreen(true);
- ensureSpashScreenVisible(true);
+ assertSpashScreenVisible(true);
JLabel statusLabel = (JLabel) getInstanceField("statusLabel", SplashScreen.class);
@@ -120,24 +92,24 @@ public class SplashScreenTest extends AbstractDockingTest {
public void testSplashScreenPasswordModality_SharedParent() throws Exception {
showSplashScreen(true);
- ensureSpashScreenVisible(true);
+ assertSpashScreenVisible(true);
// show a modal dialog with no parent (this will use the Splash Screen's parent)
showModalPasswordDialog(null);
// When the splash screen and the dialog share a parent, then the dialog should NOT
// cause the splash screen to go away
- ensureSpashScreenVisible(true);
+ assertSpashScreenVisible(true);
}
@Test
public void testSplashScreenPasswordModality_UnsharedParent() throws Exception {
// show the splash screen
showSplashScreen(true);
- ensureSpashScreenVisible(true);
+ assertSpashScreenVisible(true);
DockingFrame frame = new DockingFrame("Modal Parent Frame");
- frame.setVisible(true);
+ show(frame);
showModalPasswordDialog(frame);
ensureSplashScreenWillClose();
@@ -147,6 +119,10 @@ public class SplashScreenTest extends AbstractDockingTest {
// Private Methods
//==================================================================================================
+ private void show(JFrame frame) {
+ runSwing(() -> frame.setVisible(true));
+ }
+
private void ensureSplashScreenWillClose() {
waitForCondition(() -> {
SplashScreen splash = getSplash();
@@ -155,42 +131,44 @@ public class SplashScreenTest extends AbstractDockingTest {
}
private DockingDialog showModalPasswordDialog(Frame parentFrame) throws Exception {
+
String dialogTitle = "InfoWindowTest.testSplashScreenPasswordModality() Dialog";
DialogComponentProvider passwordDialog = runSwing(() -> new PasswordDialog(dialogTitle,
"Server Type", "Server Name", "Prompt", null, null));
+ if (parentFrame == null) {
+ // null means to share the parent
+ Object splashParent = getInstanceField("hiddenFrame", SplashScreen.class);
+ parentFrame = (Frame) splashParent;
+ }
+
+ Frame finalParent = parentFrame;
executeOnSwingWithoutBlocking(
- () -> DockingWindowManager.showDialog(parentFrame, passwordDialog));
+ () -> {
+ DockingDialog dialog =
+ DockingDialog.createDialog(finalParent, passwordDialog, finalParent);
+ dialog.setVisible(true);
+ });
JDialog dialog = waitForJDialog(dialogTitle);
assertNotNull(dialog);
- Window dialogWindow = SwingUtilities.windowForComponent(dialog);
- Msg.debug(this, "Created modal dialog with parent: " + getTitleForWindow(dialogWindow) +
- " - id: " + System.identityHashCode(dialogWindow));
-
return (DockingDialog) dialog;
}
- // handles showing the modal info window, which must be done from a thread outside of the
- // test thread
- private void showModalInfoWindow(final JFrame parentFrame) {
- // create a thread to show the modal dialog so that the current thread doesn't block
- aboutDialog = runSwing(() -> new AboutDialog());
- executeOnSwingWithoutBlocking(() -> DockingWindowManager.showDialog(null, aboutDialog));
- }
-
private void showSplashScreen(final boolean makeVisible) {
if (makeVisible) {
SplashScreen splash = runSwing(() -> SplashScreen.showSplashScreen());
assertNotNull("Failed showing splash screen", splash);
+ waitForSwing();
return;
}
SplashScreen.disposeSplashScreen();
+ waitForSwing();
}
- private void ensureSpashScreenVisible(boolean visible) {
+ private void assertSpashScreenVisible(boolean visible) {
// get the 'splashWindow' and make sure that it is not null and that it is visible
SplashScreen splashScreen = getSplash();
@@ -206,23 +184,6 @@ public class SplashScreenTest extends AbstractDockingTest {
// timing issue debug
waitForCondition(() -> splashScreen.isVisible());
-
- if (!splashScreen.isVisible()) {
-
- // this can happen if other OS windows trigger the splash window to be hidden
- printOpenWindows();
- fail("The splash screen is not visible when expected to be so - " + splashScreen);
- }
- }
-
- private void ensureInfoWindowVisible() {
- // get the 'infoDialog' and make sure that it is not null and that it is visible
- assertTrue("The info dialog is not visible after it was supposed to " + "have been shown.",
- aboutDialog.isVisible());
- }
-
- private void hideInfoWindow() throws Exception {
- runSwing(() -> aboutDialog.close());
}
private SplashScreen getSplash() {
diff --git a/Ghidra/Framework/Graph/src/main/java/ghidra/graph/viewer/popup/PopupRegulator.java b/Ghidra/Framework/Graph/src/main/java/ghidra/graph/viewer/popup/PopupRegulator.java
index 50445c0f64..1a004061c8 100644
--- a/Ghidra/Framework/Graph/src/main/java/ghidra/graph/viewer/popup/PopupRegulator.java
+++ b/Ghidra/Framework/Graph/src/main/java/ghidra/graph/viewer/popup/PopupRegulator.java
@@ -15,6 +15,7 @@
*/
package ghidra.graph.viewer.popup;
+import java.awt.Component;
import java.awt.Window;
import java.awt.event.*;
@@ -129,6 +130,13 @@ public class PopupRegulator