Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ace91af
feat(gui): rewrite hex viewer (#2415)
MrIkso Apr 29, 2025
de3b2c1
Merge remote-tracking branch 'origin/master' into new_hexviewer
MrIkso Apr 30, 2025
8dd825e
fix: resolved merge conflict
MrIkso Apr 30, 2025
c5ae1f4
fix: resolved spotless checks
MrIkso Apr 30, 2025
bd74e1d
fix: try fix CodeQL checks
MrIkso Apr 30, 2025
38a802c
fix: fixed checkstyle checks
MrIkso Apr 30, 2025
59637ed
fix: always reset selection on hex viewer by left mouse button
MrIkso Apr 30, 2025
dd7e562
fix: always reset selection on hex viewer by left mouse button
MrIkso Apr 30, 2025
cdd2ab6
Merge branch 'refs/heads/master' into new_hexviewer
MrIkso May 8, 2025
632bc93
chore(gui): changed hex viewer to bined lib
MrIkso May 8, 2025
3acedb8
fix: fixed checkstyle checks
MrIkso May 8, 2025
5f938b6
fix: fixed goto address dialog
MrIkso May 8, 2025
9a7f3a3
chore(gui): added search on hex viewer & updated bined library
MrIkso May 13, 2025
b67167b
fix: remove commented code
MrIkso May 13, 2025
613de91
Merge branch 'skylot:master' into new_hexviewer
MrIkso May 13, 2025
84f297c
Merge branch 'new_hexviewer' of https://github.com/MrIkso/jadx into n…
MrIkso May 13, 2025
0dd6e9b
fix: removed useless code
MrIkso May 13, 2025
759a158
fix: removed useless code
MrIkso May 13, 2025
ccd1583
fix: try fix CodeQL scanning
MrIkso May 13, 2025
bc78158
fix: try fix CodeQL scanning
MrIkso May 13, 2025
8ac0dff
fix: try fix CodeQL scanning
MrIkso May 13, 2025
4d204c3
fix(gui): fixed search bar on hex viewer
MrIkso May 13, 2025
753a5d5
fix(gui): fixed is hex string checker
MrIkso May 14, 2025
d791a7f
fix(gui): fixed typo
MrIkso May 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions jadx-gui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ dependencies {
implementation("com.android.tools.build:apksig:8.9.2")
implementation("io.github.skylot:jdwp:2.0.0")

// Library for hex viewing data
val bined = "0.2.2"
implementation("org.exbin.bined:bined-swing:$bined")
implementation("org.exbin.bined:bined-operation-swing:$bined")
implementation("org.exbin.bined:bined-highlight-swing:$bined")
implementation("org.exbin.bined:bined-swing-section:$bined")
implementation("org.exbin.auxiliary:binary_data:$bined")
implementation("org.exbin.auxiliary:binary_data-array:$bined")

testImplementation(project.project(":jadx-core").sourceSets.getByName("test").output)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import jadx.api.metadata.ICodeNodeRef;
import jadx.gui.treemodel.JNode;
import jadx.gui.ui.action.JNodeAction;
import jadx.gui.ui.codearea.CodeArea;
import jadx.gui.ui.codearea.JNodeAction;

public class CodePopupAction {
private final String name;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package jadx.gui.plugins.script;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.KeyEvent;
import java.util.Collections;
Expand Down Expand Up @@ -237,6 +238,11 @@ public AbstractCodeArea getCodeArea() {
return scriptArea;
}

@Override
public Component getChildrenComponent() {
return getCodeArea();
}

@Override
public void loadSettings() {
applySettings();
Expand Down
73 changes: 73 additions & 0 deletions jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.awt.event.WindowEvent;
import java.awt.geom.AffineTransform;
import java.io.File;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
Expand Down Expand Up @@ -64,6 +65,7 @@
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;

import org.exbin.bined.swing.section.SectCodeArea;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
Expand Down Expand Up @@ -132,12 +134,16 @@
import jadx.gui.ui.codearea.theme.EditorThemeManager;
import jadx.gui.ui.dialog.ADBDialog;
import jadx.gui.ui.dialog.AboutDialog;
import jadx.gui.ui.dialog.CharsetDialog;
import jadx.gui.ui.dialog.ExceptionDialog;
import jadx.gui.ui.dialog.GotoAddressDialog;
import jadx.gui.ui.dialog.LogViewerDialog;
import jadx.gui.ui.dialog.SearchDialog;
import jadx.gui.ui.export.ExportProjectDialog;
import jadx.gui.ui.filedialog.FileDialogWrapper;
import jadx.gui.ui.filedialog.FileOpenMode;
import jadx.gui.ui.hexviewer.HexInspectorPanel;
import jadx.gui.ui.hexviewer.HexPreviewPanel;
import jadx.gui.ui.menu.HiddenMenuItem;
import jadx.gui.ui.menu.JadxMenu;
import jadx.gui.ui.menu.JadxMenuBar;
Expand Down Expand Up @@ -237,6 +243,7 @@ public class MainWindow extends JFrame {
private final ShortcutsController shortcutsController;
private JadxMenuBar menuBar;
private JMenu pluginsMenu;
public JMenu hexViewerMenu;

private final transient RenameMappingsGui renameMappings;

Expand Down Expand Up @@ -970,6 +977,46 @@ public void textSearch() {
SearchDialog.search(MainWindow.this, SearchDialog.SearchPreset.TEXT);
}

private void sendActionsToHexViewer(ActionModel action) {
HexPreviewPanel hexPreviewPanel = getCurrentHexViewTab();
if (hexPreviewPanel != null) {
HexInspectorPanel inspector = hexPreviewPanel.getInspector();
SectCodeArea hexEditor = hexPreviewPanel.getEditor();
switch (action) {
case HEX_VIEWER_SHOW_INSPECTOR:
hexPreviewPanel.getInspector().setVisible(!inspector.isVisible());
break;
case HEX_VIEWER_CHANGE_ENCODING:
String result = CharsetDialog.chooseCharset(this, hexEditor.getCharset().name());
if (!StringUtils.isEmpty(result)) {
hexEditor.setCharset(Charset.forName(result));
}
break;
case HEX_VIEWER_GO_TO_ADDRESS:
new GotoAddressDialog().showSetSelectionDialog(hexEditor);
break;
case HEX_VIEWER_FIND:
hexPreviewPanel.showSearchBar();
break;
}
}
}

public HexPreviewPanel getCurrentHexViewTab() {
ContentPanel panel = tabbedPane.getSelectedContentPanel();
if (panel instanceof AbstractCodeContentPanel) {
Component childrenComponent = ((AbstractCodeContentPanel) panel).getChildrenComponent();
if (childrenComponent instanceof HexPreviewPanel) {
return (HexPreviewPanel) childrenComponent;
}
}
return null;
}

public void toggleHexViewMenu() {
hexViewerMenu.setEnabled(getCurrentHexViewTab() != null);
}

public void goToMainActivity() {
AndroidManifestParser parser = new AndroidManifestParser(
AndroidManifestParser.getAndroidManifest(getWrapper().getResources()),
Expand Down Expand Up @@ -1066,6 +1113,9 @@ private void initMenuAndToolbar() {
JMenu recentProjects = new JadxMenu(NLS.str("menu.recent_projects"), shortcutsController);
recentProjects.addMenuListener(new RecentProjectsMenuListener(this, recentProjects));

hexViewerMenu = new JadxMenu(NLS.str("menu.hex_viewer"), shortcutsController);
initHexViewMenu();

JadxGuiAction prefsAction = new JadxGuiAction(ActionModel.PREFS, this::openSettings);
JadxGuiAction exitAction = new JadxGuiAction(ActionModel.EXIT, this::closeWindow);

Expand Down Expand Up @@ -1167,6 +1217,7 @@ private void initMenuAndToolbar() {
JMenu view = new JadxMenu(NLS.str("menu.view"), shortcutsController);
view.setMnemonic(KeyEvent.VK_V);
view.add(quickTabsAction.makeCheckBoxMenuItem());
view.add(hexViewerMenu);
view.add(flatPkgMenuItem);
view.addSeparator();
view.add(enablePreviewTabAction.makeCheckBoxMenuItem());
Expand Down Expand Up @@ -1743,4 +1794,26 @@ public EditorThemeManager getEditorThemeManager() {
public JadxGuiEventsImpl events() {
return events;
}

private void initHexViewMenu() {
hexViewerMenu.setEnabled(false);

JadxGuiAction showInspectorAction = new JadxGuiAction(ActionModel.HEX_VIEWER_SHOW_INSPECTOR,
() -> sendActionsToHexViewer(ActionModel.HEX_VIEWER_SHOW_INSPECTOR));
JCheckBoxMenuItem showInspectorMenuItem = new JCheckBoxMenuItem(showInspectorAction);

JadxGuiAction changeEncoding = new JadxGuiAction(ActionModel.HEX_VIEWER_CHANGE_ENCODING,
() -> sendActionsToHexViewer(ActionModel.HEX_VIEWER_CHANGE_ENCODING));
JadxGuiAction goToAddress = new JadxGuiAction(ActionModel.HEX_VIEWER_GO_TO_ADDRESS,
() -> sendActionsToHexViewer(ActionModel.HEX_VIEWER_GO_TO_ADDRESS));

JadxGuiAction findAction = new JadxGuiAction(ActionModel.HEX_VIEWER_FIND,
() -> sendActionsToHexViewer(ActionModel.HEX_VIEWER_FIND));

hexViewerMenu.add(showInspectorMenuItem);
hexViewerMenu.add(changeEncoding);
hexViewerMenu.add(goToAddress);
hexViewerMenu.addSeparator();
hexViewerMenu.add(findAction);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
public enum ActionCategory {
MENU_TOOLBAR("action_category.menu_toolbar"),
CODE_AREA("action_category.code_area"),
PLUGIN_SCRIPT("action_category.plugin_script");
PLUGIN_SCRIPT("action_category.plugin_script"),
HEX_VIEWER_MENU("action_category.hex_viewer");

private final String nameRes;

Expand Down
11 changes: 10 additions & 1 deletion jadx-gui/src/main/java/jadx/gui/ui/action/ActionModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,16 @@ public enum ActionModel {
SCRIPT_SAVE(PLUGIN_SCRIPT, "script.save", "script.save", "ui/menu-saveall",
Shortcut.keyboard(KeyEvent.VK_S, UiUtils.ctrlButton())),
SCRIPT_AUTO_COMPLETE(PLUGIN_SCRIPT, "script.auto_complete", "script.auto_complete", null,
Shortcut.keyboard(KeyEvent.VK_SPACE, UiUtils.ctrlButton()));
Shortcut.keyboard(KeyEvent.VK_SPACE, UiUtils.ctrlButton())),

HEX_VIEWER_SHOW_INSPECTOR(HEX_VIEWER_MENU, "hex_viewer.show_inspector", "hex_viewer.show_inspector",
null, Shortcut.none()),
HEX_VIEWER_CHANGE_ENCODING(HEX_VIEWER_MENU, "hex_viewer.change_encoding", "hex_viewer.change_encoding",
null, Shortcut.none()),
HEX_VIEWER_GO_TO_ADDRESS(HEX_VIEWER_MENU, "hex_viewer.goto_address", "hex_viewer.goto_address",
null, Shortcut.keyboard(KeyEvent.VK_J, UiUtils.ctrlButton())),
HEX_VIEWER_FIND(HEX_VIEWER_MENU, "hex_viewer.find", "hex_viewer.find",
null, Shortcut.keyboard(KeyEvent.VK_F, UiUtils.ctrlButton()));

private final ActionCategory category;
private final String nameRes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package jadx.gui.ui.codearea;
package jadx.gui.ui.action;

import jadx.gui.ui.action.ActionModel;
import jadx.gui.ui.action.JadxGuiAction;
import jadx.gui.ui.codearea.CodeArea;

public class CodeAreaAction extends JadxGuiAction {
protected transient CodeArea codeArea;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package jadx.gui.ui.codearea;
package jadx.gui.ui.action;

import java.awt.event.ActionEvent;

import jadx.gui.ui.action.ActionModel;
import jadx.gui.ui.codearea.CodeArea;
import jadx.gui.ui.dialog.SearchDialog;

public class CommentSearchAction extends CodeAreaAction {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package jadx.gui.ui.codearea;
package jadx.gui.ui.action;

import jadx.gui.treemodel.JNode;
import jadx.gui.ui.action.ActionModel;
import jadx.gui.ui.codearea.CodeArea;
import jadx.gui.ui.dialog.UsageDialog;

public final class FindUsageAction extends JNodeAction {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jadx.gui.ui.codearea;
package jadx.gui.ui.action;

import java.util.List;
import java.util.Objects;
Expand All @@ -23,7 +23,7 @@
import jadx.gui.treemodel.JField;
import jadx.gui.treemodel.JMethod;
import jadx.gui.treemodel.JNode;
import jadx.gui.ui.action.ActionModel;
import jadx.gui.ui.codearea.CodeArea;
import jadx.gui.utils.NLS;
import jadx.gui.utils.UiUtils;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package jadx.gui.ui.codearea;
package jadx.gui.ui.action;

import jadx.gui.treemodel.JNode;
import jadx.gui.ui.action.ActionModel;
import jadx.gui.ui.codearea.CodeArea;

public final class GoToDeclarationAction extends JNodeAction {
private static final long serialVersionUID = -1186470538894941301L;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package jadx.gui.ui.codearea;
package jadx.gui.ui.action;

import java.awt.event.ActionEvent;
import java.beans.PropertyChangeListener;

import org.jetbrains.annotations.Nullable;

import jadx.gui.treemodel.JNode;
import jadx.gui.ui.action.ActionModel;
import jadx.gui.ui.action.JadxGuiAction;
import jadx.gui.ui.codearea.CodeArea;

/**
* Add menu and key binding actions for JNode in code area
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package jadx.gui.ui.codearea;
package jadx.gui.ui.action;

import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;

import jadx.core.utils.GsonUtils;
import jadx.gui.treemodel.JNode;
import jadx.gui.ui.action.ActionModel;
import jadx.gui.ui.codearea.CodeArea;

public class JsonPrettifyAction extends JNodeAction {
private static final long serialVersionUID = -2682529369671695550L;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package jadx.gui.ui.codearea;
package jadx.gui.ui.action;

import jadx.gui.treemodel.JNode;
import jadx.gui.treemodel.JRenameNode;
import jadx.gui.ui.action.ActionModel;
import jadx.gui.ui.codearea.CodeArea;
import jadx.gui.ui.dialog.RenameDialog;

public final class RenameAction extends JNodeAction {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jadx.gui.ui.codearea
package jadx.gui.ui.action

import jadx.core.dex.instructions.args.ArgType
import jadx.core.dex.instructions.args.PrimitiveType
Expand All @@ -8,7 +8,7 @@ import jadx.gui.treemodel.JClass
import jadx.gui.treemodel.JField
import jadx.gui.treemodel.JMethod
import jadx.gui.treemodel.JNode
import jadx.gui.ui.action.ActionModel
import jadx.gui.ui.codearea.CodeArea
import jadx.gui.utils.NLS
import jadx.gui.utils.UiUtils
import org.slf4j.Logger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import jadx.gui.treemodel.JEditableNode;
import jadx.gui.treemodel.JNode;
import jadx.gui.ui.MainWindow;
import jadx.gui.ui.action.JNodeAction;
import jadx.gui.ui.panel.ContentPanel;
import jadx.gui.utils.DefaultPopupMenuListener;
import jadx.gui.utils.JumpPosition;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package jadx.gui.ui.codearea;

import java.awt.Component;

import jadx.gui.treemodel.JNode;
import jadx.gui.ui.panel.ContentPanel;
import jadx.gui.ui.tab.TabbedPane;
Expand All @@ -15,4 +17,6 @@ protected AbstractCodeContentPanel(TabbedPane panel, JNode jnode) {
}

public abstract AbstractCodeArea getCodeArea();

public abstract Component getChildrenComponent();
}
Loading