Skip to content

Commit 80a3e8b

Browse files
committed
2 parents 86dadfa + 8b61fa2 commit 80a3e8b

10 files changed

Lines changed: 396 additions & 430 deletions

File tree

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
<darklaf.version>2.7.3</darklaf.version>
3232
<darklaf-extensions-rsta.version>0.3.4</darklaf-extensions-rsta.version>
3333
<decompiler-fernflower.version>5.2.1.Final</decompiler-fernflower.version>
34-
<dex2jar.version>v45</dex2jar.version>
35-
<fernflower.version>b803ad9</fernflower.version>
34+
<dex2jar.version>v46</dex2jar.version>
35+
<fernflower.version>5a2b2cc</fernflower.version>
3636
<gson.version>2.9.0</gson.version>
3737
<guava.version>31.0.1-jre</guava.version>
3838
<imgscalr-lib.version>4.2</imgscalr-lib.version>
@@ -44,7 +44,7 @@
4444
<objenesis.version>3.2</objenesis.version>
4545
<paged-data.version>0.2.0</paged-data.version>
4646
<procyon.version>0.6.0</procyon.version>
47-
<rsyntaxtextarea.version>3.1.6</rsyntaxtextarea.version>
47+
<rsyntaxtextarea.version>3.2.0</rsyntaxtextarea.version>
4848
<semantic-version.version>2.1.1</semantic-version.version>
4949
<slf4j.version>1.7.36</slf4j.version>
5050
<smali.version>2.5.2</smali.version>

src/main/java/the/bytecode/club/bytecodeviewer/decompilers/bytecode/InstructionPrinter.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public List<String> createPrint() {
117117
info.add("}");
118118
return info;
119119
}
120-
120+
121121
public String printInstruction(AbstractInsnNode ain)
122122
{
123123
String line = "";
@@ -136,15 +136,15 @@ public String printInstruction(AbstractInsnNode ain)
136136
} else if (ain instanceof JumpInsnNode) {
137137
line = printJumpInsnNode((JumpInsnNode) ain);
138138
} else if (ain instanceof LineNumberNode) {
139-
line = printLineNumberNode();
139+
line = printLineNumberNode((LineNumberNode) ain);
140140
} else if (ain instanceof LabelNode) {
141141
if (firstLabel
142142
&& BytecodeViewer.viewer.appendBracketsToLabels
143143
.isSelected())
144144
info.add("}");
145-
145+
146146
line = printLabelnode((LabelNode) ain);
147-
147+
148148
if (BytecodeViewer.viewer.appendBracketsToLabels.isSelected()) {
149149
if (!firstLabel)
150150
firstLabel = true;
@@ -168,7 +168,7 @@ public String printInstruction(AbstractInsnNode ain)
168168
line += "UNADDED OPCODE: " + nameOpcode(ain.getOpcode()) + " "
169169
+ ain;
170170
}
171-
171+
172172
return line;
173173
}
174174

@@ -245,8 +245,8 @@ protected String printJumpInsnNode(JumpInsnNode jin) {
245245
+ resolveLabel(jin.label);
246246
}
247247

