diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java index 91a07dca6..e768b4e22 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java @@ -738,7 +738,7 @@ public class SWFOutputStream extends OutputStream { if (value.eventFlags.clipEventKeyPress) { sos.writeUI8(value.keyCode); } - sos.write(value.actionBytes.getRangeData()); + sos.write(value.actionBytes); } byte[] data = baos.toByteArray(); writeUI32(data.length); //actionRecordSize @@ -1080,7 +1080,7 @@ public class SWFOutputStream extends OutputStream { sos.writeUB(1, value.condIdleToOverUp ? 1 : 0); sos.writeUB(7, value.condKeyPress); sos.writeUB(1, value.condOverDownToIdle ? 1 : 0); - sos.write(value.actionBytes.getRangeData()); + sos.write(value.actionBytes); } byte[] data = baos.toByteArray(); if (isLast) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/BinaryDataExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/BinaryDataExporter.java index 40b0f1399..8c0055658 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/BinaryDataExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/BinaryDataExporter.java @@ -12,7 +12,8 @@ * 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.exporters; import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; @@ -55,7 +56,7 @@ public class BinaryDataExporter { @Override public void run() throws IOException { try (FileOutputStream fos = new FileOutputStream(file)) { - fos.write(((DefineBinaryDataTag) t).binaryData); + fos.write(((DefineBinaryDataTag) t).binaryData.getRangeData()); } } }, handler).run(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/BinaryDataImporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/BinaryDataImporter.java index 2bf3a579f..c670e8222 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/BinaryDataImporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/BinaryDataImporter.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.importers; import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; +import com.jpexs.helpers.ByteArrayRange; /** * @@ -25,7 +26,7 @@ import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; public class BinaryDataImporter extends TagImporter { public void importData(DefineBinaryDataTag binaryDataTag, byte[] newData) { - binaryDataTag.binaryData = newData; + binaryDataTag.binaryData = new ByteArrayRange(newData); binaryDataTag.setModified(true); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java index dfba8769e..da6d17ca8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java @@ -38,7 +38,7 @@ public class DefineBinaryDataTag extends CharacterTag { @SWFType(BasicType.UI16) public int tag; - public byte[] binaryData; + public ByteArrayRange binaryData; @Reserved @SWFType(BasicType.UI32) @@ -77,18 +77,18 @@ public class DefineBinaryDataTag extends CharacterTag { public DefineBinaryDataTag(SWF swf) { super(swf, ID, "DefineBinaryData", null); tag = swf.getNextCharacterId(); - binaryData = new byte[0]; + binaryData = ByteArrayRange.EMPTY; } public DefineBinaryDataTag(SWFInputStream sis, ByteArrayRange data) throws IOException { super(sis.getSwf(), ID, "DefineBinaryData", data); tag = sis.readUI16("tag"); reserved = sis.readUI32("reserved"); - binaryData = sis.readBytesEx(sis.available(), "binaryData"); + binaryData = sis.readByteRangeEx(sis.available(), "binaryData"); if (Configuration.autoLoadEmbeddedSwfs.get()) { try { - SWF bswf = new SWF(new ByteArrayInputStream(binaryData), Configuration.parallelSpeedUp.get()); + SWF bswf = new SWF(new ByteArrayInputStream(binaryData.getArray(), binaryData.getPos(), binaryData.getLength()), Configuration.parallelSpeedUp.get()); bswf.fileTitle = "(SWF Data)"; innerSwf = bswf; bswf.binaryData = this; @@ -105,8 +105,8 @@ public class DefineBinaryDataTag extends CharacterTag { public boolean isSwfData() { try { - if (binaryData.length > 8) { - String signature = new String(binaryData, 0, 3, Utf8Helper.charset); + if (binaryData.getLength() > 8) { + String signature = new String(binaryData.getRangeData(0, 3), Utf8Helper.charset); if (Arrays.asList( "FWS", //Uncompressed Flash "CWS", //ZLib compressed Flash diff --git a/src/com/jpexs/decompiler/flash/gui/BinaryPanel.java b/src/com/jpexs/decompiler/flash/gui/BinaryPanel.java index 8b0ce7fb6..55a2a034f 100644 --- a/src/com/jpexs/decompiler/flash/gui/BinaryPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/BinaryPanel.java @@ -76,7 +76,7 @@ public final class BinaryPanel extends JPanel implements ComponentListener { public void setBinaryData(DefineBinaryDataTag binaryDataTag) { this.binaryDataTag = binaryDataTag; - data = binaryDataTag == null ? null : binaryDataTag.binaryData; + data = binaryDataTag == null ? null : binaryDataTag.binaryData.getRangeData(); if (data != null) { hexEditor.setData(data, null, null); swfInsidePanel.setVisible(binaryDataTag.innerSwf == null && binaryDataTag.isSwfData()); diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameClassicMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameClassicMenu.java index e4a4e5196..4ab7d4241 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameClassicMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameClassicMenu.java @@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.console.ContextMenuTools; import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.helpers.ByteArrayRange; import com.jpexs.helpers.Cache; import com.sun.jna.Platform; import java.awt.event.ActionEvent; @@ -486,7 +487,7 @@ public class MainFrameClassicMenu implements MainFrameMenu, ActionListener { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { swf.saveTo(baos); - swf.binaryData.binaryData = baos.toByteArray(); + swf.binaryData.binaryData = new ByteArrayRange(baos.toByteArray()); swf.binaryData.setModified(true); saved = true; } catch (IOException ex) { diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java index b43a9484d..42299f605 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java @@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.console.ContextMenuTools; import com.jpexs.decompiler.flash.gui.helpers.CheckResources; import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.helpers.ByteArrayRange; import com.jpexs.helpers.Cache; import com.jpexs.helpers.utf8.Utf8Helper; import com.jpexs.process.ProcessTools; @@ -861,7 +862,7 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { swf.saveTo(baos); - swf.binaryData.binaryData = baos.toByteArray(); + swf.binaryData.binaryData = new ByteArrayRange(baos.toByteArray()); swf.binaryData.setModified(true); saved = true; } catch (IOException ex) { diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 257afc0c4..e3e3ca3da 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -2223,7 +2223,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec @Override public void run() { try { - SWF bswf = new SWF(new ByteArrayInputStream(binaryDataTag.binaryData), new ProgressListener() { + SWF bswf = new SWF(new ByteArrayInputStream(binaryDataTag.binaryData.getRangeData()), new ProgressListener() { @Override public void progress(int p) { diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java index 9d64e9f7b..b2bb7cf52 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java @@ -565,17 +565,8 @@ public class TagTree extends JTree implements ActionListener { if (item instanceof DefineBinaryDataTag) { replaceSelectionMenuItem.setVisible(true); DefineBinaryDataTag bin = (DefineBinaryDataTag) item; - if (bin.binaryData.length > 8) { - String signature = new String(bin.binaryData, 0, 3, Utf8Helper.charset); - if (Arrays.asList( - "FWS", //Uncompressed Flash - "CWS", //ZLib compressed Flash - "ZWS", //LZMA compressed Flash - "GFX", //Uncompressed ScaleForm GFx - "CFX" //Compressed ScaleForm GFx - ).contains(signature)) { - openSWFInsideTagMenuItem.setVisible(true); - } + if (bin.isSwfData()) { + openSWFInsideTagMenuItem.setVisible(true); } }