random debugger package now optional

abc combobox removed
debugger attaching fixed
This commit is contained in:
Jindra Petřík
2014-10-28 17:53:50 +01:00
parent 2746f3bc32
commit eb8634d3d8
8 changed files with 48 additions and 41 deletions
+10 -4
View File
@@ -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
}
@@ -119,7 +119,6 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
public ABC abc;
public SWF swf;
public JComboBox<ABCContainerTag> 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<ABCContainerTag>()));
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<ABCContainerTag>()))), 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) {
@@ -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);
}
@@ -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<String>(), false));
}
}
@@ -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
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