Skip to content

Added new HexViewer#2469

Merged
skylot merged 24 commits intoskylot:masterfrom
MrIkso:new_hexviewer
May 14, 2025
Merged

Added new HexViewer#2469
skylot merged 24 commits intoskylot:masterfrom
MrIkso:new_hexviewer

Conversation

@MrIkso
Copy link
Copy Markdown
Contributor

@MrIkso MrIkso commented Apr 30, 2025

This PRs added new HexViewer. (Fixed #2415)
New HexViewer has this features:

  • Goto to file offset
  • Search by hex and text
  • Selecting content encoding
  • Simple Data Inspector
  • Copy Hex or Text Data
  • Better ui

For this developments used bined project and adapted for jadx

Preview

image

@jpstotz
Copy link
Copy Markdown
Collaborator

jpstotz commented Apr 30, 2025

@MrIkso If your work bases on hexcellent we should check the license of hexcellent if it is compatible. Unfortunately I wasn't able to find a license statement in that project.

@MrIkso
Copy link
Copy Markdown
Contributor Author

MrIkso commented Apr 30, 2025

@MrIkso If your work bases on hexcellent we should check the license of hexcellent if it is compatible. Unfortunately I wasn't able to find a license statement in that project.

Hello. I found this information in the Terms of Use on their website https://www.kreativekorp.com/aboutkk/, but I've just written e-mail for check if I can use their code in this project and wait for an exact answer.

P.S If the current implementation is incompatible, im found new hexview library with Apache-2.0 license on this project,

@MrIkso MrIkso marked this pull request as draft April 30, 2025 20:59
MrIkso added 2 commits May 8, 2025 15:58
# Conflicts:
#	jadx-gui/src/main/java/jadx/gui/ui/codearea/HexArea.java
#	jadx-gui/src/main/java/jadx/gui/ui/codearea/HexPreviewPanel.java
@MrIkso
Copy link
Copy Markdown
Contributor Author

MrIkso commented May 8, 2025

I not got an answer on hexcellent, so now I'm reworking the code using the bined library as it's even better.

@MrIkso MrIkso marked this pull request as ready for review May 13, 2025 00:24
}

public void performCopyAsCode() {
((CodeAreaOperationCommandHandler) hexCodeArea.getCommandHandler()).copyAsCode();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cast here should be to "DefaultCodeAreaCommandHandler" instead.
This will also allow to remove "org.exbin.bined:bined-operation-swing" library dependency. (Operation library adds undo-redo support, which I assume is not needed for JADX)

Also if you would replace all uses of "section.SectCodeArea" class with "basic.CodeArea", you could drop dependency on "org.exbin.bined:bined-swing-section" as you don't use theme/layout capabilities of this extension.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't use theme/layout capabilities

public SectionCodeAreaColorProfile getColorsProfile() {
		boolean isDarkTheme = UiUtils.isDarkTheme(Objects.requireNonNull(defaultColors.getColor(CodeAreaBasicColors.TEXT_BACKGROUND)));
		Color markAllHighlightColor = isDarkTheme ? Color.decode("#32593D") : Color.decode("#ffc800");
		Color currentMatchColor = defaultColors.getColor(CodeAreaBasicColors.SELECTION_BACKGROUND);
		defaultColors.setColor(CodeAreaMatchColorType.MATCH_BACKGROUND, markAllHighlightColor);
		defaultColors.setColor(CodeAreaMatchColorType.CURRENT_MATCH_BACKGROUND, currentMatchColor);
		return defaultColors;
	}

im used replace exits search colors, BasicCodeAreaColorsProfile dont have it

@skylot
Copy link
Copy Markdown
Owner

skylot commented May 13, 2025

@MrIkso looks good, but this PR is big, so review may take some time.

During quick check, I encounter an issue in "find" panel: just start typing some hex number and exception window will appear after you type one character:

java.lang.IllegalArgumentException: Hex string must have even length. Input length: 1
	at jadx.gui.ui.hexviewer.HexSearchBar.hexStringToByteArray(HexSearchBar.java:268)
	at jadx.gui.ui.hexviewer.HexSearchBar.makeSearchCondition(HexSearchBar.java:244)
	at jadx.gui.ui.hexviewer.HexSearchBar.getSearchParameters(HexSearchBar.java:228)
	at jadx.gui.ui.hexviewer.search.BinarySearch.invokeSearch(BinarySearch.java:190)
	at jadx.gui.ui.hexviewer.search.BinarySearch$2.performFind(BinarySearch.java:108)
	at jadx.gui.ui.hexviewer.HexSearchBar$1.keyReleased(HexSearchBar.java:75)
	at java.desktop/java.awt.Component.processKeyEvent(Component.java:6587)

We need to disable search if input is invalid.

Also, maybe it will be nice to change tooltip for Find type button because it is unclear what current type mean and do.

@MrIkso
Copy link
Copy Markdown
Contributor Author

MrIkso commented May 13, 2025

@skylot oh yes, im try fix and improve tooltip

findTypeCB.setToolTipText(NLS.str("search.find_type_hex"));
}

private boolean isValidHexSting(String hexSting) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo. It stings ;-)


private boolean isValidHexSting(String hexSting) {
String cleanS = hexSting.replace(" ", "");
private boolean isValidHexSting(String hexString) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Sting" typo still present in method name... It's probably fine, I'm not even reviewer so don't mind me...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Sting" typo still present in method name... It's probably fine, I'm not even reviewer so don't mind me...

thanks

@skylot skylot merged commit 73348e5 into skylot:master May 14, 2025
4 checks passed
@skylot
Copy link
Copy Markdown
Owner

skylot commented May 14, 2025

@MrIkso thank you for your work 👍

@MrIkso MrIkso deleted the new_hexviewer branch May 14, 2025 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[gui] Prevent opening .so library file

5 participants