diff --git a/lib/flashdebugger.jar b/lib/flashdebugger.jar index 8c405a7cc..9cdb11151 100644 Binary files a/lib/flashdebugger.jar and b/lib/flashdebugger.jar differ diff --git a/libsrc/ffdec_lib/lib/flashdebugger.jar b/libsrc/ffdec_lib/lib/flashdebugger.jar index 8c405a7cc..9cdb11151 100644 Binary files a/libsrc/ffdec_lib/lib/flashdebugger.jar and b/libsrc/ffdec_lib/lib/flashdebugger.jar differ diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index c963771cc..dd3016a39 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -181,6 +181,7 @@ import com.jpexs.helpers.Helper; import com.jpexs.helpers.ImageResizer; import com.jpexs.helpers.ImmediateFuture; import com.jpexs.helpers.NulStream; +import com.jpexs.helpers.PosMarkedInputStream; import com.jpexs.helpers.ProgressListener; import com.jpexs.helpers.Reference; import com.jpexs.helpers.SerializableImage; @@ -204,6 +205,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; +import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Arrays; @@ -695,6 +697,15 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { * Lock for characters synchronization */ private final Object charactersLock = new Object(); + + /** + * SHA 256 hash of original data + */ + private String hashSha256 = null; + + public String getHashSha256() { + return hashSha256; + } public UninitializedClassFieldsDetector getUninitializedClassFieldsDetector() { return uninitializedClassFieldsDetector; @@ -1818,9 +1829,16 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { * @param includeImported Include imported characters * @throws IOException On I/O error */ - public void saveTo(OutputStream os, boolean gfx, boolean includeImported) throws IOException { + public void saveTo(OutputStream os, boolean gfx, boolean includeImported) throws IOException { checkCharset(); byte[] newUncompressedData = saveToByteArray(gfx, includeImported); + + try { + hashSha256 = Helper.byteArrayToHex(MessageDigest.getInstance("SHA-256").digest(newUncompressedData)); + } catch (NoSuchAlgorithmException ex) { + //ignore + } + ByteArrayOutputStream baos = new ByteArrayOutputStream(); compress(new ByteArrayInputStream(newUncompressedData), baos, compression, lzmaProperties); byte[] newCompressedData = baos.toByteArray(); @@ -1828,7 +1846,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { encrypt(new ByteArrayInputStream(newCompressedData), os); } else { os.write(newCompressedData); - } + } } /** @@ -2298,7 +2316,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { public SWF(InputStream is, String file, String fileTitle, ProgressListener listener, boolean parallelRead, boolean checkOnly, boolean lazy, UrlResolver resolver, String charset, boolean allowRenameIdentifiers) throws IOException, InterruptedException { this.file = file; this.fileTitle = fileTitle; - this.charset = charset; + this.charset = charset; ByteArrayOutputStream baos = new ByteArrayOutputStream(); SWFHeader header = decompress(is, baos, true); gfx = header.gfx; @@ -2307,6 +2325,12 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { lzmaProperties = header.lzmaProperties; uncompressedData = baos.toByteArray(); originalUncompressedData = uncompressedData; + + try { + hashSha256 = Helper.byteArrayToHex(MessageDigest.getInstance("SHA-256").digest(uncompressedData)); + } catch (NoSuchAlgorithmException ex) { + //ignore + } SWFInputStream sis = new SWFInputStream(this, uncompressedData); dumpInfo = new DumpInfoSwfNode(this, "rootswf", "", null, 0, 0); diff --git a/src/com/jpexs/decompiler/flash/gui/DebugPanel.java b/src/com/jpexs/decompiler/flash/gui/DebugPanel.java index d19c5d545..8a484c6f0 100644 --- a/src/com/jpexs/decompiler/flash/gui/DebugPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/DebugPanel.java @@ -495,7 +495,7 @@ public class DebugPanel extends JPanel { SelectedTab oldSel = selectedTab; localsTable = null; - SWF swf = Main.getMainFrame().getPanel().getCurrentSwf(); + SWF swf = Main.getDebuggedSWF(); if (swf == null) { return; } diff --git a/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java b/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java index 0eb96ba53..fa84f362d 100644 --- a/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java +++ b/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java @@ -31,7 +31,9 @@ import com.jpexs.debugger.flash.messages.in.InCallFunction; import com.jpexs.debugger.flash.messages.in.InConstantPool; import com.jpexs.debugger.flash.messages.in.InContinue; import com.jpexs.debugger.flash.messages.in.InErrorException; +import com.jpexs.debugger.flash.messages.in.InExit; import com.jpexs.debugger.flash.messages.in.InFrame; +import com.jpexs.debugger.flash.messages.in.InGetSwf; import com.jpexs.debugger.flash.messages.in.InGetVariable; import com.jpexs.debugger.flash.messages.in.InNumScript; import com.jpexs.debugger.flash.messages.in.InPlaceObject; @@ -43,6 +45,7 @@ import com.jpexs.debugger.flash.messages.in.InTrace; import com.jpexs.debugger.flash.messages.in.InVersion; import com.jpexs.debugger.flash.messages.out.OutAddWatch2; import com.jpexs.debugger.flash.messages.out.OutGetBreakReason; +import com.jpexs.debugger.flash.messages.out.OutGetSwf; import com.jpexs.debugger.flash.messages.out.OutPlay; import com.jpexs.debugger.flash.messages.out.OutProcessedTag; import com.jpexs.debugger.flash.messages.out.OutRewind; @@ -51,7 +54,11 @@ import com.jpexs.debugger.flash.messages.out.OutSwfInfo; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.graph.DottedChain; +import com.jpexs.helpers.Helper; +import java.io.FileOutputStream; import java.io.IOException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -72,7 +79,7 @@ import java.util.regex.Pattern; * @author JPEXS */ public class DebuggerHandler implements DebugConnectionListener { - + private boolean connected = false; private DebuggerCommands commands = null; @@ -586,15 +593,13 @@ public class DebuggerHandler implements DebugConnectionListener { } } - public void disconnect() { + + private void disconnected() { frame = null; pool = null; breakInfo = null; breakReason = null; connected = false; - if (commands != null) { - commands.disconnect(); - } commands = null; synchronized (this) { for (SWF debuggedSwf : debuggedSwfs) { @@ -630,6 +635,18 @@ public class DebuggerHandler implements DebugConnectionListener { } debuggedSwfs.clear(); } + + public void disconnect() { + frame = null; + pool = null; + breakInfo = null; + breakReason = null; + connected = false; + if (commands != null) { + commands.disconnect(); + } + disconnected(); + } public synchronized boolean isConnected() { return connected; @@ -659,10 +676,6 @@ public class DebuggerHandler implements DebugConnectionListener { @Override public void connected(DebuggerConnection con) { - /*for (SWF debuggedSwf : debuggedSwfs) { - makeBreakPointsUnconfirmed(debuggedSwf); - }*/ - Main.startWork(AppStrings.translate("work.debugging"), null); synchronized (this) { @@ -701,7 +714,7 @@ public class DebuggerHandler implements DebugConnectionListener { final Pattern patAS3 = Pattern.compile("^(.*);(.*);(.*)\\.as$"); final Pattern patAS3PCode = Pattern.compile("^(?[0-9a-z_]+):#PCODE abc:(?[0-9]+),script:(?