From eb8634d3d8ac72459b03e23e0aa6f14f59da7718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Tue, 28 Oct 2014 17:53:50 +0100 Subject: [PATCH] random debugger package now optional abc combobox removed debugger attaching fixed --- .../flash/configuration/Configuration.java | 4 ++ .../decompiler/flash/tags/DoABCDefineTag.java | 12 +++++- .../jpexs/decompiler/flash/tags/DoABCTag.java | 12 +++++- src/com/jpexs/decompiler/flash/gui/Main.java | 14 +++++-- .../decompiler/flash/gui/abc/ABCPanel.java | 38 +++---------------- .../flash/gui/abc/DecompiledEditorPane.java | 2 +- .../decompiler/flash/gui/abc/DetailPanel.java | 2 +- .../locales/AdvancedSettingsDialog.properties | 5 ++- 8 files changed, 48 insertions(+), 41 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java index 9580c3200..6facae3b3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -345,6 +345,10 @@ public class Configuration { @ConfigurationCategory("script") public static final ConfigurationItem debuggerPort = null; + @ConfigurationDefaultBoolean(false) + @ConfigurationCategory("script") + public static final ConfigurationItem randomDebuggerPackage = null; + @ConfigurationDefaultBoolean(true) public static final ConfigurationItem displayDebuggerInfo = null; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java index a40b959a0..3126c2f96 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java @@ -12,9 +12,11 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.tags; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.abc.ABC; @@ -81,6 +83,14 @@ public class DoABCDefineTag extends Tag implements ABCContainerTag { abc = new ABC(ais, swf, this); } + @Override + public void setSwf(SWF swf) { + super.setSwf(swf); + abc.swf = swf; + } + + + /** * Gets data bytes * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCTag.java index a5cf87dd0..bc7a45fbb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCTag.java @@ -12,9 +12,11 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.tags; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.abc.ABC; @@ -92,4 +94,12 @@ public class DoABCTag extends Tag implements ABCContainerTag { public int compareTo(ABCContainerTag o) { return 0; } + + @Override + public void setSwf(SWF swf) { + super.setSwf(swf); + abc.swf = swf; + } + + } diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index 13b4b0888..f66198f67 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -1087,7 +1087,7 @@ public class Main { } else { cls = "\\." + Pattern.quote(cls); } - return tested.matches(Pattern.quote(DEBUGGER_PACKAGE) + "\\.pkg[a-f0-9]+" + cls); + return tested.matches(Pattern.quote(DEBUGGER_PACKAGE) + "(\\.pkg[a-f0-9]+)?" + cls); } private static String byteArrayToHex(byte[] a) { @@ -1144,13 +1144,18 @@ public class Main { Random rnd = new Random(); byte rb[] = new byte[16]; rnd.nextBytes(rb); - String rhex = byteArrayToHex(rb); + String rhex = byteArrayToHex(rb); try { //load debug swf SWF debugSWF = new SWF(Main.class.getClassLoader().getResourceAsStream("com/jpexs/decompiler/flash/gui/debugger/debug.swf"), false); ABCContainerTag firstAbc = swf.abcList.get(0); - String newdebuggerpkg = DEBUGGER_PACKAGE + ".pkg" + rhex; + String newdebuggerpkg = DEBUGGER_PACKAGE; + + if(Configuration.randomDebuggerPackage.get()){ + newdebuggerpkg += ".pkg"+rhex; + } + //add debug ABC tags to main SWF for (ABCContainerTag ds : debugSWF.abcList) { ABC a = ds.getABC(); @@ -1173,7 +1178,8 @@ public class Main { ((Tag) ds).setModified(true); } - } catch (Exception ex) { + } catch (Exception ex) { + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, "Error while attaching debugger", ex); //ignore } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index a0ea3503a..8387bd916 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -119,7 +119,6 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se public ABC abc; public SWF swf; public JComboBox abcComboBox; - public ABCContainerTag listIndex = null; public DecompiledEditorPane decompiledTextArea; public JScrollPane decompiledScrollPane; public JSplitPane splitPane; @@ -311,32 +310,19 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se this.swf = null; this.abc = null; constantTable.setModel(new DefaultTableModel()); - abcComboBox.setModel(new ABCComboBoxModel(new ArrayList())); navigator.clearABC(); } public void setSwf(SWF swf) { if (this.swf != swf) { this.swf = swf; - listIndex = null; - switchAbc(swf.abcList.get(0)); // todo honika: do we need this? - abcComboBox.setModel(new ABCComboBoxModel(swf.abcList)); if (swf.abcList.size() > 0) { this.abc = swf.abcList.get(0).getABC(); - } - - navigator.setABC(swf.abcList, abc); + } + navigator.setABC(swf.abcList, abc); } } - - public void switchAbc(ABCContainerTag index) { - listIndex = index; - - if (index != null) { - this.abc = index.getABC(); - } - updateConstList(); - } + public void initSplits() { //splitPaneTreeVSNavigator.setDividerLocation(splitPaneTreeVSNavigator.getHeight() / 2); @@ -472,11 +458,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se decompiledTextArea.addKeyListener(cch); decompiledTextArea.addMouseListener(cch); decompiledTextArea.addMouseMotionListener(cch); - - JPanel pan2 = new JPanel(); - pan2.setLayout(new BorderLayout()); - pan2.add((abcComboBox = new JComboBox<>(new ABCComboBoxModel(new ArrayList()))), BorderLayout.NORTH); - + navigator = new TraitsList(this); navPanel = new JPanel(new BorderLayout()); @@ -499,7 +481,6 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se tabbedPane = new JTabbedPane(); tabbedPane.addTab(AppStrings.translate("traits"), navPanel); - abcComboBox.addItemListener(this); add(splitPane, BorderLayout.CENTER); JPanel panConstants = new JPanel(); @@ -630,21 +611,14 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se } public void reload() { - switchAbc(listIndex); + lastDecompiled = ""; decompiledTextArea.clearScriptCache(); decompiledTextArea.reloadClass(); detailPanel.methodTraitPanel.methodCodePanel.clear(); } @Override - public void itemStateChanged(ItemEvent e) { - if (e.getSource() == abcComboBox) { - int index = ((JComboBox) e.getSource()).getSelectedIndex(); - if (index == -1) { - return; - } - switchAbc(swf.abcList.get(index - 1)); - } + public void itemStateChanged(ItemEvent e) { if (e.getSource() == constantTypeList) { int index = ((JComboBox) e.getSource()).getSelectedIndex(); if (index == -1) { diff --git a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java index ef8579f3c..768e035bd 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java @@ -512,7 +512,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL public void reloadClass() { int ci = classIndex; - uncache(script); + uncache(script); if ((script != null) && (abc != null)) { setScript(script, abcList); } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java index 77d566c3a..2c929434a 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java @@ -169,7 +169,7 @@ public class DetailPanel extends JPanel implements ActionListener { if (trait == null) { traitNameLabel.setText("-"); } else { - if(abcPanel!=null && trait.getName(abcPanel.abc)!=null && abcPanel.abc != null){ + if(abcPanel!=null){ traitNameLabel.setText(trait.getName(abcPanel.abc).getName(abcPanel.abc.constants, new ArrayList(), false)); } } diff --git a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties index e9026d582..c3da7724a 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties @@ -277,4 +277,7 @@ config.name.debuggerPort = Debugger port config.description.debuggerPort = Port used for socket debugging config.name.displayDebuggerInfo = (Internal) Display debugger info -config.description.displayDebuggerInfo = Display info about debugger before switching it \ No newline at end of file +config.description.displayDebuggerInfo = Display info about debugger before switching it + +config.name.randomDebuggerPackage = Use random package name for Debugger +config.description.randomDebuggerPackage = This renames Debugger package to random string which makes debugger presence harder to detect by ActionScript \ No newline at end of file