mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 14:50:47 +00:00
AS Decompilation can be disabled in menu (Disassemble only)
Go to document class fixed Clearing cache after autodeobfuscation change
This commit is contained in:
@@ -45,10 +45,6 @@ public class Configuration {
|
||||
* Turn off resolving constants in ActionScript 2
|
||||
*/
|
||||
public static final boolean RESOLVE_CONSTANTS = true;
|
||||
/**
|
||||
* Turn off decompiling if needed
|
||||
*/
|
||||
public static final boolean DO_DECOMPILE = true;
|
||||
/**
|
||||
* Find latest constant pool in the code
|
||||
*/
|
||||
|
||||
@@ -461,7 +461,17 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener {
|
||||
|
||||
public void hilightScript(String name) {
|
||||
ClassesListTreeModel clModel = (ClassesListTreeModel) classTree.getModel();
|
||||
ScriptPack pack = clModel.getList().get(name);
|
||||
HashMap<ClassPath, ScriptPack> list = clModel.getList();
|
||||
ClassPath path = null;
|
||||
for (ClassPath p : list.keySet()) {
|
||||
if (p.toString().equals(name)) {
|
||||
path = p;
|
||||
}
|
||||
}
|
||||
if (path == null) {
|
||||
return;
|
||||
}
|
||||
ScriptPack pack = clModel.getList().get(path);
|
||||
if (pack != null) {
|
||||
hilightScript(pack);
|
||||
}
|
||||
|
||||
@@ -103,8 +103,8 @@ public class MethodBody implements Cloneable, Serializable {
|
||||
|
||||
public String toString(String path, boolean pcode, boolean isStatic, int scriptIndex, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], Stack<GraphTargetItem> scopeStack, boolean isStaticInitializer, boolean hilight, List<String> fullyQualifiedNames, Traits initTraits) {
|
||||
String s = "";
|
||||
if (!Configuration.DO_DECOMPILE) {
|
||||
s = "//NOT DECOMPILED";
|
||||
if (!(Boolean) Configuration.getConfig("decompile", Boolean.TRUE)) {
|
||||
s = "//Decompilation skipped";
|
||||
if (hilight) {
|
||||
s = Highlighting.hilighMethod(s, this.method_info);
|
||||
}
|
||||
|
||||
@@ -443,11 +443,9 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
String bodyStr = "";
|
||||
bodyIndex = abc.findBodyIndex(abc.class_info[class_info].cinit_index);
|
||||
if (bodyIndex != -1) {
|
||||
if (Configuration.DO_DECOMPILE) {
|
||||
bodyStr = abc.bodies[bodyIndex].toString(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".staticinitializer", pcode, true, scriptIndex, class_info, abc, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), true, highlight, fullyQualifiedNames, abc.class_info[class_info].static_traits);
|
||||
if (!highlight) {
|
||||
bodyStr = Highlighting.stripHilights(bodyStr);
|
||||
}
|
||||
bodyStr = abc.bodies[bodyIndex].toString(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".staticinitializer", pcode, true, scriptIndex, class_info, abc, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), true, highlight, fullyQualifiedNames, abc.class_info[class_info].static_traits);
|
||||
if (!highlight) {
|
||||
bodyStr = Highlighting.stripHilights(bodyStr);
|
||||
}
|
||||
}
|
||||
if (Highlighting.stripHilights(bodyStr).equals("")) {
|
||||
@@ -482,11 +480,9 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
bodyStr = "";
|
||||
bodyIndex = abc.findBodyIndex(abc.instance_info[class_info].iinit_index);
|
||||
if (bodyIndex != -1) {
|
||||
if (Configuration.DO_DECOMPILE) {
|
||||
bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".initializer", pcode, false, scriptIndex, class_info, abc, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, highlight, fullyQualifiedNames, abc.instance_info[class_info].instance_traits), 3);
|
||||
if (!highlight) {
|
||||
bodyStr = Highlighting.stripHilights(bodyStr);
|
||||
}
|
||||
bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".initializer", pcode, false, scriptIndex, class_info, abc, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, highlight, fullyQualifiedNames, abc.instance_info[class_info].instance_traits), 3);
|
||||
if (!highlight) {
|
||||
bodyStr = Highlighting.stripHilights(bodyStr);
|
||||
}
|
||||
constructorParams = abc.method_info[abc.instance_info[class_info].iinit_index].getParamStr(abc.constants, abc.bodies[bodyIndex], abc, fullyQualifiedNames);
|
||||
} else {
|
||||
|
||||
@@ -52,9 +52,6 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
|
||||
@Override
|
||||
public String convert(String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List<String> fullyQualifiedNames, boolean paralel) {
|
||||
if (!Configuration.DO_DECOMPILE) {
|
||||
return "";
|
||||
}
|
||||
String header = convertHeader(path, abcTags, abc, isStatic, pcode, scriptIndex, classIndex, highlight, fullyQualifiedNames, paralel);
|
||||
String bodyStr = "";
|
||||
int bodyIndex = abc.findBodyIndex(method_info);
|
||||
|
||||
@@ -114,6 +114,10 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
private boolean searchRegexp;
|
||||
private Cache cache = new Cache(true);
|
||||
|
||||
public void clearCache() {
|
||||
cache.clear();
|
||||
}
|
||||
|
||||
public String getStringUnderCursor() {
|
||||
int pos = decompiledEditor.getCaretPosition();
|
||||
for (Highlighting h : decompiledHilights) {
|
||||
@@ -258,7 +262,7 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
@Override
|
||||
public void run() {
|
||||
editor.setText("; Disassembling...");
|
||||
if (Configuration.DO_DECOMPILE) {
|
||||
if ((Boolean) Configuration.getConfig("decompile", Boolean.TRUE)) {
|
||||
decompiledEditor.setText("//Waiting for dissasembly...");
|
||||
}
|
||||
DisassemblyListener listener = new DisassemblyListener() {
|
||||
@@ -286,7 +290,7 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
srcNoHex = Helper.stripComments(lastDisasm);
|
||||
editor.setText("; Disassembling - setting");
|
||||
setHex(hexButton.isSelected());
|
||||
if (Configuration.DO_DECOMPILE) {
|
||||
if ((Boolean) Configuration.getConfig("decompile", Boolean.TRUE)) {
|
||||
decompiledEditor.setText("//Decompiling...");
|
||||
String stripped = "";
|
||||
if (!useCache) {
|
||||
|
||||
@@ -221,6 +221,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
private JCheckBoxMenuItem miInternalViewer;
|
||||
private JCheckBoxMenuItem miParallelSpeedUp;
|
||||
private JCheckBoxMenuItem miAssociate;
|
||||
private JCheckBoxMenuItem miDecompile;
|
||||
|
||||
public void setPercent(int percent) {
|
||||
progressBar.setValue(percent);
|
||||
@@ -448,10 +449,16 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
miGotoDocumentClass.addActionListener(this);
|
||||
menuBar.add(menuTools);
|
||||
|
||||
miDecompile = new JCheckBoxMenuItem("Disable decompilation (Disassemble only)");
|
||||
miDecompile.setSelected(!(Boolean) Configuration.getConfig("decompile", Boolean.TRUE));
|
||||
miDecompile.setActionCommand("DISABLEDECOMPILATION");
|
||||
miDecompile.addActionListener(this);
|
||||
|
||||
JMenu menuSettings = new JMenu("Settings");
|
||||
menuSettings.add(autoDeobfuscateMenuItem);
|
||||
menuSettings.add(miInternalViewer);
|
||||
menuSettings.add(miParallelSpeedUp);
|
||||
menuSettings.add(miDecompile);
|
||||
|
||||
|
||||
miAssociate = new JCheckBoxMenuItem("Add FFDec to SWF files context menu");
|
||||
@@ -1494,9 +1501,26 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void clearCache() {
|
||||
if (abcPanel != null) {
|
||||
abcPanel.decompiledTextArea.clearScriptCache();
|
||||
}
|
||||
if (actionPanel != null) {
|
||||
actionPanel.clearCache();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
switch (e.getActionCommand()) {
|
||||
case "DISABLEDECOMPILATION":
|
||||
Configuration.setConfig("decompile", !miDecompile.isSelected());
|
||||
clearCache();
|
||||
if (abcPanel != null) {
|
||||
abcPanel.reload();
|
||||
}
|
||||
reload(true);
|
||||
break;
|
||||
case "ASSOCIATE":
|
||||
if (miAssociate.getState() == Main.isAssociated()) {
|
||||
return;
|
||||
@@ -1688,6 +1712,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
case "AUTODEOBFUSCATE":
|
||||
if (JOptionPane.showConfirmDialog(this, "Automatic deobfuscation is a way to decompile obfuscated code.\r\nDeobfuscation leads to slower decompilation and some of the dead code may be eliminated.\r\nIf the code is not obfuscated, it's better to turn autodeobfuscation off.\r\nDo you really want to " + (autoDeobfuscateMenuItem.getState() ? "turn ON" : "turn OFF") + " automatic debfuscation?", "Confirm", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
|
||||
Configuration.setConfig("autoDeobfuscate", autoDeobfuscateMenuItem.getState());
|
||||
clearCache();
|
||||
} else {
|
||||
autoDeobfuscateMenuItem.setState(!autoDeobfuscateMenuItem.getState());
|
||||
}
|
||||
@@ -1970,6 +1995,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
cnt = swf.deobfuscateIdentifiers(renameType);
|
||||
Main.stopWork();
|
||||
JOptionPane.showMessageDialog(null, "Identifiers renamed: " + cnt);
|
||||
clearCache();
|
||||
if (abcPanel != null) {
|
||||
abcPanel.reload();
|
||||
}
|
||||
@@ -2027,6 +2053,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
}
|
||||
Main.stopWork();
|
||||
JOptionPane.showMessageDialog(null, "Deobfuscation complete");
|
||||
clearCache();
|
||||
abcPanel.reload();
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user