248-
protected String printLineNumberNode() {
249-
return "";
248+
protected String printLineNumberNode(LineNumberNode lnn) {
249+
return "// line " + lnn.line;
250250
}
251251

252252
protected String printLabelnode(LabelNode label) {

src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/CFRDecompiler.java

Lines changed: 182 additions & 288 deletions
Large diffs are not rendered by default.

src/main/java/the/bytecode/club/bytecodeviewer/gui/components/SearchableJTextArea.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class SearchableJTextArea extends JTextArea
5050
private final JScrollPane scrollPane = new JScrollPane();
5151
private final JPanel searchPanel = new JPanel(new BorderLayout());
5252
private final JTextField searchInput = new JTextField();
53-
private final JCheckBox caseSensitiveSearch = new TranslatedJCheckBox("Exact", TranslatedComponents.EXACT);
53+
private final JCheckBox caseSensitiveSearch = new TranslatedJCheckBox("Match case", TranslatedComponents.MATCH_CASE);
5454

5555
public SearchableJTextArea()
5656
{

src/main/java/the/bytecode/club/bytecodeviewer/gui/components/SearchableRSyntaxTextArea.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class SearchableRSyntaxTextArea extends RSyntaxTextArea
5555
private final RTextScrollPane scrollPane = new RTextScrollPane(this);
5656
private final JPanel searchPanel = new JPanel(new BorderLayout());
5757
private final JTextField searchInput = new JTextField();
58-
private final JCheckBox caseSensitiveSearch = new TranslatedJCheckBox("Exact", TranslatedComponents.EXACT);
58+
private final JCheckBox caseSensitiveSearch = new TranslatedJCheckBox("Match case", TranslatedComponents.MATCH_CASE);
5959
private final JLabel titleHeader = new JLabel("");
6060
private final Color darkScrollBackground = new Color(0x3c3f41);
6161
private final Color darkScrollForeground = new Color(0x575859);

src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package the.bytecode.club.bytecodeviewer.gui.resourcelist;
22

3-
import java.awt.BorderLayout;
4-
import java.awt.Color;
3+
import java.awt.*;
54
import java.awt.event.FocusEvent;
65
import java.awt.event.FocusListener;
76
import java.awt.event.KeyAdapter;
@@ -71,7 +70,8 @@
7170
public class ResourceListPane extends TranslatedVisibleComponent implements FileDrop.Listener
7271
{
7372
public final JPopupMenu rightClickMenu = new JPopupMenu();
74-
public final JCheckBox exact = new TranslatedJCheckBox("Exact", TranslatedComponents.EXACT);
73+
public final JCheckBox exact = new TranslatedJCheckBox("Exact path", TranslatedComponents.EXACT_PATH);
74+
public final JCheckBox caseSensitive = new TranslatedJCheckBox("Match case", TranslatedComponents.MATCH_CASE);
7575
public final JButton open = new JButton("+");
7676
public final JButton close = new JButton("-");
7777
public final ResourceTreeNode treeRoot = new ResourceTreeNode("Loaded Files:");
@@ -104,7 +104,7 @@ public ResourceListPane()
104104

105105
tree.setRootVisible(false);
106106
tree.setShowsRootHandles(true);
107-
quickSearch.setForeground(Color.gray);
107+
quickSearch.setForeground(quickSearch.getDisabledTextColor());
108108

109109
attachTreeListeners();
110110
attachQuickSearchListeners();
@@ -118,7 +118,12 @@ public ResourceListPane()
118118

119119
quickSearchPanel.setLayout(new BorderLayout());
120120
quickSearchPanel.add(quickSearch, BorderLayout.NORTH);
121-
exactPanel.add(exact, BorderLayout.WEST);
121+
122+
JPanel btns = new JPanel(new FlowLayout());
123+
btns.add(exact);
124+
btns.add(caseSensitive);
125+
exactPanel.add(btns, BorderLayout.WEST);
126+
122127
buttonPanel.add(open, BorderLayout.EAST);
123128
buttonPanel.add(close, BorderLayout.WEST);
124129
exactPanel.add(buttonPanel, BorderLayout.EAST);
@@ -519,7 +524,7 @@ public void focusGained(final FocusEvent arg0)
519524
if (quickSearch.getText().equals(TranslatedStrings.QUICK_FILE_SEARCH_NO_FILE_EXTENSION.toString()))
520525
{
521526
quickSearch.setText("");
522-
quickSearch.setForeground(Color.black);
527+
quickSearch.setForeground(quickSearch.getSelectedTextColor());
523528
}
524529
}
525530

@@ -529,7 +534,7 @@ public void focusLost(final FocusEvent arg0)
529534
if (quickSearch.getText().isEmpty())
530535
{
531536
quickSearch.setText(TranslatedStrings.QUICK_FILE_SEARCH_NO_FILE_EXTENSION.toString());
532-
quickSearch.setForeground(Color.gray);
537+
quickSearch.setForeground(quickSearch.getDisabledTextColor());
533538
}
534539
}
535540
});
Lines changed: 102 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package the.bytecode.club.bytecodeviewer.gui.resourcelist;
22

3+
import javax.swing.tree.TreeNode;
4+
import javax.swing.tree.TreePath;
5+
import java.awt.*;
36
import java.awt.event.KeyAdapter;
47
import java.awt.event.KeyEvent;
58
import java.util.Enumeration;
6-
import javax.swing.tree.TreeNode;
7-
import javax.swing.tree.TreePath;
8-
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
99

