diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d9cb9944..a6b071d65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -91,6 +91,7 @@ All notable changes to this project will be documented in this file. - [#2162] AS3 try inside foreach - [#2152] FLA Export - wrong nonlibrary shapes detection - [#2147] Display of empty video +- Saving SWFs opened by "Open loaded while playing" feature ### Changed - [#2120] Exported assets no longer take names from assigned classes if there is more than 1 assigned class diff --git a/libsrc/ffdec_lib/testdata/as3_loader/bin/as3_loader.swf b/libsrc/ffdec_lib/testdata/as3_loader/bin/as3_loader.swf new file mode 100644 index 000000000..bba835f09 Binary files /dev/null and b/libsrc/ffdec_lib/testdata/as3_loader/bin/as3_loader.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_loader/bin/inside.swf b/libsrc/ffdec_lib/testdata/as3_loader/bin/inside.swf new file mode 100644 index 000000000..5ea7ac3dc Binary files /dev/null and b/libsrc/ffdec_lib/testdata/as3_loader/bin/inside.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_loader/bin/inside_xored.swf b/libsrc/ffdec_lib/testdata/as3_loader/bin/inside_xored.swf new file mode 100644 index 000000000..71d339ddb Binary files /dev/null and b/libsrc/ffdec_lib/testdata/as3_loader/bin/inside_xored.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_loader/build_flex_debug.bat b/libsrc/ffdec_lib/testdata/as3_loader/build_flex_debug.bat new file mode 100644 index 000000000..ad5bb752f --- /dev/null +++ b/libsrc/ffdec_lib/testdata/as3_loader/build_flex_debug.bat @@ -0,0 +1,4 @@ +@echo off +java src_xor/Xor.java bin/inside.swf bin/inside_xored.swf +call c:\flex\bin\mxmlc.bat -debug=true -output bin/as3_loader.swf src/Main.as 1> buildlog.loader.txt 2>&1 +rem -warnings=false diff --git a/libsrc/ffdec_lib/testdata/as3_loader/src/EncryptedByteArray.as b/libsrc/ffdec_lib/testdata/as3_loader/src/EncryptedByteArray.as new file mode 100644 index 000000000..ead34e662 --- /dev/null +++ b/libsrc/ffdec_lib/testdata/as3_loader/src/EncryptedByteArray.as @@ -0,0 +1,10 @@ +package +{ + import flash.utils.ByteArray; + + [Embed(source="/../bin/inside_xored.swf", mimeType="application/octet-stream")] + public class EncryptedByteArray extends ByteArray + { + + } +} diff --git a/libsrc/ffdec_lib/testdata/as3_loader/src/Main.as b/libsrc/ffdec_lib/testdata/as3_loader/src/Main.as new file mode 100644 index 000000000..d405f23b2 --- /dev/null +++ b/libsrc/ffdec_lib/testdata/as3_loader/src/Main.as @@ -0,0 +1,59 @@ +package +{ + import flash.events.Event; + import flash.utils.ByteArray; + import flash.display.Loader; + import flash.display.Sprite; + import flash.display.StageAlign; + import flash.display.StageScaleMode; + + public class Main extends Sprite + { + private var swfLoader: Loader; + + public function Main():void + { + if (stage) { + init(); + } else { + addEventListener(Event.ADDED_TO_STAGE, init); + } + } + + private function init(e:Event = null):void + { + removeEventListener(Event.ADDED_TO_STAGE, init); + + var encrypted:ByteArray = new EncryptedByteArray(); + var decrypted:ByteArray = decrypt(encrypted); + + this.swfLoader = new Loader(); + this.swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onSWFLoaded); + this.swfLoader.loadBytes(decrypted); + } + + private function decrypt(encrypted: ByteArray): ByteArray + { + var decrypted:ByteArray = new ByteArray(); + + for (var i:int = 0; i < encrypted.length; i++) { + decrypted[i] = encrypted[i] ^ 65; + } + return decrypted; + } + + private function onSWFLoaded(event:Event):void { + var loadedSWF:Sprite = this.swfLoader.content as Sprite; + + addChild(loadedSWF); + + stage.scaleMode = StageScaleMode.NO_SCALE; + stage.align = StageAlign.TOP_LEFT; + + // loadedSWF.x = ... + // loadedSWF.y = ... + // loadedSWF.width = ... + // loadedSWF.height = ... + } + } +} diff --git a/libsrc/ffdec_lib/testdata/as3_loader/src_inside/chest.svg b/libsrc/ffdec_lib/testdata/as3_loader/src_inside/chest.svg new file mode 100644 index 000000000..e70834759 --- /dev/null +++ b/libsrc/ffdec_lib/testdata/as3_loader/src_inside/chest.svg @@ -0,0 +1,380 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libsrc/ffdec_lib/testdata/as3_loader/src_xor/Xor.java b/libsrc/ffdec_lib/testdata/as3_loader/src_xor/Xor.java new file mode 100644 index 000000000..883d6e316 --- /dev/null +++ b/libsrc/ffdec_lib/testdata/as3_loader/src_xor/Xor.java @@ -0,0 +1,26 @@ + +import java.io.FileInputStream; +import java.io.FileOutputStream; + +public class Xor { + public static void main(String args[]) throws Exception { + if (args.length != 2) { + System.out.println("Usage: java Xor.java inputfile.ext outputfile.ext"); + System.exit(1); + } + + int xorval = 65; + + try(FileInputStream fis = new FileInputStream(args[0]); + FileOutputStream fos = new FileOutputStream(args[1]);){ + byte[] buf = new byte[1024]; + int cnt; + while((cnt = fis.read(buf)) > 0) { + for (int i = 0; i < cnt; i++) { + buf[i] = (byte) ((buf[i] & 0xff) ^ xorval); + } + fos.write(buf, 0, cnt); + } + } + } +} diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index f12a9e1d7..051fe910e 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -47,7 +47,6 @@ import com.jpexs.decompiler.flash.console.ContextMenuTools; import com.jpexs.decompiler.flash.exporters.modes.ExeExportMode; import com.jpexs.decompiler.flash.gfx.GfxConvertor; import com.jpexs.decompiler.flash.gui.debugger.DebugAdapter; -import com.jpexs.decompiler.flash.gui.debugger.DebugListener; import com.jpexs.decompiler.flash.gui.debugger.DebuggerTools; import com.jpexs.decompiler.flash.gui.pipes.FirstInstance; import com.jpexs.decompiler.flash.gui.proxy.ProxyFrame; @@ -71,6 +70,7 @@ import com.jpexs.helpers.Helper; import com.jpexs.helpers.MemoryInputStream; import com.jpexs.helpers.Path; import com.jpexs.helpers.ProgressListener; +import com.jpexs.helpers.ReReadableInputStream; import com.jpexs.helpers.Reference; import com.jpexs.helpers.Stopwatch; import com.jpexs.helpers.streams.SeekableInputStream; @@ -2436,18 +2436,13 @@ public class Main { String title = swf == null ? "?" : swf.getTitleOrShortFileName(); final String titleWithHash = title + ":" + hash; - try { - final String tfile = tempFile(titleWithHash); - Helper.writeFile(tfile, data); - View.execInEventDispatch(new Runnable() { - @Override - public void run() { - openFile(new OpenableSourceInfo(null, tfile, titleWithHash)); - } - }); - } catch (IOException ex) { - logger.log(Level.SEVERE, "Cannot create tempfile"); - } + View.execInEventDispatch(new Runnable() { + @Override + public void run() { + OpenableSourceInfo osi = new OpenableSourceInfo(new ReReadableInputStream(new ByteArrayInputStream(data)), null, titleWithHash); + openFile(osi); + } + }); } });