diff --git a/src/com/jpexs/decompiler/flash/SWFInputStream.java b/src/com/jpexs/decompiler/flash/SWFInputStream.java index 9073a5cdb..948265753 100644 --- a/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -2264,6 +2264,7 @@ public class SWFInputStream implements AutoCloseable { if (!ret.buttonHasBlendMode && !ret.buttonHasFilterList && !ret.buttonStateHitTest && !ret.buttonStateDown && !ret.buttonStateOver && !ret.buttonStateUp && ret.reserved == 0) { + endDumpLevel(); return null; } diff --git a/src/com/jpexs/decompiler/flash/SWFOutputStream.java b/src/com/jpexs/decompiler/flash/SWFOutputStream.java index 51a990026..a8d3ffd52 100644 --- a/src/com/jpexs/decompiler/flash/SWFOutputStream.java +++ b/src/com/jpexs/decompiler/flash/SWFOutputStream.java @@ -695,7 +695,7 @@ public class SWFOutputStream extends OutputStream { if (value.eventFlags.clipEventKeyPress) { sos.writeUI8(value.keyCode); } - sos.write(value.actionBytes); + sos.write(value.actionBytes.getRangeData()); } byte[] data = baos.toByteArray(); writeUI32(data.length); //actionRecordSize @@ -1037,7 +1037,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); + sos.write(value.actionBytes.getRangeData()); } byte[] data = baos.toByteArray(); if (isLast) { diff --git a/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java b/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java index 34404b456..d294bfb4d 100644 --- a/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java +++ b/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java @@ -31,6 +31,7 @@ import com.jpexs.decompiler.flash.tags.base.Exportable; import com.jpexs.decompiler.flash.types.annotations.Conditional; import com.jpexs.decompiler.flash.types.annotations.Internal; import com.jpexs.decompiler.flash.types.annotations.SWFType; +import com.jpexs.helpers.ByteArrayRange; import com.jpexs.helpers.Helper; import java.io.IOException; import java.io.Serializable; @@ -71,11 +72,14 @@ public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem, S condIdleToOverUp = sis.readUB(1, "condIdleToOverUp") == 1; condKeyPress = (int) sis.readUB(7, "condKeyPress"); condOverDownToIdle = sis.readUB(1, "condOverDownToIdle") == 1; + int actionBytesPos = (int) sis.getPos(); + byte[] bytes; if (condActionSize <= 0) { - actionBytes = sis.readBytesEx(sis.available(), "actionBytes"); + bytes = sis.readBytesEx(sis.available(), "actionBytes"); } else { - actionBytes = sis.readBytesEx(condActionSize - 4, "actionBytes"); + bytes = sis.readBytesEx(condActionSize - 4, "actionBytes"); } + actionBytes = new ByteArrayRange(swf.uncompressedData, actionBytesPos, bytes.length); } /** * Is this BUTTONCONDACTION last in the list? @@ -132,7 +136,7 @@ public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem, S * Actions to perform in byte array */ @Internal - public byte[] actionBytes; + public ByteArrayRange actionBytes; /** * Sets actions associated with this object @@ -188,7 +192,12 @@ public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem, S @Override public ActionList getActions() throws InterruptedException { try { - ActionList list = ActionListReader.readActionListTimeout(listeners, new SWFInputStream(swf, actionBytes), swf.version, 0, -1, toString()/*FIXME?*/); + int prevLength = actionBytes.pos; + SWFInputStream rri = new SWFInputStream(swf, actionBytes.array); + if (prevLength != 0) { + rri.seek(prevLength); + } + ActionList list = ActionListReader.readActionListTimeout(listeners, rri, swf.version, prevLength, prevLength + actionBytes.length, toString()/*FIXME?*/); return list; } catch (InterruptedException ex) { @@ -201,17 +210,18 @@ public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem, S @Override public void setActions(List actions) { - actionBytes = Action.actionsToBytes(actions, true, swf.version); + byte[] bytes = Action.actionsToBytes(actions, true, swf.version); + actionBytes = new ByteArrayRange(bytes, 0, bytes.length); } @Override public byte[] getActionBytes() { - return actionBytes; + return actionBytes.getRangeData(); } @Override public void setActionBytes(byte[] actionBytes) { - this.actionBytes = actionBytes; + this.actionBytes = new ByteArrayRange(actionBytes); } @Override @@ -223,7 +233,7 @@ public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem, S @Override public GraphTextWriter getActionBytesAsHex(GraphTextWriter writer) { - return Helper.byteArrayToHexWithHeader(writer, actionBytes); + return Helper.byteArrayToHexWithHeader(writer, actionBytes.getRangeData()); } List listeners = new ArrayList<>(); diff --git a/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java b/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java index 627b7675a..3d29352c9 100644 --- a/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java +++ b/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java @@ -30,6 +30,7 @@ import com.jpexs.decompiler.flash.tags.base.ContainerItem; import com.jpexs.decompiler.flash.tags.base.Exportable; import com.jpexs.decompiler.flash.types.annotations.Conditional; import com.jpexs.decompiler.flash.types.annotations.Internal; +import com.jpexs.helpers.ByteArrayRange; import com.jpexs.helpers.Helper; import java.io.IOException; import java.io.Serializable; @@ -94,16 +95,13 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem, S private final Tag tag; @Internal private long pos; - @Internal - private long hdrPos; //Constructor for Generic tag editor. TODO:Handle this somehow better public CLIPACTIONRECORD() { swf = null; tag = null; eventFlags = new CLIPEVENTFLAGS(); - actionBytes = new byte[0]; - hdrPos = 0; + actionBytes = new ByteArrayRange(new byte[0]); } public CLIPACTIONRECORD(SWF swf, SWFInputStream sis, long pos, Tag tag) throws IOException { @@ -118,8 +116,9 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem, S keyCode = sis.readUI8("keyCode"); actionRecordSize--; } - hdrPos = sis.getPos(); - actionBytes = sis.readBytesEx(actionRecordSize, "actionBytes"); + int actionBytesPos = (int) sis.getPos(); + byte[] bytes = sis.readBytesEx(actionRecordSize, "actionBytes"); + actionBytes = new ByteArrayRange(swf.uncompressedData, actionBytesPos, bytes.length); this.pos = pos; } @@ -142,7 +141,7 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem, S */ //public List actions; @Internal - public byte[] actionBytes; + public ByteArrayRange actionBytes; /** * Returns a string representation of the object @@ -198,7 +197,12 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem, S @Override public ActionList getActions() throws InterruptedException { try { - ActionList list = ActionListReader.readActionListTimeout(listeners, new SWFInputStream(swf, actionBytes), swf.version, 0, -1, toString()/*FIXME?*/); + int prevLength = actionBytes.pos; + SWFInputStream rri = new SWFInputStream(swf, actionBytes.array); + if (prevLength != 0) { + rri.seek(prevLength); + } + ActionList list = ActionListReader.readActionListTimeout(listeners, rri, swf.version, prevLength, prevLength + actionBytes.length, toString()/*FIXME?*/); return list; } catch (InterruptedException ex) { throw ex; @@ -210,17 +214,18 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem, S @Override public void setActions(List actions) { - actionBytes = Action.actionsToBytes(actions, true, swf.version); + byte[] bytes = Action.actionsToBytes(actions, true, swf.version); + actionBytes = new ByteArrayRange(bytes, 0, bytes.length); } @Override public byte[] getActionBytes() { - return actionBytes; + return actionBytes.getRangeData(); } @Override public void setActionBytes(byte[] actionBytes) { - this.actionBytes = actionBytes; + this.actionBytes = new ByteArrayRange(actionBytes); } @Override @@ -232,7 +237,7 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem, S @Override public GraphTextWriter getActionBytesAsHex(GraphTextWriter writer) { - return Helper.byteArrayToHexWithHeader(writer, actionBytes); + return Helper.byteArrayToHexWithHeader(writer, actionBytes.getRangeData()); } List listeners = new ArrayList<>();