1010
/***************************************************************************
1111
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
@@ -29,118 +29,103 @@
2929
* @author Konloch
3030
* @since 6/22/2021
3131
*/
32-
public class SearchKeyAdapter extends KeyAdapter
33-
{
34-
private final ResourceListPane resourceListPane;
35-
36-
public SearchKeyAdapter(ResourceListPane resourceListPane) {this.resourceListPane = resourceListPane;}
37-
38-
@Override
39-
public void keyPressed(final KeyEvent ke)
40-
{
41-
//only trigger on enter
42-
if (ke.getKeyCode() != KeyEvent.VK_ENTER)
43-
return;
44-
45-
final String qt = resourceListPane.quickSearch.getText();
46-
resourceListPane.quickSearch.setText("");
47-
48-
if (qt.isEmpty()) //NOPE
49-
return;
50-
51-
String[] path;
52-
int found = 0;
53-
54-
if (qt.contains("."))
55-
{
56-
path = qt.split("\\.");
57-
}
58-
else
59-
{
60-
path = new String[]{qt};
61-
}
62-
63-
ResourceTreeNode curNode = resourceListPane.treeRoot;
64-
if (resourceListPane.exact.isSelected())
65-
{
66-
pathLoop:
67-
for (int i = 0; i < path.length; i++)
68-
{
69-
final String pathName = path[i];
70-
final boolean isLast = i == path.length - 1;
71-
72-
for (int c = 0; c < curNode.getChildCount(); c++)
73-
{
74-
final ResourceTreeNode child = (ResourceTreeNode) curNode.getChildAt(c);
75-
System.out.println(pathName + ":" + child.getUserObject());
76-
77-
if (child.getUserObject().equals(pathName))
78-
{
79-
curNode = child;
80-
if (isLast)
81-
{
82-
System.out.println("Found! " + curNode);
83-
found++;
84-
final TreePath pathn = new TreePath(curNode.getPath());
85-
resourceListPane.tree.setSelectionPath(pathn);
86-
resourceListPane.tree.makeVisible(pathn);
87-
resourceListPane.tree.scrollPathToVisible(pathn);
88-
resourceListPane.openPath(pathn); //auto open
89-
break pathLoop;
90-
}
91-
continue pathLoop;
92-
}
93-
}
94-
95-
System.out.println("Could not find " + pathName);
96-
break;
97-
}
98-
}
99-
else
100-
{
101-
@SuppressWarnings("unchecked")
102-
Enumeration<TreeNode> enums = curNode.depthFirstEnumeration();
103-
while (enums != null && enums.hasMoreElements())
104-
{
105-
ResourceTreeNode node = (ResourceTreeNode) enums.nextElement();
106-
if (node.isLeaf())
107-
{
108-
if (((String) (node.getUserObject())).toLowerCase().contains(path[path.length - 1].toLowerCase()))
109-
{
110-
TreeNode[] pathArray = node.getPath();
111-
int k = 0;
112-
StringBuilder fullPath = new StringBuilder();
113-
while (pathArray != null
114-
&& k < pathArray.length)
115-
{
116-
ResourceTreeNode n = (ResourceTreeNode) pathArray[k];
117-
String s = (String) (n.getUserObject());
118-
fullPath.append(s);
119-
if (k++ != pathArray.length - 1)
120-
{
121-
fullPath.append(".");
122-
}
123-
}
124-
String fullPathString = fullPath.toString();
125-
if (fullPathString.toLowerCase().contains(qt.toLowerCase()))
126-
{
127-
System.out.println("Found! " + node);
128-
found++;
129-
if (found >= 30)
130-
{ //TODO probably make this a setting, no real reason it's 30
131-
BytecodeViewer.showMessage("Uh oh, there could be more results but you've"
132-
+ " triggered the 30 classes at once limit. Try refining your search.");
133-
return;
134-
}
135-
final TreePath pathn = new TreePath(node.getPath());
136-
resourceListPane.tree.setSelectionPath(pathn.getParentPath());
137-
resourceListPane.tree.setSelectionPath(pathn);
138-
resourceListPane.tree.makeVisible(pathn);
139-
resourceListPane.tree.scrollPathToVisible(pathn);
140-
}
141-
}
142-
}
143-
}
144-
}
145-
}
32+
public class SearchKeyAdapter extends KeyAdapter {
33+
private final ResourceListPane resourceListPane;
34+
35+
public SearchKeyAdapter(ResourceListPane resourceListPane) {
36+
this.resourceListPane = resourceListPane;
37+
}
38+
39+
@Override
40+
public void keyPressed(final KeyEvent ke) {
41+
//only trigger on enter
42+
if (ke.getKeyCode() != KeyEvent.VK_ENTER)
43+
return;
44+
45+
final String qt = resourceListPane.quickSearch.getText();
46+
47+
if (qt.trim().isEmpty()) //NOPE
48+
return;
49+
50+
String[] path;
51+
if (qt.contains(".")) {
52+
path = qt.split("\\.");
53+
} else {
54+
path = new String[]{qt};
55+
}
56+
57+
ResourceTreeNode curNode = resourceListPane.treeRoot;
58+
boolean caseSensitive = resourceListPane.caseSensitive.isSelected();
59+
60+
boolean success = false;
61+
if (resourceListPane.exact.isSelected()) {
62+
pathLoop:
63+
for (int i = 0; i < path.length; i++) {
64+
final String pathName = path[i];
65+
final boolean isLast = i == path.length - 1;
66+
67+
for (int c = 0; c < curNode.getChildCount(); c++) {
68+
final ResourceTreeNode child = (ResourceTreeNode) curNode.getChildAt(c);
69+
Object userObject = child.getUserObject();
70+
if (caseSensitive ? userObject.equals(pathName) : userObject.toString().equalsIgnoreCase(pathName)) {
71+
curNode = child;
72+
if (isLast) {
73+
final TreePath pathn = new TreePath(curNode.getPath());
74+
resourceListPane.tree.setSelectionPath(pathn);
75+
resourceListPane.tree.makeVisible(pathn);
76+
resourceListPane.tree.scrollPathToVisible(pathn);
77+
resourceListPane.openPath(pathn); //auto open
78+
success = true;
79+
break pathLoop;
80+
}
81+
continue pathLoop;
82+
}
83+
}
84+
85+
System.out.println("Could not find " + pathName);
86+
break;
87+
}
88+
} else {
89+
@SuppressWarnings("unchecked")
90+
Enumeration<TreeNode> enums = curNode.depthFirstEnumeration();
91+
while (enums != null && enums.hasMoreElements()) {
92+
ResourceTreeNode node = (ResourceTreeNode) enums.nextElement();
93+
if (node.isLeaf()) {
94+
String userObject = (String) (node.getUserObject());
95+
String lastElem = path[path.length - 1];
96+
97+
if (caseSensitive ? userObject.contains(lastElem) : userObject.toLowerCase().contains(lastElem.toLowerCase())) {
98+
TreeNode[] pathArray = node.getPath();
99+
int k = 0;
100+
StringBuilder fullPath = new StringBuilder();
101+
while (pathArray != null
102+
&& k < pathArray.length) {
103+
ResourceTreeNode n = (ResourceTreeNode) pathArray[k];
104+
String s = (String) (n.getUserObject());
105+
fullPath.append(s);
106+
if (k++ != pathArray.length - 1) {
107+
fullPath.append(".");
108+
}
109+
}
110+
String fullPathString = fullPath.toString();
111+
112+
if (caseSensitive ? fullPathString.contains(qt) : fullPathString.toLowerCase().contains(qt.toLowerCase())) {
113+
final TreePath pathn = new TreePath(node.getPath());
114+
resourceListPane.tree.setSelectionPath(pathn.getParentPath());
115+
resourceListPane.tree.setSelectionPath(pathn);
116+
resourceListPane.tree.makeVisible(pathn);
117+
resourceListPane.tree.scrollPathToVisible(pathn);
118+
success = true;
119+
break;
120+
}
121+
}
122+
}
123+
}
124+
125+
}
126+
127+
if (!success) {
128+
Toolkit.getDefaultToolkit().beep();
129+
}
130+
}
146131
}

src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/SearchType.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package the.bytecode.club.bytecodeviewer.gui.resourcesearch;
22

33
import the.bytecode.club.bytecodeviewer.searching.SearchPanel;
4-
import the.bytecode.club.bytecodeviewer.searching.impl.FieldCallSearch;
5-
import the.bytecode.club.bytecodeviewer.searching.impl.LDCSearch;
6-
import the.bytecode.club.bytecodeviewer.searching.impl.MethodCallSearch;
7-
import the.bytecode.club.bytecodeviewer.searching.impl.RegexSearch;
4+
import the.bytecode.club.bytecodeviewer.searching.impl.*;
85

96
/***************************************************************************
107
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
@@ -34,6 +31,7 @@ public enum SearchType
3431
Regex(new RegexSearch()),
3532
MethodCall(new MethodCallSearch()),
3633
FieldCall(new FieldCallSearch()),
34+
MemberWithAnnotation(new MemberWithAnnotationSearch())
3735
;
3836

3937
public final SearchPanel panel;

0 commit comments

Comments
 (0)