mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-11 13:38:17 +00:00
Warning panel on scripts containing §§ instructions (Tip for Settings/Automatic deobfuscation)
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [Unreleased]
|
||||
### Added
|
||||
- Warning panel on scripts containing §§ instructions (Tip for Settings/Automatic deobfuscation)
|
||||
|
||||
### Changed
|
||||
- AS1/2 Better unresolved constant handling - §§constant(xx) func instead of §§constantxx
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.jpexs.decompiler.flash.action.deobfuscation;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class BrokenScriptDetector {
|
||||
|
||||
public boolean codeIsBroken(String code) {
|
||||
return code.contains("\u00A7\u00A7");
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
|
||||
import com.jpexs.decompiler.flash.abc.usages.MultinameUsage;
|
||||
import com.jpexs.decompiler.flash.abc.usages.TraitMultinameUsage;
|
||||
import com.jpexs.decompiler.flash.action.deobfuscation.BrokenScriptDetector;
|
||||
import com.jpexs.decompiler.flash.action.parser.ActionParseException;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionScriptLexer;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ParsedSymbol;
|
||||
@@ -83,7 +84,9 @@ import com.jpexs.helpers.Helper;
|
||||
import de.hameister.treetable.MyTreeTable;
|
||||
import de.hameister.treetable.MyTreeTableModel;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
@@ -106,6 +109,8 @@ import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
@@ -121,6 +126,7 @@ import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingWorker;
|
||||
import javax.swing.ToolTipManager;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.event.EventListenerList;
|
||||
import javax.swing.event.TableModelListener;
|
||||
import javax.swing.event.TreeModelEvent;
|
||||
@@ -166,6 +172,8 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
|
||||
private final JPanel navPanel;
|
||||
|
||||
public final JPanel brokenHintPanel;
|
||||
|
||||
public final JTabbedPane tabbedPane;
|
||||
|
||||
public final SearchPanel<ABCSearchResult> searchPanel;
|
||||
@@ -821,25 +829,26 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String TryGetDebugHoverToolTipText(String varName) {
|
||||
String lowerName = varName.toLowerCase();
|
||||
String lowerName = varName.toLowerCase();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
|
||||
FindVarAndAppendDataToString(root, lowerName, builder);
|
||||
String text = builder.toString();
|
||||
|
||||
if (text == null || text.isEmpty())
|
||||
|
||||
if (text == null || text.isEmpty()) {
|
||||
return null;
|
||||
else
|
||||
} else {
|
||||
return "<html>" + text + "</html>";
|
||||
}
|
||||
}
|
||||
|
||||
private void FindVarAndAppendDataToString(VariableNode node, String lowerVarName, StringBuilder builder) {
|
||||
if (node.var != null && node.var.name.toLowerCase().contains(lowerVarName)) {
|
||||
builder.append(node.var.name + ": " + node.var.getValueAsStr() + "<br>");
|
||||
}
|
||||
|
||||
|
||||
if (node.childs != null) {
|
||||
for (int i = 0; i < node.childs.size(); i++) {
|
||||
FindVarAndAppendDataToString(node.childs.get(i), lowerVarName, builder);
|
||||
@@ -877,8 +886,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
// So that #getToolTipText(MouseEvent) gets invoked when the mouse
|
||||
// hovers the component, and we can show debug information
|
||||
ToolTipManager.sharedInstance().registerComponent(decompiledTextArea);
|
||||
decompiledTextArea.addMouseListener(new MouseAdapter()
|
||||
{
|
||||
decompiledTextArea.addMouseListener(new MouseAdapter() {
|
||||
final int initialTimeout = ToolTipManager.sharedInstance().getInitialDelay();
|
||||
final int dismissTimeout = ToolTipManager.sharedInstance().getDismissDelay();
|
||||
|
||||
@@ -894,9 +902,14 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
ToolTipManager.sharedInstance().setDismissDelay(dismissTimeout);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
searchPanel = new SearchPanel<>(new FlowLayout(), this);
|
||||
|
||||
brokenHintPanel = new JPanel(new BorderLayout(10, 10));
|
||||
brokenHintPanel.add(new JLabel("<html>" + AppStrings.translate("script.seemsBroken") + "</html>"), BorderLayout.CENTER);
|
||||
brokenHintPanel.setBackground(new Color(253, 205, 137));
|
||||
brokenHintPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED), new EmptyBorder(5, 5, 5, 5)));
|
||||
|
||||
decompiledScrollPane = new JScrollPane(decompiledTextArea);
|
||||
|
||||
JPanel iconDecPanel = new JPanel();
|
||||
@@ -916,8 +929,13 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
decompiledScrollPane.setAlignmentX(0);
|
||||
iconDecPanel.add(scriptNameLabel);
|
||||
iconDecPanel.add(iconsPanel);
|
||||
iconDecPanel.add(decompiledScrollPane);
|
||||
|
||||
JPanel panelWithHint = new JPanel(new BorderLayout());
|
||||
panelWithHint.setAlignmentX(0);
|
||||
panelWithHint.add(brokenHintPanel, BorderLayout.NORTH);
|
||||
panelWithHint.add(decompiledScrollPane, BorderLayout.CENTER);
|
||||
|
||||
iconDecPanel.add(panelWithHint);
|
||||
final JPanel decButtonsPan = new JPanel(new FlowLayout());
|
||||
decButtonsPan.setBorder(new BevelBorder(BevelBorder.RAISED));
|
||||
decButtonsPan.add(editDecompiledButton);
|
||||
@@ -1582,7 +1600,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
|
||||
return detailPanel.isEditing() || isModified();
|
||||
}
|
||||
|
||||
|
||||
public DebugPanel getDebugPanel() {
|
||||
return debugPanel;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitFunction;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
|
||||
import com.jpexs.decompiler.flash.action.deobfuscation.BrokenScriptDetector;
|
||||
import com.jpexs.decompiler.flash.gui.AppStrings;
|
||||
import com.jpexs.decompiler.flash.gui.Main;
|
||||
import com.jpexs.decompiler.flash.gui.View;
|
||||
@@ -750,6 +751,13 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
|
||||
highlightedText = decompiledText;
|
||||
if (decompiledText != null) {
|
||||
String hilightedCode = decompiledText.text;
|
||||
BrokenScriptDetector det = new BrokenScriptDetector();
|
||||
if (det.codeIsBroken(hilightedCode)) {
|
||||
abcPanel.brokenHintPanel.setVisible(true);
|
||||
} else {
|
||||
abcPanel.brokenHintPanel.setVisible(false);
|
||||
}
|
||||
|
||||
setText(hilightedCode);
|
||||
|
||||
if (highlightedText.getClassHighlights().size() > 0) {
|
||||
@@ -792,21 +800,21 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToolTipText(MouseEvent e) {
|
||||
public String getToolTipText(MouseEvent e) {
|
||||
// not debugging: so return existing text
|
||||
if (abcPanel.getDebugPanel().localsTable == null)
|
||||
return super.getToolTipText();
|
||||
|
||||
final Point point = new Point(e.getX(), e.getY());
|
||||
final int pos = abcPanel.decompiledTextArea.viewToModel(point);
|
||||
if (abcPanel.getDebugPanel().localsTable == null) {
|
||||
return super.getToolTipText();
|
||||
}
|
||||
|
||||
final Point point = new Point(e.getX(), e.getY());
|
||||
final int pos = abcPanel.decompiledTextArea.viewToModel(point);
|
||||
final String identifier = abcPanel.getMainPanel().getActionPanel().getStringUnderPosition(pos, abcPanel.decompiledTextArea);
|
||||
|
||||
if (identifier != null && !identifier.isEmpty())
|
||||
{
|
||||
if (identifier != null && !identifier.isEmpty()) {
|
||||
String tooltipText = abcPanel.getDebugPanel().localsTable.TryGetDebugHoverToolTipText(identifier);
|
||||
return (tooltipText == null ? super.getToolTipText() : tooltipText);
|
||||
}
|
||||
|
||||
|
||||
// not found: so return existing text
|
||||
return super.getToolTipText();
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.ActionGraph;
|
||||
import com.jpexs.decompiler.flash.action.ActionList;
|
||||
import com.jpexs.decompiler.flash.action.ConstantPoolTooBigException;
|
||||
import com.jpexs.decompiler.flash.action.deobfuscation.BrokenScriptDetector;
|
||||
import com.jpexs.decompiler.flash.action.parser.ActionParseException;
|
||||
import com.jpexs.decompiler.flash.action.parser.pcode.ASMParser;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionScript2Parser;
|
||||
@@ -61,6 +62,7 @@ import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.helpers.CancellableWorker;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Insets;
|
||||
@@ -72,6 +74,8 @@ import java.util.List;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
@@ -82,6 +86,8 @@ import javax.swing.JScrollPane;
|
||||
import javax.swing.JSplitPane;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.event.CaretEvent;
|
||||
import javax.swing.event.CaretListener;
|
||||
import javax.swing.text.Highlighter;
|
||||
@@ -100,6 +106,7 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ActionPanel.class.getName());
|
||||
|
||||
private JPanel brokenHintPanel;
|
||||
private MainPanel mainPanel;
|
||||
|
||||
public DebuggableEditorPane editor;
|
||||
@@ -280,6 +287,13 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
|
||||
ignoreCarret = true;
|
||||
decompiledEditor.setScriptName(scriptName);
|
||||
decompiledEditor.setText(text);
|
||||
BrokenScriptDetector det = new BrokenScriptDetector();
|
||||
if (det.codeIsBroken(text)) {
|
||||
brokenHintPanel.setVisible(true);
|
||||
} else {
|
||||
brokenHintPanel.setVisible(false);
|
||||
}
|
||||
|
||||
ignoreCarret = false;
|
||||
}
|
||||
|
||||
@@ -746,7 +760,16 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
|
||||
|
||||
DebugPanel debugPanel = new DebugPanel();
|
||||
|
||||
panA.add(new JPersistentSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(decompiledEditor), debugPanel, Configuration.guiActionVarsSplitPaneDividerLocationPercent), BorderLayout.CENTER);
|
||||
JPanel panelWithHint = new JPanel(new BorderLayout());
|
||||
brokenHintPanel = new JPanel(new BorderLayout(10, 10));
|
||||
brokenHintPanel.add(new JLabel("<html>" + AppStrings.translate("script.seemsBroken") + "</html>"), BorderLayout.CENTER);
|
||||
brokenHintPanel.setBackground(new Color(253, 205, 137));
|
||||
brokenHintPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED), new EmptyBorder(5, 5, 5, 5)));
|
||||
|
||||
panelWithHint.add(brokenHintPanel, BorderLayout.NORTH);
|
||||
panelWithHint.add(new JScrollPane(decompiledEditor), BorderLayout.CENTER);
|
||||
|
||||
panA.add(new JPersistentSplitPane(JSplitPane.VERTICAL_SPLIT, panelWithHint, debugPanel, Configuration.guiActionVarsSplitPaneDividerLocationPercent), BorderLayout.CENTER);
|
||||
panA.add(decButtonsPan, BorderLayout.SOUTH);
|
||||
|
||||
//decPanel.add(searchPanel, BorderLayout.NORTH);
|
||||
|
||||
@@ -772,3 +772,8 @@ message.font.setadvancevalues = This operation will set advance of ALL character
|
||||
menu.tools.deobfuscation.renameColliding = Rename colliding traits/classes
|
||||
|
||||
filter.iggy = Iggy files (*.iggy)
|
||||
|
||||
#after 11.1.0
|
||||
script.seemsBroken = <b>WARNING</b>: The code decompilation contains <font color=red>\u00a7\u00a7 instructions</font>. \
|
||||
This is usually caused by an obfuscation (See Settings/Automatic deobfuscation) \
|
||||
or a nonstandard compiler used (Haxe, etc.).
|
||||
|
||||
@@ -749,4 +749,9 @@ button.edit.script.disassembled = Upravit P-k\u00f3d
|
||||
|
||||
message.font.setadvancevalues = Tato operace nastav\u00ed advance V\u0160ECH znak\u016f v tomto tagu na advance hodnoty zdrojov\u00e9ho p\u00edsma.
|
||||
|
||||
filter.iggy = Iggy soubory (*.iggy)
|
||||
filter.iggy = Iggy soubory (*.iggy)
|
||||
|
||||
#after 11.1.0
|
||||
script.seemsBroken = <b>VAROV\u00c1N\u00cd</b>: K\u00f3d dekompilace obsahuje <font color=red>\u00a7\u00a7 instrukce</font>. \
|
||||
To je obvykle zp\u016fsobeno n\u011bjakou obfuskac\u00ed (viz Nastaven\u00ed/Automatick\u00e1 deobfuskace) \
|
||||
nebo pou\u017eit\u00edm nestandardn\u00edho kompil\u00e1toru (Haxe, etc.).
|
||||
|
||||
Reference in New Issue
Block a user