diff --git a/src/com/jpexs/decompiler/flash/SWF.java b/src/com/jpexs/decompiler/flash/SWF.java index 32a2c58df..4933516a3 100644 --- a/src/com/jpexs/decompiler/flash/SWF.java +++ b/src/com/jpexs/decompiler/flash/SWF.java @@ -514,19 +514,19 @@ public final class SWF implements TreeItem, Timelined { SWFInputStream sis = new SWFInputStream(this, uncompressedData); dumpInfo = new DumpInfo("rootswf", "", null, 0, 0); sis.dumpInfo = dumpInfo; - sis.readBytesEx(3); // skip siganture - version = sis.readUI8(); - fileSize = sis.readUI32(); + sis.readBytesEx(3, "signature"); // skip siganture + version = sis.readUI8("version"); + fileSize = sis.readUI32("fileSize"); sis.dumpInfo.lengthBytes = fileSize; if (listener != null) { sis.addPercentListener(listener); } sis.setPercentMax(fileSize); - displayRect = sis.readRECT(); + displayRect = sis.readRECT("displayRect"); // FIXED8 (16 bit fixed point) frameRate - sis.readUI8(); //tmpFirstByetOfFrameRate - frameRate = sis.readUI8(); - frameCount = sis.readUI16(); + sis.readUI8("tmpFirstByetOfFrameRate"); //tmpFirstByetOfFrameRate + frameRate = sis.readUI8("frameRate"); + frameCount = sis.readUI16("frameCount"); List tags = sis.readTagList(this, 0, parallelRead, true, !checkOnly, gfx); if (tags.get(tags.size() - 1).getId() == EndTag.ID) { hasEndTag = true; @@ -713,7 +713,7 @@ public final class SWF implements TreeItem, Timelined { int version = hdr[3]; SWFInputStream sis = new SWFInputStream(null, Arrays.copyOfRange(hdr, 4, 8), 4, 4); - long fileSize = sis.readUI32(); + long fileSize = sis.readUI32("fileSize"); SWFHeader header = new SWFHeader(); header.version = version; header.fileSize = fileSize; @@ -734,10 +734,10 @@ public final class SWF implements TreeItem, Timelined { break; } case 'Z': { // ZWS - sis.readUI32(); // compressed LZMA data size = compressed SWF - 17 byte, + sis.readUI32("LZMAsize"); // compressed LZMA data size = compressed SWF - 17 byte, // where 17 = 8 byte header + this 4 byte + 5 bytes decoder properties int propertiesSize = 5; - byte[] lzmaProperties = sis.readBytes(propertiesSize); + byte[] lzmaProperties = sis.readBytes(propertiesSize, "lzmaproperties"); if (lzmaProperties.length != propertiesSize) { throw new IOException("LZMA:input .lzma file is too short"); } diff --git a/src/com/jpexs/decompiler/flash/SWFInputStream.java b/src/com/jpexs/decompiler/flash/SWFInputStream.java index 778895cae..cba8513a9 100644 --- a/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -362,10 +362,9 @@ public class SWFInputStream implements AutoCloseable { is.seek(pos - startingPos); } - private void newDumpLevel(String name) { - String type = name; + private void newDumpLevel(String name, String type) { if (dumpInfo != null) { - DumpInfo di = new DumpInfo(name, type, null, is.getPos(), 0); + DumpInfo di = new DumpInfo(name, type, null, is.getPos(), bitPos, 0, 0); di.parent = dumpInfo; dumpInfo.childInfos.add(di); dumpInfo = di; @@ -373,10 +372,17 @@ public class SWFInputStream implements AutoCloseable { } private void endDumpLevel() { + endDumpLevel(null); + } + + private void endDumpLevel(Object value) { if (dumpInfo != null) { - if (dumpInfo.lengthBits == 0) { + if (dumpInfo.startBit == 0 && bitPos == 0) { dumpInfo.lengthBytes = is.getPos() - dumpInfo.startByte; + } else { + dumpInfo.lengthBits = (int) ((is.getPos() - dumpInfo.startByte - (dumpInfo.startBit == 0 ? 1 : 0)) * 8 - dumpInfo.startBit + bitPos); } + dumpInfo.previewValue = value; dumpInfo = dumpInfo.parent; } } @@ -418,24 +424,26 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one UI8 (Unsigned 8bit integer) value from the stream * + * @param name * @return UI8 value or -1 on error * @throws IOException */ - public int readUI8() throws IOException { - newDumpLevel("UI8"); + public int readUI8(String name) throws IOException { + newDumpLevel(name, "UI8"); int ret = readEx(); - endDumpLevel(); + endDumpLevel(ret); return ret; } /** * Reads one string value from the stream * + * @param name * @return String value * @throws IOException */ - public String readString() throws IOException { - newDumpLevel("string"); + public String readString(String name) throws IOException { + newDumpLevel(name, "string"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int r; while (true) { @@ -451,13 +459,38 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one UI32 (Unsigned 32bit integer) value from the stream * + * @param name * @return UI32 value * @throws IOException */ - public long readUI32() throws IOException { - newDumpLevel("UI8"); - long ret = (readEx() + (readEx() << 8) + (readEx() << 16) + (readEx() << 24)) & 0xffffffff; - endDumpLevel(); + public long readUI32(String name) throws IOException { + newDumpLevel(name, "UI32"); + long ret = readUI32Internal(); + endDumpLevel(ret); + return ret; + } + + /** + * Reads one UI32 (Unsigned 32bit integer) value from the stream + * + * @return UI32 value + * @throws IOException + */ + private long readUI32Internal() throws IOException { + return (readEx() + (readEx() << 8) + (readEx() << 16) + (readEx() << 24)) & 0xffffffff; + } + + /** + * Reads one UI16 (Unsigned 16bit integer) value from the stream + * + * @param name + * @return UI16 value + * @throws IOException + */ + public int readUI16(String name) throws IOException { + newDumpLevel(name, "UI16"); + int ret = readUI16Internal(); + endDumpLevel(ret); return ret; } @@ -467,101 +500,102 @@ public class SWFInputStream implements AutoCloseable { * @return UI16 value * @throws IOException */ - public int readUI16() throws IOException { - newDumpLevel("UI16"); - int ret = readEx() + (readEx() << 8); - endDumpLevel(); - return ret; + private int readUI16Internal() throws IOException { + return readEx() + (readEx() << 8); } - public int readUI24() throws IOException { - newDumpLevel("UI24"); + public int readUI24(String name) throws IOException { + newDumpLevel(name, "UI24"); int ret = readEx() + (readEx() << 8) + (readEx() << 16); - endDumpLevel(); + endDumpLevel(ret); return ret; } /** * Reads one SI32 (Signed 32bit integer) value from the stream * + * @param name * @return SI32 value * @throws IOException */ - public long readSI32() throws IOException { - newDumpLevel("SI32"); + public long readSI32(String name) throws IOException { + newDumpLevel(name, "SI32"); long uval = readEx() + (readEx() << 8) + (readEx() << 16) + (readEx() << 24); - endDumpLevel(); if (uval >= 0x80000000) { - return -(((~uval) & 0xffffffff) + 1); - } else { - return uval; + uval = -(((~uval) & 0xffffffff) + 1); } + endDumpLevel(uval); + return uval; } /** * Reads one SI16 (Signed 16bit integer) value from the stream * + * @param name * @return SI16 value * @throws IOException */ - public int readSI16() throws IOException { - newDumpLevel("SI16"); + public int readSI16(String name) throws IOException { + newDumpLevel(name, "SI16"); int uval = readEx() + (readEx() << 8); - endDumpLevel(); if (uval >= 0x8000) { - return -(((~uval) & 0xffff) + 1); - } else { - return uval; + uval = -(((~uval) & 0xffff) + 1); } + endDumpLevel(uval); + return uval; } /** * Reads one SI8 (Signed 8bit integer) value from the stream * + * @param name * @return SI8 value * @throws IOException */ - public int readSI8() throws IOException { - newDumpLevel("SI8"); + public int readSI8(String name) throws IOException { + newDumpLevel(name, "SI8"); int uval = readEx(); - endDumpLevel(); if (uval >= 0x80) { - return -(((~uval) & 0xff) + 1); - } else { - return uval; + uval = -(((~uval) & 0xff) + 1); } + endDumpLevel(uval); + return uval; } /** * Reads one FIXED (Fixed point 16.16) value from the stream * + * @param name * @return FIXED value * @throws IOException */ - public double readFIXED() throws IOException { - newDumpLevel("FIXED"); - int afterPoint = readUI16(); - int beforePoint = readUI16(); - endDumpLevel(); - return ((double) ((beforePoint << 16) + afterPoint)) / 65536; + public double readFIXED(String name) throws IOException { + newDumpLevel(name, "FIXED"); + int afterPoint = readUI16Internal(); + int beforePoint = readUI16Internal(); + double ret = ((double) ((beforePoint << 16) + afterPoint)) / 65536; + endDumpLevel(ret); + return ret; } /** * Reads one FIXED8 (Fixed point 8.8) value from the stream * + * @param name * @return FIXED8 value * @throws IOException */ - public float readFIXED8() throws IOException { - newDumpLevel("FIXED8"); + public float readFIXED8(String name) throws IOException { + newDumpLevel(name, "FIXED8"); int afterPoint = readEx(); int beforePoint = readEx(); - endDumpLevel(); - return beforePoint + (((float) afterPoint) / 256); + float ret = beforePoint + (((float) afterPoint) / 256); + endDumpLevel(ret); + return ret; } private long readLong() throws IOException { - byte[] readBuffer = readBytesEx(8); + byte[] readBuffer = readBytesInternalEx(8); return (((long) readBuffer[3] << 56) + ((long) (readBuffer[2] & 255) << 48) + ((long) (readBuffer[1] & 255) << 40) @@ -576,14 +610,15 @@ public class SWFInputStream implements AutoCloseable { * Reads one DOUBLE (double precision floating point value) value from the * stream * + * @param name * @return DOUBLE value * @throws IOException */ - public double readDOUBLE() throws IOException { - newDumpLevel("DOUBLE"); + public double readDOUBLE(String name) throws IOException { + newDumpLevel(name, "DOUBLE"); long el = readLong(); - endDumpLevel(); double ret = Double.longBitsToDouble(el); + endDumpLevel(ret); return ret; } @@ -591,12 +626,15 @@ public class SWFInputStream implements AutoCloseable { * Reads one FLOAT (single precision floating point value) value from the * stream * + * @param name * @return FLOAT value * @throws IOException */ - public float readFLOAT() throws IOException { - int val = (int) readUI32(); + public float readFLOAT(String name) throws IOException { + newDumpLevel(name, "FLOAT"); + int val = (int) readUI32Internal(); float ret = Float.intBitsToFloat(val); + endDumpLevel(ret); /*int sign = val >> 31; int mantisa = val & 0x3FFFFF; int exp = (val >> 22) & 0xFF; @@ -607,15 +645,36 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one FLOAT16 (16bit floating point value) value from the stream * + * @param name * @return FLOAT16 value * @throws IOException */ - public float readFLOAT16() throws IOException { - int val = readUI16(); + public float readFLOAT16(String name) throws IOException { + newDumpLevel(name, "FLOAT16"); + int val = readUI16Internal(); int sign = val >> 15; int mantisa = val & 0x3FF; int exp = (val >> 10) & 0x1F; float ret = (sign == 1 ? -1 : 1) * (float) Math.pow(2, exp) * (1 + ((mantisa) / (float) (1 << 10))); + endDumpLevel(ret); + return ret; + } + + /** + * Reads bytes from the stream + * + * @param count Number of bytes to read + * @param name + * @return Array of read bytes + * @throws IOException + */ + public byte[] readBytesEx(long count, String name) throws IOException { + if (count <= 0) { + return new byte[0]; + } + newDumpLevel(name, "bytes"); + byte[] ret = readBytesInternalEx(count); + endDumpLevel(); return ret; } @@ -626,19 +685,16 @@ public class SWFInputStream implements AutoCloseable { * @return Array of read bytes * @throws IOException */ - public byte[] readBytesEx(long count) throws IOException { + private byte[] readBytesInternalEx(long count) throws IOException { if (count <= 0) { return new byte[0]; } - newDumpLevel("bytes"); byte[] ret = new byte[(int) count]; for (int i = 0; i < count; i++) { ret[i] = (byte) readEx(); } - endDumpLevel(); return ret; } - /** * Skip bytes from the stream * @@ -660,14 +716,15 @@ public class SWFInputStream implements AutoCloseable { * Reads bytes from the stream * * @param count Number of bytes to read + * @param name * @return Array of read bytes * @throws IOException */ - public byte[] readBytes(int count) throws IOException { + public byte[] readBytes(int count, String name) throws IOException { if (count <= 0) { return new byte[0]; } - newDumpLevel("bytes"); + newDumpLevel(name, "bytes"); byte[] ret = new byte[count]; int i = 0; try { @@ -682,8 +739,10 @@ public class SWFInputStream implements AutoCloseable { return ret; } - public byte[] readBytesZlib(long count) throws IOException { - byte[] data = readBytesEx(count); + public byte[] readBytesZlib(long count, String name) throws IOException { + newDumpLevel(name, "bytesZlib"); + byte[] data = readBytesInternalEx(count); + endDumpLevel(); InflaterInputStream dis = new InflaterInputStream(new ByteArrayInputStream(data)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buf = new byte[4096]; @@ -697,33 +756,34 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one EncodedU32 (Encoded unsigned 32bit value) value from the stream * + * @param name * @return U32 value * @throws IOException */ - public long readEncodedU32() throws IOException { - newDumpLevel("encodedU32"); + public long readEncodedU32(String name) throws IOException { + newDumpLevel(name, "encodedU32"); int result = readEx(); if ((result & 0x00000080) == 0) { - endDumpLevel(); + endDumpLevel(result); return result; } result = (result & 0x0000007f) | (readEx()) << 7; if ((result & 0x00004000) == 0) { - endDumpLevel(); + endDumpLevel(result); return result; } result = (result & 0x00003fff) | (readEx()) << 14; if ((result & 0x00200000) == 0) { - endDumpLevel(); + endDumpLevel(result); return result; } result = (result & 0x001fffff) | (readEx()) << 21; if ((result & 0x10000000) == 0) { - endDumpLevel(); + endDumpLevel(result); return result; } result = (result & 0x0fffffff) | (readEx()) << 28; - endDumpLevel(); + endDumpLevel(result); return result; } private int bitPos = 0; @@ -733,10 +793,28 @@ public class SWFInputStream implements AutoCloseable { * Reads UB[nBits] (Unsigned-bit value) value from the stream * * @param nBits Number of bits which represent value + * @param name * @return Unsigned value * @throws IOException */ - public long readUB(int nBits) throws IOException { + public long readUB(int nBits, String name) throws IOException { + if (nBits == 0) { + return 0; + } + newDumpLevel(name, "UB"); + long ret = readUBInternal(nBits); + endDumpLevel(ret); + return ret; + } + + /** + * Reads UB[nBits] (Unsigned-bit value) value from the stream + * + * @param nBits Number of bits which represent value + * @return Unsigned value + * @throws IOException + */ + private long readUBInternal(int nBits) throws IOException { if (nBits == 0) { return 0; } @@ -744,7 +822,6 @@ public class SWFInputStream implements AutoCloseable { if (bitPos == 0) { tempByte = readNoBitReset(); } - newDumpLevel("UB"); for (int bit = 0; bit < nBits; bit++) { int nb = (tempByte >> (7 - bitPos)) & 1; ret += (nb << (nBits - 1 - bit)); @@ -756,7 +833,6 @@ public class SWFInputStream implements AutoCloseable { } } } - endDumpLevel(); return ret; } @@ -764,11 +840,26 @@ public class SWFInputStream implements AutoCloseable { * Reads SB[nBits] (Signed-bit value) value from the stream * * @param nBits Number of bits which represent value + * @param name * @return Signed value * @throws IOException */ - public long readSB(int nBits) throws IOException { - int uval = (int) readUB(nBits); + public long readSB(int nBits, String name) throws IOException { + newDumpLevel(name, "SB"); + long ret = readSBInternal(nBits); + endDumpLevel(ret); + return ret; + } + + /** + * Reads SB[nBits] (Signed-bit value) value from the stream + * + * @param nBits Number of bits which represent value + * @return Signed value + * @throws IOException + */ + private long readSBInternal(int nBits) throws IOException { + int uval = (int) readUBInternal(nBits); int shift = 32 - nBits; // sign extension @@ -780,32 +871,36 @@ public class SWFInputStream implements AutoCloseable { * Reads FB[nBits] (Signed fixed-point bit value) value from the stream * * @param nBits Number of bits which represent value + * @param name * @return Fixed-point value * @throws IOException */ - public float readFB(int nBits) throws IOException { + public float readFB(int nBits, String name) throws IOException { if (nBits == 0) { return 0; } - float val = readSB(nBits); + newDumpLevel(name, "FB"); + float val = readSBInternal(nBits); float ret = val / 0x10000; + endDumpLevel(ret); return ret; } /** * Reads one RECT value from the stream * + * @param name * @return RECT value * @throws IOException */ - public RECT readRECT() throws IOException { + public RECT readRECT(String name) throws IOException { RECT ret = new RECT(); - newDumpLevel("RECT"); - int NBits = (int) readUB(5); - ret.Xmin = (int) readSB(NBits); - ret.Xmax = (int) readSB(NBits); - ret.Ymin = (int) readSB(NBits); - ret.Ymax = (int) readSB(NBits); + newDumpLevel(name, "RECT"); + int NBits = (int) readUB(5, "NBits"); + ret.Xmin = (int) readSB(NBits, "Xmin"); + ret.Xmax = (int) readSB(NBits, "Xmax"); + ret.Ymin = (int) readSB(NBits, "Ymin"); + ret.Ymax = (int) readSB(NBits, "Ymax"); ret.nbits = NBits; alignByte(); endDumpLevel(); @@ -890,13 +985,16 @@ public class SWFInputStream implements AutoCloseable { boolean isAS3 = false; while (true) { long pos = getPos(); - newDumpLevel("TAG"); + newDumpLevel(null, "TAG"); try { tag = readTag(level, pos, parseTags && !parallel, parallel, skipUnusualTags, gfx); } catch (EOFException | EndOfStreamException ex) { tag = null; } - endDumpLevel(); + if (tag != null) { + dumpInfo.name = tag.getName(); + } + endDumpLevel(tag == null ? null : tag.getId()); if (tag == null) { break; } @@ -1289,7 +1387,7 @@ public class SWFInputStream implements AutoCloseable { * @throws java.lang.InterruptedException */ public Tag readTag(int level, long pos, boolean resolve, boolean parallel, boolean skipUnusualTags, boolean gfx) throws IOException, InterruptedException { - int tagIDTagLength = readUI16(); + int tagIDTagLength = readUI16("tagIDTagLength"); int tagID = (tagIDTagLength) >> 6; logger.log(Level.INFO, "Reading tag. ID={0}, position: {1}", new Object[]{tagID, pos}); @@ -1297,7 +1395,7 @@ public class SWFInputStream implements AutoCloseable { long tagLength = (tagIDTagLength & 0x003F); boolean readLong = false; if (tagLength == 0x3f) { - tagLength = readSI32(); + tagLength = readSI32("tagLength"); readLong = true; } int headerLength = readLong ? 6 : 2; @@ -1363,7 +1461,7 @@ public class SWFInputStream implements AutoCloseable { int actionCode = -1; try { - actionCode = readUI8(); + actionCode = readUI8("actionCode"); if (actionCode == 0) { return new ActionEnd(); } @@ -1372,7 +1470,7 @@ public class SWFInputStream implements AutoCloseable { } int actionLength = 0; if (actionCode >= 0x80) { - actionLength = readUI16(); + actionLength = readUI16("actionLength"); } switch (actionCode) { //SWF3 Actions @@ -1597,29 +1695,30 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one MATRIX value from the stream * + * @param name * @return MATRIX value * @throws IOException */ - public MATRIX readMatrix() throws IOException { + public MATRIX readMatrix(String name) throws IOException { MATRIX ret = new MATRIX(); - newDumpLevel("MATRIX"); - ret.hasScale = readUB(1) == 1; + newDumpLevel(name, "MATRIX"); + ret.hasScale = readUB(1, "hasScale") == 1; if (ret.hasScale) { - int NScaleBits = (int) readUB(5); - ret.scaleX = (int) readSB(NScaleBits); - ret.scaleY = (int) readSB(NScaleBits); + int NScaleBits = (int) readUB(5, "NScaleBits"); + ret.scaleX = (int) readSB(NScaleBits, "scaleX"); + ret.scaleY = (int) readSB(NScaleBits, "scaleY"); ret.nScaleBits = NScaleBits; } - ret.hasRotate = readUB(1) == 1; + ret.hasRotate = readUB(1, "hasRotate") == 1; if (ret.hasRotate) { - int NRotateBits = (int) readUB(5); - ret.rotateSkew0 = (int) readSB(NRotateBits); - ret.rotateSkew1 = (int) readSB(NRotateBits); + int NRotateBits = (int) readUB(5, "NRotateBits"); + ret.rotateSkew0 = (int) readSB(NRotateBits, "rotateSkew0"); + ret.rotateSkew1 = (int) readSB(NRotateBits, "rotateSkew1"); ret.nRotateBits = NRotateBits; } - int NTranslateBits = (int) readUB(5); - ret.translateX = (int) readSB(NTranslateBits); - ret.translateY = (int) readSB(NTranslateBits); + int NTranslateBits = (int) readUB(5, "NTranslateBits"); + ret.translateX = (int) readSB(NTranslateBits, "translateX"); + ret.translateY = (int) readSB(NTranslateBits, "translateY"); ret.nTranslateBits = NTranslateBits; alignByte(); endDumpLevel(); @@ -1629,27 +1728,28 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one CXFORMWITHALPHA value from the stream * + * @param name * @return CXFORMWITHALPHA value * @throws IOException */ - public CXFORMWITHALPHA readCXFORMWITHALPHA() throws IOException { + public CXFORMWITHALPHA readCXFORMWITHALPHA(String name) throws IOException { CXFORMWITHALPHA ret = new CXFORMWITHALPHA(); - newDumpLevel("CXFORMWITHALPHA"); - ret.hasAddTerms = readUB(1) == 1; - ret.hasMultTerms = readUB(1) == 1; - int Nbits = (int) readUB(4); + newDumpLevel(name, "CXFORMWITHALPHA"); + ret.hasAddTerms = readUB(1, "hasAddTerms") == 1; + ret.hasMultTerms = readUB(1, "hasMultTerms") == 1; + int Nbits = (int) readUB(4, "Nbits"); ret.nbits = Nbits; if (ret.hasMultTerms) { - ret.redMultTerm = (int) readSB(Nbits); - ret.greenMultTerm = (int) readSB(Nbits); - ret.blueMultTerm = (int) readSB(Nbits); - ret.alphaMultTerm = (int) readSB(Nbits); + ret.redMultTerm = (int) readSB(Nbits, "redMultTerm"); + ret.greenMultTerm = (int) readSB(Nbits, "greenMultTerm"); + ret.blueMultTerm = (int) readSB(Nbits, "blueMultTerm"); + ret.alphaMultTerm = (int) readSB(Nbits, "alphaMultTerm"); } if (ret.hasAddTerms) { - ret.redAddTerm = (int) readSB(Nbits); - ret.greenAddTerm = (int) readSB(Nbits); - ret.blueAddTerm = (int) readSB(Nbits); - ret.alphaAddTerm = (int) readSB(Nbits); + ret.redAddTerm = (int) readSB(Nbits, "redAddTerm"); + ret.greenAddTerm = (int) readSB(Nbits, "greenAddTerm"); + ret.blueAddTerm = (int) readSB(Nbits, "blueAddTerm"); + ret.alphaAddTerm = (int) readSB(Nbits, "alphaAddTerm"); } alignByte(); endDumpLevel(); @@ -1659,25 +1759,26 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one CXFORM value from the stream * + * @param name * @return CXFORM value * @throws IOException */ - public CXFORM readCXFORM() throws IOException { + public CXFORM readCXFORM(String name) throws IOException { CXFORM ret = new CXFORM(); - newDumpLevel("CXFORM"); - ret.hasAddTerms = readUB(1) == 1; - ret.hasMultTerms = readUB(1) == 1; - int Nbits = (int) readUB(4); + newDumpLevel(name, "CXFORM"); + ret.hasAddTerms = readUB(1, "hasAddTerms") == 1; + ret.hasMultTerms = readUB(1, "hasMultTerms") == 1; + int Nbits = (int) readUB(4, "Nbits"); ret.nbits = Nbits; if (ret.hasMultTerms) { - ret.redMultTerm = (int) readSB(Nbits); - ret.greenMultTerm = (int) readSB(Nbits); - ret.blueMultTerm = (int) readSB(Nbits); + ret.redMultTerm = (int) readSB(Nbits, "redMultTerm"); + ret.greenMultTerm = (int) readSB(Nbits, "greenMultTerm"); + ret.blueMultTerm = (int) readSB(Nbits, "blueMultTerm"); } if (ret.hasAddTerms) { - ret.redAddTerm = (int) readSB(Nbits); - ret.greenAddTerm = (int) readSB(Nbits); - ret.blueAddTerm = (int) readSB(Nbits); + ret.redAddTerm = (int) readSB(Nbits, "redAddTerm"); + ret.greenAddTerm = (int) readSB(Nbits, "greenAddTerm"); + ret.blueAddTerm = (int) readSB(Nbits, "blueAddTerm"); } alignByte(); endDumpLevel(); @@ -1687,34 +1788,35 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one CLIPEVENTFLAGS value from the stream * + * @param name * @return CLIPEVENTFLAGS value * @throws IOException */ - public CLIPEVENTFLAGS readCLIPEVENTFLAGS() throws IOException { + public CLIPEVENTFLAGS readCLIPEVENTFLAGS(String name) throws IOException { CLIPEVENTFLAGS ret = new CLIPEVENTFLAGS(); - newDumpLevel("CLIPEVENTFLAGS"); - ret.clipEventKeyUp = readUB(1) == 1; - ret.clipEventKeyDown = readUB(1) == 1; - ret.clipEventMouseUp = readUB(1) == 1; - ret.clipEventMouseDown = readUB(1) == 1; - ret.clipEventMouseMove = readUB(1) == 1; - ret.clipEventUnload = readUB(1) == 1; - ret.clipEventEnterFrame = readUB(1) == 1; - ret.clipEventLoad = readUB(1) == 1; - ret.clipEventDragOver = readUB(1) == 1; - ret.clipEventRollOut = readUB(1) == 1; - ret.clipEventRollOver = readUB(1) == 1; - ret.clipEventReleaseOutside = readUB(1) == 1; - ret.clipEventRelease = readUB(1) == 1; - ret.clipEventPress = readUB(1) == 1; - ret.clipEventInitialize = readUB(1) == 1; - ret.clipEventData = readUB(1) == 1; + newDumpLevel(name, "CLIPEVENTFLAGS"); + ret.clipEventKeyUp = readUB(1, "clipEventKeyUp") == 1; + ret.clipEventKeyDown = readUB(1, "clipEventKeyDown") == 1; + ret.clipEventMouseUp = readUB(1, "clipEventMouseUp") == 1; + ret.clipEventMouseDown = readUB(1, "clipEventMouseDown") == 1; + ret.clipEventMouseMove = readUB(1, "clipEventMouseMove") == 1; + ret.clipEventUnload = readUB(1, "clipEventUnload") == 1; + ret.clipEventEnterFrame = readUB(1, "clipEventEnterFrame") == 1; + ret.clipEventLoad = readUB(1, "clipEventLoad") == 1; + ret.clipEventDragOver = readUB(1, "clipEventDragOver") == 1; + ret.clipEventRollOut = readUB(1, "clipEventRollOut") == 1; + ret.clipEventRollOver = readUB(1, "clipEventRollOver") == 1; + ret.clipEventReleaseOutside = readUB(1, "clipEventReleaseOutside") == 1; + ret.clipEventRelease = readUB(1, "clipEventRelease") == 1; + ret.clipEventPress = readUB(1, "clipEventPress") == 1; + ret.clipEventInitialize = readUB(1, "clipEventInitialize") == 1; + ret.clipEventData = readUB(1, "clipEventData") == 1; if (swf.version >= 6) { - ret.reserved = (int) readUB(5); - ret.clipEventConstruct = readUB(1) == 1; - ret.clipEventKeyPress = readUB(1) == 1; - ret.clipEventDragOut = readUB(1) == 1; - ret.reserved2 = (int) readUB(8); + ret.reserved = (int) readUB(5, "reserved"); + ret.clipEventConstruct = readUB(1, "clipEventConstruct") == 1; + ret.clipEventKeyPress = readUB(1, "clipEventKeyPress") == 1; + ret.clipEventDragOut = readUB(1, "clipEventDragOut") == 1; + ret.reserved2 = (int) readUB(8, "reserved2"); } endDumpLevel(); return ret; @@ -1725,11 +1827,12 @@ public class SWFInputStream implements AutoCloseable { * * @param swf * @param tag + * @param name * @return CLIPACTIONRECORD value * @throws IOException */ - public CLIPACTIONRECORD readCLIPACTIONRECORD(SWF swf, Tag tag) throws IOException { - newDumpLevel("CLIPACTIONRECORD"); + public CLIPACTIONRECORD readCLIPACTIONRECORD(SWF swf, Tag tag, String name) throws IOException { + newDumpLevel(name, "CLIPACTIONRECORD"); CLIPACTIONRECORD ret = new CLIPACTIONRECORD(swf, this, getPos(), tag); endDumpLevel(); if (ret.eventFlags.isClear()) { @@ -1743,17 +1846,18 @@ public class SWFInputStream implements AutoCloseable { * * @param swf * @param tag + * @param name * @return CLIPACTIONS value * @throws IOException */ - public CLIPACTIONS readCLIPACTIONS(SWF swf, Tag tag) throws IOException { + public CLIPACTIONS readCLIPACTIONS(SWF swf, Tag tag, String name) throws IOException { CLIPACTIONS ret = new CLIPACTIONS(); - newDumpLevel("CLIPACTIONS"); - ret.reserved = readUI16(); - ret.allEventFlags = readCLIPEVENTFLAGS(); + newDumpLevel(name, "CLIPACTIONS"); + ret.reserved = readUI16("reserved"); + ret.allEventFlags = readCLIPEVENTFLAGS("allEventFlags"); CLIPACTIONRECORD cr; ret.clipActionRecords = new ArrayList<>(); - while ((cr = readCLIPACTIONRECORD(swf, tag)) != null) { + while ((cr = readCLIPACTIONRECORD(swf, tag, "record")) != null) { ret.clipActionRecords.add(cr); } endDumpLevel(); @@ -1763,15 +1867,16 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one COLORMATRIXFILTER value from the stream * + * @param name * @return COLORMATRIXFILTER value * @throws IOException */ - public COLORMATRIXFILTER readCOLORMATRIXFILTER() throws IOException { + public COLORMATRIXFILTER readCOLORMATRIXFILTER(String name) throws IOException { COLORMATRIXFILTER ret = new COLORMATRIXFILTER(); - newDumpLevel("COLORMATRIXFILTER"); + newDumpLevel(name, "COLORMATRIXFILTER"); ret.matrix = new float[20]; for (int i = 0; i < 20; i++) { - ret.matrix[i] = readFLOAT(); + ret.matrix[i] = readFLOAT("cell"); } endDumpLevel(); return ret; @@ -1780,16 +1885,17 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one RGBA value from the stream * + * @param name * @return RGBA value * @throws IOException */ - public RGBA readRGBA() throws IOException { + public RGBA readRGBA(String name) throws IOException { RGBA ret = new RGBA(); - newDumpLevel("RGBA"); - ret.red = readUI8(); - ret.green = readUI8(); - ret.blue = readUI8(); - ret.alpha = readUI8(); + newDumpLevel(name, "RGBA"); + ret.red = readUI8("red"); + ret.green = readUI8("green"); + ret.blue = readUI8("blue"); + ret.alpha = readUI8("alpha"); endDumpLevel(); return ret; } @@ -1797,16 +1903,17 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one ARGB value from the stream * + * @param name * @return ARGB value * @throws IOException */ - public ARGB readARGB() throws IOException { + public ARGB readARGB(String name) throws IOException { ARGB ret = new ARGB(); - newDumpLevel("ARGB"); - ret.alpha = readUI8(); - ret.red = readUI8(); - ret.green = readUI8(); - ret.blue = readUI8(); + newDumpLevel(name, "ARGB"); + ret.alpha = readUI8("alpha"); + ret.red = readUI8("red"); + ret.green = readUI8("green"); + ret.blue = readUI8("blue"); endDumpLevel(); return ret; } @@ -1814,15 +1921,16 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one RGB value from the stream * + * @param name * @return RGB value * @throws IOException */ - public RGB readRGB() throws IOException { + public RGB readRGB(String name) throws IOException { RGB ret = new RGB(); - newDumpLevel("RGB"); - ret.red = readUI8(); - ret.green = readUI8(); - ret.blue = readUI8(); + newDumpLevel(name, "RGB"); + ret.red = readUI8("red"); + ret.green = readUI8("green"); + ret.blue = readUI8("blue"); endDumpLevel(); return ret; } @@ -1830,26 +1938,27 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one CONVOLUTIONFILTER value from the stream * + * @param name * @return CONVOLUTIONFILTER value * @throws IOException */ - public CONVOLUTIONFILTER readCONVOLUTIONFILTER() throws IOException { + public CONVOLUTIONFILTER readCONVOLUTIONFILTER(String name) throws IOException { CONVOLUTIONFILTER ret = new CONVOLUTIONFILTER(); - newDumpLevel("CONVOLUTIONFILTER"); - ret.matrixX = readUI8(); - ret.matrixY = readUI8(); - ret.divisor = readFLOAT(); - ret.bias = readFLOAT(); + newDumpLevel(name, "CONVOLUTIONFILTER"); + ret.matrixX = readUI8("matrixX"); + ret.matrixY = readUI8("matrixY"); + ret.divisor = readFLOAT("divisor"); + ret.bias = readFLOAT("bias"); ret.matrix = new float[ret.matrixX][ret.matrixY]; for (int x = 0; x < ret.matrixX; x++) { for (int y = 0; y < ret.matrixY; y++) { - ret.matrix[x][y] = readFLOAT(); + ret.matrix[x][y] = readFLOAT("cell"); } } - ret.defaultColor = readRGBA(); - ret.reserved = (int) readUB(6); - ret.clamp = readUB(1) == 1; - ret.preserveAlpha = readUB(1) == 1; + ret.defaultColor = readRGBA("defaultColor"); + ret.reserved = (int) readUB(6, "reserved"); + ret.clamp = readUB(1, "clamp") == 1; + ret.preserveAlpha = readUB(1, "preserveAlpha") == 1; endDumpLevel(); return ret; } @@ -1857,16 +1966,17 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one BLURFILTER value from the stream * + * @param name * @return BLURFILTER value * @throws IOException */ - public BLURFILTER readBLURFILTER() throws IOException { + public BLURFILTER readBLURFILTER(String name) throws IOException { BLURFILTER ret = new BLURFILTER(); - newDumpLevel("BLURFILTER"); - ret.blurX = readFIXED(); - ret.blurY = readFIXED(); - ret.passes = (int) readUB(5); - ret.reserved = (int) readUB(3); + newDumpLevel(name, "BLURFILTER"); + ret.blurX = readFIXED("blurX"); + ret.blurY = readFIXED("blurY"); + ret.passes = (int) readUB(5, "passes"); + ret.reserved = (int) readUB(3, "reserved"); endDumpLevel(); return ret; } @@ -1874,22 +1984,23 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one DROPSHADOWFILTER value from the stream * + * @param name * @return DROPSHADOWFILTER value * @throws IOException */ - public DROPSHADOWFILTER readDROPSHADOWFILTER() throws IOException { + public DROPSHADOWFILTER readDROPSHADOWFILTER(String name) throws IOException { DROPSHADOWFILTER ret = new DROPSHADOWFILTER(); - newDumpLevel("DROPSHADOWFILTER"); - ret.dropShadowColor = readRGBA(); - ret.blurX = readFIXED(); - ret.blurY = readFIXED(); - ret.angle = readFIXED(); - ret.distance = readFIXED(); - ret.strength = readFIXED8(); - ret.innerShadow = readUB(1) == 1; - ret.knockout = readUB(1) == 1; - ret.compositeSource = readUB(1) == 1; - ret.passes = (int) readUB(5); + newDumpLevel(name, "DROPSHADOWFILTER"); + ret.dropShadowColor = readRGBA("dropShadowColor"); + ret.blurX = readFIXED("blurX"); + ret.blurY = readFIXED("blurY"); + ret.angle = readFIXED("angle"); + ret.distance = readFIXED("distance"); + ret.strength = readFIXED8("strength"); + ret.innerShadow = readUB(1, "innerShadow") == 1; + ret.knockout = readUB(1, "knockout") == 1; + ret.compositeSource = readUB(1, "compositeSource") == 1; + ret.passes = (int) readUB(5, "passes"); endDumpLevel(); return ret; } @@ -1897,20 +2008,21 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one GLOWFILTER value from the stream * + * @param name * @return GLOWFILTER value * @throws IOException */ - public GLOWFILTER readGLOWFILTER() throws IOException { + public GLOWFILTER readGLOWFILTER(String name) throws IOException { GLOWFILTER ret = new GLOWFILTER(); - newDumpLevel("GLOWFILTER"); - ret.glowColor = readRGBA(); - ret.blurX = readFIXED(); - ret.blurY = readFIXED(); - ret.strength = readFIXED8(); - ret.innerGlow = readUB(1) == 1; - ret.knockout = readUB(1) == 1; - ret.compositeSource = readUB(1) == 1; - ret.passes = (int) readUB(5); + newDumpLevel(name, "GLOWFILTER"); + ret.glowColor = readRGBA("glowColor"); + ret.blurX = readFIXED("blurX"); + ret.blurY = readFIXED("blurY"); + ret.strength = readFIXED8("strength"); + ret.innerGlow = readUB(1, "innerGlow") == 1; + ret.knockout = readUB(1, "knockout") == 1; + ret.compositeSource = readUB(1, "compositeSource") == 1; + ret.passes = (int) readUB(5, "passes"); endDumpLevel(); return ret; } @@ -1918,24 +2030,25 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one BEVELFILTER value from the stream * + * @param name * @return BEVELFILTER value * @throws IOException */ - public BEVELFILTER readBEVELFILTER() throws IOException { + public BEVELFILTER readBEVELFILTER(String name) throws IOException { BEVELFILTER ret = new BEVELFILTER(); - newDumpLevel("BEVELFILTER"); - ret.highlightColor = readRGBA(); //Highlight color first. It it opposite of the documentation - ret.shadowColor = readRGBA(); - ret.blurX = readFIXED(); - ret.blurY = readFIXED(); - ret.angle = readFIXED(); - ret.distance = readFIXED(); - ret.strength = readFIXED8(); - ret.innerShadow = readUB(1) == 1; - ret.knockout = readUB(1) == 1; - ret.compositeSource = readUB(1) == 1; - ret.onTop = readUB(1) == 1; - ret.passes = (int) readUB(4); + newDumpLevel(name, "BEVELFILTER"); + ret.highlightColor = readRGBA("highlightColor"); //Highlight color first. It it opposite of the documentation + ret.shadowColor = readRGBA("shadowColor"); + ret.blurX = readFIXED("blurX"); + ret.blurY = readFIXED("blurY"); + ret.angle = readFIXED("angle"); + ret.distance = readFIXED("distance"); + ret.strength = readFIXED8("strength"); + ret.innerShadow = readUB(1, "innerShadow") == 1; + ret.knockout = readUB(1, "knockout") == 1; + ret.compositeSource = readUB(1, "compositeSource") == 1; + ret.onTop = readUB(1, "onTop") == 1; + ret.passes = (int) readUB(4, "passes"); endDumpLevel(); return ret; } @@ -1943,31 +2056,32 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one GRADIENTGLOWFILTER value from the stream * + * @param name * @return GRADIENTGLOWFILTER value * @throws IOException */ - public GRADIENTGLOWFILTER readGRADIENTGLOWFILTER() throws IOException { + public GRADIENTGLOWFILTER readGRADIENTGLOWFILTER(String name) throws IOException { GRADIENTGLOWFILTER ret = new GRADIENTGLOWFILTER(); - newDumpLevel("GRADIENTGLOWFILTER"); - int numColors = readUI8(); + newDumpLevel(name, "GRADIENTGLOWFILTER"); + int numColors = readUI8("numColors"); ret.gradientColors = new RGBA[numColors]; ret.gradientRatio = new int[numColors]; for (int i = 0; i < numColors; i++) { - ret.gradientColors[i] = readRGBA(); + ret.gradientColors[i] = readRGBA("gradientColor"); } for (int i = 0; i < numColors; i++) { - ret.gradientRatio[i] = readUI8(); + ret.gradientRatio[i] = readUI8("gradientRatio"); } - ret.blurX = readFIXED(); - ret.blurY = readFIXED(); - ret.angle = readFIXED(); - ret.distance = readFIXED(); - ret.strength = readFIXED8(); - ret.innerShadow = readUB(1) == 1; - ret.knockout = readUB(1) == 1; - ret.compositeSource = readUB(1) == 1; - ret.onTop = readUB(1) == 1; - ret.passes = (int) readUB(4); + ret.blurX = readFIXED("blurX"); + ret.blurY = readFIXED("blurY"); + ret.angle = readFIXED("angle"); + ret.distance = readFIXED("distance"); + ret.strength = readFIXED8("strength"); + ret.innerShadow = readUB(1, "innerShadow") == 1; + ret.knockout = readUB(1, "knockout") == 1; + ret.compositeSource = readUB(1, "compositeSource") == 1; + ret.onTop = readUB(1, "onTop") == 1; + ret.passes = (int) readUB(4, "passes"); endDumpLevel(); return ret; } @@ -1975,31 +2089,32 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one GRADIENTBEVELFILTER value from the stream * + * @param name * @return GRADIENTBEVELFILTER value * @throws IOException */ - public GRADIENTBEVELFILTER readGRADIENTBEVELFILTER() throws IOException { + public GRADIENTBEVELFILTER readGRADIENTBEVELFILTER(String name) throws IOException { GRADIENTBEVELFILTER ret = new GRADIENTBEVELFILTER(); - newDumpLevel("GRADIENTBEVELFILTER"); - int numColors = readUI8(); + newDumpLevel(name, "GRADIENTBEVELFILTER"); + int numColors = readUI8("numColors"); ret.gradientColors = new RGBA[numColors]; ret.gradientRatio = new int[numColors]; for (int i = 0; i < numColors; i++) { - ret.gradientColors[i] = readRGBA(); + ret.gradientColors[i] = readRGBA("gradientColor"); } for (int i = 0; i < numColors; i++) { - ret.gradientRatio[i] = readUI8(); + ret.gradientRatio[i] = readUI8("gradientRatio"); } - ret.blurX = readFIXED(); - ret.blurY = readFIXED(); - ret.angle = readFIXED(); - ret.distance = readFIXED(); - ret.strength = readFIXED8(); - ret.innerShadow = readUB(1) == 1; - ret.knockout = readUB(1) == 1; - ret.compositeSource = readUB(1) == 1; - ret.onTop = readUB(1) == 1; - ret.passes = (int) readUB(4); + ret.blurX = readFIXED("blurX"); + ret.blurY = readFIXED("blurY"); + ret.angle = readFIXED("angle"); + ret.distance = readFIXED("distance"); + ret.strength = readFIXED8("strength"); + ret.innerShadow = readUB(1, "innerShadow") == 1; + ret.knockout = readUB(1, "knockout") == 1; + ret.compositeSource = readUB(1, "compositeSource") == 1; + ret.onTop = readUB(1, "onTop") == 1; + ret.passes = (int) readUB(4, "passes"); endDumpLevel(); return ret; } @@ -2007,15 +2122,16 @@ public class SWFInputStream implements AutoCloseable { /** * Reads list of FILTER values from the stream * + * @param name * @return List of FILTER values * @throws IOException */ - public List readFILTERLIST() throws IOException { + public List readFILTERLIST(String name) throws IOException { List ret = new ArrayList<>(); - newDumpLevel("FILTERLIST"); - int numberOfFilters = readUI8(); + newDumpLevel(name, "FILTERLIST"); + int numberOfFilters = readUI8("numberOfFilters"); for (int i = 0; i < numberOfFilters; i++) { - ret.add(readFILTER()); + ret.add(readFILTER("filter")); } endDumpLevel(); return ret; @@ -2024,37 +2140,38 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one FILTER value from the stream * + * @param name * @return FILTER value * @throws IOException */ - public FILTER readFILTER() throws IOException { - newDumpLevel("FILTER"); - int filterId = readUI8(); + public FILTER readFILTER(String name) throws IOException { + newDumpLevel(name, "FILTER"); + int filterId = readUI8("filterId"); FILTER ret = null; switch (filterId) { case 0: - ret = readDROPSHADOWFILTER(); + ret = readDROPSHADOWFILTER("filter"); break; case 1: - ret = readBLURFILTER(); + ret = readBLURFILTER("filter"); break; case 2: - ret = readGLOWFILTER(); + ret = readGLOWFILTER("filter"); break; case 3: - ret = readBEVELFILTER(); + ret = readBEVELFILTER("filter"); break; case 4: - ret = readGRADIENTGLOWFILTER(); + ret = readGRADIENTGLOWFILTER("filter"); break; case 5: - ret = readCONVOLUTIONFILTER(); + ret = readCONVOLUTIONFILTER("filter"); break; case 6: - ret = readCOLORMATRIXFILTER(); + ret = readCOLORMATRIXFILTER("filter"); break; case 7: - ret = readGRADIENTBEVELFILTER(); + ret = readGRADIENTBEVELFILTER("filter"); break; } endDumpLevel(); @@ -2066,14 +2183,15 @@ public class SWFInputStream implements AutoCloseable { * * @param inDefineButton2 Whether read from inside of DefineButton2Tag or * not + * @param name * @return List of BUTTONRECORD values * @throws IOException */ - public List readBUTTONRECORDList(boolean inDefineButton2) throws IOException { + public List readBUTTONRECORDList(boolean inDefineButton2, String name) throws IOException { List ret = new ArrayList<>(); - newDumpLevel("BUTTONRECORDList"); + newDumpLevel(name, "BUTTONRECORDList"); BUTTONRECORD br; - while ((br = readBUTTONRECORD(inDefineButton2)) != null) { + while ((br = readBUTTONRECORD(inDefineButton2, "record")) != null) { ret.add(br); } endDumpLevel(); @@ -2084,19 +2202,20 @@ public class SWFInputStream implements AutoCloseable { * Reads one BUTTONRECORD value from the stream * * @param inDefineButton2 True when in DefineButton2 + * @param name * @return BUTTONRECORD value * @throws IOException */ - public BUTTONRECORD readBUTTONRECORD(boolean inDefineButton2) throws IOException { + public BUTTONRECORD readBUTTONRECORD(boolean inDefineButton2, String name) throws IOException { BUTTONRECORD ret = new BUTTONRECORD(); - newDumpLevel("BUTTONRECORD"); - ret.reserved = (int) readUB(2); - ret.buttonHasBlendMode = readUB(1) == 1; - ret.buttonHasFilterList = readUB(1) == 1; - ret.buttonStateHitTest = readUB(1) == 1; - ret.buttonStateDown = readUB(1) == 1; - ret.buttonStateOver = readUB(1) == 1; - ret.buttonStateUp = readUB(1) == 1; + newDumpLevel(name, "BUTTONRECORD"); + ret.reserved = (int) readUB(2, "reserved"); + ret.buttonHasBlendMode = readUB(1, "buttonHasBlendMode") == 1; + ret.buttonHasFilterList = readUB(1, "buttonHasFilterList") == 1; + ret.buttonStateHitTest = readUB(1, "buttonStateHitTest") == 1; + ret.buttonStateDown = readUB(1, "buttonStateDown") == 1; + ret.buttonStateOver = readUB(1, "buttonStateOver") == 1; + ret.buttonStateUp = readUB(1, "buttonStateUp") == 1; if (!ret.buttonHasBlendMode && !ret.buttonHasFilterList && !ret.buttonStateHitTest && !ret.buttonStateDown @@ -2104,16 +2223,16 @@ public class SWFInputStream implements AutoCloseable { return null; } - ret.characterId = readUI16(); - ret.placeDepth = readUI16(); - ret.placeMatrix = readMatrix(); + ret.characterId = readUI16("characterId"); + ret.placeDepth = readUI16("placeDepth"); + ret.placeMatrix = readMatrix("placeMatrix"); if (inDefineButton2) { - ret.colorTransform = readCXFORMWITHALPHA(); + ret.colorTransform = readCXFORMWITHALPHA("colorTransform"); if (ret.buttonHasFilterList) { - ret.filterList = readFILTERLIST(); + ret.filterList = readFILTERLIST("filterList"); } if (ret.buttonHasBlendMode) { - ret.blendMode = readUI8(); + ret.blendMode = readUI8("blendMode"); } } endDumpLevel(); @@ -2125,14 +2244,15 @@ public class SWFInputStream implements AutoCloseable { * * @param swf * @param tag + * @param name * @return List of BUTTONCONDACTION values * @throws IOException */ - public List readBUTTONCONDACTIONList(SWF swf, Tag tag) throws IOException { + public List readBUTTONCONDACTIONList(SWF swf, Tag tag, String name) throws IOException { List ret = new ArrayList<>(); - newDumpLevel("BUTTONCONDACTIONList"); + newDumpLevel(name, "BUTTONCONDACTIONList"); BUTTONCONDACTION bc; - while (!(bc = readBUTTONCONDACTION(swf, tag)).isLast) { + while (!(bc = readBUTTONCONDACTION(swf, tag, "action")).isLast) { ret.add(bc); } ret.add(bc); @@ -2145,11 +2265,12 @@ public class SWFInputStream implements AutoCloseable { * * @param swf * @param tag + * @param name * @return BUTTONCONDACTION value * @throws IOException */ - public BUTTONCONDACTION readBUTTONCONDACTION(SWF swf, Tag tag) throws IOException { - newDumpLevel("BUTTONCONDACTION"); + public BUTTONCONDACTION readBUTTONCONDACTION(SWF swf, Tag tag, String name) throws IOException { + newDumpLevel(name, "BUTTONCONDACTION"); BUTTONCONDACTION ret = new BUTTONCONDACTION(swf, this, getPos(), tag); //ret.actions = readActionList(); endDumpLevel(); @@ -2160,17 +2281,18 @@ public class SWFInputStream implements AutoCloseable { * Reads one GRADRECORD value from the stream * * @param shapeNum 1 in DefineShape, 2 in DefineShape2... + * @param name * @return GRADRECORD value * @throws IOException */ - public GRADRECORD readGRADRECORD(int shapeNum) throws IOException { + public GRADRECORD readGRADRECORD(int shapeNum, String name) throws IOException { GRADRECORD ret = new GRADRECORD(); - newDumpLevel("GRADRECORD"); - ret.ratio = readUI8(); + newDumpLevel(name, "GRADRECORD"); + ret.ratio = readUI8("ratio"); if (shapeNum >= 3) { - ret.color = readRGBA(); + ret.color = readRGBA("color"); } else { - ret.color = readRGB(); + ret.color = readRGB("color"); } endDumpLevel(); return ret; @@ -2180,18 +2302,19 @@ public class SWFInputStream implements AutoCloseable { * Reads one GRADIENT value from the stream * * @param shapeNum 1 in DefineShape, 2 in DefineShape2... + * @param name * @return GRADIENT value * @throws IOException */ - public GRADIENT readGRADIENT(int shapeNum) throws IOException { + public GRADIENT readGRADIENT(int shapeNum, String name) throws IOException { GRADIENT ret = new GRADIENT(); - newDumpLevel("GRADIENT"); - ret.spreadMode = (int) readUB(2); - ret.interpolationMode = (int) readUB(2); - int numGradients = (int) readUB(4); + newDumpLevel(name, "GRADIENT"); + ret.spreadMode = (int) readUB(2, "spreadMode"); + ret.interpolationMode = (int) readUB(2, "interpolationMode"); + int numGradients = (int) readUB(4, "numGradients"); ret.gradientRecords = new GRADRECORD[numGradients]; for (int i = 0; i < numGradients; i++) { - ret.gradientRecords[i] = readGRADRECORD(shapeNum); + ret.gradientRecords[i] = readGRADRECORD(shapeNum, "gradientRecord"); } endDumpLevel(); @@ -2202,20 +2325,21 @@ public class SWFInputStream implements AutoCloseable { * Reads one FOCALGRADIENT value from the stream * * @param shapeNum 1 in DefineShape, 2 in DefineShape2... + * @param name * @return FOCALGRADIENT value * @throws IOException */ - public FOCALGRADIENT readFOCALGRADIENT(int shapeNum) throws IOException { + public FOCALGRADIENT readFOCALGRADIENT(int shapeNum, String name) throws IOException { FOCALGRADIENT ret = new FOCALGRADIENT(); - newDumpLevel("FOCALGRADIENT"); - ret.spreadMode = (int) readUB(2); - ret.interpolationMode = (int) readUB(2); - int numGradients = (int) readUB(4); + newDumpLevel(name, "FOCALGRADIENT"); + ret.spreadMode = (int) readUB(2, "spreadMode"); + ret.interpolationMode = (int) readUB(2, "interpolationMode"); + int numGradients = (int) readUB(4, "numGradients"); ret.gradientRecords = new GRADRECORD[numGradients]; for (int i = 0; i < numGradients; i++) { - ret.gradientRecords[i] = readGRADRECORD(shapeNum); + ret.gradientRecords[i] = readGRADRECORD(shapeNum, "gradientRecord"); } - ret.focalPoint = readFIXED8(); + ret.focalPoint = readFIXED8("focalPoint"); endDumpLevel(); return ret; } @@ -2224,39 +2348,40 @@ public class SWFInputStream implements AutoCloseable { * Reads one FILLSTYLE value from the stream * * @param shapeNum 1 in DefineShape, 2 in DefineShape2... + * @param name * @return FILLSTYLE value * @throws IOException */ - public FILLSTYLE readFILLSTYLE(int shapeNum) throws IOException { + public FILLSTYLE readFILLSTYLE(int shapeNum, String name) throws IOException { FILLSTYLE ret = new FILLSTYLE(); - newDumpLevel("FILLSTYLE"); - ret.fillStyleType = readUI8(); + newDumpLevel(name, "FILLSTYLE"); + ret.fillStyleType = readUI8("fillStyleType"); if (ret.fillStyleType == FILLSTYLE.SOLID) { if (shapeNum >= 3) { - ret.color = readRGBA(); + ret.color = readRGBA("color"); } else { - ret.color = readRGB(); + ret.color = readRGB("color"); } } if ((ret.fillStyleType == FILLSTYLE.LINEAR_GRADIENT) || (ret.fillStyleType == FILLSTYLE.RADIAL_GRADIENT) || (ret.fillStyleType == FILLSTYLE.FOCAL_RADIAL_GRADIENT)) { - ret.gradientMatrix = readMatrix(); + ret.gradientMatrix = readMatrix("gradientMatrix"); } if ((ret.fillStyleType == FILLSTYLE.LINEAR_GRADIENT) || (ret.fillStyleType == FILLSTYLE.RADIAL_GRADIENT)) { - ret.gradient = readGRADIENT(shapeNum); + ret.gradient = readGRADIENT(shapeNum, "gradient"); } if (ret.fillStyleType == FILLSTYLE.FOCAL_RADIAL_GRADIENT) { - ret.gradient = readFOCALGRADIENT(shapeNum); + ret.gradient = readFOCALGRADIENT(shapeNum, "gradient"); } if ((ret.fillStyleType == FILLSTYLE.REPEATING_BITMAP) || (ret.fillStyleType == FILLSTYLE.CLIPPED_BITMAP) || (ret.fillStyleType == FILLSTYLE.NON_SMOOTHED_REPEATING_BITMAP) || (ret.fillStyleType == FILLSTYLE.NON_SMOOTHED_CLIPPED_BITMAP)) { - ret.bitmapId = readUI16(); - ret.bitmapMatrix = readMatrix(); + ret.bitmapId = readUI16("bitmapId"); + ret.bitmapMatrix = readMatrix("bitmapMatrix"); } endDumpLevel(); return ret; @@ -2266,20 +2391,21 @@ public class SWFInputStream implements AutoCloseable { * Reads one FILLSTYLEARRAY value from the stream * * @param shapeNum 1 in DefineShape, 2 in DefineShape2... + * @param name * @return FILLSTYLEARRAY value * @throws IOException */ - public FILLSTYLEARRAY readFILLSTYLEARRAY(int shapeNum) throws IOException { + public FILLSTYLEARRAY readFILLSTYLEARRAY(int shapeNum, String name) throws IOException { FILLSTYLEARRAY ret = new FILLSTYLEARRAY(); - newDumpLevel("FILLSTYLEARRAY"); - int fillStyleCount = readUI8(); + newDumpLevel(name, "FILLSTYLEARRAY"); + int fillStyleCount = readUI8("fillStyleCount"); if (((shapeNum == 2) || (shapeNum == 3) || (shapeNum == 4/*?*/)) && (fillStyleCount == 0xff)) { - fillStyleCount = readUI16(); + fillStyleCount = readUI16("fillStyleCount"); } ret.fillStyles = new FILLSTYLE[fillStyleCount]; for (int i = 0; i < fillStyleCount; i++) { - ret.fillStyles[i] = readFILLSTYLE(shapeNum); + ret.fillStyles[i] = readFILLSTYLE(shapeNum, "fillStyle"); } endDumpLevel(); return ret; @@ -2289,18 +2415,19 @@ public class SWFInputStream implements AutoCloseable { * Reads one LINESTYLE value from the stream * * @param shapeNum 1 in DefineShape, 2 in DefineShape2... + * @param name * @return LINESTYLE value * @throws IOException */ - public LINESTYLE readLINESTYLE(int shapeNum) throws IOException { + public LINESTYLE readLINESTYLE(int shapeNum, String name) throws IOException { LINESTYLE ret = new LINESTYLE(); - newDumpLevel("LINESTYLE"); - ret.width = readUI16(); + newDumpLevel(name, "LINESTYLE"); + ret.width = readUI16("width"); if ((shapeNum == 1) || (shapeNum == 2)) { - ret.color = readRGB(); + ret.color = readRGB("color"); } if (shapeNum == 3) { - ret.color = readRGBA(); + ret.color = readRGBA("color"); } endDumpLevel(); return ret; @@ -2310,29 +2437,30 @@ public class SWFInputStream implements AutoCloseable { * Reads one LINESTYLE2 value from the stream * * @param shapeNum 1 in DefineShape, 2 in DefineShape2... + * @param name * @return LINESTYLE2 value * @throws IOException */ - public LINESTYLE2 readLINESTYLE2(int shapeNum) throws IOException { + public LINESTYLE2 readLINESTYLE2(int shapeNum, String name) throws IOException { LINESTYLE2 ret = new LINESTYLE2(); - newDumpLevel("LINESTYLE2"); - ret.width = readUI16(); - ret.startCapStyle = (int) readUB(2); - ret.joinStyle = (int) readUB(2); - ret.hasFillFlag = (int) readUB(1) == 1; - ret.noHScaleFlag = (int) readUB(1) == 1; - ret.noVScaleFlag = (int) readUB(1) == 1; - ret.pixelHintingFlag = (int) readUB(1) == 1; - ret.reserved = (int) readUB(5); - ret.noClose = (int) readUB(1) == 1; - ret.endCapStyle = (int) readUB(2); + newDumpLevel(name, "LINESTYLE2"); + ret.width = readUI16("width"); + ret.startCapStyle = (int) readUB(2, "startCapStyle"); + ret.joinStyle = (int) readUB(2, "joinStyle"); + ret.hasFillFlag = (int) readUB(1, "hasFillFlag") == 1; + ret.noHScaleFlag = (int) readUB(1, "noHScaleFlag") == 1; + ret.noVScaleFlag = (int) readUB(1, "noVScaleFlag") == 1; + ret.pixelHintingFlag = (int) readUB(1, "pixelHintingFlag") == 1; + ret.reserved = (int) readUB(5, "reserved"); + ret.noClose = (int) readUB(1, "noClose") == 1; + ret.endCapStyle = (int) readUB(2, "endCapStyle"); if (ret.joinStyle == LINESTYLE2.MITER_JOIN) { - ret.miterLimitFactor = readUI16(); + ret.miterLimitFactor = readUI16("miterLimitFactor"); } if (!ret.hasFillFlag) { - ret.color = readRGBA(); + ret.color = readRGBA("color"); } else { - ret.fillType = readFILLSTYLE(shapeNum); + ret.fillType = readFILLSTYLE(shapeNum, "fillType"); } endDumpLevel(); return ret; @@ -2342,25 +2470,26 @@ public class SWFInputStream implements AutoCloseable { * Reads one LINESTYLEARRAY value from the stream * * @param shapeNum 1 in DefineShape, 2 in DefineShape2... + * @param name * @return LINESTYLEARRAY value * @throws IOException */ - public LINESTYLEARRAY readLINESTYLEARRAY(int shapeNum) throws IOException { + public LINESTYLEARRAY readLINESTYLEARRAY(int shapeNum, String name) throws IOException { LINESTYLEARRAY ret = new LINESTYLEARRAY(); - newDumpLevel("LINESTYLEARRAY"); - int lineStyleCount = readUI8(); + newDumpLevel(name, "LINESTYLEARRAY"); + int lineStyleCount = readUI8("lineStyleCount"); if (lineStyleCount == 0xff) { - lineStyleCount = readUI16(); + lineStyleCount = readUI16("lineStyleCount"); } if ((shapeNum == 1 || shapeNum == 2 || shapeNum == 3)) { ret.lineStyles = new LINESTYLE[lineStyleCount]; for (int i = 0; i < lineStyleCount; i++) { - ret.lineStyles[i] = readLINESTYLE(shapeNum); + ret.lineStyles[i] = readLINESTYLE(shapeNum, "lineStyle"); } } else if (shapeNum == 4) { ret.lineStyles = new LINESTYLE2[lineStyleCount]; for (int i = 0; i < lineStyleCount; i++) { - ret.lineStyles[i] = readLINESTYLE2(shapeNum); + ret.lineStyles[i] = readLINESTYLE2(shapeNum, "lineStyle"); } } endDumpLevel(); @@ -2376,16 +2505,16 @@ public class SWFInputStream implements AutoCloseable { * @return SHAPERECORD value * @throws IOException */ - private SHAPERECORD readSHAPERECORD(int fillBits, int lineBits, int shapeNum, boolean morphShape) throws IOException { + private SHAPERECORD readSHAPERECORD(int fillBits, int lineBits, int shapeNum, boolean morphShape, String name) throws IOException { SHAPERECORD ret; - newDumpLevel("SHAPERECORD"); - int typeFlag = (int) readUB(1); + newDumpLevel(name, "SHAPERECORD"); + int typeFlag = (int) readUB(1, "typeFlag"); if (typeFlag == 0) { - boolean stateNewStyles = readUB(1) == 1; - boolean stateLineStyle = readUB(1) == 1; - boolean stateFillStyle1 = readUB(1) == 1; - boolean stateFillStyle0 = readUB(1) == 1; - boolean stateMoveTo = readUB(1) == 1; + boolean stateNewStyles = readUB(1, "stateNewStyles") == 1; + boolean stateLineStyle = readUB(1, "stateLineStyle") == 1; + boolean stateFillStyle1 = readUB(1, "stateFillStyle1") == 1; + boolean stateFillStyle0 = readUB(1, "stateFillStyle0") == 1; + boolean stateMoveTo = readUB(1, "stateMoveTo") == 1; if ((!stateNewStyles) && (!stateLineStyle) && (!stateFillStyle1) && (!stateFillStyle0) && (!stateMoveTo)) { ret = new EndShapeRecord(); } else { @@ -2396,54 +2525,54 @@ public class SWFInputStream implements AutoCloseable { scr.stateFillStyle1 = stateFillStyle1; scr.stateMoveTo = stateMoveTo; if (stateMoveTo) { - scr.moveBits = (int) readUB(5); - scr.moveDeltaX = (int) readSB(scr.moveBits); - scr.moveDeltaY = (int) readSB(scr.moveBits); + scr.moveBits = (int) readUB(5, "moveBits"); + scr.moveDeltaX = (int) readSB(scr.moveBits, "moveDeltaX"); + scr.moveDeltaY = (int) readSB(scr.moveBits, "moveDeltaY"); } if (stateFillStyle0) { - scr.fillStyle0 = (int) readUB(fillBits); + scr.fillStyle0 = (int) readUB(fillBits, "fillStyle0"); } if (stateFillStyle1) { - scr.fillStyle1 = (int) readUB(fillBits); + scr.fillStyle1 = (int) readUB(fillBits, "fillStyle1"); } if (stateLineStyle) { - scr.lineStyle = (int) readUB(lineBits); + scr.lineStyle = (int) readUB(lineBits, "lineStyle"); } if (stateNewStyles) { if (morphShape) { //This should never happen } else { - scr.fillStyles = readFILLSTYLEARRAY(shapeNum); - scr.lineStyles = readLINESTYLEARRAY(shapeNum); + scr.fillStyles = readFILLSTYLEARRAY(shapeNum, "fillStyles"); + scr.lineStyles = readLINESTYLEARRAY(shapeNum, "lineStyles"); } - scr.numFillBits = (int) readUB(4); - scr.numLineBits = (int) readUB(4); + scr.numFillBits = (int) readUB(4, "numFillBits"); + scr.numLineBits = (int) readUB(4, "numLineBits"); } ret = scr; } } else {//typeFlag==1 - int straightFlag = (int) readUB(1); + int straightFlag = (int) readUB(1, "straightFlag"); if (straightFlag == 1) { StraightEdgeRecord ser = new StraightEdgeRecord(); - ser.numBits = (int) readUB(4); - ser.generalLineFlag = readUB(1) == 1; + ser.numBits = (int) readUB(4, "numBits"); + ser.generalLineFlag = readUB(1, "generalLineFlag") == 1; if (!ser.generalLineFlag) { - ser.vertLineFlag = readUB(1) == 1; + ser.vertLineFlag = readUB(1, "vertLineFlag") == 1; } if (ser.generalLineFlag || (!ser.vertLineFlag)) { - ser.deltaX = (int) readSB(ser.numBits + 2); + ser.deltaX = (int) readSB(ser.numBits + 2, "deltaX"); } if (ser.generalLineFlag || (ser.vertLineFlag)) { - ser.deltaY = (int) readSB(ser.numBits + 2); + ser.deltaY = (int) readSB(ser.numBits + 2, "deltaY"); } ret = ser; } else { CurvedEdgeRecord cer = new CurvedEdgeRecord(); - cer.numBits = (int) readUB(4); - cer.controlDeltaX = (int) readSB(cer.numBits + 2); - cer.controlDeltaY = (int) readSB(cer.numBits + 2); - cer.anchorDeltaX = (int) readSB(cer.numBits + 2); - cer.anchorDeltaY = (int) readSB(cer.numBits + 2); + cer.numBits = (int) readUB(4, "numBits"); + cer.controlDeltaX = (int) readSB(cer.numBits + 2, "controlDeltaX"); + cer.controlDeltaY = (int) readSB(cer.numBits + 2, "controlDeltaY"); + cer.anchorDeltaX = (int) readSB(cer.numBits + 2, "anchorDeltaX"); + cer.anchorDeltaY = (int) readSB(cer.numBits + 2, "anchorDeltaY"); ret = cer; } } @@ -2456,15 +2585,16 @@ public class SWFInputStream implements AutoCloseable { * * @param shapeNum 1 in DefineShape, 2 in DefineShape2... * @param morphShape + * @param name * @return SHAPE value * @throws IOException */ - public SHAPE readSHAPE(int shapeNum, boolean morphShape) throws IOException { + public SHAPE readSHAPE(int shapeNum, boolean morphShape, String name) throws IOException { SHAPE ret = new SHAPE(); - newDumpLevel("SHAPE"); - ret.numFillBits = (int) readUB(4); - ret.numLineBits = (int) readUB(4); - ret.shapeRecords = readSHAPERECORDS(shapeNum, ret.numFillBits, ret.numLineBits, morphShape); + newDumpLevel(name, "SHAPE"); + ret.numFillBits = (int) readUB(4, "numFillBits"); + ret.numLineBits = (int) readUB(4, "numLineBits"); + ret.shapeRecords = readSHAPERECORDS(shapeNum, ret.numFillBits, ret.numLineBits, morphShape, "shapeRecords"); endDumpLevel(); return ret; } @@ -2474,17 +2604,18 @@ public class SWFInputStream implements AutoCloseable { * * @param shapeNum 1 in DefineShape, 2 in DefineShape2... * @param morphShape + * @param name * @return SHAPEWITHSTYLE value * @throws IOException */ - public SHAPEWITHSTYLE readSHAPEWITHSTYLE(int shapeNum, boolean morphShape) throws IOException { + public SHAPEWITHSTYLE readSHAPEWITHSTYLE(int shapeNum, boolean morphShape, String name) throws IOException { SHAPEWITHSTYLE ret = new SHAPEWITHSTYLE(); - newDumpLevel("SHAPEWITHSTYLE"); - ret.fillStyles = readFILLSTYLEARRAY(shapeNum); - ret.lineStyles = readLINESTYLEARRAY(shapeNum); - ret.numFillBits = (int) readUB(4); - ret.numLineBits = (int) readUB(4); - ret.shapeRecords = readSHAPERECORDS(shapeNum, ret.numFillBits, ret.numLineBits, morphShape); + newDumpLevel(name, "SHAPEWITHSTYLE"); + ret.fillStyles = readFILLSTYLEARRAY(shapeNum, "fillStyles"); + ret.lineStyles = readLINESTYLEARRAY(shapeNum, "lineStyles"); + ret.numFillBits = (int) readUB(4, "numFillBits"); + ret.numLineBits = (int) readUB(4, "numLineBits"); + ret.shapeRecords = readSHAPERECORDS(shapeNum, ret.numFillBits, ret.numLineBits, morphShape, "shapeRecords"); endDumpLevel(); return ret; } @@ -2498,12 +2629,12 @@ public class SWFInputStream implements AutoCloseable { * @return SHAPERECORDs array * @throws IOException */ - private List readSHAPERECORDS(int shapeNum, int fillBits, int lineBits, boolean morphShape) throws IOException { + private List readSHAPERECORDS(int shapeNum, int fillBits, int lineBits, boolean morphShape, String name) throws IOException { List ret = new ArrayList<>(); - newDumpLevel("SHAPERECORDS"); + newDumpLevel(name, "SHAPERECORDS"); SHAPERECORD rec; do { - rec = readSHAPERECORD(fillBits, lineBits, shapeNum, morphShape); + rec = readSHAPERECORD(fillBits, lineBits, shapeNum, morphShape, "record"); if (rec instanceof StyleChangeRecord) { StyleChangeRecord scRec = (StyleChangeRecord) rec; if (scRec.stateNewStyles) { @@ -2521,33 +2652,34 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one SOUNDINFO value from the stream * + * @param name * @return SOUNDINFO value * @throws IOException */ - public SOUNDINFO readSOUNDINFO() throws IOException { + public SOUNDINFO readSOUNDINFO(String name) throws IOException { SOUNDINFO ret = new SOUNDINFO(); - newDumpLevel("SOUNDINFO"); - ret.reserved = (int) readUB(2); - ret.syncStop = readUB(1) == 1; - ret.syncNoMultiple = readUB(1) == 1; - ret.hasEnvelope = readUB(1) == 1; - ret.hasLoops = readUB(1) == 1; - ret.hasOutPoint = readUB(1) == 1; - ret.hasInPoint = readUB(1) == 1; + newDumpLevel(name, "SOUNDINFO"); + ret.reserved = (int) readUB(2, "reserved"); + ret.syncStop = readUB(1, "syncStop") == 1; + ret.syncNoMultiple = readUB(1, "syncNoMultiple") == 1; + ret.hasEnvelope = readUB(1, "hasEnvelope") == 1; + ret.hasLoops = readUB(1, "hasLoops") == 1; + ret.hasOutPoint = readUB(1, "hasOutPoint") == 1; + ret.hasInPoint = readUB(1, "hasInPoint") == 1; if (ret.hasInPoint) { - ret.inPoint = readUI32(); + ret.inPoint = readUI32("inPoint"); } if (ret.hasOutPoint) { - ret.outPoint = readUI32(); + ret.outPoint = readUI32("outPoint"); } if (ret.hasLoops) { - ret.loopCount = readUI16(); + ret.loopCount = readUI16("loopCount"); } if (ret.hasEnvelope) { - int envPoints = readUI8(); + int envPoints = readUI8("envPoints"); ret.envelopeRecords = new SOUNDENVELOPE[envPoints]; for (int i = 0; i < envPoints; i++) { - ret.envelopeRecords[i] = readSOUNDENVELOPE(); + ret.envelopeRecords[i] = readSOUNDENVELOPE("envelopeRecord"); } } endDumpLevel(); @@ -2557,15 +2689,16 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one SOUNDENVELOPE value from the stream * + * @param name * @return SOUNDENVELOPE value * @throws IOException */ - public SOUNDENVELOPE readSOUNDENVELOPE() throws IOException { + public SOUNDENVELOPE readSOUNDENVELOPE(String name) throws IOException { SOUNDENVELOPE ret = new SOUNDENVELOPE(); - newDumpLevel("SOUNDENVELOPE"); - ret.pos44 = readUI32(); - ret.leftLevel = readUI16(); - ret.rightLevel = readUI16(); + newDumpLevel(name, "SOUNDENVELOPE"); + ret.pos44 = readUI32("pos44"); + ret.leftLevel = readUI16("leftLevel"); + ret.rightLevel = readUI16("rightLevel"); endDumpLevel(); return ret; } @@ -2575,14 +2708,15 @@ public class SWFInputStream implements AutoCloseable { * * @param glyphBits * @param advanceBits + * @param name * @return GLYPHENTRY value * @throws IOException */ - public GLYPHENTRY readGLYPHENTRY(int glyphBits, int advanceBits) throws IOException { + public GLYPHENTRY readGLYPHENTRY(int glyphBits, int advanceBits, String name) throws IOException { GLYPHENTRY ret = new GLYPHENTRY(); - newDumpLevel("GLYPHENTRY"); - ret.glyphIndex = (int) readUB(glyphBits); - ret.glyphAdvance = (int) readUB(advanceBits); + newDumpLevel(name, "GLYPHENTRY"); + ret.glyphIndex = (int) readUB(glyphBits, "glyphIndex"); + ret.glyphAdvance = (int) readUB(advanceBits, "glyphAdvance"); endDumpLevel(); return ret; } @@ -2593,45 +2727,46 @@ public class SWFInputStream implements AutoCloseable { * @param inDefineText2 * @param glyphBits * @param advanceBits + * @param name * @return TEXTRECORD value * @throws IOException */ - public TEXTRECORD readTEXTRECORD(boolean inDefineText2, int glyphBits, int advanceBits) throws IOException { + public TEXTRECORD readTEXTRECORD(boolean inDefineText2, int glyphBits, int advanceBits, String name) throws IOException { TEXTRECORD ret = new TEXTRECORD(); - newDumpLevel("TEXTRECORD"); - int first = (int) readUB(1); //always 1 - readUB(3); //always 0 - ret.styleFlagsHasFont = readUB(1) == 1; - ret.styleFlagsHasColor = readUB(1) == 1; - ret.styleFlagsHasYOffset = readUB(1) == 1; - ret.styleFlagsHasXOffset = readUB(1) == 1; + newDumpLevel(name, "TEXTRECORD"); + int first = (int) readUB(1, "first"); //always 1 + readUB(3, "styleFlagsHasReserved"); //always 0 + ret.styleFlagsHasFont = readUB(1, "styleFlagsHasFont") == 1; + ret.styleFlagsHasColor = readUB(1, "styleFlagsHasColor") == 1; + ret.styleFlagsHasYOffset = readUB(1, "styleFlagsHasYOffset") == 1; + ret.styleFlagsHasXOffset = readUB(1, "styleFlagsHasXOffset") == 1; if ((!ret.styleFlagsHasFont) && (!ret.styleFlagsHasColor) && (!ret.styleFlagsHasYOffset) && (!ret.styleFlagsHasXOffset) && (first == 0)) { //final text record endDumpLevel(); return null; } if (ret.styleFlagsHasFont) { - ret.fontId = readUI16(); + ret.fontId = readUI16("fontId"); } if (ret.styleFlagsHasColor) { if (inDefineText2) { - ret.textColorA = readRGBA(); + ret.textColorA = readRGBA("textColorA"); } else { - ret.textColor = readRGB(); + ret.textColor = readRGB("textColor"); } } if (ret.styleFlagsHasXOffset) { - ret.xOffset = readSI16(); + ret.xOffset = readSI16("xOffset"); } if (ret.styleFlagsHasYOffset) { - ret.yOffset = readSI16(); + ret.yOffset = readSI16("yOffset"); } if (ret.styleFlagsHasFont) { - ret.textHeight = readUI16(); + ret.textHeight = readUI16("textHeight"); } - int glyphCount = readUI8(); + int glyphCount = readUI8("glyphCount"); ret.glyphEntries = new GLYPHENTRY[glyphCount]; for (int i = 0; i < glyphCount; i++) { - ret.glyphEntries[i] = readGLYPHENTRY(glyphBits, advanceBits); + ret.glyphEntries[i] = readGLYPHENTRY(glyphBits, advanceBits, "glyphEntry"); } alignByte(); endDumpLevel(); @@ -2641,16 +2776,17 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one MORPHGRADRECORD value from the stream * + * @param name * @return MORPHGRADRECORD value * @throws IOException */ - public MORPHGRADRECORD readMORPHGRADRECORD() throws IOException { + public MORPHGRADRECORD readMORPHGRADRECORD(String name) throws IOException { MORPHGRADRECORD ret = new MORPHGRADRECORD(); - newDumpLevel("MORPHGRADRECORD"); - ret.startRatio = readUI8(); - ret.startColor = readRGBA(); - ret.endRatio = readUI8(); - ret.endColor = readRGBA(); + newDumpLevel(name, "MORPHGRADRECORD"); + ret.startRatio = readUI8("startRatio"); + ret.startColor = readRGBA("startColor"); + ret.endRatio = readUI8("endRatio"); + ret.endColor = readRGBA("endColor"); endDumpLevel(); return ret; } @@ -2658,20 +2794,21 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one MORPHGRADIENT value from the stream * + * @param name * @return MORPHGRADIENT value * @throws IOException */ - public MORPHGRADIENT readMORPHGRADIENT() throws IOException { + public MORPHGRADIENT readMORPHGRADIENT(String name) throws IOException { MORPHGRADIENT ret = new MORPHGRADIENT(); - newDumpLevel("MORPHGRADIENT"); + newDumpLevel(name, "MORPHGRADIENT"); //Despite of documentation (UI8 1-8), there are two fields // spreadMode and interPolationMode which are same as in GRADIENT - ret.spreadMode = (int) readUB(2); - ret.interPolationMode = (int) readUB(2); - int numGradients = (int) readUB(4); + ret.spreadMode = (int) readUB(2, "spreadMode"); + ret.interPolationMode = (int) readUB(2, "interPolationMode"); + int numGradients = (int) readUB(4, "numGradients"); ret.gradientRecords = new MORPHGRADRECORD[numGradients]; for (int i = 0; i < numGradients; i++) { - ret.gradientRecords[i] = readMORPHGRADRECORD(); + ret.gradientRecords[i] = readMORPHGRADRECORD("gradientRecord"); } endDumpLevel(); return ret; @@ -2682,21 +2819,22 @@ public class SWFInputStream implements AutoCloseable { * * This is undocumented feature * + * @param name * @return MORPHGRADIENT value * @throws IOException */ - public MORPHFOCALGRADIENT readMORPHFOCALGRADIENT() throws IOException { + public MORPHFOCALGRADIENT readMORPHFOCALGRADIENT(String name) throws IOException { MORPHFOCALGRADIENT ret = new MORPHFOCALGRADIENT(); - newDumpLevel("MORPHFOCALGRADIENT"); - ret.spreadMode = (int) readUB(2); - ret.interPolationMode = (int) readUB(2); - int numGradients = (int) readUB(4); + newDumpLevel(name, "MORPHFOCALGRADIENT"); + ret.spreadMode = (int) readUB(2, "spreadMode"); + ret.interPolationMode = (int) readUB(2, "interPolationMode"); + int numGradients = (int) readUB(4, "numGradients"); ret.gradientRecords = new MORPHGRADRECORD[numGradients]; for (int i = 0; i < numGradients; i++) { - ret.gradientRecords[i] = readMORPHGRADRECORD(); + ret.gradientRecords[i] = readMORPHGRADRECORD("gradientRecord"); } - ret.startFocalPoint = readFIXED8(); - ret.endFocalPoint = readFIXED8(); + ret.startFocalPoint = readFIXED8("startFocalPoint"); + ret.endFocalPoint = readFIXED8("endFocalPoint"); endDumpLevel(); return ret; } @@ -2704,38 +2842,39 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one MORPHFILLSTYLE value from the stream * + * @param name * @return MORPHFILLSTYLE value * @throws IOException */ - public MORPHFILLSTYLE readMORPHFILLSTYLE() throws IOException { + public MORPHFILLSTYLE readMORPHFILLSTYLE(String name) throws IOException { MORPHFILLSTYLE ret = new MORPHFILLSTYLE(); - newDumpLevel("MORPHFILLSTYLE"); - ret.fillStyleType = readUI8(); + newDumpLevel(name, "MORPHFILLSTYLE"); + ret.fillStyleType = readUI8("fillStyleType"); if (ret.fillStyleType == MORPHFILLSTYLE.SOLID) { - ret.startColor = readRGBA(); - ret.endColor = readRGBA(); + ret.startColor = readRGBA("startColor"); + ret.endColor = readRGBA("endColor"); } if ((ret.fillStyleType == MORPHFILLSTYLE.LINEAR_GRADIENT) || (ret.fillStyleType == MORPHFILLSTYLE.RADIAL_GRADIENT) || (ret.fillStyleType == MORPHFILLSTYLE.FOCAL_RADIAL_GRADIENT)) { - ret.startGradientMatrix = readMatrix(); - ret.endGradientMatrix = readMatrix(); + ret.startGradientMatrix = readMatrix("startGradientMatrix"); + ret.endGradientMatrix = readMatrix("endGradientMatrix"); } if ((ret.fillStyleType == MORPHFILLSTYLE.LINEAR_GRADIENT) || (ret.fillStyleType == MORPHFILLSTYLE.RADIAL_GRADIENT)) { - ret.gradient = readMORPHGRADIENT(); + ret.gradient = readMORPHGRADIENT("gradient"); } if (ret.fillStyleType == MORPHFILLSTYLE.FOCAL_RADIAL_GRADIENT) { - ret.gradient = readMORPHFOCALGRADIENT(); + ret.gradient = readMORPHFOCALGRADIENT("gradient"); } if ((ret.fillStyleType == MORPHFILLSTYLE.REPEATING_BITMAP) || (ret.fillStyleType == MORPHFILLSTYLE.CLIPPED_BITMAP) || (ret.fillStyleType == MORPHFILLSTYLE.NON_SMOOTHED_REPEATING_BITMAP) || (ret.fillStyleType == MORPHFILLSTYLE.NON_SMOOTHED_CLIPPED_BITMAP)) { - ret.bitmapId = readUI16(); - ret.startBitmapMatrix = readMatrix(); - ret.endBitmapMatrix = readMatrix(); + ret.bitmapId = readUI16("bitmapId"); + ret.startBitmapMatrix = readMatrix("startBitmapMatrix"); + ret.endBitmapMatrix = readMatrix("endBitmapMatrix"); } endDumpLevel(); return ret; @@ -2744,20 +2883,21 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one MORPHFILLSTYLEARRAY value from the stream * + * @param name * @return MORPHFILLSTYLEARRAY value * @throws IOException */ - public MORPHFILLSTYLEARRAY readMORPHFILLSTYLEARRAY() throws IOException { + public MORPHFILLSTYLEARRAY readMORPHFILLSTYLEARRAY(String name) throws IOException { MORPHFILLSTYLEARRAY ret = new MORPHFILLSTYLEARRAY(); - newDumpLevel("MORPHFILLSTYLEARRAY"); - int fillStyleCount = readUI8(); + newDumpLevel(name, "MORPHFILLSTYLEARRAY"); + int fillStyleCount = readUI8("fillStyleCount"); if (fillStyleCount == 0xff) { - fillStyleCount = readUI16(); + fillStyleCount = readUI16("fillStyleCount"); } ret.fillStyles = new MORPHFILLSTYLE[fillStyleCount]; for (int i = 0; i < fillStyleCount; i++) { - ret.fillStyles[i] = readMORPHFILLSTYLE(); + ret.fillStyles[i] = readMORPHFILLSTYLE("fillStyle"); } endDumpLevel(); return ret; @@ -2766,16 +2906,17 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one MORPHLINESTYLE value from the stream * + * @param name * @return MORPHLINESTYLE value * @throws IOException */ - public MORPHLINESTYLE readMORPHLINESTYLE() throws IOException { + public MORPHLINESTYLE readMORPHLINESTYLE(String name) throws IOException { MORPHLINESTYLE ret = new MORPHLINESTYLE(); - newDumpLevel("MORPHLINESTYLE"); - ret.startWidth = readUI16(); - ret.endWidth = readUI16(); - ret.startColor = readRGBA(); - ret.endColor = readRGBA(); + newDumpLevel(name, "MORPHLINESTYLE"); + ret.startWidth = readUI16("startWidth"); + ret.endWidth = readUI16("endWidth"); + ret.startColor = readRGBA("startColor"); + ret.endColor = readRGBA("endColor"); endDumpLevel(); return ret; } @@ -2783,31 +2924,32 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one MORPHLINESTYLE2 value from the stream * + * @param name * @return MORPHLINESTYLE2 value * @throws IOException */ - public MORPHLINESTYLE2 readMORPHLINESTYLE2() throws IOException { + public MORPHLINESTYLE2 readMORPHLINESTYLE2(String name) throws IOException { MORPHLINESTYLE2 ret = new MORPHLINESTYLE2(); - newDumpLevel("MORPHLINESTYLE2"); - ret.startWidth = readUI16(); - ret.endWidth = readUI16(); - ret.startCapStyle = (int) readUB(2); - ret.joinStyle = (int) readUB(2); - ret.hasFillFlag = (int) readUB(1) == 1; - ret.noHScaleFlag = (int) readUB(1) == 1; - ret.noVScaleFlag = (int) readUB(1) == 1; - ret.pixelHintingFlag = (int) readUB(1) == 1; - ret.reserved = (int) readUB(5); - ret.noClose = (int) readUB(1) == 1; - ret.endCapStyle = (int) readUB(2); + newDumpLevel(name, "MORPHLINESTYLE2"); + ret.startWidth = readUI16("startWidth"); + ret.endWidth = readUI16("endWidth"); + ret.startCapStyle = (int) readUB(2, "startCapStyle"); + ret.joinStyle = (int) readUB(2, "joinStyle"); + ret.hasFillFlag = (int) readUB(1, "hasFillFlag") == 1; + ret.noHScaleFlag = (int) readUB(1, "noHScaleFlag") == 1; + ret.noVScaleFlag = (int) readUB(1, "noVScaleFlag") == 1; + ret.pixelHintingFlag = (int) readUB(1, "pixelHintingFlag") == 1; + ret.reserved = (int) readUB(5, "reserved"); + ret.noClose = (int) readUB(1, "noClose") == 1; + ret.endCapStyle = (int) readUB(2, "endCapStyle"); if (ret.joinStyle == LINESTYLE2.MITER_JOIN) { - ret.miterLimitFactor = readUI16(); + ret.miterLimitFactor = readUI16("miterLimitFactor"); } if (!ret.hasFillFlag) { - ret.startColor = readRGBA(); - ret.endColor = readRGBA(); + ret.startColor = readRGBA("startColor"); + ret.endColor = readRGBA("endColor"); } else { - ret.fillType = readMORPHFILLSTYLE(); + ret.fillType = readMORPHFILLSTYLE("fillType"); } endDumpLevel(); return ret; @@ -2817,25 +2959,26 @@ public class SWFInputStream implements AutoCloseable { * Reads one MORPHLINESTYLEARRAY value from the stream * * @param morphShapeNum 1 on DefineMorphShape, 2 on DefineMorphShape2 + * @param name * @return MORPHLINESTYLEARRAY value * @throws IOException */ - public MORPHLINESTYLEARRAY readMORPHLINESTYLEARRAY(int morphShapeNum) throws IOException { + public MORPHLINESTYLEARRAY readMORPHLINESTYLEARRAY(int morphShapeNum, String name) throws IOException { MORPHLINESTYLEARRAY ret = new MORPHLINESTYLEARRAY(); - newDumpLevel("MORPHLINESTYLEARRAY"); - int lineStyleCount = readUI8(); + newDumpLevel(name, "MORPHLINESTYLEARRAY"); + int lineStyleCount = readUI8("lineStyleCount"); if (lineStyleCount == 0xff) { - lineStyleCount = readUI16(); + lineStyleCount = readUI16("lineStyleCount"); } if (morphShapeNum == 1) { ret.lineStyles = new MORPHLINESTYLE[lineStyleCount]; for (int i = 0; i < lineStyleCount; i++) { - ret.lineStyles[i] = readMORPHLINESTYLE(); + ret.lineStyles[i] = readMORPHLINESTYLE("lineStyle"); } } else if (morphShapeNum == 2) { ret.lineStyles2 = new MORPHLINESTYLE2[lineStyleCount]; for (int i = 0; i < lineStyleCount; i++) { - ret.lineStyles2[i] = readMORPHLINESTYLE2(); + ret.lineStyles2[i] = readMORPHLINESTYLE2("lineStyle2"); } } endDumpLevel(); @@ -2846,20 +2989,21 @@ public class SWFInputStream implements AutoCloseable { * Reads one KERNINGRECORD value from the stream * * @param fontFlagsWideCodes + * @param name * @return KERNINGRECORD value * @throws IOException */ - public KERNINGRECORD readKERNINGRECORD(boolean fontFlagsWideCodes) throws IOException { + public KERNINGRECORD readKERNINGRECORD(boolean fontFlagsWideCodes, String name) throws IOException { KERNINGRECORD ret = new KERNINGRECORD(); - newDumpLevel("KERNINGRECORD"); + newDumpLevel(name, "KERNINGRECORD"); if (fontFlagsWideCodes) { - ret.fontKerningCode1 = readUI16(); - ret.fontKerningCode2 = readUI16(); + ret.fontKerningCode1 = readUI16("fontKerningCode1"); + ret.fontKerningCode2 = readUI16("fontKerningCode2"); } else { - ret.fontKerningCode1 = readUI8(); - ret.fontKerningCode2 = readUI8(); + ret.fontKerningCode1 = readUI8("fontKerningCode1"); + ret.fontKerningCode2 = readUI8("fontKerningCode2"); } - ret.fontKerningAdjustment = readSI16(); + ret.fontKerningAdjustment = readSI16("fontKerningAdjustment"); endDumpLevel(); return ret; } @@ -2867,13 +3011,14 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one LANGCODE value from the stream * + * @param name * @return LANGCODE value * @throws IOException */ - public LANGCODE readLANGCODE() throws IOException { + public LANGCODE readLANGCODE(String name) throws IOException { LANGCODE ret = new LANGCODE(); - newDumpLevel("LANGCODE"); - ret.languageCode = readUI8(); + newDumpLevel(name, "LANGCODE"); + ret.languageCode = readUI8("languageCode"); endDumpLevel(); return ret; } @@ -2881,20 +3026,21 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one ZONERECORD value from the stream * + * @param name * @return ZONERECORD value * @throws IOException */ - public ZONERECORD readZONERECORD() throws IOException { + public ZONERECORD readZONERECORD(String name) throws IOException { ZONERECORD ret = new ZONERECORD(); - newDumpLevel("ZONERECORD"); - int numZoneData = readUI8(); + newDumpLevel(name, "ZONERECORD"); + int numZoneData = readUI8("numZoneData"); ret.zonedata = new ZONEDATA[numZoneData]; for (int i = 0; i < numZoneData; i++) { - ret.zonedata[i] = readZONEDATA(); + ret.zonedata[i] = readZONEDATA("zonedata"); } - readUB(6); - ret.zoneMaskY = readUB(1) == 1; - ret.zoneMaskX = readUB(1) == 1; + readUB(6, "reserved"); + ret.zoneMaskY = readUB(1, "zoneMaskY") == 1; + ret.zoneMaskX = readUB(1, "zoneMaskX") == 1; endDumpLevel(); return ret; } @@ -2902,14 +3048,15 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one ZONEDATA value from the stream * + * @param name * @return ZONEDATA value * @throws IOException */ - public ZONEDATA readZONEDATA() throws IOException { + public ZONEDATA readZONEDATA(String name) throws IOException { ZONEDATA ret = new ZONEDATA(); - newDumpLevel("ZONEDATA"); - ret.alignmentCoordinate = readUI16(); - ret.range = readUI16(); + newDumpLevel(name, "ZONEDATA"); + ret.alignmentCoordinate = readUI16("alignmentCoordinate"); + ret.range = readUI16("range"); endDumpLevel(); return ret; } @@ -2917,16 +3064,17 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one PIX15 value from the stream * + * @param name * @return PIX15 value * @throws IOException */ - public PIX15 readPIX15() throws IOException { + public PIX15 readPIX15(String name) throws IOException { PIX15 ret = new PIX15(); - newDumpLevel("PIX15"); - readUB(1); - ret.red = (int) readUB(5); - ret.green = (int) readUB(5); - ret.blue = (int) readUB(5); + newDumpLevel(name, "PIX15"); + readUB(1, "reserved"); + ret.red = (int) readUB(5, "red"); + ret.green = (int) readUB(5, "green"); + ret.blue = (int) readUB(5, "blue"); endDumpLevel(); return ret; } @@ -2934,16 +3082,17 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one PIX24 value from the stream * + * @param name * @return PIX24 value * @throws IOException */ - public PIX24 readPIX24() throws IOException { + public PIX24 readPIX24(String name) throws IOException { PIX24 ret = new PIX24(); - newDumpLevel("PIX24"); - ret.reserved = readUI8(); - ret.red = readUI8(); - ret.green = readUI8(); - ret.blue = readUI8(); + newDumpLevel(name, "PIX24"); + ret.reserved = readUI8("reserved"); + ret.red = readUI8("red"); + ret.green = readUI8("green"); + ret.blue = readUI8("blue"); endDumpLevel(); return ret; } @@ -2954,15 +3103,16 @@ public class SWFInputStream implements AutoCloseable { * @param colorTableSize * @param bitmapWidth * @param bitmapHeight + * @param name * @return COLORMAPDATA value * @throws IOException */ - public COLORMAPDATA readCOLORMAPDATA(int colorTableSize, int bitmapWidth, int bitmapHeight) throws IOException { + public COLORMAPDATA readCOLORMAPDATA(int colorTableSize, int bitmapWidth, int bitmapHeight, String name) throws IOException { COLORMAPDATA ret = new COLORMAPDATA(); - newDumpLevel("COLORMAPDATA"); + newDumpLevel(name, "COLORMAPDATA"); ret.colorTableRGB = new RGB[colorTableSize + 1]; for (int i = 0; i < colorTableSize + 1; i++) { - ret.colorTableRGB[i] = readRGB(); + ret.colorTableRGB[i] = readRGB("colorTableRGB"); } int dataLen = 0; for (int y = 0; y < bitmapHeight; y++) { @@ -2975,7 +3125,7 @@ public class SWFInputStream implements AutoCloseable { x++; } } - ret.colorMapPixelData = readBytesEx(dataLen); + ret.colorMapPixelData = readBytesEx(dataLen, "colorMapPixelData"); endDumpLevel(); return ret; } @@ -2986,12 +3136,13 @@ public class SWFInputStream implements AutoCloseable { * @param bitmapFormat * @param bitmapWidth * @param bitmapHeight + * @param name * @return COLORMAPDATA value * @throws IOException */ - public BITMAPDATA readBITMAPDATA(int bitmapFormat, int bitmapWidth, int bitmapHeight) throws IOException { + public BITMAPDATA readBITMAPDATA(int bitmapFormat, int bitmapWidth, int bitmapHeight, String name) throws IOException { BITMAPDATA ret = new BITMAPDATA(); - newDumpLevel("BITMAPDATA"); + newDumpLevel(name, "BITMAPDATA"); List pix15 = new ArrayList<>(); List pix24 = new ArrayList<>(); int dataLen = 0; @@ -3000,16 +3151,16 @@ public class SWFInputStream implements AutoCloseable { for (; x < bitmapWidth; x++) { if (bitmapFormat == DefineBitsLosslessTag.FORMAT_15BIT_RGB) { dataLen += 2; - pix15.add(readPIX15()); + pix15.add(readPIX15("pix15")); } if (bitmapFormat == DefineBitsLosslessTag.FORMAT_24BIT_RGB) { dataLen += 4; - pix24.add(readPIX24()); + pix24.add(readPIX24("pix24")); } } while ((dataLen % 4) != 0) { dataLen++; - readUI8(); + readUI8("padding"); } } if (bitmapFormat == DefineBitsLosslessTag.FORMAT_15BIT_RGB) { @@ -3027,16 +3178,17 @@ public class SWFInputStream implements AutoCloseable { * @param bitmapFormat * @param bitmapWidth * @param bitmapHeight + * @param name * @return COLORMAPDATA value * @throws IOException */ - public ALPHABITMAPDATA readALPHABITMAPDATA(int bitmapFormat, int bitmapWidth, int bitmapHeight) throws IOException { + public ALPHABITMAPDATA readALPHABITMAPDATA(int bitmapFormat, int bitmapWidth, int bitmapHeight, String name) throws IOException { ALPHABITMAPDATA ret = new ALPHABITMAPDATA(); - newDumpLevel("ALPHABITMAPDATA"); + newDumpLevel(name, "ALPHABITMAPDATA"); ret.bitmapPixelData = new ARGB[bitmapWidth * bitmapHeight]; for (int y = 0; y < bitmapHeight; y++) { for (int x = 0; x < bitmapWidth; x++) { - ret.bitmapPixelData[y * bitmapWidth + x] = readARGB(); + ret.bitmapPixelData[y * bitmapWidth + x] = readARGB("bitmapPixelData"); } } endDumpLevel(); @@ -3049,15 +3201,16 @@ public class SWFInputStream implements AutoCloseable { * @param colorTableSize * @param bitmapWidth * @param bitmapHeight + * @param name * @return ALPHACOLORMAPDATA value * @throws IOException */ - public ALPHACOLORMAPDATA readALPHACOLORMAPDATA(int colorTableSize, int bitmapWidth, int bitmapHeight) throws IOException { + public ALPHACOLORMAPDATA readALPHACOLORMAPDATA(int colorTableSize, int bitmapWidth, int bitmapHeight, String name) throws IOException { ALPHACOLORMAPDATA ret = new ALPHACOLORMAPDATA(); - newDumpLevel("ALPHACOLORMAPDATA"); + newDumpLevel(name, "ALPHACOLORMAPDATA"); ret.colorTableRGB = new RGBA[colorTableSize + 1]; for (int i = 0; i < colorTableSize + 1; i++) { - ret.colorTableRGB[i] = readRGBA(); + ret.colorTableRGB[i] = readRGBA("colorTableRGB"); } int dataLen = 0; for (int y = 0; y < bitmapHeight; y++) { @@ -3070,7 +3223,7 @@ public class SWFInputStream implements AutoCloseable { x++; } } - ret.colorMapPixelData = readBytesEx(dataLen); + ret.colorMapPixelData = readBytesEx(dataLen, ""); endDumpLevel(); return ret; } diff --git a/src/com/jpexs/decompiler/flash/SWFOutputStream.java b/src/com/jpexs/decompiler/flash/SWFOutputStream.java index d74b0be4c..0e183bbaf 100644 --- a/src/com/jpexs/decompiler/flash/SWFOutputStream.java +++ b/src/com/jpexs/decompiler/flash/SWFOutputStream.java @@ -1038,7 +1038,7 @@ public class SWFOutputStream extends OutputStream { sos.writeUB(1, value.condOverUpToIddle ? 1 : 0); sos.writeUB(1, value.condIdleToOverUp ? 1 : 0); sos.writeUB(7, value.condKeyPress); - sos.writeUB(1, value.condOverDownToIddle ? 1 : 0); + sos.writeUB(1, value.condOverDownToIdle ? 1 : 0); sos.write(value.actionBytes); } byte[] data = baos.toByteArray(); diff --git a/src/com/jpexs/decompiler/flash/action/flashlite/ActionStrictMode.java b/src/com/jpexs/decompiler/flash/action/flashlite/ActionStrictMode.java index 049669c93..3da86c4c1 100644 --- a/src/com/jpexs/decompiler/flash/action/flashlite/ActionStrictMode.java +++ b/src/com/jpexs/decompiler/flash/action/flashlite/ActionStrictMode.java @@ -1,67 +1,67 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.flashlite; - -import com.jpexs.decompiler.flash.SWFInputStream; -import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.StrictModeActionItem; -import com.jpexs.decompiler.flash.action.parser.ParseException; -import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionStrictMode extends Action { - - public int mode; - - public ActionStrictMode(SWFInputStream sis) throws IOException { - super(0x89, 1); - mode = sis.readUI8(); - } - - public ActionStrictMode(FlasmLexer lexer) throws IOException, ParseException { - super(0x89, 1); - mode = (int) lexLong(lexer); - } - - @Override - public byte[] getBytes(int version) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - try { - sos.writeUI8(mode); - sos.close(); - } catch (IOException e) { - } - return surroundWithAction(baos.toByteArray(), version); - } - - @Override - public String toString() { - return "StrictMode " + mode; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - output.add(new StrictModeActionItem(this, mode)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.flashlite; + +import com.jpexs.decompiler.flash.SWFInputStream; +import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.StrictModeActionItem; +import com.jpexs.decompiler.flash.action.parser.ParseException; +import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionStrictMode extends Action { + + public int mode; + + public ActionStrictMode(SWFInputStream sis) throws IOException { + super(0x89, 1); + mode = sis.readUI8("mode"); + } + + public ActionStrictMode(FlasmLexer lexer) throws IOException, ParseException { + super(0x89, 1); + mode = (int) lexLong(lexer); + } + + @Override + public byte[] getBytes(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + try { + sos.writeUI8(mode); + sos.close(); + } catch (IOException e) { + } + return surroundWithAction(baos.toByteArray(), version); + } + + @Override + public String toString() { + return "StrictMode " + mode; + } + + @Override + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + output.add(new StrictModeActionItem(this, mode)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java index 68ae45d27..8e459ca2c 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java @@ -1,114 +1,114 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf3; - -import com.jpexs.decompiler.flash.SWFInputStream; -import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; -import com.jpexs.decompiler.flash.action.model.FSCommandActionItem; -import com.jpexs.decompiler.flash.action.model.GetURLActionItem; -import com.jpexs.decompiler.flash.action.model.LoadMovieNumActionItem; -import com.jpexs.decompiler.flash.action.model.UnLoadMovieActionItem; -import com.jpexs.decompiler.flash.action.model.UnLoadMovieNumActionItem; -import com.jpexs.decompiler.flash.action.parser.ParseException; -import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.helpers.Helper; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionGetURL extends Action { - - public String urlString; - public String targetString; - - public ActionGetURL(String urlString, String targetString) { - super(0x83, 0); - this.urlString = urlString; - this.targetString = targetString; - } - - public ActionGetURL(int actionLength, SWFInputStream sis, int version) throws IOException { - super(0x83, actionLength); - //byte[] data = sis.readBytes(actionLength); - //sis = new SWFInputStream(new ByteArrayInputStream(data), version); - urlString = sis.readString(); - targetString = sis.readString(); - } - - public ActionGetURL(FlasmLexer lexer) throws IOException, ParseException { - super(0x83, 0); - urlString = lexString(lexer); - targetString = lexString(lexer); - } - - @Override - public byte[] getBytes(int version) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - try { - sos.writeString(urlString); - sos.writeString(targetString); - sos.close(); - } catch (IOException e) { - } - return surroundWithAction(baos.toByteArray(), version); - } - - @Override - public String toString() { - return "GetUrl \"" + Helper.escapeString(urlString) + "\" \"" + Helper.escapeString(targetString) + "\""; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - String fsCommandPrefix = "FSCommand:"; - if (urlString.startsWith(fsCommandPrefix) && targetString.isEmpty()) { - String command = urlString.substring(fsCommandPrefix.length()); - output.add(new FSCommandActionItem(this, new DirectValueActionItem(command))); - return; - } - String levelPrefix = "_level"; - if (targetString.startsWith(levelPrefix)) { - try { - int num = Integer.valueOf(targetString.substring(levelPrefix.length())); - if (urlString.isEmpty()) { - output.add(new UnLoadMovieNumActionItem(this, new DirectValueActionItem((Long) (long) (int) num))); - } else { - DirectValueActionItem urlStringDi = new DirectValueActionItem(null, 0, urlString, new ArrayList()); - output.add(new LoadMovieNumActionItem(this, urlStringDi, new DirectValueActionItem((Long) (long) (int) num), 1/*GET*/)); - } - return; - } catch (NumberFormatException nfe) { - } - - } - - if (urlString.isEmpty()) { - DirectValueActionItem targetStringDi = new DirectValueActionItem(null, 0, targetString, new ArrayList()); - output.add(new UnLoadMovieActionItem(this, targetStringDi)); - } else { - output.add(new GetURLActionItem(this, urlString, targetString)); - } - - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf3; + +import com.jpexs.decompiler.flash.SWFInputStream; +import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; +import com.jpexs.decompiler.flash.action.model.FSCommandActionItem; +import com.jpexs.decompiler.flash.action.model.GetURLActionItem; +import com.jpexs.decompiler.flash.action.model.LoadMovieNumActionItem; +import com.jpexs.decompiler.flash.action.model.UnLoadMovieActionItem; +import com.jpexs.decompiler.flash.action.model.UnLoadMovieNumActionItem; +import com.jpexs.decompiler.flash.action.parser.ParseException; +import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionGetURL extends Action { + + public String urlString; + public String targetString; + + public ActionGetURL(String urlString, String targetString) { + super(0x83, 0); + this.urlString = urlString; + this.targetString = targetString; + } + + public ActionGetURL(int actionLength, SWFInputStream sis, int version) throws IOException { + super(0x83, actionLength); + //byte[] data = sis.readBytes(actionLength); + //sis = new SWFInputStream(new ByteArrayInputStream(data), version); + urlString = sis.readString("urlString"); + targetString = sis.readString("targetString"); + } + + public ActionGetURL(FlasmLexer lexer) throws IOException, ParseException { + super(0x83, 0); + urlString = lexString(lexer); + targetString = lexString(lexer); + } + + @Override + public byte[] getBytes(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + try { + sos.writeString(urlString); + sos.writeString(targetString); + sos.close(); + } catch (IOException e) { + } + return surroundWithAction(baos.toByteArray(), version); + } + + @Override + public String toString() { + return "GetUrl \"" + Helper.escapeString(urlString) + "\" \"" + Helper.escapeString(targetString) + "\""; + } + + @Override + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + String fsCommandPrefix = "FSCommand:"; + if (urlString.startsWith(fsCommandPrefix) && targetString.isEmpty()) { + String command = urlString.substring(fsCommandPrefix.length()); + output.add(new FSCommandActionItem(this, new DirectValueActionItem(command))); + return; + } + String levelPrefix = "_level"; + if (targetString.startsWith(levelPrefix)) { + try { + int num = Integer.valueOf(targetString.substring(levelPrefix.length())); + if (urlString.isEmpty()) { + output.add(new UnLoadMovieNumActionItem(this, new DirectValueActionItem((Long) (long) (int) num))); + } else { + DirectValueActionItem urlStringDi = new DirectValueActionItem(null, 0, urlString, new ArrayList()); + output.add(new LoadMovieNumActionItem(this, urlStringDi, new DirectValueActionItem((Long) (long) (int) num), 1/*GET*/)); + } + return; + } catch (NumberFormatException nfe) { + } + + } + + if (urlString.isEmpty()) { + DirectValueActionItem targetStringDi = new DirectValueActionItem(null, 0, targetString, new ArrayList()); + output.add(new UnLoadMovieActionItem(this, targetStringDi)); + } else { + output.add(new GetURLActionItem(this, urlString, targetString)); + } + + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java index 749ed187e..060690c57 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java @@ -1,75 +1,75 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf3; - -import com.jpexs.decompiler.flash.SWFInputStream; -import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.GotoLabelActionItem; -import com.jpexs.decompiler.flash.action.parser.ParseException; -import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.helpers.Helper; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionGoToLabel extends Action { - - public String label; - - public ActionGoToLabel(String label) { - super(0x8C, 0); - this.label = label; - } - - public ActionGoToLabel(int actionLength, SWFInputStream sis, int version) throws IOException { - super(0x8C, actionLength); - //byte[] data = sis.readBytes(actionLength); - //sis = new SWFInputStream(new ByteArrayInputStream(data), version); - label = sis.readString(); - } - - @Override - public String toString() { - return "GoToLabel \"" + Helper.escapeString(label) + "\""; - } - - @Override - public byte[] getBytes(int version) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - try { - sos.writeString(label); - sos.close(); - } catch (IOException e) { - } - return surroundWithAction(baos.toByteArray(), version); - } - - public ActionGoToLabel(FlasmLexer lexer) throws IOException, ParseException { - super(0x8C, -1); - label = lexString(lexer); - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - output.add(new GotoLabelActionItem(this, label)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf3; + +import com.jpexs.decompiler.flash.SWFInputStream; +import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.GotoLabelActionItem; +import com.jpexs.decompiler.flash.action.parser.ParseException; +import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionGoToLabel extends Action { + + public String label; + + public ActionGoToLabel(String label) { + super(0x8C, 0); + this.label = label; + } + + public ActionGoToLabel(int actionLength, SWFInputStream sis, int version) throws IOException { + super(0x8C, actionLength); + //byte[] data = sis.readBytes(actionLength); + //sis = new SWFInputStream(new ByteArrayInputStream(data), version); + label = sis.readString("label"); + } + + @Override + public String toString() { + return "GoToLabel \"" + Helper.escapeString(label) + "\""; + } + + @Override + public byte[] getBytes(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + try { + sos.writeString(label); + sos.close(); + } catch (IOException e) { + } + return surroundWithAction(baos.toByteArray(), version); + } + + public ActionGoToLabel(FlasmLexer lexer) throws IOException, ParseException { + super(0x8C, -1); + label = lexString(lexer); + } + + @Override + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + output.add(new GotoLabelActionItem(this, label)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionGotoFrame.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionGotoFrame.java index ca89cb326..93a98086d 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionGotoFrame.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionGotoFrame.java @@ -1,72 +1,72 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf3; - -import com.jpexs.decompiler.flash.SWFInputStream; -import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.GotoFrameActionItem; -import com.jpexs.decompiler.flash.action.parser.ParseException; -import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionGotoFrame extends Action { - - public int frame; - - public ActionGotoFrame(int frame) { - super(0x81, 2); - this.frame = frame; - } - - public ActionGotoFrame(int actionLength, SWFInputStream sis) throws IOException { - super(0x81, actionLength); - frame = sis.readUI16(); - } - - @Override - public String toString() { - return "GotoFrame " + frame; - } - - @Override - public byte[] getBytes(int version) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - try { - sos.writeUI16(frame); - sos.close(); - } catch (IOException e) { - } - return surroundWithAction(baos.toByteArray(), version); - } - - public ActionGotoFrame(FlasmLexer lexer) throws IOException, ParseException { - super(0x81, 0); - frame = (int) lexLong(lexer); - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - output.add(new GotoFrameActionItem(this, frame)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf3; + +import com.jpexs.decompiler.flash.SWFInputStream; +import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.GotoFrameActionItem; +import com.jpexs.decompiler.flash.action.parser.ParseException; +import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionGotoFrame extends Action { + + public int frame; + + public ActionGotoFrame(int frame) { + super(0x81, 2); + this.frame = frame; + } + + public ActionGotoFrame(int actionLength, SWFInputStream sis) throws IOException { + super(0x81, actionLength); + frame = sis.readUI16("frame"); + } + + @Override + public String toString() { + return "GotoFrame " + frame; + } + + @Override + public byte[] getBytes(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + try { + sos.writeUI16(frame); + sos.close(); + } catch (IOException e) { + } + return surroundWithAction(baos.toByteArray(), version); + } + + public ActionGotoFrame(FlasmLexer lexer) throws IOException, ParseException { + super(0x81, 0); + frame = (int) lexLong(lexer); + } + + @Override + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + output.add(new GotoFrameActionItem(this, frame)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java index a5b1f822f..137fc9a90 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java @@ -1,75 +1,75 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf3; - -import com.jpexs.decompiler.flash.SWFInputStream; -import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.SetTargetActionItem; -import com.jpexs.decompiler.flash.action.parser.ParseException; -import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.helpers.Helper; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionSetTarget extends Action { - - public String targetName; - - public ActionSetTarget(String targetName) { - super(0x8B, 0); - this.targetName = targetName; - } - - public ActionSetTarget(int actionLength, SWFInputStream sis, int version) throws IOException { - super(0x8B, actionLength); - //byte[] data = sis.readBytes(actionLength); - //sis = new SWFInputStream(new ByteArrayInputStream(data), version); - targetName = sis.readString(); - } - - @Override - public String toString() { - return "SetTarget \"" + Helper.escapeString(targetName) + "\""; - } - - @Override - public byte[] getBytes(int version) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - try { - sos.writeString(targetName); - sos.close(); - } catch (IOException e) { - } - return surroundWithAction(baos.toByteArray(), version); - } - - public ActionSetTarget(FlasmLexer lexer) throws IOException, ParseException { - super(0x8B, -1); - targetName = lexString(lexer); - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - output.add(new SetTargetActionItem(this, targetName)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf3; + +import com.jpexs.decompiler.flash.SWFInputStream; +import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.SetTargetActionItem; +import com.jpexs.decompiler.flash.action.parser.ParseException; +import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionSetTarget extends Action { + + public String targetName; + + public ActionSetTarget(String targetName) { + super(0x8B, 0); + this.targetName = targetName; + } + + public ActionSetTarget(int actionLength, SWFInputStream sis, int version) throws IOException { + super(0x8B, actionLength); + //byte[] data = sis.readBytes(actionLength); + //sis = new SWFInputStream(new ByteArrayInputStream(data), version); + targetName = sis.readString("targetName"); + } + + @Override + public String toString() { + return "SetTarget \"" + Helper.escapeString(targetName) + "\""; + } + + @Override + public byte[] getBytes(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + try { + sos.writeString(targetName); + sos.close(); + } catch (IOException e) { + } + return surroundWithAction(baos.toByteArray(), version); + } + + public ActionSetTarget(FlasmLexer lexer) throws IOException, ParseException { + super(0x8B, -1); + targetName = lexString(lexer); + } + + @Override + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + output.add(new SetTargetActionItem(this, targetName)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java index 8e27591b4..0378aa329 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java @@ -1,101 +1,101 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf3; - -import com.jpexs.decompiler.flash.SWF; -import com.jpexs.decompiler.flash.SWFInputStream; -import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.ActionGraph; -import com.jpexs.decompiler.flash.action.model.ConstantPool; -import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; -import com.jpexs.decompiler.flash.action.model.clauses.IfFrameLoadedActionItem; -import com.jpexs.decompiler.flash.action.parser.ParseException; -import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.flash.action.special.ActionStore; -import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; -import com.jpexs.decompiler.graph.GraphSourceItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionWaitForFrame extends Action implements ActionStore { - - public int frame; - public int skipCount; - public List skipped; - - public ActionWaitForFrame(int actionLength, SWFInputStream sis, ConstantPool cpool) throws IOException { - super(0x8A, actionLength); - frame = sis.readUI16(); - skipCount = sis.readUI8(); - skipped = new ArrayList<>(); - } - - @Override - public String toString() { - return "WaitForFrame"; - } - - @Override - public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { - String ret = "WaitForFrame " + frame + " " + skipCount; - return ret; - } - - @Override - public byte[] getBytes(int version) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - try { - sos.writeUI16(frame); - sos.writeUI8(skipCount); - sos.close(); - } catch (IOException e) { - } - return surroundWithAction(baos.toByteArray(), version); - } - - public ActionWaitForFrame(FlasmLexer lexer) throws IOException, ParseException { - super(0x8A, -1); - frame = (int) lexLong(lexer); - skipCount = (int) lexLong(lexer); - skipped = new ArrayList<>(); - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) throws InterruptedException { - GraphTargetItem frameTi = new DirectValueActionItem(null, 0, new Long(frame), new ArrayList()); - List body = ActionGraph.translateViaGraph(regNames, variables, functions, skipped, SWF.DEFAULT_VERSION, staticOperation, path); - output.add(new IfFrameLoadedActionItem(frameTi, body, this)); - } - - @Override - public int getStoreSize() { - return skipCount; - } - - @Override - public void setStore(List store) { - skipped = store; - skipCount = store.size(); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf3; + +import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.SWFInputStream; +import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.ActionGraph; +import com.jpexs.decompiler.flash.action.model.ConstantPool; +import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; +import com.jpexs.decompiler.flash.action.model.clauses.IfFrameLoadedActionItem; +import com.jpexs.decompiler.flash.action.parser.ParseException; +import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; +import com.jpexs.decompiler.flash.action.special.ActionStore; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionWaitForFrame extends Action implements ActionStore { + + public int frame; + public int skipCount; + public List skipped; + + public ActionWaitForFrame(int actionLength, SWFInputStream sis, ConstantPool cpool) throws IOException { + super(0x8A, actionLength); + frame = sis.readUI16("frame"); + skipCount = sis.readUI8("skipCount"); + skipped = new ArrayList<>(); + } + + @Override + public String toString() { + return "WaitForFrame"; + } + + @Override + public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { + String ret = "WaitForFrame " + frame + " " + skipCount; + return ret; + } + + @Override + public byte[] getBytes(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + try { + sos.writeUI16(frame); + sos.writeUI8(skipCount); + sos.close(); + } catch (IOException e) { + } + return surroundWithAction(baos.toByteArray(), version); + } + + public ActionWaitForFrame(FlasmLexer lexer) throws IOException, ParseException { + super(0x8A, -1); + frame = (int) lexLong(lexer); + skipCount = (int) lexLong(lexer); + skipped = new ArrayList<>(); + } + + @Override + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) throws InterruptedException { + GraphTargetItem frameTi = new DirectValueActionItem(null, 0, new Long(frame), new ArrayList()); + List body = ActionGraph.translateViaGraph(regNames, variables, functions, skipped, SWF.DEFAULT_VERSION, staticOperation, path); + output.add(new IfFrameLoadedActionItem(frameTi, body, this)); + } + + @Override + public int getStoreSize() { + return skipCount; + } + + @Override + public void setStore(List store) { + skipped = store; + skipCount = store.size(); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java index 93ac2cf94..c81180876 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java @@ -1,155 +1,155 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.SWFInputStream; -import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; -import com.jpexs.decompiler.flash.action.model.GetURL2ActionItem; -import com.jpexs.decompiler.flash.action.model.LoadMovieActionItem; -import com.jpexs.decompiler.flash.action.model.LoadMovieNumActionItem; -import com.jpexs.decompiler.flash.action.model.LoadVariablesActionItem; -import com.jpexs.decompiler.flash.action.model.LoadVariablesNumActionItem; -import com.jpexs.decompiler.flash.action.model.PrintActionItem; -import com.jpexs.decompiler.flash.action.model.PrintAsBitmapActionItem; -import com.jpexs.decompiler.flash.action.model.PrintAsBitmapNumActionItem; -import com.jpexs.decompiler.flash.action.model.PrintNumActionItem; -import com.jpexs.decompiler.flash.action.model.UnLoadMovieActionItem; -import com.jpexs.decompiler.flash.action.model.UnLoadMovieNumActionItem; -import com.jpexs.decompiler.flash.action.parser.ParseException; -import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionGetURL2 extends Action { - - public int sendVarsMethod; - public static final int GET = 1; - public static final int POST = 2; - public boolean loadTargetFlag; - public boolean loadVariablesFlag; - public int reserved; - - public ActionGetURL2(int sendVarsMethod, boolean loadVariablesFlag, boolean loadTargetFlag) { - super(0x9A, 1); - this.loadTargetFlag = loadTargetFlag; - this.loadVariablesFlag = loadVariablesFlag; - this.sendVarsMethod = sendVarsMethod; - } - - public ActionGetURL2(int actionLength, SWFInputStream sis) throws IOException { - super(0x9A, actionLength); - loadVariablesFlag = sis.readUB(1) == 1; - loadTargetFlag = sis.readUB(1) == 1; - reserved = (int) sis.readUB(4); - sendVarsMethod = (int) sis.readUB(2); //This is first in documentation, which is WRONG! - } - - @Override - public String toString() { - return "GetURL2 " + loadVariablesFlag + " " + loadTargetFlag + " " + sendVarsMethod; - } - - @Override - public byte[] getBytes(int version) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - try { - sos.writeUB(1, loadVariablesFlag ? 1 : 0); - sos.writeUB(1, loadTargetFlag ? 1 : 0); - sos.writeUB(4, reserved); - sos.writeUB(2, sendVarsMethod); - sos.close(); - } catch (IOException e) { - } - return surroundWithAction(baos.toByteArray(), version); - } - - public ActionGetURL2(FlasmLexer lexer) throws IOException, ParseException { - super(0x9A, -1); - loadVariablesFlag = lexBoolean(lexer); - loadTargetFlag = lexBoolean(lexer); - sendVarsMethod = (int) lexLong(lexer); - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem targetString = stack.pop(); - GraphTargetItem urlString = stack.pop(); - Integer num = null; - if (targetString.isCompileTime()) { - Object res = targetString.getResult(); - if (res instanceof String) { - String tarStr = (String) res; - String levelPrefix = "_level"; - if (tarStr.startsWith(levelPrefix)) { - try { - num = Integer.valueOf(tarStr.substring(levelPrefix.length())); - } catch (NumberFormatException nfe) { - } - } - } - } - if (loadVariablesFlag) { - if (num != null) { - output.add(new LoadVariablesNumActionItem(this, urlString, new DirectValueActionItem(null, 0, (Long) (long) (int) num, new ArrayList()), sendVarsMethod)); - } else { - output.add(new LoadVariablesActionItem(this, urlString, targetString, sendVarsMethod)); - } - } else if (loadTargetFlag) { - if ((urlString instanceof DirectValueActionItem) && (urlString.getResult().equals(""))) { - output.add(new UnLoadMovieActionItem(this, targetString)); - } else { - output.add(new LoadMovieActionItem(this, urlString, targetString, sendVarsMethod)); - } - } else { - String printPrefix = "print:#"; - String printAsBitmapPrefix = "printasbitmap:#"; - String urlStr = null; - if (urlString.isCompileTime() && (urlString.getResult() instanceof String)) { - urlStr = (String) urlString.getResult(); - } - - if (num != null) { - if ("".equals(urlStr)) { - output.add(new UnLoadMovieNumActionItem(this, new DirectValueActionItem(null, 0, (Long) (long) (int) num, new ArrayList()))); - } else if (urlStr != null && urlStr.startsWith(printPrefix)) { - output.add(new PrintNumActionItem(this, new DirectValueActionItem((Long) (long) (int) num), - new DirectValueActionItem(urlStr.substring(printPrefix.length())))); - } else if (urlStr != null && urlStr.startsWith(printAsBitmapPrefix)) { - output.add(new PrintAsBitmapNumActionItem(this, new DirectValueActionItem((Long) (long) (int) num), new DirectValueActionItem(urlStr.substring(printAsBitmapPrefix.length())))); - } else { - output.add(new LoadMovieNumActionItem(this, urlString, new DirectValueActionItem(null, 0, (Long) (long) (int) num, new ArrayList()), sendVarsMethod)); - } - } else { - if (urlStr != null && urlStr.startsWith(printPrefix)) { - output.add(new PrintActionItem(this, targetString, new DirectValueActionItem(urlStr.substring(printPrefix.length())))); - } else if (urlStr != null && urlStr.startsWith(printAsBitmapPrefix)) { - output.add(new PrintAsBitmapActionItem(this, targetString, new DirectValueActionItem(urlStr.substring(printAsBitmapPrefix.length())))); - } else { - output.add(new GetURL2ActionItem(this, urlString, targetString, sendVarsMethod)); - } - } - } - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.SWFInputStream; +import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; +import com.jpexs.decompiler.flash.action.model.GetURL2ActionItem; +import com.jpexs.decompiler.flash.action.model.LoadMovieActionItem; +import com.jpexs.decompiler.flash.action.model.LoadMovieNumActionItem; +import com.jpexs.decompiler.flash.action.model.LoadVariablesActionItem; +import com.jpexs.decompiler.flash.action.model.LoadVariablesNumActionItem; +import com.jpexs.decompiler.flash.action.model.PrintActionItem; +import com.jpexs.decompiler.flash.action.model.PrintAsBitmapActionItem; +import com.jpexs.decompiler.flash.action.model.PrintAsBitmapNumActionItem; +import com.jpexs.decompiler.flash.action.model.PrintNumActionItem; +import com.jpexs.decompiler.flash.action.model.UnLoadMovieActionItem; +import com.jpexs.decompiler.flash.action.model.UnLoadMovieNumActionItem; +import com.jpexs.decompiler.flash.action.parser.ParseException; +import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionGetURL2 extends Action { + + public int sendVarsMethod; + public static final int GET = 1; + public static final int POST = 2; + public boolean loadTargetFlag; + public boolean loadVariablesFlag; + public int reserved; + + public ActionGetURL2(int sendVarsMethod, boolean loadVariablesFlag, boolean loadTargetFlag) { + super(0x9A, 1); + this.loadTargetFlag = loadTargetFlag; + this.loadVariablesFlag = loadVariablesFlag; + this.sendVarsMethod = sendVarsMethod; + } + + public ActionGetURL2(int actionLength, SWFInputStream sis) throws IOException { + super(0x9A, actionLength); + loadVariablesFlag = sis.readUB(1, "loadVariablesFlag") == 1; + loadTargetFlag = sis.readUB(1, "loadTargetFlag") == 1; + reserved = (int) sis.readUB(4, "reserved"); + sendVarsMethod = (int) sis.readUB(2, "sendVarsMethod"); //This is first in documentation, which is WRONG! + } + + @Override + public String toString() { + return "GetURL2 " + loadVariablesFlag + " " + loadTargetFlag + " " + sendVarsMethod; + } + + @Override + public byte[] getBytes(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + try { + sos.writeUB(1, loadVariablesFlag ? 1 : 0); + sos.writeUB(1, loadTargetFlag ? 1 : 0); + sos.writeUB(4, reserved); + sos.writeUB(2, sendVarsMethod); + sos.close(); + } catch (IOException e) { + } + return surroundWithAction(baos.toByteArray(), version); + } + + public ActionGetURL2(FlasmLexer lexer) throws IOException, ParseException { + super(0x9A, -1); + loadVariablesFlag = lexBoolean(lexer); + loadTargetFlag = lexBoolean(lexer); + sendVarsMethod = (int) lexLong(lexer); + } + + @Override + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem targetString = stack.pop(); + GraphTargetItem urlString = stack.pop(); + Integer num = null; + if (targetString.isCompileTime()) { + Object res = targetString.getResult(); + if (res instanceof String) { + String tarStr = (String) res; + String levelPrefix = "_level"; + if (tarStr.startsWith(levelPrefix)) { + try { + num = Integer.valueOf(tarStr.substring(levelPrefix.length())); + } catch (NumberFormatException nfe) { + } + } + } + } + if (loadVariablesFlag) { + if (num != null) { + output.add(new LoadVariablesNumActionItem(this, urlString, new DirectValueActionItem(null, 0, (Long) (long) (int) num, new ArrayList()), sendVarsMethod)); + } else { + output.add(new LoadVariablesActionItem(this, urlString, targetString, sendVarsMethod)); + } + } else if (loadTargetFlag) { + if ((urlString instanceof DirectValueActionItem) && (urlString.getResult().equals(""))) { + output.add(new UnLoadMovieActionItem(this, targetString)); + } else { + output.add(new LoadMovieActionItem(this, urlString, targetString, sendVarsMethod)); + } + } else { + String printPrefix = "print:#"; + String printAsBitmapPrefix = "printasbitmap:#"; + String urlStr = null; + if (urlString.isCompileTime() && (urlString.getResult() instanceof String)) { + urlStr = (String) urlString.getResult(); + } + + if (num != null) { + if ("".equals(urlStr)) { + output.add(new UnLoadMovieNumActionItem(this, new DirectValueActionItem(null, 0, (Long) (long) (int) num, new ArrayList()))); + } else if (urlStr != null && urlStr.startsWith(printPrefix)) { + output.add(new PrintNumActionItem(this, new DirectValueActionItem((Long) (long) (int) num), + new DirectValueActionItem(urlStr.substring(printPrefix.length())))); + } else if (urlStr != null && urlStr.startsWith(printAsBitmapPrefix)) { + output.add(new PrintAsBitmapNumActionItem(this, new DirectValueActionItem((Long) (long) (int) num), new DirectValueActionItem(urlStr.substring(printAsBitmapPrefix.length())))); + } else { + output.add(new LoadMovieNumActionItem(this, urlString, new DirectValueActionItem(null, 0, (Long) (long) (int) num, new ArrayList()), sendVarsMethod)); + } + } else { + if (urlStr != null && urlStr.startsWith(printPrefix)) { + output.add(new PrintActionItem(this, targetString, new DirectValueActionItem(urlStr.substring(printPrefix.length())))); + } else if (urlStr != null && urlStr.startsWith(printAsBitmapPrefix)) { + output.add(new PrintAsBitmapActionItem(this, targetString, new DirectValueActionItem(urlStr.substring(printAsBitmapPrefix.length())))); + } else { + output.add(new GetURL2ActionItem(this, urlString, targetString, sendVarsMethod)); + } + } + } + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java index f6aa53720..a35d71757 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java @@ -1,92 +1,92 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.SWFInputStream; -import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.GotoFrame2ActionItem; -import com.jpexs.decompiler.flash.action.parser.ParseException; -import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionGotoFrame2 extends Action { - - boolean sceneBiasFlag; - boolean playFlag; - public int sceneBias; - int reserved; - - public ActionGotoFrame2(boolean playFlag, boolean sceneBiasFlag, int sceneBias) { - super(0x9F, 0); - this.sceneBiasFlag = sceneBiasFlag; - this.playFlag = playFlag; - this.sceneBias = sceneBias; - } - - public ActionGotoFrame2(int actionLength, SWFInputStream sis) throws IOException { - super(0x9F, actionLength); - reserved = (int) sis.readUB(6); - sceneBiasFlag = sis.readUB(1) == 1; - playFlag = sis.readUB(1) == 1; - if (sceneBiasFlag) { - sceneBias = sis.readUI16(); - } - } - - @Override - public byte[] getBytes(int version) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - try { - sos.writeUB(6, reserved); - sos.writeUB(1, sceneBiasFlag ? 1 : 0); - sos.writeUB(1, playFlag ? 1 : 0); - if (sceneBiasFlag) { - sos.writeUI16(sceneBias); - } - sos.close(); - } catch (IOException e) { - } - return surroundWithAction(baos.toByteArray(), version); - } - - @Override - public String toString() { - return "GotoFrame2 " + sceneBiasFlag + " " + playFlag + " " + (sceneBiasFlag ? " " + sceneBias : ""); - } - - public ActionGotoFrame2(FlasmLexer lexer) throws IOException, ParseException { - super(0x9F, -1); - sceneBiasFlag = lexBoolean(lexer); - playFlag = lexBoolean(lexer); - if (sceneBiasFlag) { - sceneBias = (int) lexLong(lexer); - } - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem frame = stack.pop(); - output.add(new GotoFrame2ActionItem(this, frame, sceneBiasFlag, playFlag, sceneBias)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.SWFInputStream; +import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.GotoFrame2ActionItem; +import com.jpexs.decompiler.flash.action.parser.ParseException; +import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionGotoFrame2 extends Action { + + boolean sceneBiasFlag; + boolean playFlag; + public int sceneBias; + int reserved; + + public ActionGotoFrame2(boolean playFlag, boolean sceneBiasFlag, int sceneBias) { + super(0x9F, 0); + this.sceneBiasFlag = sceneBiasFlag; + this.playFlag = playFlag; + this.sceneBias = sceneBias; + } + + public ActionGotoFrame2(int actionLength, SWFInputStream sis) throws IOException { + super(0x9F, actionLength); + reserved = (int) sis.readUB(6, "reserved"); + sceneBiasFlag = sis.readUB(1, "sceneBiasFlag") == 1; + playFlag = sis.readUB(1, "playFlag") == 1; + if (sceneBiasFlag) { + sceneBias = sis.readUI16("sceneBias"); + } + } + + @Override + public byte[] getBytes(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + try { + sos.writeUB(6, reserved); + sos.writeUB(1, sceneBiasFlag ? 1 : 0); + sos.writeUB(1, playFlag ? 1 : 0); + if (sceneBiasFlag) { + sos.writeUI16(sceneBias); + } + sos.close(); + } catch (IOException e) { + } + return surroundWithAction(baos.toByteArray(), version); + } + + @Override + public String toString() { + return "GotoFrame2 " + sceneBiasFlag + " " + playFlag + " " + (sceneBiasFlag ? " " + sceneBias : ""); + } + + public ActionGotoFrame2(FlasmLexer lexer) throws IOException, ParseException { + super(0x9F, -1); + sceneBiasFlag = lexBoolean(lexer); + playFlag = lexBoolean(lexer); + if (sceneBiasFlag) { + sceneBias = (int) lexLong(lexer); + } + } + + @Override + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem frame = stack.pop(); + output.add(new GotoFrame2ActionItem(this, frame, sceneBiasFlag, playFlag, sceneBias)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java index 8c88a5020..31fb71c8e 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java @@ -1,131 +1,131 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.SWFInputStream; -import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.ActionGraphSource; -import com.jpexs.decompiler.flash.action.parser.ParseException; -import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; -import com.jpexs.decompiler.graph.GraphSource; -import com.jpexs.decompiler.graph.GraphSourceItem; -import com.jpexs.helpers.Helper; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - -public class ActionIf extends Action { - - private int offset; - public String identifier; - public boolean jumpUsed = true; - public boolean ignoreUsed = true; - - public int getJumpOffset() { - return offset; - } - - public final void setJumpOffset(int offset) { - this.offset = offset; - } - - public ActionIf(int offset) { - super(0x9D, 2); - setJumpOffset(offset); - } - - public ActionIf(int actionLength, SWFInputStream sis) throws IOException { - super(0x9D, actionLength); - setJumpOffset(sis.readSI16()); - } - - @Override - public List getAllRefs(int version) { - List ret = new ArrayList<>(); - ret.add(getRef(version)); - return ret; - } - - public long getRef(int version) { - return getAddress() + getBytes(version).length + offset; - } - - @Override - public byte[] getBytes(int version) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - try { - sos.writeSI16(offset); - sos.close(); - } catch (IOException e) { - } - return surroundWithAction(baos.toByteArray(), version); - } - - @Override - public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { - String ofsStr = Helper.formatAddress(getAddress() + getBytes(version).length + offset); - return "If loc" + ofsStr + (!jumpUsed ? " ;compileTimeIgnore" : (!ignoreUsed ? " ;compileTimeJump" : "")); - } - - public ActionIf(FlasmLexer lexer) throws IOException, ParseException { - super(0x9D, -1); - identifier = lexIdentifier(lexer); - } - - @Override - public List getAllIfsOrJumps() { - List ret = new ArrayList<>(); - ret.add(this); - return ret; - } - - @Override - public String toString() { - return "ActionIf"; - } - - @Override - public boolean isBranch() { - return true; - } - - @Override - public List getBranches(GraphSource code) { - List ret = super.getBranches(code); - int jmp = code.adr2pos(getAddress() + getBytes(((ActionGraphSource) code).version).length + offset); - int after = code.adr2pos(getAddress() + getBytes(((ActionGraphSource) code).version).length); - if (jmp == -1) { - Logger.getLogger(ActionIf.class.getName()).log(Level.SEVERE, "Invalid IF jump to ofs" + Helper.formatAddress(getAddress() + getBytes(((ActionGraphSource) code).version).length + offset)); - ret.add(after); - } else { - ret.add(jmp); - } - ret.add(after); - return ret; - } - - @Override - public boolean ignoredLoops() { - return false; //compileTime; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.SWFInputStream; +import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.ActionGraphSource; +import com.jpexs.decompiler.flash.action.parser.ParseException; +import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; +import com.jpexs.decompiler.graph.GraphSource; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.helpers.Helper; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class ActionIf extends Action { + + private int offset; + public String identifier; + public boolean jumpUsed = true; + public boolean ignoreUsed = true; + + public int getJumpOffset() { + return offset; + } + + public final void setJumpOffset(int offset) { + this.offset = offset; + } + + public ActionIf(int offset) { + super(0x9D, 2); + setJumpOffset(offset); + } + + public ActionIf(int actionLength, SWFInputStream sis) throws IOException { + super(0x9D, actionLength); + setJumpOffset(sis.readSI16("offset")); + } + + @Override + public List getAllRefs(int version) { + List ret = new ArrayList<>(); + ret.add(getRef(version)); + return ret; + } + + public long getRef(int version) { + return getAddress() + getBytes(version).length + offset; + } + + @Override + public byte[] getBytes(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + try { + sos.writeSI16(offset); + sos.close(); + } catch (IOException e) { + } + return surroundWithAction(baos.toByteArray(), version); + } + + @Override + public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { + String ofsStr = Helper.formatAddress(getAddress() + getBytes(version).length + offset); + return "If loc" + ofsStr + (!jumpUsed ? " ;compileTimeIgnore" : (!ignoreUsed ? " ;compileTimeJump" : "")); + } + + public ActionIf(FlasmLexer lexer) throws IOException, ParseException { + super(0x9D, -1); + identifier = lexIdentifier(lexer); + } + + @Override + public List getAllIfsOrJumps() { + List ret = new ArrayList<>(); + ret.add(this); + return ret; + } + + @Override + public String toString() { + return "ActionIf"; + } + + @Override + public boolean isBranch() { + return true; + } + + @Override + public List getBranches(GraphSource code) { + List ret = super.getBranches(code); + int jmp = code.adr2pos(getAddress() + getBytes(((ActionGraphSource) code).version).length + offset); + int after = code.adr2pos(getAddress() + getBytes(((ActionGraphSource) code).version).length); + if (jmp == -1) { + Logger.getLogger(ActionIf.class.getName()).log(Level.SEVERE, "Invalid IF jump to ofs" + Helper.formatAddress(getAddress() + getBytes(((ActionGraphSource) code).version).length + offset)); + ret.add(after); + } else { + ret.add(jmp); + } + ret.add(after); + return ret; + } + + @Override + public boolean ignoredLoops() { + return false; //compileTime; + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java index 5685489e4..3a27a927a 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java @@ -1,124 +1,124 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.SWFInputStream; -import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.ActionGraphSource; -import com.jpexs.decompiler.flash.action.parser.ParseException; -import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; -import com.jpexs.decompiler.graph.GraphSource; -import com.jpexs.decompiler.graph.GraphSourceItem; -import com.jpexs.helpers.Helper; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - -public class ActionJump extends Action { - - private int offset; - public String identifier; - public boolean isContinue = false; - public boolean isBreak = false; - - public int getJumpOffset() { - return offset; - } - - public final void setJumpOffset(int offset) { - this.offset = offset; - } - - public ActionJump(int offset) { - super(0x99, 2); - setJumpOffset(offset); - } - - public ActionJump(int actionLength, SWFInputStream sis) throws IOException { - super(0x99, actionLength); - setJumpOffset(sis.readSI16()); - } - - @Override - public List getAllRefs(int version) { - List ret = new ArrayList<>(); - ret.add(getRef(version)); - return ret; - } - - public long getRef(int version) { - return getAddress() + getBytes(version).length + offset; - } - - @Override - public byte[] getBytes(int version) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - try { - sos.writeSI16(offset); - sos.close(); - } catch (IOException e) { - } - return surroundWithAction(baos.toByteArray(), version); - } - - @Override - public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { - String ofsStr = Helper.formatAddress(getAddress() + getBytes(version).length + offset); - return "Jump loc" + ofsStr; - } - - public ActionJump(FlasmLexer lexer) throws IOException, ParseException { - super(0x99, 0); - identifier = lexIdentifier(lexer); - } - - @Override - public List getAllIfsOrJumps() { - List ret = new ArrayList<>(); - ret.add(this); - return ret; - } - - @Override - public String toString() { - return "Jump " + offset; - } - - @Override - public boolean isJump() { - return true; - } - - @Override - public List getBranches(GraphSource code) { - List ret = super.getBranches(code); - int ofs = code.adr2pos(getAddress() + getBytes(((ActionGraphSource) code).version).length + offset); - if (ofs == -1) { - ofs = code.adr2pos(getAddress() + getBytes(((ActionGraphSource) code).version).length); - new Exception().printStackTrace(); - Logger.getLogger(ActionJump.class.getName()).log(Level.SEVERE, "Invalid jump to ofs" + Helper.formatAddress(getAddress() + getBytes(((ActionGraphSource) code).version).length + offset) + " from ofs" + Helper.formatAddress(getAddress())); - } - ret.add(ofs); - return ret; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.SWFInputStream; +import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.ActionGraphSource; +import com.jpexs.decompiler.flash.action.parser.ParseException; +import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; +import com.jpexs.decompiler.graph.GraphSource; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.helpers.Helper; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class ActionJump extends Action { + + private int offset; + public String identifier; + public boolean isContinue = false; + public boolean isBreak = false; + + public int getJumpOffset() { + return offset; + } + + public final void setJumpOffset(int offset) { + this.offset = offset; + } + + public ActionJump(int offset) { + super(0x99, 2); + setJumpOffset(offset); + } + + public ActionJump(int actionLength, SWFInputStream sis) throws IOException { + super(0x99, actionLength); + setJumpOffset(sis.readSI16("offset")); + } + + @Override + public List getAllRefs(int version) { + List ret = new ArrayList<>(); + ret.add(getRef(version)); + return ret; + } + + public long getRef(int version) { + return getAddress() + getBytes(version).length + offset; + } + + @Override + public byte[] getBytes(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + try { + sos.writeSI16(offset); + sos.close(); + } catch (IOException e) { + } + return surroundWithAction(baos.toByteArray(), version); + } + + @Override + public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { + String ofsStr = Helper.formatAddress(getAddress() + getBytes(version).length + offset); + return "Jump loc" + ofsStr; + } + + public ActionJump(FlasmLexer lexer) throws IOException, ParseException { + super(0x99, 0); + identifier = lexIdentifier(lexer); + } + + @Override + public List getAllIfsOrJumps() { + List ret = new ArrayList<>(); + ret.add(this); + return ret; + } + + @Override + public String toString() { + return "Jump " + offset; + } + + @Override + public boolean isJump() { + return true; + } + + @Override + public List getBranches(GraphSource code) { + List ret = super.getBranches(code); + int ofs = code.adr2pos(getAddress() + getBytes(((ActionGraphSource) code).version).length + offset); + if (ofs == -1) { + ofs = code.adr2pos(getAddress() + getBytes(((ActionGraphSource) code).version).length); + new Exception().printStackTrace(); + Logger.getLogger(ActionJump.class.getName()).log(Level.SEVERE, "Invalid jump to ofs" + Helper.formatAddress(getAddress() + getBytes(((ActionGraphSource) code).version).length + offset) + " from ofs" + Helper.formatAddress(getAddress())); + } + ret.add(ofs); + return ret; + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java index 63eca896a..1678949f3 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java @@ -77,16 +77,16 @@ public class ActionPush extends Action { super(0x96, actionLength); int type; values = new ArrayList<>(); - sis = new SWFInputStream(sis.getSwf(), sis.readBytesEx(actionLength)); + sis = new SWFInputStream(sis.getSwf(), sis.readBytesEx(actionLength, "actionPush")); try { while (sis.available() > 0) { - type = sis.readUI8(); + type = sis.readUI8("type"); switch (type) { case 0: - values.add(sis.readString()); + values.add(sis.readString("string")); break; case 1: - values.add(sis.readFLOAT()); + values.add(sis.readFLOAT("float")); break; case 2: values.add(new Null()); @@ -95,10 +95,10 @@ public class ActionPush extends Action { values.add(new Undefined()); break; case 4: - values.add(new RegisterNumber(sis.readUI8())); + values.add(new RegisterNumber(sis.readUI8("registerNumber"))); break; case 5: - int b = sis.readUI8(); + int b = sis.readUI8("boolean"); if (b == 0) { values.add((Boolean) false); } else { @@ -107,17 +107,17 @@ public class ActionPush extends Action { break; case 6: - values.add(sis.readDOUBLE()); + values.add(sis.readDOUBLE("double")); break; case 7: - long el = sis.readSI32(); + long el = sis.readSI32("el"); values.add((Long) el); break; case 8: - values.add(new ConstantIndex(sis.readUI8())); + values.add(new ConstantIndex(sis.readUI8("constantIndex"))); break; case 9: - values.add(new ConstantIndex(sis.readUI16())); + values.add(new ConstantIndex(sis.readUI16("constantIndex"))); break; } } diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java index efa9f0ffe..d29fa6b53 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java @@ -1,136 +1,136 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.SWF; -import com.jpexs.decompiler.flash.SWFInputStream; -import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.ActionGraph; -import com.jpexs.decompiler.flash.action.model.ConstantPool; -import com.jpexs.decompiler.flash.action.model.clauses.IfFrameLoadedActionItem; -import com.jpexs.decompiler.flash.action.parser.ParseException; -import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.flash.action.special.ActionStore; -import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; -import com.jpexs.decompiler.graph.GraphSourceItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionWaitForFrame2 extends Action implements ActionStore { - - public int skipCount; - List skipped; - - public ActionWaitForFrame2(int skipCount) { - super(0x8D, 1); - this.skipCount = skipCount; - skipped = new ArrayList<>(); - } - - @Override - public int getStoreSize() { - return skipCount; - } - - @Override - public void setStore(List store) { - skipped = store; - skipCount = store.size(); - } - - public ActionWaitForFrame2(int actionLength, SWFInputStream sis, ConstantPool cpool) throws IOException { - super(0x8D, actionLength); - skipCount = sis.readUI8(); - skipped = new ArrayList<>(); - /*for (int i = 0; i < skipCount; i++) { - Action a = sis.readAction(cpool); - if (a instanceof ActionEnd) { - skipCount = i; - break; - } - if (a == null) { - skipCount = i; - break; - } - skipped.add(a); - } - boolean deobfuscate = Configuration.getConfig("autoDeobfuscate", true); - if (deobfuscate) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - for (int i = 0; i < skipCount; i++) { - baos.write(skipped.get(i).getBytes(sis.getVersion())); - } - baos.write(new ActionEnd().getBytes(sis.getVersion())); - SWFInputStream sis2 = new SWFInputStream(new ByteArrayInputStream(baos.toByteArray()), sis.getVersion()); - skipped = sis2.readActionList(new ArrayList(), 0, ""); - if (!skipped.isEmpty()) { - if (skipped.get(skipped.size() - 1) instanceof ActionEnd) { - skipped.remove(skipped.size() - 1); - } - } - skipCount = skipped.size(); - }*/ - } - - public ActionWaitForFrame2(FlasmLexer lexer) throws IOException, ParseException { - super(0x8D, -1); - skipCount = (int) lexLong(lexer); - skipped = new ArrayList<>(); - } - - @Override - public byte[] getBytes(int version) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - try { - sos.writeUI8(skipCount); - sos.close(); - } catch (IOException e) { - } - return surroundWithAction(baos.toByteArray(), version); - } - - @Override - public String toString() { - return "WaitForFrame2"; - } - - @Override - public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { - String ret = "WaitForFrame2 " + skipCount; - /*for (int i = 0; i < skipped.size(); i++) { - if (skipped.get(i) instanceof ActionEnd) { - break; - } - ret += "\r\n" + skipped.get(i).getASMSource(container, knownAddreses, constantPool, version, exportMode); - }*/ - return ret; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) throws InterruptedException { - GraphTargetItem frame = stack.pop(); - List body = ActionGraph.translateViaGraph(regNames, variables, functions, skipped, SWF.DEFAULT_VERSION, staticOperation, path); - output.add(new IfFrameLoadedActionItem(frame, body, this)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.SWFInputStream; +import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.ActionGraph; +import com.jpexs.decompiler.flash.action.model.ConstantPool; +import com.jpexs.decompiler.flash.action.model.clauses.IfFrameLoadedActionItem; +import com.jpexs.decompiler.flash.action.parser.ParseException; +import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; +import com.jpexs.decompiler.flash.action.special.ActionStore; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionWaitForFrame2 extends Action implements ActionStore { + + public int skipCount; + List skipped; + + public ActionWaitForFrame2(int skipCount) { + super(0x8D, 1); + this.skipCount = skipCount; + skipped = new ArrayList<>(); + } + + @Override + public int getStoreSize() { + return skipCount; + } + + @Override + public void setStore(List store) { + skipped = store; + skipCount = store.size(); + } + + public ActionWaitForFrame2(int actionLength, SWFInputStream sis, ConstantPool cpool) throws IOException { + super(0x8D, actionLength); + skipCount = sis.readUI8("skipCount"); + skipped = new ArrayList<>(); + /*for (int i = 0; i < skipCount; i++) { + Action a = sis.readAction(cpool); + if (a instanceof ActionEnd) { + skipCount = i; + break; + } + if (a == null) { + skipCount = i; + break; + } + skipped.add(a); + } + boolean deobfuscate = Configuration.getConfig("autoDeobfuscate", true); + if (deobfuscate) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + for (int i = 0; i < skipCount; i++) { + baos.write(skipped.get(i).getBytes(sis.getVersion())); + } + baos.write(new ActionEnd().getBytes(sis.getVersion())); + SWFInputStream sis2 = new SWFInputStream(new ByteArrayInputStream(baos.toByteArray()), sis.getVersion()); + skipped = sis2.readActionList(new ArrayList(), 0, ""); + if (!skipped.isEmpty()) { + if (skipped.get(skipped.size() - 1) instanceof ActionEnd) { + skipped.remove(skipped.size() - 1); + } + } + skipCount = skipped.size(); + }*/ + } + + public ActionWaitForFrame2(FlasmLexer lexer) throws IOException, ParseException { + super(0x8D, -1); + skipCount = (int) lexLong(lexer); + skipped = new ArrayList<>(); + } + + @Override + public byte[] getBytes(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + try { + sos.writeUI8(skipCount); + sos.close(); + } catch (IOException e) { + } + return surroundWithAction(baos.toByteArray(), version); + } + + @Override + public String toString() { + return "WaitForFrame2"; + } + + @Override + public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { + String ret = "WaitForFrame2 " + skipCount; + /*for (int i = 0; i < skipped.size(); i++) { + if (skipped.get(i) instanceof ActionEnd) { + break; + } + ret += "\r\n" + skipped.get(i).getASMSource(container, knownAddreses, constantPool, version, exportMode); + }*/ + return ret; + } + + @Override + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) throws InterruptedException { + GraphTargetItem frame = stack.pop(); + List body = ActionGraph.translateViaGraph(regNames, variables, functions, skipped, SWF.DEFAULT_VERSION, staticOperation, path); + output.add(new IfFrameLoadedActionItem(frame, body, this)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java index 4a04fef39..9cd23e5bd 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java @@ -1,95 +1,95 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.SWFInputStream; -import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.parser.ParseException; -import com.jpexs.decompiler.flash.action.parser.pcode.ASMParsedSymbol; -import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.helpers.Helper; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionConstantPool extends Action { - - public List constantPool = new ArrayList<>(); - - public ActionConstantPool(List constantPool) { - super(0x88, 0); - this.constantPool = constantPool; - } - - public ActionConstantPool(int actionLength, SWFInputStream sis, int version) throws IOException { - super(0x88, actionLength); - //sis = new SWFInputStream(new ByteArrayInputStream(sis.readBytes(actionLength)), version); - int count = sis.readUI16(); - for (int i = 0; i < count; i++) { - constantPool.add(sis.readString()); - } - } - - public ActionConstantPool(FlasmLexer lexer) throws IOException, ParseException { - super(0x88, 0); - while (true) { - ASMParsedSymbol symb = lexer.yylex(); - if (symb.type == ASMParsedSymbol.TYPE_STRING) { - constantPool.add((String) symb.value); - } else { - lexer.yypushback(lexer.yylength()); - break; - } - } - } - - @Override - public byte[] getBytes(int version) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - try { - sos.writeUI16(constantPool.size()); - for (String s : constantPool) { - sos.writeString(s); - } - sos.close(); - } catch (IOException e) { - } - return surroundWithAction(baos.toByteArray(), version); - } - - @Override - public String toString() { - String ret = ""; - for (int i = 0; i < constantPool.size(); i++) { - if (i > 0) { - ret += " "; - } - ret += "\"" + Helper.escapeString(constantPool.get(i)) + "\""; - } - return "ConstantPool " + ret; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.SWFInputStream; +import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.parser.ParseException; +import com.jpexs.decompiler.flash.action.parser.pcode.ASMParsedSymbol; +import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionConstantPool extends Action { + + public List constantPool = new ArrayList<>(); + + public ActionConstantPool(List constantPool) { + super(0x88, 0); + this.constantPool = constantPool; + } + + public ActionConstantPool(int actionLength, SWFInputStream sis, int version) throws IOException { + super(0x88, actionLength); + //sis = new SWFInputStream(new ByteArrayInputStream(sis.readBytes(actionLength)), version); + int count = sis.readUI16("count"); + for (int i = 0; i < count; i++) { + constantPool.add(sis.readString("constant")); + } + } + + public ActionConstantPool(FlasmLexer lexer) throws IOException, ParseException { + super(0x88, 0); + while (true) { + ASMParsedSymbol symb = lexer.yylex(); + if (symb.type == ASMParsedSymbol.TYPE_STRING) { + constantPool.add((String) symb.value); + } else { + lexer.yypushback(lexer.yylength()); + break; + } + } + } + + @Override + public byte[] getBytes(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + try { + sos.writeUI16(constantPool.size()); + for (String s : constantPool) { + sos.writeString(s); + } + sos.close(); + } catch (IOException e) { + } + return surroundWithAction(baos.toByteArray(), version); + } + + @Override + public String toString() { + String ret = ""; + for (int i = 0; i < constantPool.size(); i++) { + if (i > 0) { + ret += " "; + } + ret += "\"" + Helper.escapeString(constantPool.get(i)) + "\""; + } + return "ConstantPool " + ret; + } + + @Override + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java index 29a72de5c..32b62d0bf 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java @@ -1,248 +1,248 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.SWFInputStream; -import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.FunctionActionItem; -import com.jpexs.decompiler.flash.action.parser.ParseException; -import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.flash.action.parser.script.VariableActionItem; -import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; -import com.jpexs.decompiler.flash.helpers.GraphTextWriter; -import com.jpexs.decompiler.graph.GraphSourceItem; -import com.jpexs.decompiler.graph.GraphSourceItemContainer; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.helpers.Helper; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionDefineFunction extends Action implements GraphSourceItemContainer { - - public String functionName; - public String replacedFunctionName; - public List paramNames = new ArrayList<>(); - public List replacedParamNames; - //public List code; - public int codeSize; - private int version; - public List constantPool; - private long hdrSize; - - public ActionDefineFunction(String functionName, List paramNames, int codeSize, int version) { - super(0x9B, 0); - this.functionName = functionName; - this.codeSize = codeSize; - this.version = version; - this.paramNames = paramNames; - } - - public ActionDefineFunction(int actionLength, SWFInputStream sis, int version) throws IOException { - super(0x9B, actionLength); - this.version = version; - //byte[] data=sis.readBytes(actionLength); - //sis=new SWFInputStream(new ByteArrayInputStream(data),version); - long startPos = sis.getPos(); - functionName = sis.readString(); - int numParams = sis.readUI16(); - for (int i = 0; i < numParams; i++) { - paramNames.add(sis.readString()); - } - codeSize = sis.readUI16(); - long endPos = sis.getPos(); - //code = new ArrayList(); - hdrSize = endPos - startPos; - //int posBef2 = (int) rri.getPos(); - //code = sis.readActionList(rri.getPos(), getFileAddress() + hdrSize, rri, codeSize); - //rri.setPos(posBef2 + codeSize); - } - - public ActionDefineFunction(FlasmLexer lexer) throws IOException, ParseException { - super(0x9B, -1); - functionName = lexString(lexer); - int numParams = (int) lexLong(lexer); - for (int i = 0; i < numParams; i++) { - paramNames.add(lexString(lexer)); - } - lexBlockOpen(lexer); - } - - @Override - public long getHeaderSize() { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); - try { - sos.writeString(functionName); - sos.writeUI16(paramNames.size()); - for (String s : paramNames) { - sos.writeString(s); - } - sos.writeUI16(0); - sos.close(); - - baos2.write(surroundWithAction(baos.toByteArray(), version)); - } catch (IOException e) { - } - return baos2.toByteArray().length; - } - - @Override - public byte[] getBytes(int version) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); - try { - sos.writeString(functionName); - sos.writeUI16(paramNames.size()); - for (String s : paramNames) { - sos.writeString(s); - } - //byte[] codeBytes = Action.actionsToBytes(code, false, version); - sos.writeUI16(codeSize); //codeBytes.length); - sos.close(); - - baos2.write(surroundWithAction(baos.toByteArray(), version)); - //baos2.write(codeBytes); - } catch (IOException e) { - } - return baos2.toByteArray(); - } - - private long getPreLen(int version) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - try { - sos.writeString(functionName); - sos.writeUI16(paramNames.size()); - for (String s : paramNames) { - sos.writeString(s); - } - sos.writeUI16(0); - sos.close(); - } catch (IOException e) { - } - - return surroundWithAction(baos.toByteArray(), version).length; - } - - @Override - public void setAddress(long address, int version, boolean recursive) { - super.setAddress(address, version, recursive); - if (recursive) { - //Action.setActionsAddresses(, address + getPreLen(version), version); - } - } - - @Override - public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { - String paramStr = ""; - for (int i = 0; i < paramNames.size(); i++) { - paramStr += "\"" + Helper.escapeString(paramNames.get(i)) + "\""; - paramStr += " "; - } - - return "DefineFunction \"" + Helper.escapeString(functionName) + "\" " + paramNames.size() + " " + paramStr + " {" + (codeSize == 0 ? "\r\n}" : "");// + "\r\n" +Action.actionsToString(getAddress() + getHeaderLength(),getItems(container) , knownAddreses, constantPool, version, hex, getFileAddress() + hdrSize) + "}"; - } - - @Override - public GraphTextWriter getASMSourceReplaced(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode, GraphTextWriter writer) { - List oldParamNames = paramNames; - if (replacedParamNames != null) { - paramNames = replacedParamNames; - } - String oldFunctionName = functionName; - if (replacedFunctionName != null) { - functionName = replacedFunctionName; - } - String ret = getASMSource(container, knownAddreses, constantPool, version, exportMode); - paramNames = oldParamNames; - functionName = oldFunctionName; - writer.appendNoHilight(ret); - return writer; - - } - - @Override - public List getAllRefs(int version) { - return super.getAllRefs(version);//Action.getActionsAllRefs(getActions(null), version); - } - - @Override - public List getAllIfsOrJumps() { - return super.getAllIfsOrJumps(); //Action.getActionsAllIfsOrJumps(code); - } - - @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - } - - @Override - public HashMap getRegNames() { - return new HashMap<>(); - } - - @Override - public void translateContainer(List> content, Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions) { - FunctionActionItem fti = new FunctionActionItem(this, functionName, paramNames, content.get(0), constantPool, 1, new ArrayList()); - //ActionGraph.translateViaGraph(regNames, variables, functions, code, version) - stack.push(fti); - functions.put(functionName, fti); - } - - @Override - public String toString() { - return "DefineFunction"; - } - - @Override - public boolean parseDivision(long size, FlasmLexer lexer) { - codeSize = (int) (size - getHeaderSize()); - return false; - } - - @Override - public List getContainerSizes() { - List ret = new ArrayList<>(); - ret.add((Long) (long) codeSize); - return ret; - } - - @Override - public void setContainerSize(int index, long size) { - if (index == 0) { - codeSize = (int) size; - } else { - throw new IllegalArgumentException("Index must be 0."); - } - } - - @Override - public String getASMSourceBetween(int pos) { - return ""; - } - - @Override - public String getName() { - return "function"; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.SWFInputStream; +import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.FunctionActionItem; +import com.jpexs.decompiler.flash.action.parser.ParseException; +import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; +import com.jpexs.decompiler.flash.action.parser.script.VariableActionItem; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.decompiler.graph.GraphSourceItemContainer; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionDefineFunction extends Action implements GraphSourceItemContainer { + + public String functionName; + public String replacedFunctionName; + public List paramNames = new ArrayList<>(); + public List replacedParamNames; + //public List code; + public int codeSize; + private int version; + public List constantPool; + private long hdrSize; + + public ActionDefineFunction(String functionName, List paramNames, int codeSize, int version) { + super(0x9B, 0); + this.functionName = functionName; + this.codeSize = codeSize; + this.version = version; + this.paramNames = paramNames; + } + + public ActionDefineFunction(int actionLength, SWFInputStream sis, int version) throws IOException { + super(0x9B, actionLength); + this.version = version; + //byte[] data=sis.readBytes(actionLength); + //sis=new SWFInputStream(new ByteArrayInputStream(data),version); + long startPos = sis.getPos(); + functionName = sis.readString("functionName"); + int numParams = sis.readUI16("numParams"); + for (int i = 0; i < numParams; i++) { + paramNames.add(sis.readString("paramName")); + } + codeSize = sis.readUI16("codeSize"); + long endPos = sis.getPos(); + //code = new ArrayList(); + hdrSize = endPos - startPos; + //int posBef2 = (int) rri.getPos(); + //code = sis.readActionList(rri.getPos(), getFileAddress() + hdrSize, rri, codeSize); + //rri.setPos(posBef2 + codeSize); + } + + public ActionDefineFunction(FlasmLexer lexer) throws IOException, ParseException { + super(0x9B, -1); + functionName = lexString(lexer); + int numParams = (int) lexLong(lexer); + for (int i = 0; i < numParams; i++) { + paramNames.add(lexString(lexer)); + } + lexBlockOpen(lexer); + } + + @Override + public long getHeaderSize() { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); + try { + sos.writeString(functionName); + sos.writeUI16(paramNames.size()); + for (String s : paramNames) { + sos.writeString(s); + } + sos.writeUI16(0); + sos.close(); + + baos2.write(surroundWithAction(baos.toByteArray(), version)); + } catch (IOException e) { + } + return baos2.toByteArray().length; + } + + @Override + public byte[] getBytes(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); + try { + sos.writeString(functionName); + sos.writeUI16(paramNames.size()); + for (String s : paramNames) { + sos.writeString(s); + } + //byte[] codeBytes = Action.actionsToBytes(code, false, version); + sos.writeUI16(codeSize); //codeBytes.length); + sos.close(); + + baos2.write(surroundWithAction(baos.toByteArray(), version)); + //baos2.write(codeBytes); + } catch (IOException e) { + } + return baos2.toByteArray(); + } + + private long getPreLen(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + try { + sos.writeString(functionName); + sos.writeUI16(paramNames.size()); + for (String s : paramNames) { + sos.writeString(s); + } + sos.writeUI16(0); + sos.close(); + } catch (IOException e) { + } + + return surroundWithAction(baos.toByteArray(), version).length; + } + + @Override + public void setAddress(long address, int version, boolean recursive) { + super.setAddress(address, version, recursive); + if (recursive) { + //Action.setActionsAddresses(, address + getPreLen(version), version); + } + } + + @Override + public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { + String paramStr = ""; + for (int i = 0; i < paramNames.size(); i++) { + paramStr += "\"" + Helper.escapeString(paramNames.get(i)) + "\""; + paramStr += " "; + } + + return "DefineFunction \"" + Helper.escapeString(functionName) + "\" " + paramNames.size() + " " + paramStr + " {" + (codeSize == 0 ? "\r\n}" : "");// + "\r\n" +Action.actionsToString(getAddress() + getHeaderLength(),getItems(container) , knownAddreses, constantPool, version, hex, getFileAddress() + hdrSize) + "}"; + } + + @Override + public GraphTextWriter getASMSourceReplaced(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode, GraphTextWriter writer) { + List oldParamNames = paramNames; + if (replacedParamNames != null) { + paramNames = replacedParamNames; + } + String oldFunctionName = functionName; + if (replacedFunctionName != null) { + functionName = replacedFunctionName; + } + String ret = getASMSource(container, knownAddreses, constantPool, version, exportMode); + paramNames = oldParamNames; + functionName = oldFunctionName; + writer.appendNoHilight(ret); + return writer; + + } + + @Override + public List getAllRefs(int version) { + return super.getAllRefs(version);//Action.getActionsAllRefs(getActions(null), version); + } + + @Override + public List getAllIfsOrJumps() { + return super.getAllIfsOrJumps(); //Action.getActionsAllIfsOrJumps(code); + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + } + + @Override + public HashMap getRegNames() { + return new HashMap<>(); + } + + @Override + public void translateContainer(List> content, Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions) { + FunctionActionItem fti = new FunctionActionItem(this, functionName, paramNames, content.get(0), constantPool, 1, new ArrayList()); + //ActionGraph.translateViaGraph(regNames, variables, functions, code, version) + stack.push(fti); + functions.put(functionName, fti); + } + + @Override + public String toString() { + return "DefineFunction"; + } + + @Override + public boolean parseDivision(long size, FlasmLexer lexer) { + codeSize = (int) (size - getHeaderSize()); + return false; + } + + @Override + public List getContainerSizes() { + List ret = new ArrayList<>(); + ret.add((Long) (long) codeSize); + return ret; + } + + @Override + public void setContainerSize(int index, long size) { + if (index == 0) { + codeSize = (int) size; + } else { + throw new IllegalArgumentException("Index must be 0."); + } + } + + @Override + public String getASMSourceBetween(int pos) { + return ""; + } + + @Override + public String getName() { + return "function"; + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java index 9b005de96..23af6ebb9 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java @@ -1,140 +1,140 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.SWFInputStream; -import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.StoreTypeAction; -import com.jpexs.decompiler.flash.action.model.ConstantPool; -import com.jpexs.decompiler.flash.action.model.DecrementActionItem; -import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; -import com.jpexs.decompiler.flash.action.model.IncrementActionItem; -import com.jpexs.decompiler.flash.action.model.PostDecrementActionItem; -import com.jpexs.decompiler.flash.action.model.PostIncrementActionItem; -import com.jpexs.decompiler.flash.action.model.StoreRegisterActionItem; -import com.jpexs.decompiler.flash.action.model.TemporaryRegister; -import com.jpexs.decompiler.flash.action.parser.ParseException; -import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; -import com.jpexs.decompiler.graph.GraphSourceItemPos; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionStoreRegister extends Action implements StoreTypeAction { - - public int registerNumber; - - public ActionStoreRegister(int registerNumber) { - super(0x87, 1); - this.registerNumber = registerNumber; - } - - public ActionStoreRegister(int actionLength, SWFInputStream sis) throws IOException { - super(0x87, actionLength); - registerNumber = sis.readUI8(); - } - - public ActionStoreRegister(FlasmLexer lexer) throws IOException, ParseException { - super(0x87, 0); - registerNumber = (int) lexLong(lexer); - } - - @Override - public byte[] getBytes(int version) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - try { - sos.writeUI8(registerNumber); - sos.close(); - } catch (IOException e) { - } - return surroundWithAction(baos.toByteArray(), version); - } - - @Override - public String toString() { - return "StoreRegister " + registerNumber; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem value = stack.pop(); - RegisterNumber rn = new RegisterNumber(registerNumber); - if (regNames.containsKey(registerNumber)) { - rn.name = regNames.get(registerNumber); - } - value.moreSrc.add(new GraphSourceItemPos(this, 0)); - if (variables.containsKey("__register" + registerNumber)) { - if (variables.get("__register" + registerNumber) instanceof TemporaryRegister) { - variables.remove("__register" + registerNumber); - } - } - boolean define = !variables.containsKey("__register" + registerNumber); - if (regNames.containsKey(registerNumber)) { - define = false; - } - variables.put("__register" + registerNumber, value); - if (value instanceof DirectValueActionItem) { - if (((DirectValueActionItem) value).value instanceof RegisterNumber) { - if (((RegisterNumber) ((DirectValueActionItem) value).value).number == registerNumber) { - stack.push(value); - return; - } - } - } - if (value instanceof StoreRegisterActionItem) { - if (((StoreRegisterActionItem) value).register.number == registerNumber) { - stack.push(value); - return; - } - } - - if (value instanceof IncrementActionItem) { - GraphTargetItem obj = ((IncrementActionItem) value).object; - if (!stack.isEmpty()) { - if (stack.peek().valueEquals(obj)) { - stack.pop(); - stack.push(new PostIncrementActionItem(this, obj)); - stack.push(obj); - return; - } - } - } - if (value instanceof DecrementActionItem) { - GraphTargetItem obj = ((DecrementActionItem) value).object; - if (!stack.isEmpty()) { - if (stack.peek().valueEquals(obj)) { - stack.pop(); - stack.push(new PostDecrementActionItem(this, obj)); - stack.push(obj); - return; - } - } - } - stack.push(new StoreRegisterActionItem(this, rn, value, define)); - } - - @Override - public String getVariableName(Stack stack, ConstantPool cpool) { - return "__register" + registerNumber; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.SWFInputStream; +import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.StoreTypeAction; +import com.jpexs.decompiler.flash.action.model.ConstantPool; +import com.jpexs.decompiler.flash.action.model.DecrementActionItem; +import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; +import com.jpexs.decompiler.flash.action.model.IncrementActionItem; +import com.jpexs.decompiler.flash.action.model.PostDecrementActionItem; +import com.jpexs.decompiler.flash.action.model.PostIncrementActionItem; +import com.jpexs.decompiler.flash.action.model.StoreRegisterActionItem; +import com.jpexs.decompiler.flash.action.model.TemporaryRegister; +import com.jpexs.decompiler.flash.action.parser.ParseException; +import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; +import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; +import com.jpexs.decompiler.graph.GraphSourceItemPos; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionStoreRegister extends Action implements StoreTypeAction { + + public int registerNumber; + + public ActionStoreRegister(int registerNumber) { + super(0x87, 1); + this.registerNumber = registerNumber; + } + + public ActionStoreRegister(int actionLength, SWFInputStream sis) throws IOException { + super(0x87, actionLength); + registerNumber = sis.readUI8("registerNumber"); + } + + public ActionStoreRegister(FlasmLexer lexer) throws IOException, ParseException { + super(0x87, 0); + registerNumber = (int) lexLong(lexer); + } + + @Override + public byte[] getBytes(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + try { + sos.writeUI8(registerNumber); + sos.close(); + } catch (IOException e) { + } + return surroundWithAction(baos.toByteArray(), version); + } + + @Override + public String toString() { + return "StoreRegister " + registerNumber; + } + + @Override + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem value = stack.pop(); + RegisterNumber rn = new RegisterNumber(registerNumber); + if (regNames.containsKey(registerNumber)) { + rn.name = regNames.get(registerNumber); + } + value.moreSrc.add(new GraphSourceItemPos(this, 0)); + if (variables.containsKey("__register" + registerNumber)) { + if (variables.get("__register" + registerNumber) instanceof TemporaryRegister) { + variables.remove("__register" + registerNumber); + } + } + boolean define = !variables.containsKey("__register" + registerNumber); + if (regNames.containsKey(registerNumber)) { + define = false; + } + variables.put("__register" + registerNumber, value); + if (value instanceof DirectValueActionItem) { + if (((DirectValueActionItem) value).value instanceof RegisterNumber) { + if (((RegisterNumber) ((DirectValueActionItem) value).value).number == registerNumber) { + stack.push(value); + return; + } + } + } + if (value instanceof StoreRegisterActionItem) { + if (((StoreRegisterActionItem) value).register.number == registerNumber) { + stack.push(value); + return; + } + } + + if (value instanceof IncrementActionItem) { + GraphTargetItem obj = ((IncrementActionItem) value).object; + if (!stack.isEmpty()) { + if (stack.peek().valueEquals(obj)) { + stack.pop(); + stack.push(new PostIncrementActionItem(this, obj)); + stack.push(obj); + return; + } + } + } + if (value instanceof DecrementActionItem) { + GraphTargetItem obj = ((DecrementActionItem) value).object; + if (!stack.isEmpty()) { + if (stack.peek().valueEquals(obj)) { + stack.pop(); + stack.push(new PostDecrementActionItem(this, obj)); + stack.push(obj); + return; + } + } + } + stack.push(new StoreRegisterActionItem(this, rn, value, define)); + } + + @Override + public String getVariableName(Stack stack, ConstantPool cpool) { + return "__register" + registerNumber; + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java index a23c3b0d7..9ee914ee2 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java @@ -1,137 +1,137 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.SWFInputStream; -import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.clauses.WithActionItem; -import com.jpexs.decompiler.flash.action.parser.ParseException; -import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; -import com.jpexs.decompiler.graph.GraphSourceItem; -import com.jpexs.decompiler.graph.GraphSourceItemContainer; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionWith extends Action implements GraphSourceItemContainer { - - public int codeSize; - public int version; - - public ActionWith(int codeSize) { - super(0x94, 2); - this.codeSize = codeSize; - } - - @Override - public boolean parseDivision(long size, FlasmLexer lexer) { - codeSize = (int) (size - getHeaderSize()); - return false; - } - - public ActionWith(int actionLength, SWFInputStream sis, int version) throws IOException { - super(0x94, actionLength); - codeSize = sis.readUI16(); - this.version = version; - } - - public ActionWith(FlasmLexer lexer) throws IOException, ParseException { - super(0x94, 2); - lexBlockOpen(lexer); - } - - @Override - public void setAddress(long address, int version, boolean recursive) { - super.setAddress(address, version, recursive); - } - - @Override - public byte[] getBytes(int version) { - ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - try { - sos.writeUI16(codeSize);//codeBytes.length); - sos.close(); - baos2.write(surroundWithAction(baos.toByteArray(), version)); - } catch (IOException e) { - } - return baos2.toByteArray(); - } - - @Override - public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { - return "With {"; - } - - @Override - public List getAllRefs(int version) { - return super.getAllRefs(version); - } - - @Override - public List getAllIfsOrJumps() { - return super.getAllIfsOrJumps(); - } - - @Override - public void translateContainer(List> content, Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions) { - output.add(new WithActionItem(this, stack.pop(), content.get(0))); - } - - @Override - public List getContainerSizes() { - List ret = new ArrayList<>(); - ret.add((Long) (long) codeSize); - return ret; - } - - @Override - public void setContainerSize(int index, long size) { - if (index == 0) { - codeSize = (int) size; - } else { - throw new IllegalArgumentException("Index must be 0."); - } - } - - @Override - public String getASMSourceBetween(int pos) { - return ""; - } - - @Override - public long getHeaderSize() { - return surroundWithAction(new byte[]{0, 0}, version).length; - } - - @Override - public HashMap getRegNames() { - return new HashMap<>(); - } - - @Override - public String getName() { - return null; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.SWFInputStream; +import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.clauses.WithActionItem; +import com.jpexs.decompiler.flash.action.parser.ParseException; +import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.decompiler.graph.GraphSourceItemContainer; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionWith extends Action implements GraphSourceItemContainer { + + public int codeSize; + public int version; + + public ActionWith(int codeSize) { + super(0x94, 2); + this.codeSize = codeSize; + } + + @Override + public boolean parseDivision(long size, FlasmLexer lexer) { + codeSize = (int) (size - getHeaderSize()); + return false; + } + + public ActionWith(int actionLength, SWFInputStream sis, int version) throws IOException { + super(0x94, actionLength); + codeSize = sis.readUI16("codeSize"); + this.version = version; + } + + public ActionWith(FlasmLexer lexer) throws IOException, ParseException { + super(0x94, 2); + lexBlockOpen(lexer); + } + + @Override + public void setAddress(long address, int version, boolean recursive) { + super.setAddress(address, version, recursive); + } + + @Override + public byte[] getBytes(int version) { + ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + try { + sos.writeUI16(codeSize);//codeBytes.length); + sos.close(); + baos2.write(surroundWithAction(baos.toByteArray(), version)); + } catch (IOException e) { + } + return baos2.toByteArray(); + } + + @Override + public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { + return "With {"; + } + + @Override + public List getAllRefs(int version) { + return super.getAllRefs(version); + } + + @Override + public List getAllIfsOrJumps() { + return super.getAllIfsOrJumps(); + } + + @Override + public void translateContainer(List> content, Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions) { + output.add(new WithActionItem(this, stack.pop(), content.get(0))); + } + + @Override + public List getContainerSizes() { + List ret = new ArrayList<>(); + ret.add((Long) (long) codeSize); + return ret; + } + + @Override + public void setContainerSize(int index, long size) { + if (index == 0) { + codeSize = (int) size; + } else { + throw new IllegalArgumentException("Index must be 0."); + } + } + + @Override + public String getASMSourceBetween(int pos) { + return ""; + } + + @Override + public long getHeaderSize() { + return surroundWithAction(new byte[]{0, 0}, version).length; + } + + @Override + public HashMap getRegNames() { + return new HashMap<>(); + } + + @Override + public String getName() { + return null; + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java b/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java index 93ff7c866..50e369171 100644 --- a/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java +++ b/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java @@ -1,391 +1,391 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf7; - -import com.jpexs.decompiler.flash.SWFInputStream; -import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.FunctionActionItem; -import com.jpexs.decompiler.flash.action.parser.ParseException; -import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.flash.action.parser.script.VariableActionItem; -import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; -import com.jpexs.decompiler.flash.helpers.GraphTextWriter; -import com.jpexs.decompiler.graph.GraphSourceItem; -import com.jpexs.decompiler.graph.GraphSourceItemContainer; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.helpers.Helper; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionDefineFunction2 extends Action implements GraphSourceItemContainer { - - public String functionName; - public String replacedFunctionName; - public List paramNames = new ArrayList<>(); - public List replacedParamNames; - public List paramRegisters = new ArrayList<>(); - public boolean preloadParentFlag; - public boolean preloadRootFlag; - public boolean suppressSuperFlag; - public boolean preloadSuperFlag; - public boolean suppressArgumentsFlag; - public boolean preloadArgumentsFlag; - public boolean suppressThisFlag; - public boolean preloadThisFlag; - public int reserved; - public boolean preloadGlobalFlag; - public int registerCount; - public int codeSize; - //public List code; - private int version; - public List constantPool; - private long hdrSize; - - public ActionDefineFunction2(String functionName, boolean preloadParentFlag, boolean preloadRootFlag, boolean suppressSuperFlag, boolean preloadSuperFlag, boolean suppressArgumentsFlag, boolean preloadArgumentsFlag, boolean suppressThisFlag, boolean preloadThisFlag, boolean preloadGlobalFlag, int registerCount, int codeSize, int version, List paramNames, List paramRegisters) { - super(0x8E, 0); - this.functionName = functionName; - this.preloadParentFlag = preloadParentFlag; - this.preloadRootFlag = preloadRootFlag; - this.suppressSuperFlag = suppressSuperFlag; - this.preloadSuperFlag = preloadSuperFlag; - this.suppressArgumentsFlag = suppressArgumentsFlag; - this.preloadArgumentsFlag = preloadArgumentsFlag; - this.suppressThisFlag = suppressThisFlag; - this.preloadThisFlag = preloadThisFlag; - this.preloadGlobalFlag = preloadGlobalFlag; - this.registerCount = registerCount; - this.codeSize = codeSize; - this.version = version; - this.paramNames = paramNames; - this.paramRegisters = paramRegisters; - } - - public ActionDefineFunction2(int actionLength, SWFInputStream sis, int version) throws IOException { - super(0x8E, actionLength); - long posBef = sis.getPos(); - this.version = version; - functionName = sis.readString(); - int numParams = sis.readUI16(); - registerCount = sis.readUI8(); - preloadParentFlag = sis.readUB(1) == 1; - preloadRootFlag = sis.readUB(1) == 1; - suppressSuperFlag = sis.readUB(1) == 1; - preloadSuperFlag = sis.readUB(1) == 1; - suppressArgumentsFlag = sis.readUB(1) == 1; - preloadArgumentsFlag = sis.readUB(1) == 1; - suppressThisFlag = sis.readUB(1) == 1; - preloadThisFlag = sis.readUB(1) == 1; - reserved = (int) sis.readUB(7); - preloadGlobalFlag = sis.readUB(1) == 1; - for (int i = 0; i < numParams; i++) { - paramRegisters.add(sis.readUI8()); - paramNames.add(sis.readString()); - } - codeSize = sis.readUI16(); - long posAfter = sis.getPos(); - hdrSize = posAfter - posBef; - //code = new ArrayList(); - //int posBef2 = (int) rri.getPos(); - //code = sis.readActionList(rri.getPos(), getFileAddress() + hdrSize, rri, codeSize); - //rri.setPos(posBef2 + codeSize); - } - - public ActionDefineFunction2(FlasmLexer lexer) throws IOException, ParseException { - super(0x8E, -1); - functionName = lexString(lexer); - int numParams = (int) lexLong(lexer); - registerCount = (int) lexLong(lexer); - preloadParentFlag = lexBoolean(lexer); - preloadRootFlag = lexBoolean(lexer); - suppressSuperFlag = lexBoolean(lexer); - preloadSuperFlag = lexBoolean(lexer); - suppressArgumentsFlag = lexBoolean(lexer); - preloadArgumentsFlag = lexBoolean(lexer); - suppressThisFlag = lexBoolean(lexer); - preloadThisFlag = lexBoolean(lexer); - preloadGlobalFlag = lexBoolean(lexer); - for (int i = 0; i < numParams; i++) { - paramRegisters.add((int) lexLong(lexer)); - paramNames.add(lexString(lexer)); - } - lexBlockOpen(lexer); - } - - @Override - public long getHeaderSize() { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); - try { - sos.writeString(functionName); - sos.writeUI16(paramNames.size()); - sos.writeUI8(registerCount); - sos.writeUB(1, preloadParentFlag ? 1 : 0); - sos.writeUB(1, preloadRootFlag ? 1 : 0); - sos.writeUB(1, suppressSuperFlag ? 1 : 0); - sos.writeUB(1, preloadSuperFlag ? 1 : 0); - sos.writeUB(1, suppressArgumentsFlag ? 1 : 0); - sos.writeUB(1, preloadArgumentsFlag ? 1 : 0); - sos.writeUB(1, suppressThisFlag ? 1 : 0); - sos.writeUB(1, preloadThisFlag ? 1 : 0); - sos.writeUB(7, reserved); - sos.writeUB(1, preloadGlobalFlag ? 1 : 0); - for (int i = 0; i < paramNames.size(); i++) { - sos.writeUI8(paramRegisters.get(i)); - - sos.writeString(paramNames.get(i)); - } - sos.writeUI16(0); - sos.close(); - baos2.write(surroundWithAction(baos.toByteArray(), version)); - } catch (IOException e) { - } - return baos2.toByteArray().length; - } - - @Override - public byte[] getBytes(int version) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); - try { - sos.writeString(functionName); - sos.writeUI16(paramNames.size()); - sos.writeUI8(registerCount); - sos.writeUB(1, preloadParentFlag ? 1 : 0); - sos.writeUB(1, preloadRootFlag ? 1 : 0); - sos.writeUB(1, suppressSuperFlag ? 1 : 0); - sos.writeUB(1, preloadSuperFlag ? 1 : 0); - sos.writeUB(1, suppressArgumentsFlag ? 1 : 0); - sos.writeUB(1, preloadArgumentsFlag ? 1 : 0); - sos.writeUB(1, suppressThisFlag ? 1 : 0); - sos.writeUB(1, preloadThisFlag ? 1 : 0); - sos.writeUB(7, 0); - sos.writeUB(1, preloadGlobalFlag ? 1 : 0); - for (int i = 0; i < paramNames.size(); i++) { - sos.writeUI8(paramRegisters.get(i)); - sos.writeString(paramNames.get(i)); - } - //byte[] codeBytes = Action.actionsToBytes(code, false, version); - sos.writeUI16(codeSize);//codeBytes.length); - sos.close(); - - baos2.write(surroundWithAction(baos.toByteArray(), version)); - //baos2.write(codeBytes); - } catch (IOException e) { - } - return baos2.toByteArray(); - } - - private long getPreLen(int version) { - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - try { - sos.writeString(functionName); - sos.writeUI16(paramNames.size()); - sos.writeUI8(registerCount); - sos.writeUB(1, preloadParentFlag ? 1 : 0); - sos.writeUB(1, preloadRootFlag ? 1 : 0); - sos.writeUB(1, suppressSuperFlag ? 1 : 0); - sos.writeUB(1, preloadSuperFlag ? 1 : 0); - sos.writeUB(1, suppressArgumentsFlag ? 1 : 0); - sos.writeUB(1, preloadArgumentsFlag ? 1 : 0); - sos.writeUB(1, suppressThisFlag ? 1 : 0); - sos.writeUB(1, preloadThisFlag ? 1 : 0); - sos.writeUB(7, 0); - sos.writeUB(1, preloadGlobalFlag ? 1 : 0); - for (int i = 0; i < paramNames.size(); i++) { - sos.writeUI8(paramRegisters.get(i)); - sos.writeString(paramNames.get(i)); - } - sos.writeUI16(0); - sos.close(); - } catch (IOException e) { - } - return surroundWithAction(baos.toByteArray(), version).length; - } - - @Override - public void setAddress(long address, int version, boolean recursive) { - super.setAddress(address, version, recursive); - if (recursive) { - //Action.setActionsAddresses(code, address + getPreLen(version), version); - } - } - - @Override - public GraphTextWriter getASMSourceReplaced(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode, GraphTextWriter writer) { - List oldParamNames = paramNames; - if (replacedParamNames != null) { - paramNames = replacedParamNames; - } - String oldFunctionName = functionName; - if (replacedFunctionName != null) { - functionName = replacedFunctionName; - } - String ret = getASMSource(container, knownAddreses, constantPool, version, exportMode); - paramNames = oldParamNames; - functionName = oldFunctionName; - writer.appendNoHilight(ret); - return writer; - - } - - @Override - public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { - String paramStr = ""; - for (int i = 0; i < paramNames.size(); i++) { - paramStr += paramRegisters.get(i) + " \"" + Helper.escapeString(paramNames.get(i)) + "\""; - paramStr += " "; - } - - return ("DefineFunction2 \"" + Helper.escapeString(functionName) + "\" " + paramRegisters.size() + " " + registerCount - + " " + preloadParentFlag - + " " + preloadRootFlag - + " " + suppressSuperFlag - + " " + preloadSuperFlag - + " " + suppressArgumentsFlag - + " " + preloadArgumentsFlag - + " " + suppressThisFlag - + " " + preloadThisFlag - + " " + preloadGlobalFlag).trim() + " " + paramStr + " {" + (codeSize == 0 ? "\r\n}" : "");// + "\r\n" + Action.actionsToString(getAddress() + getHeaderLength(), getItems(container), knownAddreses, constantPool, version, hex, getFileAddress() + hdrSize) + "}"; - } - - @Override - public String toString() { - return "DefineFunction2"; - } - - public int getFirstRegister() { - int pos = 1; - if (preloadThisFlag) { - pos++; - } - if (preloadArgumentsFlag) { - pos++; - } - if (preloadSuperFlag) { - pos++; - } - if (preloadRootFlag) { - pos++; - } - if (preloadParentFlag) { - pos++; - } - if (preloadGlobalFlag) { - pos++; - } - return pos; - } - - @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - } - - @Override - public HashMap getRegNames() { - HashMap funcRegNames = new HashMap<>(); - for (int f = 0; f < paramNames.size(); f++) { - int reg = paramRegisters.get(f); - if (reg != 0) { - funcRegNames.put(reg, paramNames.get(f)); - } - } - int pos = 1; - if (preloadThisFlag) { - funcRegNames.put(pos, "this"); - pos++; - } - if (preloadArgumentsFlag) { - funcRegNames.put(pos, "arguments"); - pos++; - } - if (preloadSuperFlag) { - funcRegNames.put(pos, "super"); - pos++; - } - if (preloadRootFlag) { - funcRegNames.put(pos, "_root"); - pos++; - } - if (preloadParentFlag) { - funcRegNames.put(pos, "_parent"); - pos++; - } - if (preloadGlobalFlag) { - funcRegNames.put(pos, "_global"); - pos++; - } - return funcRegNames; - } - - @Override - public void translateContainer(List> content, Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions) { - FunctionActionItem fti = new FunctionActionItem(this, functionName, paramNames, content.get(0), constantPool, getFirstRegister(), new ArrayList()); - functions.put(functionName, fti); - stack.push(fti); - } - - @Override - public List getAllRefs(int version) { - return super.getAllRefs(version);//return Action.getActionsAllRefs(code, version); - } - - @Override - public List getAllIfsOrJumps() { - return super.getAllIfsOrJumps(); //return Action.getActionsAllIfsOrJumps(code); - } - - @Override - public List getContainerSizes() { - List ret = new ArrayList<>(); - ret.add((Long) (long) codeSize); - return ret; - } - - @Override - public void setContainerSize(int index, long size) { - if (index == 0) { - codeSize = (int) size; - } else { - throw new IllegalArgumentException("Index must be 0."); - } - } - - @Override - public boolean parseDivision(long size, FlasmLexer lexer) { - codeSize = (int) (size - getHeaderSize()); - return false; - } - - @Override - public String getASMSourceBetween(int pos) { - return ""; - } - - @Override - public String getName() { - return "function"; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf7; + +import com.jpexs.decompiler.flash.SWFInputStream; +import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.FunctionActionItem; +import com.jpexs.decompiler.flash.action.parser.ParseException; +import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; +import com.jpexs.decompiler.flash.action.parser.script.VariableActionItem; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.decompiler.graph.GraphSourceItemContainer; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionDefineFunction2 extends Action implements GraphSourceItemContainer { + + public String functionName; + public String replacedFunctionName; + public List paramNames = new ArrayList<>(); + public List replacedParamNames; + public List paramRegisters = new ArrayList<>(); + public boolean preloadParentFlag; + public boolean preloadRootFlag; + public boolean suppressSuperFlag; + public boolean preloadSuperFlag; + public boolean suppressArgumentsFlag; + public boolean preloadArgumentsFlag; + public boolean suppressThisFlag; + public boolean preloadThisFlag; + public int reserved; + public boolean preloadGlobalFlag; + public int registerCount; + public int codeSize; + //public List code; + private int version; + public List constantPool; + private long hdrSize; + + public ActionDefineFunction2(String functionName, boolean preloadParentFlag, boolean preloadRootFlag, boolean suppressSuperFlag, boolean preloadSuperFlag, boolean suppressArgumentsFlag, boolean preloadArgumentsFlag, boolean suppressThisFlag, boolean preloadThisFlag, boolean preloadGlobalFlag, int registerCount, int codeSize, int version, List paramNames, List paramRegisters) { + super(0x8E, 0); + this.functionName = functionName; + this.preloadParentFlag = preloadParentFlag; + this.preloadRootFlag = preloadRootFlag; + this.suppressSuperFlag = suppressSuperFlag; + this.preloadSuperFlag = preloadSuperFlag; + this.suppressArgumentsFlag = suppressArgumentsFlag; + this.preloadArgumentsFlag = preloadArgumentsFlag; + this.suppressThisFlag = suppressThisFlag; + this.preloadThisFlag = preloadThisFlag; + this.preloadGlobalFlag = preloadGlobalFlag; + this.registerCount = registerCount; + this.codeSize = codeSize; + this.version = version; + this.paramNames = paramNames; + this.paramRegisters = paramRegisters; + } + + public ActionDefineFunction2(int actionLength, SWFInputStream sis, int version) throws IOException { + super(0x8E, actionLength); + long posBef = sis.getPos(); + this.version = version; + functionName = sis.readString("functionName"); + int numParams = sis.readUI16("numParams"); + registerCount = sis.readUI8("registerCount"); + preloadParentFlag = sis.readUB(1, "preloadParentFlag") == 1; + preloadRootFlag = sis.readUB(1, "preloadRootFlag") == 1; + suppressSuperFlag = sis.readUB(1, "suppressSuperFlag") == 1; + preloadSuperFlag = sis.readUB(1, "preloadSuperFlag") == 1; + suppressArgumentsFlag = sis.readUB(1, "suppressArgumentsFlag") == 1; + preloadArgumentsFlag = sis.readUB(1, "preloadArgumentsFlag") == 1; + suppressThisFlag = sis.readUB(1, "suppressThisFlag") == 1; + preloadThisFlag = sis.readUB(1, "preloadThisFlag") == 1; + reserved = (int) sis.readUB(7, "reserved"); + preloadGlobalFlag = sis.readUB(1, "preloadGlobalFlag") == 1; + for (int i = 0; i < numParams; i++) { + paramRegisters.add(sis.readUI8("paramRegister")); + paramNames.add(sis.readString("paramName")); + } + codeSize = sis.readUI16("codeSize"); + long posAfter = sis.getPos(); + hdrSize = posAfter - posBef; + //code = new ArrayList(); + //int posBef2 = (int) rri.getPos(); + //code = sis.readActionList(rri.getPos(), getFileAddress() + hdrSize, rri, codeSize); + //rri.setPos(posBef2 + codeSize); + } + + public ActionDefineFunction2(FlasmLexer lexer) throws IOException, ParseException { + super(0x8E, -1); + functionName = lexString(lexer); + int numParams = (int) lexLong(lexer); + registerCount = (int) lexLong(lexer); + preloadParentFlag = lexBoolean(lexer); + preloadRootFlag = lexBoolean(lexer); + suppressSuperFlag = lexBoolean(lexer); + preloadSuperFlag = lexBoolean(lexer); + suppressArgumentsFlag = lexBoolean(lexer); + preloadArgumentsFlag = lexBoolean(lexer); + suppressThisFlag = lexBoolean(lexer); + preloadThisFlag = lexBoolean(lexer); + preloadGlobalFlag = lexBoolean(lexer); + for (int i = 0; i < numParams; i++) { + paramRegisters.add((int) lexLong(lexer)); + paramNames.add(lexString(lexer)); + } + lexBlockOpen(lexer); + } + + @Override + public long getHeaderSize() { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); + try { + sos.writeString(functionName); + sos.writeUI16(paramNames.size()); + sos.writeUI8(registerCount); + sos.writeUB(1, preloadParentFlag ? 1 : 0); + sos.writeUB(1, preloadRootFlag ? 1 : 0); + sos.writeUB(1, suppressSuperFlag ? 1 : 0); + sos.writeUB(1, preloadSuperFlag ? 1 : 0); + sos.writeUB(1, suppressArgumentsFlag ? 1 : 0); + sos.writeUB(1, preloadArgumentsFlag ? 1 : 0); + sos.writeUB(1, suppressThisFlag ? 1 : 0); + sos.writeUB(1, preloadThisFlag ? 1 : 0); + sos.writeUB(7, reserved); + sos.writeUB(1, preloadGlobalFlag ? 1 : 0); + for (int i = 0; i < paramNames.size(); i++) { + sos.writeUI8(paramRegisters.get(i)); + + sos.writeString(paramNames.get(i)); + } + sos.writeUI16(0); + sos.close(); + baos2.write(surroundWithAction(baos.toByteArray(), version)); + } catch (IOException e) { + } + return baos2.toByteArray().length; + } + + @Override + public byte[] getBytes(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); + try { + sos.writeString(functionName); + sos.writeUI16(paramNames.size()); + sos.writeUI8(registerCount); + sos.writeUB(1, preloadParentFlag ? 1 : 0); + sos.writeUB(1, preloadRootFlag ? 1 : 0); + sos.writeUB(1, suppressSuperFlag ? 1 : 0); + sos.writeUB(1, preloadSuperFlag ? 1 : 0); + sos.writeUB(1, suppressArgumentsFlag ? 1 : 0); + sos.writeUB(1, preloadArgumentsFlag ? 1 : 0); + sos.writeUB(1, suppressThisFlag ? 1 : 0); + sos.writeUB(1, preloadThisFlag ? 1 : 0); + sos.writeUB(7, 0); + sos.writeUB(1, preloadGlobalFlag ? 1 : 0); + for (int i = 0; i < paramNames.size(); i++) { + sos.writeUI8(paramRegisters.get(i)); + sos.writeString(paramNames.get(i)); + } + //byte[] codeBytes = Action.actionsToBytes(code, false, version); + sos.writeUI16(codeSize);//codeBytes.length); + sos.close(); + + baos2.write(surroundWithAction(baos.toByteArray(), version)); + //baos2.write(codeBytes); + } catch (IOException e) { + } + return baos2.toByteArray(); + } + + private long getPreLen(int version) { + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + try { + sos.writeString(functionName); + sos.writeUI16(paramNames.size()); + sos.writeUI8(registerCount); + sos.writeUB(1, preloadParentFlag ? 1 : 0); + sos.writeUB(1, preloadRootFlag ? 1 : 0); + sos.writeUB(1, suppressSuperFlag ? 1 : 0); + sos.writeUB(1, preloadSuperFlag ? 1 : 0); + sos.writeUB(1, suppressArgumentsFlag ? 1 : 0); + sos.writeUB(1, preloadArgumentsFlag ? 1 : 0); + sos.writeUB(1, suppressThisFlag ? 1 : 0); + sos.writeUB(1, preloadThisFlag ? 1 : 0); + sos.writeUB(7, 0); + sos.writeUB(1, preloadGlobalFlag ? 1 : 0); + for (int i = 0; i < paramNames.size(); i++) { + sos.writeUI8(paramRegisters.get(i)); + sos.writeString(paramNames.get(i)); + } + sos.writeUI16(0); + sos.close(); + } catch (IOException e) { + } + return surroundWithAction(baos.toByteArray(), version).length; + } + + @Override + public void setAddress(long address, int version, boolean recursive) { + super.setAddress(address, version, recursive); + if (recursive) { + //Action.setActionsAddresses(code, address + getPreLen(version), version); + } + } + + @Override + public GraphTextWriter getASMSourceReplaced(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode, GraphTextWriter writer) { + List oldParamNames = paramNames; + if (replacedParamNames != null) { + paramNames = replacedParamNames; + } + String oldFunctionName = functionName; + if (replacedFunctionName != null) { + functionName = replacedFunctionName; + } + String ret = getASMSource(container, knownAddreses, constantPool, version, exportMode); + paramNames = oldParamNames; + functionName = oldFunctionName; + writer.appendNoHilight(ret); + return writer; + + } + + @Override + public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { + String paramStr = ""; + for (int i = 0; i < paramNames.size(); i++) { + paramStr += paramRegisters.get(i) + " \"" + Helper.escapeString(paramNames.get(i)) + "\""; + paramStr += " "; + } + + return ("DefineFunction2 \"" + Helper.escapeString(functionName) + "\" " + paramRegisters.size() + " " + registerCount + + " " + preloadParentFlag + + " " + preloadRootFlag + + " " + suppressSuperFlag + + " " + preloadSuperFlag + + " " + suppressArgumentsFlag + + " " + preloadArgumentsFlag + + " " + suppressThisFlag + + " " + preloadThisFlag + + " " + preloadGlobalFlag).trim() + " " + paramStr + " {" + (codeSize == 0 ? "\r\n}" : "");// + "\r\n" + Action.actionsToString(getAddress() + getHeaderLength(), getItems(container), knownAddreses, constantPool, version, hex, getFileAddress() + hdrSize) + "}"; + } + + @Override + public String toString() { + return "DefineFunction2"; + } + + public int getFirstRegister() { + int pos = 1; + if (preloadThisFlag) { + pos++; + } + if (preloadArgumentsFlag) { + pos++; + } + if (preloadSuperFlag) { + pos++; + } + if (preloadRootFlag) { + pos++; + } + if (preloadParentFlag) { + pos++; + } + if (preloadGlobalFlag) { + pos++; + } + return pos; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + } + + @Override + public HashMap getRegNames() { + HashMap funcRegNames = new HashMap<>(); + for (int f = 0; f < paramNames.size(); f++) { + int reg = paramRegisters.get(f); + if (reg != 0) { + funcRegNames.put(reg, paramNames.get(f)); + } + } + int pos = 1; + if (preloadThisFlag) { + funcRegNames.put(pos, "this"); + pos++; + } + if (preloadArgumentsFlag) { + funcRegNames.put(pos, "arguments"); + pos++; + } + if (preloadSuperFlag) { + funcRegNames.put(pos, "super"); + pos++; + } + if (preloadRootFlag) { + funcRegNames.put(pos, "_root"); + pos++; + } + if (preloadParentFlag) { + funcRegNames.put(pos, "_parent"); + pos++; + } + if (preloadGlobalFlag) { + funcRegNames.put(pos, "_global"); + pos++; + } + return funcRegNames; + } + + @Override + public void translateContainer(List> content, Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions) { + FunctionActionItem fti = new FunctionActionItem(this, functionName, paramNames, content.get(0), constantPool, getFirstRegister(), new ArrayList()); + functions.put(functionName, fti); + stack.push(fti); + } + + @Override + public List getAllRefs(int version) { + return super.getAllRefs(version);//return Action.getActionsAllRefs(code, version); + } + + @Override + public List getAllIfsOrJumps() { + return super.getAllIfsOrJumps(); //return Action.getActionsAllIfsOrJumps(code); + } + + @Override + public List getContainerSizes() { + List ret = new ArrayList<>(); + ret.add((Long) (long) codeSize); + return ret; + } + + @Override + public void setContainerSize(int index, long size) { + if (index == 0) { + codeSize = (int) size; + } else { + throw new IllegalArgumentException("Index must be 0."); + } + } + + @Override + public boolean parseDivision(long size, FlasmLexer lexer) { + codeSize = (int) (size - getHeaderSize()); + return false; + } + + @Override + public String getASMSourceBetween(int pos) { + return ""; + } + + @Override + public String getName() { + return "function"; + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java b/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java index 3653a60d3..661c8aeac 100644 --- a/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java +++ b/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java @@ -1,320 +1,320 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf7; - -import com.jpexs.decompiler.flash.SWFInputStream; -import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.ActionItem; -import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; -import com.jpexs.decompiler.flash.action.model.clauses.TryActionItem; -import com.jpexs.decompiler.flash.action.parser.ParseException; -import com.jpexs.decompiler.flash.action.parser.pcode.ASMParsedSymbol; -import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; -import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; -import com.jpexs.decompiler.graph.GraphSourceItem; -import com.jpexs.decompiler.graph.GraphSourceItemContainer; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.helpers.Helper; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionTry extends Action implements GraphSourceItemContainer { - - public int reserved; - public boolean catchInRegisterFlag; - public boolean finallyBlockFlag; - public boolean catchBlockFlag; - public String catchName; - public int catchRegister; - long trySize; - long catchSize; - long finallySize; - private final int version; - - public ActionTry(boolean catchInRegisterFlag, boolean finallyBlockFlag, boolean catchBlockFlag, String catchName, int catchRegister, long trySize, long catchSize, long finallySize, int version) { - super(0x8F, 0); - this.catchInRegisterFlag = catchInRegisterFlag; - this.finallyBlockFlag = finallyBlockFlag; - this.catchBlockFlag = catchBlockFlag; - this.catchName = catchName; - this.catchRegister = catchRegister; - this.trySize = trySize; - this.catchSize = catchSize; - this.finallySize = finallySize; - this.version = version; - } - - public ActionTry(int actionLength, SWFInputStream sis, int version) throws IOException { - super(0x8F, actionLength); - long startPos = sis.getPos(); - this.version = version; - reserved = (int) sis.readUB(5); - catchInRegisterFlag = sis.readUB(1) == 1; - finallyBlockFlag = sis.readUB(1) == 1; - catchBlockFlag = sis.readUB(1) == 1; - trySize = sis.readUI16(); - catchSize = sis.readUI16(); - finallySize = sis.readUI16(); - if (catchInRegisterFlag) { - catchRegister = sis.readUI8(); - } else { - catchName = sis.readString(); - } - } - - @Override - public void setAddress(long address, int version, boolean recursive) { - super.setAddress(address, version, recursive); - } - - @Override - public byte[] getBytes(int version) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - try { - sos.writeUB(5, reserved); - sos.writeUB(1, catchInRegisterFlag ? 1 : 0); - sos.writeUB(1, finallyBlockFlag ? 1 : 0); - sos.writeUB(1, catchBlockFlag ? 1 : 0); - sos.writeUI16((int) trySize); - sos.writeUI16((int) catchSize); - sos.writeUI16((int) finallySize); - if (catchInRegisterFlag) { - sos.writeUI8(catchRegister); - } else { - sos.writeString(catchName == null ? "" : catchName); - } - sos.close(); - } catch (IOException e) { - } - return surroundWithAction(baos.toByteArray(), version); - } - - public ActionTry(FlasmLexer lexer, int version) throws IOException, ParseException { - super(0x8F, 0); - this.version = version; - - ASMParsedSymbol symb = lexer.yylex(); - if (symb.type == ASMParsedSymbol.TYPE_STRING) { - catchInRegisterFlag = false; - catchName = (String) symb.value; - } else if (symb.type == ASMParsedSymbol.TYPE_REGISTER) { - catchRegister = ((RegisterNumber) symb.value).number; - catchInRegisterFlag = true; - } else if (symb.type == ASMParsedSymbol.TYPE_BLOCK_START) { - return; - } else { - throw new ParseException("Unknown symbol after Try", lexer.yyline()); - } - lexBlockOpen(lexer); - } - - @Override - public String getASMSourceBetween(int pos) { - String ret = ""; - if (pos == 0) { - if (catchBlockFlag) { - ret += "Catch"; - ret += " {\r\n"; - return ret; - } - if (finallyBlockFlag) { - ret += "Finally {\r\n"; - return ret; - } - } - if (pos == 1) { - if (catchBlockFlag && finallyBlockFlag) { - ret += "Finally {\r\n"; - return ret; - } - } - return ret; - } - - @Override - public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { - String ret = ""; - ret += "Try "; - if (catchBlockFlag) { - if (catchInRegisterFlag) { - ret += "register" + catchRegister; - } else { - ret += "\"" + Helper.escapeString(catchName) + "\""; - } - ret += " "; - } - ret += "{"; - return ret; - } - - @Override - public List getAllRefs(int version) { - List ret = new ArrayList<>(); - return ret; - } - - @Override - public List getAllIfsOrJumps() { - List ret = new ArrayList<>(); - return ret; - } - - @Override - public long getHeaderSize() { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - try { - sos.writeUB(5, reserved); - sos.writeUB(1, catchInRegisterFlag ? 1 : 0); - sos.writeUB(1, finallyBlockFlag ? 1 : 0); - sos.writeUB(1, catchBlockFlag ? 1 : 0); - sos.writeUI16((int) trySize); - sos.writeUI16((int) catchSize); - sos.writeUI16((int) finallySize); - if (catchInRegisterFlag) { - sos.writeUI8(catchRegister); - } else { - sos.writeString(catchName == null ? "" : catchName); - } - /*sos.write(tryBodyBytes); - sos.write(catchBodyBytes); - sos.write(finallyBodyBytes);*/ - sos.close(); - } catch (IOException e) { - } - return surroundWithAction(baos.toByteArray(), version).length; - } - - public long getTrySize() { - return trySize; - } - - @Override - public List getContainerSizes() { - List ret = new ArrayList<>(); - ret.add(trySize); - ret.add(catchSize); - ret.add(finallySize); - return ret; - } - - @Override - public void setContainerSize(int index, long size) { - switch (index) { - case 0: - trySize = size; - break; - case 1: - catchSize = size; - break; - case 2: - finallySize = size; - break; - default: - throw new IllegalArgumentException("Valid indexes are 0, 1, and 2."); - } - } - - @Override - public boolean parseDivision(long size, FlasmLexer lexer) { - try { - ASMParsedSymbol symb = lexer.yylex(); - //catchBlockFlag = false; - if (symb.type == ASMParsedSymbol.TYPE_INSTRUCTION_NAME) { - if (((String) symb.value).toLowerCase().equals("catch")) { - trySize = size - getHeaderSize(); - catchBlockFlag = true; - lexBlockOpen(lexer); - return true; - } - if (symb.type == ASMParsedSymbol.TYPE_INSTRUCTION_NAME) { - if (((String) symb.value).toLowerCase().equals("finally")) { - if (catchBlockFlag) { - catchSize = size - getHeaderSize() - trySize; - } else { - trySize = size - getHeaderSize(); - } - finallyBlockFlag = true; - lexBlockOpen(lexer); - return true; - } else { - //finallyBlockFlag = false; - lexer.yypushback(lexer.yylength()); - } - } else { - //finallyBlockFlag = false; - lexer.yypushback(lexer.yylength()); - } - } else { - lexer.yypushback(lexer.yylength()); - } - } catch (IOException | ParseException ex) { - } - - if (finallyBlockFlag) { - finallySize = size - getHeaderSize() - trySize - catchSize; - } else if (catchBlockFlag) { - catchSize = size - getHeaderSize() - trySize; - } - lexer.yybegin(0); - return false; - } - - @Override - public void translateContainer(List> contents, Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions) { - List tryCommands = contents.get(0); - ActionItem catchName; - if (catchInRegisterFlag) { - catchName = new DirectValueActionItem(this, -1, new RegisterNumber(this.catchRegister), new ArrayList()); - } else { - catchName = new DirectValueActionItem(this, -1, this.catchName, new ArrayList()); - } - List catchExceptions = new ArrayList<>(); - if (catchBlockFlag) { - catchExceptions.add(catchName); - } - List> catchCommands = new ArrayList<>(); - if (catchBlockFlag) { - catchCommands.add(contents.get(1)); - } - List finallyCommands = contents.get(2); - output.add(new TryActionItem(tryCommands, catchExceptions, catchCommands, finallyCommands)); - - } - - @Override - public String toString() { - return "Try"; - } - - @Override - public HashMap getRegNames() { - return new HashMap<>(); - } - - @Override - public String getName() { - return null; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf7; + +import com.jpexs.decompiler.flash.SWFInputStream; +import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.ActionItem; +import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; +import com.jpexs.decompiler.flash.action.model.clauses.TryActionItem; +import com.jpexs.decompiler.flash.action.parser.ParseException; +import com.jpexs.decompiler.flash.action.parser.pcode.ASMParsedSymbol; +import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; +import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.decompiler.graph.GraphSourceItemContainer; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.helpers.Helper; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionTry extends Action implements GraphSourceItemContainer { + + public int reserved; + public boolean catchInRegisterFlag; + public boolean finallyBlockFlag; + public boolean catchBlockFlag; + public String catchName; + public int catchRegister; + long trySize; + long catchSize; + long finallySize; + private final int version; + + public ActionTry(boolean catchInRegisterFlag, boolean finallyBlockFlag, boolean catchBlockFlag, String catchName, int catchRegister, long trySize, long catchSize, long finallySize, int version) { + super(0x8F, 0); + this.catchInRegisterFlag = catchInRegisterFlag; + this.finallyBlockFlag = finallyBlockFlag; + this.catchBlockFlag = catchBlockFlag; + this.catchName = catchName; + this.catchRegister = catchRegister; + this.trySize = trySize; + this.catchSize = catchSize; + this.finallySize = finallySize; + this.version = version; + } + + public ActionTry(int actionLength, SWFInputStream sis, int version) throws IOException { + super(0x8F, actionLength); + long startPos = sis.getPos(); + this.version = version; + reserved = (int) sis.readUB(5, "reserved"); + catchInRegisterFlag = sis.readUB(1, "catchInRegisterFlag") == 1; + finallyBlockFlag = sis.readUB(1, "finallyBlockFlag") == 1; + catchBlockFlag = sis.readUB(1, "catchBlockFlag") == 1; + trySize = sis.readUI16("trySize"); + catchSize = sis.readUI16("catchSize"); + finallySize = sis.readUI16("finallySize"); + if (catchInRegisterFlag) { + catchRegister = sis.readUI8("catchRegister"); + } else { + catchName = sis.readString("catchName"); + } + } + + @Override + public void setAddress(long address, int version, boolean recursive) { + super.setAddress(address, version, recursive); + } + + @Override + public byte[] getBytes(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + try { + sos.writeUB(5, reserved); + sos.writeUB(1, catchInRegisterFlag ? 1 : 0); + sos.writeUB(1, finallyBlockFlag ? 1 : 0); + sos.writeUB(1, catchBlockFlag ? 1 : 0); + sos.writeUI16((int) trySize); + sos.writeUI16((int) catchSize); + sos.writeUI16((int) finallySize); + if (catchInRegisterFlag) { + sos.writeUI8(catchRegister); + } else { + sos.writeString(catchName == null ? "" : catchName); + } + sos.close(); + } catch (IOException e) { + } + return surroundWithAction(baos.toByteArray(), version); + } + + public ActionTry(FlasmLexer lexer, int version) throws IOException, ParseException { + super(0x8F, 0); + this.version = version; + + ASMParsedSymbol symb = lexer.yylex(); + if (symb.type == ASMParsedSymbol.TYPE_STRING) { + catchInRegisterFlag = false; + catchName = (String) symb.value; + } else if (symb.type == ASMParsedSymbol.TYPE_REGISTER) { + catchRegister = ((RegisterNumber) symb.value).number; + catchInRegisterFlag = true; + } else if (symb.type == ASMParsedSymbol.TYPE_BLOCK_START) { + return; + } else { + throw new ParseException("Unknown symbol after Try", lexer.yyline()); + } + lexBlockOpen(lexer); + } + + @Override + public String getASMSourceBetween(int pos) { + String ret = ""; + if (pos == 0) { + if (catchBlockFlag) { + ret += "Catch"; + ret += " {\r\n"; + return ret; + } + if (finallyBlockFlag) { + ret += "Finally {\r\n"; + return ret; + } + } + if (pos == 1) { + if (catchBlockFlag && finallyBlockFlag) { + ret += "Finally {\r\n"; + return ret; + } + } + return ret; + } + + @Override + public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { + String ret = ""; + ret += "Try "; + if (catchBlockFlag) { + if (catchInRegisterFlag) { + ret += "register" + catchRegister; + } else { + ret += "\"" + Helper.escapeString(catchName) + "\""; + } + ret += " "; + } + ret += "{"; + return ret; + } + + @Override + public List getAllRefs(int version) { + List ret = new ArrayList<>(); + return ret; + } + + @Override + public List getAllIfsOrJumps() { + List ret = new ArrayList<>(); + return ret; + } + + @Override + public long getHeaderSize() { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + try { + sos.writeUB(5, reserved); + sos.writeUB(1, catchInRegisterFlag ? 1 : 0); + sos.writeUB(1, finallyBlockFlag ? 1 : 0); + sos.writeUB(1, catchBlockFlag ? 1 : 0); + sos.writeUI16((int) trySize); + sos.writeUI16((int) catchSize); + sos.writeUI16((int) finallySize); + if (catchInRegisterFlag) { + sos.writeUI8(catchRegister); + } else { + sos.writeString(catchName == null ? "" : catchName); + } + /*sos.write(tryBodyBytes); + sos.write(catchBodyBytes); + sos.write(finallyBodyBytes);*/ + sos.close(); + } catch (IOException e) { + } + return surroundWithAction(baos.toByteArray(), version).length; + } + + public long getTrySize() { + return trySize; + } + + @Override + public List getContainerSizes() { + List ret = new ArrayList<>(); + ret.add(trySize); + ret.add(catchSize); + ret.add(finallySize); + return ret; + } + + @Override + public void setContainerSize(int index, long size) { + switch (index) { + case 0: + trySize = size; + break; + case 1: + catchSize = size; + break; + case 2: + finallySize = size; + break; + default: + throw new IllegalArgumentException("Valid indexes are 0, 1, and 2."); + } + } + + @Override + public boolean parseDivision(long size, FlasmLexer lexer) { + try { + ASMParsedSymbol symb = lexer.yylex(); + //catchBlockFlag = false; + if (symb.type == ASMParsedSymbol.TYPE_INSTRUCTION_NAME) { + if (((String) symb.value).toLowerCase().equals("catch")) { + trySize = size - getHeaderSize(); + catchBlockFlag = true; + lexBlockOpen(lexer); + return true; + } + if (symb.type == ASMParsedSymbol.TYPE_INSTRUCTION_NAME) { + if (((String) symb.value).toLowerCase().equals("finally")) { + if (catchBlockFlag) { + catchSize = size - getHeaderSize() - trySize; + } else { + trySize = size - getHeaderSize(); + } + finallyBlockFlag = true; + lexBlockOpen(lexer); + return true; + } else { + //finallyBlockFlag = false; + lexer.yypushback(lexer.yylength()); + } + } else { + //finallyBlockFlag = false; + lexer.yypushback(lexer.yylength()); + } + } else { + lexer.yypushback(lexer.yylength()); + } + } catch (IOException | ParseException ex) { + } + + if (finallyBlockFlag) { + finallySize = size - getHeaderSize() - trySize - catchSize; + } else if (catchBlockFlag) { + catchSize = size - getHeaderSize() - trySize; + } + lexer.yybegin(0); + return false; + } + + @Override + public void translateContainer(List> contents, Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions) { + List tryCommands = contents.get(0); + ActionItem catchName; + if (catchInRegisterFlag) { + catchName = new DirectValueActionItem(this, -1, new RegisterNumber(this.catchRegister), new ArrayList()); + } else { + catchName = new DirectValueActionItem(this, -1, this.catchName, new ArrayList()); + } + List catchExceptions = new ArrayList<>(); + if (catchBlockFlag) { + catchExceptions.add(catchName); + } + List> catchCommands = new ArrayList<>(); + if (catchBlockFlag) { + catchCommands.add(contents.get(1)); + } + List finallyCommands = contents.get(2); + output.add(new TryActionItem(tryCommands, catchExceptions, catchCommands, finallyCommands)); + + } + + @Override + public String toString() { + return "Try"; + } + + @Override + public HashMap getRegNames() { + return new HashMap<>(); + } + + @Override + public String getName() { + return null; + } +} diff --git a/src/com/jpexs/decompiler/flash/dumpview/DumpInfo.java b/src/com/jpexs/decompiler/flash/dumpview/DumpInfo.java index f8754da65..a72566631 100644 --- a/src/com/jpexs/decompiler/flash/dumpview/DumpInfo.java +++ b/src/com/jpexs/decompiler/flash/dumpview/DumpInfo.java @@ -65,6 +65,6 @@ public class DumpInfo { @Override public String toString() { String value = previewValue == null ? "" : previewValue.toString(); - return name + "(" + type + ")" + (value.isEmpty() ? "" : " = " + value); + return name + " (" + type + ")" + (value.isEmpty() ? "" : " = " + value); } } diff --git a/src/com/jpexs/decompiler/flash/exporters/MovieExporter.java b/src/com/jpexs/decompiler/flash/exporters/MovieExporter.java index fc6cf3f77..7f94935da 100644 --- a/src/com/jpexs/decompiler/flash/exporters/MovieExporter.java +++ b/src/com/jpexs/decompiler/flash/exporters/MovieExporter.java @@ -103,28 +103,28 @@ public class MovieExporter { || (videoStream.codecID == DefineVideoStreamTag.CODEC_VP6_ALPHA)) { SWFInputStream sis = new SWFInputStream(swf, tag.videoData); if (videoStream.codecID == DefineVideoStreamTag.CODEC_VP6_ALPHA) { - sis.readUI24(); //offsetToAlpha + sis.readUI24("offsetToAlpha"); //offsetToAlpha } - int frameMode = (int) sis.readUB(1); + int frameMode = (int) sis.readUB(1, "frameMode"); if (frameMode == 0) { frameType = 1; //intra } else { frameType = 2; //inter } - sis.readUB(6); //qp - int marker = (int) sis.readUB(1); + sis.readUB(6, "qp"); //qp + int marker = (int) sis.readUB(1, "marker"); if (frameMode == 0) { - int version = (int) sis.readUB(5); - int version2 = (int) sis.readUB(2); - sis.readUB(1);//interlace + int version = (int) sis.readUB(5, "version"); + int version2 = (int) sis.readUB(2, "version2"); + sis.readUB(1, "interlace"); //interlace if (marker == 1 || version2 == 0) { - sis.readUI16();//offset + sis.readUI16("offset"); //offset } - int dim_y = sis.readUI8(); - int dim_x = sis.readUI8(); - sis.readUI8(); //render_y - sis.readUI8(); //render_x + int dim_y = sis.readUI8("dim_y"); + int dim_x = sis.readUI8("dim_x"); + sis.readUI8("render_y"); //render_y + sis.readUI8("render_x"); //render_x horizontalAdjustment = (int) (dim_x * Math.ceil(((double) videoStream.width) / (double) dim_x)) - videoStream.width; verticalAdjustment = (int) (dim_y * Math.ceil(((double) videoStream.height) / (double) dim_y)) - videoStream.height; @@ -136,19 +136,19 @@ public class MovieExporter { } if (videoStream.codecID == DefineVideoStreamTag.CODEC_SORENSON_H263) { SWFInputStream sis = new SWFInputStream(swf, tag.videoData); - sis.readUB(17);//pictureStartCode - sis.readUB(5); //version - sis.readUB(8); //temporalReference - int pictureSize = (int) sis.readUB(3); //pictureSize + sis.readUB(17, "pictureStartCode");//pictureStartCode + sis.readUB(5, "version"); //version + sis.readUB(8, "temporalReference"); //temporalReference + int pictureSize = (int) sis.readUB(3, "pictureSize"); //pictureSize if (pictureSize == 0) { - sis.readUB(8); //customWidth - sis.readUB(8); //customHeight + sis.readUB(8, "customWidth"); //customWidth + sis.readUB(8, "customHeight"); //customHeight } if (pictureSize == 1) { - sis.readUB(16); //customWidth - sis.readUB(16); //customHeight + sis.readUB(16, "customWidth"); //customWidth + sis.readUB(16, "customHeight"); //customHeight } - int pictureType = (int) sis.readUB(2); + int pictureType = (int) sis.readUB(2, "pictureType"); switch (pictureType) { case 0: //intra frameType = 1; //keyframe diff --git a/src/com/jpexs/decompiler/flash/tags/CSMTextSettingsTag.java b/src/com/jpexs/decompiler/flash/tags/CSMTextSettingsTag.java index a13c8c3aa..29e66fd45 100644 --- a/src/com/jpexs/decompiler/flash/tags/CSMTextSettingsTag.java +++ b/src/com/jpexs/decompiler/flash/tags/CSMTextSettingsTag.java @@ -90,13 +90,13 @@ public class CSMTextSettingsTag extends Tag { */ public CSMTextSettingsTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "CSMTextSettings", pos, length); - textID = sis.readUI16(); - useFlashType = (int) sis.readUB(2); - gridFit = (int) sis.readUB(3); - reserved = (int) sis.readUB(3); - thickness = sis.readFLOAT(); //F32 = FLOAT - sharpness = sis.readFLOAT(); //F32 = FLOAT - reserved2 = sis.readUI8(); //reserved + textID = sis.readUI16("textID"); + useFlashType = (int) sis.readUB(2, "useFlashType"); + gridFit = (int) sis.readUB(3, "gridFit"); + reserved = (int) sis.readUB(3, "reserved"); + thickness = sis.readFLOAT("thickness"); //F32 = FLOAT + sharpness = sis.readFLOAT("sharpness"); //F32 = FLOAT + reserved2 = sis.readUI8("reserved2"); //reserved } /** diff --git a/src/com/jpexs/decompiler/flash/tags/DebugIDTag.java b/src/com/jpexs/decompiler/flash/tags/DebugIDTag.java index b2028bb30..a9a918b28 100644 --- a/src/com/jpexs/decompiler/flash/tags/DebugIDTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DebugIDTag.java @@ -63,6 +63,6 @@ public class DebugIDTag extends Tag { */ public DebugIDTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DebugID", pos, length); - debugId = sis.readBytesEx(16); + debugId = sis.readBytesEx(16, "debugId"); } } diff --git a/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java b/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java index 98c2cfb78..71624ef38 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java @@ -60,9 +60,9 @@ public class DefineBinaryDataTag extends CharacterTag { public DefineBinaryDataTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineBinaryData", pos, length); - tag = sis.readUI16(); - reserved = sis.readUI32(); - binaryData = sis.readBytesEx(sis.available()); + tag = sis.readUI16("tag"); + reserved = sis.readUI32("reserved"); + binaryData = sis.readBytesEx(sis.available(),"binaryData"); } @Override diff --git a/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG2Tag.java b/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG2Tag.java index 998a60035..1c40ec753 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG2Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG2Tag.java @@ -70,8 +70,8 @@ public class DefineBitsJPEG2Tag extends ImageTag implements AloneTag { public DefineBitsJPEG2Tag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineBitsJPEG2", pos, length); - characterID = sis.readUI16(); - imageData = sis.readBytesEx(sis.available()); + characterID = sis.readUI16("characterID"); + imageData = sis.readBytesEx(sis.available(), "imageData"); } public DefineBitsJPEG2Tag(SWF swf, long pos, int length, int characterID, byte[] imageData) throws IOException { diff --git a/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG3Tag.java b/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG3Tag.java index b04e2182b..479032cec 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG3Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG3Tag.java @@ -109,10 +109,10 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag { public DefineBitsJPEG3Tag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineBitsJPEG3", pos, length); - characterID = sis.readUI16(); - long alphaDataOffset = sis.readUI32(); - imageData = sis.readBytesEx(alphaDataOffset); - bitmapAlphaData = sis.readBytesZlib(sis.available()); + characterID = sis.readUI16("characterID"); + long alphaDataOffset = sis.readUI32("alphaDataOffset"); + imageData = sis.readBytesEx(alphaDataOffset, "imageData"); + bitmapAlphaData = sis.readBytesZlib(sis.available(), "bitmapAlphaData"); } /** diff --git a/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG4Tag.java b/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG4Tag.java index c37250f6e..b33dee6c8 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG4Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG4Tag.java @@ -139,10 +139,10 @@ public class DefineBitsJPEG4Tag extends ImageTag implements AloneTag { */ public DefineBitsJPEG4Tag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineBitsJPEG4", pos, length); - characterID = sis.readUI16(); - long alphaDataOffset = sis.readUI32(); - deblockParam = sis.readUI16(); - imageData = sis.readBytesEx(alphaDataOffset); - bitmapAlphaData = sis.readBytesEx(sis.available()); + characterID = sis.readUI16("characterID"); + long alphaDataOffset = sis.readUI32("alphaDataOffset"); + deblockParam = sis.readUI16("deblockParam"); + imageData = sis.readBytesEx(alphaDataOffset, "imageData"); + bitmapAlphaData = sis.readBytesEx(sis.available(), "bitmapAlphaData"); } } diff --git a/src/com/jpexs/decompiler/flash/tags/DefineBitsLossless2Tag.java b/src/com/jpexs/decompiler/flash/tags/DefineBitsLossless2Tag.java index 87792e68c..3dd7a6278 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineBitsLossless2Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineBitsLossless2Tag.java @@ -109,14 +109,14 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag { public DefineBitsLossless2Tag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineBitsLossless2", pos, length); - characterID = sis.readUI16(); - bitmapFormat = sis.readUI8(); - bitmapWidth = sis.readUI16(); - bitmapHeight = sis.readUI16(); + characterID = sis.readUI16("characterID"); + bitmapFormat = sis.readUI8("bitmapFormat"); + bitmapWidth = sis.readUI16("bitmapWidth"); + bitmapHeight = sis.readUI16("bitmapHeight"); if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) { - bitmapColorTableSize = sis.readUI8(); + bitmapColorTableSize = sis.readUI8("bitmapColorTableSize"); } - zlibBitmapData = sis.readBytesEx(sis.available()); + zlibBitmapData = sis.readBytesEx(sis.available(), "zlibBitmapData"); } private ALPHACOLORMAPDATA colorMapData; private ALPHABITMAPDATA bitmapData; @@ -140,10 +140,10 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag { try { SWFInputStream sis = new SWFInputStream(swf, Helper.readStream(new InflaterInputStream(new ByteArrayInputStream(zlibBitmapData)))); if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) { - colorMapData = sis.readALPHACOLORMAPDATA(bitmapColorTableSize, bitmapWidth, bitmapHeight); + colorMapData = sis.readALPHACOLORMAPDATA(bitmapColorTableSize, bitmapWidth, bitmapHeight, "colorMapData"); } if (bitmapFormat == FORMAT_32BIT_ARGB) { - bitmapData = sis.readALPHABITMAPDATA(bitmapFormat, bitmapWidth, bitmapHeight); + bitmapData = sis.readALPHABITMAPDATA(bitmapFormat, bitmapWidth, bitmapHeight, "bitmapData"); } } catch (IOException ex) { } diff --git a/src/com/jpexs/decompiler/flash/tags/DefineBitsLosslessTag.java b/src/com/jpexs/decompiler/flash/tags/DefineBitsLosslessTag.java index 78f1bb3d2..03b536e71 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineBitsLosslessTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineBitsLosslessTag.java @@ -171,10 +171,10 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag { try { SWFInputStream sis = new SWFInputStream(swf, Helper.readStream(new InflaterInputStream(new ByteArrayInputStream(zlibBitmapData)))); if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) { - colorMapData = sis.readCOLORMAPDATA(bitmapColorTableSize, bitmapWidth, bitmapHeight); + colorMapData = sis.readCOLORMAPDATA(bitmapColorTableSize, bitmapWidth, bitmapHeight, "colorMapData"); } if ((bitmapFormat == FORMAT_15BIT_RGB) || (bitmapFormat == FORMAT_24BIT_RGB)) { - bitmapData = sis.readBITMAPDATA(bitmapFormat, bitmapWidth, bitmapHeight); + bitmapData = sis.readBITMAPDATA(bitmapFormat, bitmapWidth, bitmapHeight, "bitmapData"); } } catch (IOException ex) { } @@ -183,14 +183,14 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag { public DefineBitsLosslessTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineBitsLossless", pos, length); - characterID = sis.readUI16(); - bitmapFormat = sis.readUI8(); - bitmapWidth = sis.readUI16(); - bitmapHeight = sis.readUI16(); + characterID = sis.readUI16("characterID"); + bitmapFormat = sis.readUI8("bitmapFormat"); + bitmapWidth = sis.readUI16("bitmapWidth"); + bitmapHeight = sis.readUI16("bitmapHeight"); if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) { - bitmapColorTableSize = sis.readUI8(); + bitmapColorTableSize = sis.readUI8("bitmapColorTableSize"); } - zlibBitmapData = sis.readBytesEx(sis.available()); + zlibBitmapData = sis.readBytesEx(sis.available(), "zlibBitmapData"); } /** diff --git a/src/com/jpexs/decompiler/flash/tags/DefineBitsTag.java b/src/com/jpexs/decompiler/flash/tags/DefineBitsTag.java index 42b8f6c2d..1f4c84815 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineBitsTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineBitsTag.java @@ -56,8 +56,8 @@ public class DefineBitsTag extends ImageTag { public DefineBitsTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineBits", pos, length); - characterID = sis.readUI16(); - jpegData = sis.readBytesEx(sis.available()); + characterID = sis.readUI16("characterID"); + jpegData = sis.readBytesEx(sis.available(), "jpegData"); } private void getJPEGTables() { diff --git a/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java b/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java index 9e2ca4aba..6ac90fa25 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java @@ -103,13 +103,13 @@ public class DefineButton2Tag extends ButtonTag implements Container { */ public DefineButton2Tag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineButton2", pos, length); - buttonId = sis.readUI16(); - reserved = (int) sis.readUB(7); - trackAsMenu = sis.readUB(1) == 1; - int actionOffset = sis.readUI16(); - characters = sis.readBUTTONRECORDList(true); + buttonId = sis.readUI16("buttonId"); + reserved = (int) sis.readUB(7, "reserved"); + trackAsMenu = sis.readUB(1, "trackAsMenu") == 1; + int actionOffset = sis.readUI16("actionOffset"); + characters = sis.readBUTTONRECORDList(true, "characters"); if (actionOffset > 0) { - actions = sis.readBUTTONCONDACTIONList(swf, this); + actions = sis.readBUTTONCONDACTIONList(swf, this, "actions"); } } diff --git a/src/com/jpexs/decompiler/flash/tags/DefineButtonCxformTag.java b/src/com/jpexs/decompiler/flash/tags/DefineButtonCxformTag.java index 63f935ec5..bef332d66 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineButtonCxformTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineButtonCxformTag.java @@ -65,7 +65,7 @@ public class DefineButtonCxformTag extends Tag { */ public DefineButtonCxformTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineButtonCxform", pos, length); - buttonId = sis.readUI16(); - buttonColorTransform = sis.readCXFORM(); + buttonId = sis.readUI16("buttonId"); + buttonColorTransform = sis.readCXFORM("buttonColorTransform"); } } diff --git a/src/com/jpexs/decompiler/flash/tags/DefineButtonSoundTag.java b/src/com/jpexs/decompiler/flash/tags/DefineButtonSoundTag.java index 02bf558f8..e0c7a0fcd 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineButtonSoundTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineButtonSoundTag.java @@ -105,22 +105,22 @@ public class DefineButtonSoundTag extends CharacterIdTag { */ public DefineButtonSoundTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineButtonSound", pos, length); - buttonId = sis.readUI16(); - buttonSoundChar0 = sis.readUI16(); + buttonId = sis.readUI16("buttonId"); + buttonSoundChar0 = sis.readUI16("buttonSoundChar0"); if (buttonSoundChar0 != 0) { - buttonSoundInfo0 = sis.readSOUNDINFO(); + buttonSoundInfo0 = sis.readSOUNDINFO("buttonSoundInfo0"); } - buttonSoundChar1 = sis.readUI16(); + buttonSoundChar1 = sis.readUI16("buttonSoundChar1"); if (buttonSoundChar1 != 0) { - buttonSoundInfo1 = sis.readSOUNDINFO(); + buttonSoundInfo1 = sis.readSOUNDINFO("buttonSoundInfo1"); } - buttonSoundChar2 = sis.readUI16(); + buttonSoundChar2 = sis.readUI16("buttonSoundChar2"); if (buttonSoundChar2 != 0) { - buttonSoundInfo2 = sis.readSOUNDINFO(); + buttonSoundInfo2 = sis.readSOUNDINFO("buttonSoundInfo2"); } - buttonSoundChar3 = sis.readUI16(); + buttonSoundChar3 = sis.readUI16("buttonSoundChar3"); if (buttonSoundChar3 != 0) { - buttonSoundInfo3 = sis.readSOUNDINFO(); + buttonSoundInfo3 = sis.readSOUNDINFO("buttonSoundInfo3"); } } } diff --git a/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java b/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java index bb1a3d2b9..2efe47da2 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java @@ -101,10 +101,10 @@ public class DefineButtonTag extends ButtonTag implements ASMSource { */ public DefineButtonTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineButton", pos, length); - buttonId = sis.readUI16(); - characters = sis.readBUTTONRECORDList(false); + buttonId = sis.readUI16("buttonId"); + characters = sis.readBUTTONRECORDList(false, "characters"); hdrSize = sis.getPos(); - actionBytes = sis.readBytesEx(sis.available()); + actionBytes = sis.readBytesEx(sis.available(), "actionBytes"); } /** diff --git a/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java b/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java index dfc1b1af2..f58f95801 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java @@ -701,49 +701,49 @@ public class DefineEditTextTag extends TextTag { */ public DefineEditTextTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineEditText", pos, length); - characterID = sis.readUI16(); - bounds = sis.readRECT(); - hasText = sis.readUB(1) == 1; - wordWrap = sis.readUB(1) == 1; - multiline = sis.readUB(1) == 1; - password = sis.readUB(1) == 1; - readOnly = sis.readUB(1) == 1; - hasTextColor = sis.readUB(1) == 1; - hasMaxLength = sis.readUB(1) == 1; - hasFont = sis.readUB(1) == 1; - hasFontClass = sis.readUB(1) == 1; - autoSize = sis.readUB(1) == 1; - hasLayout = sis.readUB(1) == 1; - noSelect = sis.readUB(1) == 1; - border = sis.readUB(1) == 1; - wasStatic = sis.readUB(1) == 1; - html = sis.readUB(1) == 1; - useOutlines = sis.readUB(1) == 1; + characterID = sis.readUI16("characterID"); + bounds = sis.readRECT("bounds"); + hasText = sis.readUB(1, "hasText") == 1; + wordWrap = sis.readUB(1, "wordWrap") == 1; + multiline = sis.readUB(1, "multiline") == 1; + password = sis.readUB(1, "password") == 1; + readOnly = sis.readUB(1, "readOnly") == 1; + hasTextColor = sis.readUB(1, "hasTextColor") == 1; + hasMaxLength = sis.readUB(1, "hasMaxLength") == 1; + hasFont = sis.readUB(1, "hasFont") == 1; + hasFontClass = sis.readUB(1, "hasFontClass") == 1; + autoSize = sis.readUB(1, "autoSize") == 1; + hasLayout = sis.readUB(1, "hasLayout") == 1; + noSelect = sis.readUB(1, "noSelect") == 1; + border = sis.readUB(1, "border") == 1; + wasStatic = sis.readUB(1, "wasStatic") == 1; + html = sis.readUB(1, "html") == 1; + useOutlines = sis.readUB(1, "useOutlines") == 1; if (hasFont) { - fontId = sis.readUI16(); + fontId = sis.readUI16("fontId"); } if (hasFontClass) { - fontClass = sis.readString(); + fontClass = sis.readString("fontClass"); } if (hasFont) { - fontHeight = sis.readUI16(); + fontHeight = sis.readUI16("fontHeight"); } if (hasTextColor) { - textColor = sis.readRGBA(); + textColor = sis.readRGBA("textColor"); } if (hasMaxLength) { - maxLength = sis.readUI16(); + maxLength = sis.readUI16("maxLength"); } if (hasLayout) { - align = sis.readUI8(); //0 left,1 right, 2 center, 3 justify - leftMargin = sis.readUI16(); - rightMargin = sis.readUI16(); - indent = sis.readUI16(); - leading = sis.readSI16(); + align = sis.readUI8("align"); //0 left,1 right, 2 center, 3 justify + leftMargin = sis.readUI16("leftMargin"); + rightMargin = sis.readUI16("rightMargin"); + indent = sis.readUI16("indent"); + leading = sis.readSI16("leading"); } - variableName = sis.readString(); + variableName = sis.readString("variableName"); if (hasText) { - initialText = sis.readString(); + initialText = sis.readString("initialText"); } } diff --git a/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java b/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java index f11f79528..8eb5d3ee4 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java @@ -198,68 +198,68 @@ public class DefineFont2Tag extends FontTag { */ public DefineFont2Tag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineFont2", pos, length); - fontId = sis.readUI16(); - fontFlagsHasLayout = sis.readUB(1) == 1; - fontFlagsShiftJIS = sis.readUB(1) == 1; - fontFlagsSmallText = sis.readUB(1) == 1; - fontFlagsANSI = sis.readUB(1) == 1; - fontFlagsWideOffsets = sis.readUB(1) == 1; - fontFlagsWideCodes = sis.readUB(1) == 1; - fontFlagsItalic = sis.readUB(1) == 1; - fontFlagsBold = sis.readUB(1) == 1; - languageCode = sis.readLANGCODE(); - int fontNameLen = sis.readUI8(); + fontId = sis.readUI16("fontId"); + fontFlagsHasLayout = sis.readUB(1, "fontFlagsHasLayout") == 1; + fontFlagsShiftJIS = sis.readUB(1, "fontFlagsShiftJIS") == 1; + fontFlagsSmallText = sis.readUB(1, "fontFlagsSmallText") == 1; + fontFlagsANSI = sis.readUB(1, "fontFlagsANSI") == 1; + fontFlagsWideOffsets = sis.readUB(1, "fontFlagsWideOffsets") == 1; + fontFlagsWideCodes = sis.readUB(1, "fontFlagsWideCodes") == 1; + fontFlagsItalic = sis.readUB(1, "fontFlagsItalic") == 1; + fontFlagsBold = sis.readUB(1, "fontFlagsBold") == 1; + languageCode = sis.readLANGCODE("languageCode"); + int fontNameLen = sis.readUI8("fontNameLen"); if (swf.version >= 6) { - fontName = new String(sis.readBytesEx(fontNameLen), Utf8Helper.charset); + fontName = new String(sis.readBytesEx(fontNameLen, "fontName"), Utf8Helper.charset); } else { - fontName = new String(sis.readBytesEx(fontNameLen)); + fontName = new String(sis.readBytesEx(fontNameLen, "fontName")); } - numGlyphs = sis.readUI16(); + numGlyphs = sis.readUI16("numGlyphs"); //offsetTable = new long[numGlyphs]; for (int i = 0; i < numGlyphs; i++) { //offsetTable if (fontFlagsWideOffsets) { - sis.readUI32(); + sis.readUI32("offset"); } else { - sis.readUI16(); + sis.readUI16("offset"); } } if (numGlyphs > 0) { //codeTableOffset if (fontFlagsWideOffsets) { - sis.readUI32(); + sis.readUI32("offset"); } else { - sis.readUI16(); + sis.readUI16("offset"); } } glyphShapeTable = new ArrayList<>(); for (int i = 0; i < numGlyphs; i++) { - glyphShapeTable.add(sis.readSHAPE(1, false)); + glyphShapeTable.add(sis.readSHAPE(1, false, "shape")); } codeTable = new ArrayList<>(); //[numGlyphs]; for (int i = 0; i < numGlyphs; i++) { if (fontFlagsWideCodes) { - codeTable.add(sis.readUI16()); + codeTable.add(sis.readUI16("code")); } else { - codeTable.add(sis.readUI8()); + codeTable.add(sis.readUI8("code")); } } if (fontFlagsHasLayout) { - fontAscent = sis.readSI16(); - fontDescent = sis.readSI16(); - fontLeading = sis.readSI16(); + fontAscent = sis.readSI16("fontAscent"); + fontDescent = sis.readSI16("fontDescent"); + fontLeading = sis.readSI16("fontLeading"); fontAdvanceTable = new ArrayList<>(); for (int i = 0; i < numGlyphs; i++) { - fontAdvanceTable.add(sis.readSI16()); + fontAdvanceTable.add(sis.readSI16("fontAdvance")); } fontBoundsTable = new ArrayList<>(); for (int i = 0; i < numGlyphs; i++) { - fontBoundsTable.add(sis.readRECT()); + fontBoundsTable.add(sis.readRECT("rect")); } - int kerningCount = sis.readUI16(); + int kerningCount = sis.readUI16("kerningCount"); fontKerningTable = new KERNINGRECORD[kerningCount]; for (int i = 0; i < kerningCount; i++) { - fontKerningTable[i] = sis.readKERNINGRECORD(fontFlagsWideCodes); + fontKerningTable[i] = sis.readKERNINGRECORD(fontFlagsWideCodes, "record"); } } } diff --git a/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java b/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java index 2e12ca786..25fb9d5bf 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java @@ -112,65 +112,65 @@ public class DefineFont3Tag extends FontTag { public DefineFont3Tag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineFont3", pos, length); - fontId = sis.readUI16(); - fontFlagsHasLayout = sis.readUB(1) == 1; - fontFlagsShiftJIS = sis.readUB(1) == 1; - fontFlagsSmallText = sis.readUB(1) == 1; - fontFlagsANSI = sis.readUB(1) == 1; - fontFlagsWideOffsets = sis.readUB(1) == 1; - fontFlagsWideCodes = sis.readUB(1) == 1; - fontFlagsItalic = sis.readUB(1) == 1; - fontFlagsBold = sis.readUB(1) == 1; - languageCode = sis.readLANGCODE(); - int fontNameLen = sis.readUI8(); + fontId = sis.readUI16("fontId"); + fontFlagsHasLayout = sis.readUB(1, "fontFlagsHasLayout") == 1; + fontFlagsShiftJIS = sis.readUB(1, "fontFlagsShiftJIS") == 1; + fontFlagsSmallText = sis.readUB(1, "fontFlagsSmallText") == 1; + fontFlagsANSI = sis.readUB(1, "fontFlagsANSI") == 1; + fontFlagsWideOffsets = sis.readUB(1, "fontFlagsWideOffsets") == 1; + fontFlagsWideCodes = sis.readUB(1, "fontFlagsWideCodes") == 1; + fontFlagsItalic = sis.readUB(1, "fontFlagsItalic") == 1; + fontFlagsBold = sis.readUB(1, "fontFlagsBold") == 1; + languageCode = sis.readLANGCODE("languageCode"); + int fontNameLen = sis.readUI8("fontNameLen"); if (swf.version >= 6) { - fontName = new String(sis.readBytesEx(fontNameLen), Utf8Helper.charset); + fontName = new String(sis.readBytesEx(fontNameLen, "fontName"), Utf8Helper.charset); } else { - fontName = new String(sis.readBytesEx(fontNameLen)); + fontName = new String(sis.readBytesEx(fontNameLen, "fontName")); } - numGlyphs = sis.readUI16(); + numGlyphs = sis.readUI16("numGlyphs"); for (int i = 0; i < numGlyphs; i++) { //offsetTable if (fontFlagsWideOffsets) { - sis.readUI32(); + sis.readUI32("offset"); } else { - sis.readUI16(); + sis.readUI16("offset"); } } if (numGlyphs > 0) { if (fontFlagsWideOffsets) { - sis.readUI32(); //codeTableOffset + sis.readUI32("offset"); //codeTableOffset } else { - sis.readUI16(); //codeTableOffset + sis.readUI16("offset"); //codeTableOffset } } glyphShapeTable = new ArrayList<>(); for (int i = 0; i < numGlyphs; i++) { - glyphShapeTable.add(sis.readSHAPE(1, false)); + glyphShapeTable.add(sis.readSHAPE(1, false, "shape")); } codeTable = new ArrayList<>(); for (int i = 0; i < numGlyphs; i++) { if (fontFlagsWideCodes) { - codeTable.add(sis.readUI16()); + codeTable.add(sis.readUI16("code")); } else { - codeTable.add(sis.readUI8()); + codeTable.add(sis.readUI8("code")); } } if (fontFlagsHasLayout) { - fontAscent = sis.readSI16(); - fontDescent = sis.readSI16(); - fontLeading = sis.readSI16(); + fontAscent = sis.readSI16("fontAscent"); + fontDescent = sis.readSI16("fontDescent"); + fontLeading = sis.readSI16("fontLeading"); fontAdvanceTable = new ArrayList<>(); for (int i = 0; i < numGlyphs; i++) { - fontAdvanceTable.add(sis.readSI16()); + fontAdvanceTable.add(sis.readSI16("fontAdvance")); } fontBoundsTable = new ArrayList<>(); for (int i = 0; i < numGlyphs; i++) { - fontBoundsTable.add(sis.readRECT()); + fontBoundsTable.add(sis.readRECT("rect")); } - int kerningCount = sis.readUI16(); + int kerningCount = sis.readUI16("kerningCount"); fontKerningTable = new KERNINGRECORD[kerningCount]; for (int i = 0; i < kerningCount; i++) { - fontKerningTable[i] = sis.readKERNINGRECORD(fontFlagsWideCodes); + fontKerningTable[i] = sis.readKERNINGRECORD(fontFlagsWideCodes, "record"); } } } diff --git a/src/com/jpexs/decompiler/flash/tags/DefineFont4Tag.java b/src/com/jpexs/decompiler/flash/tags/DefineFont4Tag.java index 99dfd3de8..37c679063 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineFont4Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineFont4Tag.java @@ -48,13 +48,13 @@ public class DefineFont4Tag extends CharacterTag { public DefineFont4Tag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineFont4", pos, length); - fontID = sis.readUI16(); - reserved = (int) sis.readUB(5); - fontFlagsHasFontData = sis.readUB(1) == 1; - fontFlagsItalic = sis.readUB(1) == 1; - fontFlagsBold = sis.readUB(1) == 1; - fontName = sis.readString(); - fontData = sis.readBytesEx(sis.available()); + fontID = sis.readUI16("fontID"); + reserved = (int) sis.readUB(5, "reserved"); + fontFlagsHasFontData = sis.readUB(1, "fontFlagsHasFontData") == 1; + fontFlagsItalic = sis.readUB(1, "fontFlagsItalic") == 1; + fontFlagsBold = sis.readUB(1, "fontFlagsBold") == 1; + fontName = sis.readString("fontName"); + fontData = sis.readBytesEx(sis.available(), "fontData"); } /** diff --git a/src/com/jpexs/decompiler/flash/tags/DefineFontAlignZonesTag.java b/src/com/jpexs/decompiler/flash/tags/DefineFontAlignZonesTag.java index bc4315c64..10c46b4c1 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineFontAlignZonesTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineFontAlignZonesTag.java @@ -44,12 +44,12 @@ public class DefineFontAlignZonesTag extends Tag { public DefineFontAlignZonesTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineFontAlignZones", pos, length); - fontID = sis.readUI16(); - CSMTableHint = (int) sis.readUB(2); - reserved = (int) sis.readUB(6); + fontID = sis.readUI16("fontID"); + CSMTableHint = (int) sis.readUB(2, "CSMTableHint"); + reserved = (int) sis.readUB(6, "reserved"); zoneTable = new ArrayList<>(); while (sis.available() > 0) { - ZONERECORD zr = sis.readZONERECORD(); + ZONERECORD zr = sis.readZONERECORD("record"); zoneTable.add(zr); } } diff --git a/src/com/jpexs/decompiler/flash/tags/DefineFontInfo2Tag.java b/src/com/jpexs/decompiler/flash/tags/DefineFontInfo2Tag.java index 99c9291a9..98483e1c1 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineFontInfo2Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineFontInfo2Tag.java @@ -94,25 +94,25 @@ public class DefineFontInfo2Tag extends Tag { */ public DefineFontInfo2Tag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineFontInfo2", pos, length); - fontID = sis.readUI16(); - int fontNameLen = sis.readUI8(); + fontID = sis.readUI16("fontID"); + int fontNameLen = sis.readUI8("fontNameLen"); if (swf.version >= 6) { - fontName = new String(sis.readBytesEx(fontNameLen), Utf8Helper.charset); + fontName = new String(sis.readBytesEx(fontNameLen, "fontName"), Utf8Helper.charset); } else { - fontName = new String(sis.readBytesEx(fontNameLen)); + fontName = new String(sis.readBytesEx(fontNameLen, "fontName")); } - reserved = (int) sis.readUB(2); - fontFlagsSmallText = sis.readUB(1) == 1; - fontFlagsShiftJIS = sis.readUB(1) == 1; - fontFlagsANSI = sis.readUB(1) == 1; - fontFlagsItalic = sis.readUB(1) == 1; - fontFlagsBold = sis.readUB(1) == 1; - fontFlagsWideCodes = sis.readUB(1) == 1; //Always 1 - languageCode = sis.readLANGCODE(); + reserved = (int) sis.readUB(2, "reserved"); + fontFlagsSmallText = sis.readUB(1, "fontFlagsSmallText") == 1; + fontFlagsShiftJIS = sis.readUB(1, "fontFlagsShiftJIS") == 1; + fontFlagsANSI = sis.readUB(1, "fontFlagsANSI") == 1; + fontFlagsItalic = sis.readUB(1, "fontFlagsItalic") == 1; + fontFlagsBold = sis.readUB(1, "fontFlagsBold") == 1; + fontFlagsWideCodes = sis.readUB(1, "fontFlagsWideCodes") == 1; //Always 1 + languageCode = sis.readLANGCODE("languageCode"); int ctLen = sis.available() / 2; codeTable = new ArrayList<>(); for (int i = 0; i < ctLen; i++) { - codeTable.add(sis.readUI16()); + codeTable.add(sis.readUI16("code")); } } } diff --git a/src/com/jpexs/decompiler/flash/tags/DefineFontInfoTag.java b/src/com/jpexs/decompiler/flash/tags/DefineFontInfoTag.java index 5d313beab..695bac8fd 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineFontInfoTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineFontInfoTag.java @@ -95,26 +95,26 @@ public class DefineFontInfoTag extends Tag { */ public DefineFontInfoTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineFontInfo", pos, length); - fontId = sis.readUI16(); - int fontNameLen = sis.readUI8(); + fontId = sis.readUI16("fontId"); + int fontNameLen = sis.readUI8("fontNameLen"); if (swf.version >= 6) { - fontName = new String(sis.readBytesEx(fontNameLen), Utf8Helper.charset); + fontName = new String(sis.readBytesEx(fontNameLen, "fontName"), Utf8Helper.charset); } else { - fontName = new String(sis.readBytesEx(fontNameLen)); + fontName = new String(sis.readBytesEx(fontNameLen, "fontName")); } - reserved = (int) sis.readUB(2); - fontFlagsSmallText = sis.readUB(1) == 1; - fontFlagsShiftJIS = sis.readUB(1) == 1; - fontFlagsANSI = sis.readUB(1) == 1; - fontFlagsItalic = sis.readUB(1) == 1; - fontFlagsBold = sis.readUB(1) == 1; - fontFlagsWideCodes = sis.readUB(1) == 1; + reserved = (int) sis.readUB(2, "reserved"); + fontFlagsSmallText = sis.readUB(1, "fontFlagsSmallText") == 1; + fontFlagsShiftJIS = sis.readUB(1, "fontFlagsShiftJIS") == 1; + fontFlagsANSI = sis.readUB(1, "fontFlagsANSI") == 1; + fontFlagsItalic = sis.readUB(1, "fontFlagsItalic") == 1; + fontFlagsBold = sis.readUB(1, "fontFlagsBold") == 1; + fontFlagsWideCodes = sis.readUB(1, "fontFlagsWideCodes") == 1; codeTable = new ArrayList<>(); do { if (fontFlagsWideCodes) { - codeTable.add(sis.readUI16()); + codeTable.add(sis.readUI16("code")); } else { - codeTable.add(sis.readUI8()); + codeTable.add(sis.readUI8("code")); } } while (sis.available() > 0); } diff --git a/src/com/jpexs/decompiler/flash/tags/DefineFontNameTag.java b/src/com/jpexs/decompiler/flash/tags/DefineFontNameTag.java index f6c73c331..3c24891f9 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineFontNameTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineFontNameTag.java @@ -31,8 +31,8 @@ public class DefineFontNameTag extends Tag { public DefineFontNameTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineFontName", pos, length); - fontId = sis.readUI16(); - fontName = sis.readString(); - fontCopyright = sis.readString(); + fontId = sis.readUI16("fontId"); + fontName = sis.readString("fontName"); + fontCopyright = sis.readString("fontCopyright"); } } diff --git a/src/com/jpexs/decompiler/flash/tags/DefineFontTag.java b/src/com/jpexs/decompiler/flash/tags/DefineFontTag.java index 3317f7c34..107dd175e 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineFontTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineFontTag.java @@ -142,16 +142,16 @@ public class DefineFontTag extends FontTag { */ public DefineFontTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineFont", pos, length); - fontId = sis.readUI16(); - int firstOffset = sis.readUI16(); + fontId = sis.readUI16("fontId"); + int firstOffset = sis.readUI16("firstOffset"); int nGlyphs = firstOffset / 2; glyphShapeTable = new ArrayList<>(); for (int i = 1; i < nGlyphs; i++) { - sis.readUI16(); //offset + sis.readUI16("offset"); //offset } for (int i = 0; i < nGlyphs; i++) { - glyphShapeTable.add(sis.readSHAPE(1, false)); + glyphShapeTable.add(sis.readSHAPE(1, false, "shape")); } } diff --git a/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java b/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java index 67d209e72..05cf928ad 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java @@ -154,19 +154,19 @@ public class DefineMorphShape2Tag extends CharacterTag implements MorphShapeTag */ public DefineMorphShape2Tag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineMorphShape2", pos, length); - characterId = sis.readUI16(); - startBounds = sis.readRECT(); - endBounds = sis.readRECT(); - startEdgeBounds = sis.readRECT(); - endEdgeBounds = sis.readRECT(); - reserved = (int) sis.readUB(6); - usesNonScalingStrokes = sis.readUB(1) == 1; - usesScalingStrokes = sis.readUB(1) == 1; - long offset = sis.readUI32(); - morphFillStyles = sis.readMORPHFILLSTYLEARRAY(); - morphLineStyles = sis.readMORPHLINESTYLEARRAY(2); - startEdges = sis.readSHAPE(2, true); - endEdges = sis.readSHAPE(2, true); + characterId = sis.readUI16("characterId"); + startBounds = sis.readRECT("startBounds"); + endBounds = sis.readRECT("endBounds"); + startEdgeBounds = sis.readRECT("startEdgeBounds"); + endEdgeBounds = sis.readRECT("endEdgeBounds"); + reserved = (int) sis.readUB(6, "reserved"); + usesNonScalingStrokes = sis.readUB(1, "usesNonScalingStrokes") == 1; + usesScalingStrokes = sis.readUB(1, "usesScalingStrokes") == 1; + long offset = sis.readUI32("offset"); + morphFillStyles = sis.readMORPHFILLSTYLEARRAY("morphFillStyles"); + morphLineStyles = sis.readMORPHLINESTYLEARRAY(2, "morphLineStyles"); + startEdges = sis.readSHAPE(2, true, "startEdges"); + endEdges = sis.readSHAPE(2, true, "endEdges"); } @Override diff --git a/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java b/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java index 18da30c50..1c9876818 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java @@ -132,14 +132,14 @@ public class DefineMorphShapeTag extends CharacterTag implements MorphShapeTag { */ public DefineMorphShapeTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineMorphShape", pos, length); - characterId = sis.readUI16(); - startBounds = sis.readRECT(); - endBounds = sis.readRECT(); - long offset = sis.readUI32(); //ignore - morphFillStyles = sis.readMORPHFILLSTYLEARRAY(); - morphLineStyles = sis.readMORPHLINESTYLEARRAY(1); - startEdges = sis.readSHAPE(1, true); - endEdges = sis.readSHAPE(1, true); + characterId = sis.readUI16("characterId"); + startBounds = sis.readRECT("startBounds"); + endBounds = sis.readRECT("endBounds"); + long offset = sis.readUI32("offset"); //ignore + morphFillStyles = sis.readMORPHFILLSTYLEARRAY("morphFillStyles"); + morphLineStyles = sis.readMORPHLINESTYLEARRAY(1, "morphLineStyles"); + startEdges = sis.readSHAPE(1, true, "startEdges"); + endEdges = sis.readSHAPE(1, true, "endEdges"); } @Override diff --git a/src/com/jpexs/decompiler/flash/tags/DefineScalingGridTag.java b/src/com/jpexs/decompiler/flash/tags/DefineScalingGridTag.java index 81866cbfa..894825098 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineScalingGridTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineScalingGridTag.java @@ -37,8 +37,8 @@ public class DefineScalingGridTag extends Tag { public DefineScalingGridTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineScalingGrid", pos, length); - characterId = sis.readUI16(); - splitter = sis.readRECT(); + characterId = sis.readUI16("characterId"); + splitter = sis.readRECT("splitter"); } /** diff --git a/src/com/jpexs/decompiler/flash/tags/DefineSceneAndFrameLabelDataTag.java b/src/com/jpexs/decompiler/flash/tags/DefineSceneAndFrameLabelDataTag.java index ee14bd304..23aa5f44c 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineSceneAndFrameLabelDataTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineSceneAndFrameLabelDataTag.java @@ -84,19 +84,19 @@ public class DefineSceneAndFrameLabelDataTag extends Tag { */ public DefineSceneAndFrameLabelDataTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineSceneAndFrameLabelData", pos, length); - int sceneCount = (int) sis.readEncodedU32(); + int sceneCount = (int) sis.readEncodedU32("sceneCount"); sceneOffsets = new long[sceneCount]; sceneNames = new String[sceneCount]; for (int i = 0; i < sceneCount; i++) { - sceneOffsets[i] = sis.readEncodedU32(); - sceneNames[i] = sis.readString(); + sceneOffsets[i] = sis.readEncodedU32("sceneOffset"); + sceneNames[i] = sis.readString("sceneName"); } - int frameLabelCount = (int) sis.readEncodedU32(); + int frameLabelCount = (int) sis.readEncodedU32("frameLabelCount"); frameNums = new long[frameLabelCount]; frameNames = new String[frameLabelCount]; for (int i = 0; i < frameLabelCount; i++) { - frameNums[i] = sis.readEncodedU32(); - frameNames[i] = sis.readString(); + frameNums[i] = sis.readEncodedU32("frameNum"); + frameNames[i] = sis.readString("frameName"); } } diff --git a/src/com/jpexs/decompiler/flash/tags/DefineShape2Tag.java b/src/com/jpexs/decompiler/flash/tags/DefineShape2Tag.java index 3c8e2b855..c5e533331 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineShape2Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineShape2Tag.java @@ -69,9 +69,9 @@ public class DefineShape2Tag extends ShapeTag { public DefineShape2Tag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineShape2", pos, length); - shapeId = sis.readUI16(); - shapeBounds = sis.readRECT(); - shapes = sis.readSHAPEWITHSTYLE(2, false); + shapeId = sis.readUI16("shapeId"); + shapeBounds = sis.readRECT("shapeBounds"); + shapes = sis.readSHAPEWITHSTYLE(2, false, "shapes"); } @Override diff --git a/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java b/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java index 1d75a0b9f..dd3af5fa6 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineShape3Tag.java @@ -69,9 +69,9 @@ public class DefineShape3Tag extends ShapeTag { public DefineShape3Tag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineShape3", pos, length); - shapeId = sis.readUI16(); - shapeBounds = sis.readRECT(); - shapes = sis.readSHAPEWITHSTYLE(3, false); + shapeId = sis.readUI16("shapeId"); + shapeBounds = sis.readRECT("shapeBounds"); + shapes = sis.readSHAPEWITHSTYLE(3, false, "shapes"); } @Override diff --git a/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java b/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java index 96b979773..c849fed99 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineShape4Tag.java @@ -77,14 +77,14 @@ public class DefineShape4Tag extends ShapeTag { public DefineShape4Tag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineShape4", pos, length); - shapeId = sis.readUI16(); - shapeBounds = sis.readRECT(); - edgeBounds = sis.readRECT(); - reserved = (int) sis.readUB(5); - usesFillWindingRule = sis.readUB(1) == 1; - usesNonScalingStrokes = sis.readUB(1) == 1; - usesScalingStrokes = sis.readUB(1) == 1; - shapes = sis.readSHAPEWITHSTYLE(4, false); + shapeId = sis.readUI16("shapeId"); + shapeBounds = sis.readRECT("shapeBounds"); + edgeBounds = sis.readRECT("edgeBounds"); + reserved = (int) sis.readUB(5, "reserved"); + usesFillWindingRule = sis.readUB(1, "usesFillWindingRule") == 1; + usesNonScalingStrokes = sis.readUB(1, "usesNonScalingStrokes") == 1; + usesScalingStrokes = sis.readUB(1, "usesScalingStrokes") == 1; + shapes = sis.readSHAPEWITHSTYLE(4, false, "shapes"); } @Override diff --git a/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java b/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java index 976f14c93..a5378304e 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineShapeTag.java @@ -66,9 +66,9 @@ public class DefineShapeTag extends ShapeTag { public DefineShapeTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineShape", pos, length); - shapeId = sis.readUI16(); - shapeBounds = sis.readRECT(); - shapes = sis.readSHAPEWITHSTYLE(1, false); + shapeId = sis.readUI16("shapeId"); + shapeBounds = sis.readRECT("shapeBounds"); + shapes = sis.readSHAPEWITHSTYLE(1, false, "shapes"); } /** diff --git a/src/com/jpexs/decompiler/flash/tags/DefineSoundTag.java b/src/com/jpexs/decompiler/flash/tags/DefineSoundTag.java index 7a55a09a2..0cbdebc7e 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineSoundTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineSoundTag.java @@ -102,13 +102,13 @@ public class DefineSoundTag extends CharacterTag implements SoundTag { */ public DefineSoundTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineSound", pos, length); - soundId = sis.readUI16(); - soundFormat = (int) sis.readUB(4); - soundRate = (int) sis.readUB(2); - soundSize = sis.readUB(1) == 1; - soundType = sis.readUB(1) == 1; - soundSampleCount = sis.readUI32(); - soundData = sis.readBytesEx(sis.available()); + soundId = sis.readUI16("soundId"); + soundFormat = (int) sis.readUB(4, "soundFormat"); + soundRate = (int) sis.readUB(2, "soundRate"); + soundSize = sis.readUB(1, "soundSize") == 1; + soundType = sis.readUB(1, "soundType") == 1; + soundSampleCount = sis.readUI32("soundSampleCount"); + soundData = sis.readBytesEx(sis.available(), "soundData"); } @Override diff --git a/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java b/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java index f4f847ab1..81bce1d7f 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java @@ -203,8 +203,8 @@ public class DefineSpriteTag extends CharacterTag implements Container, Drawable */ public DefineSpriteTag(SWFInputStream sis, int level, long pos, int length, boolean parallel, boolean skipUnusualTags) throws IOException, InterruptedException { super(sis.getSwf(), ID, "DefineSprite", pos, length); - spriteId = sis.readUI16(); - frameCount = sis.readUI16(); + spriteId = sis.readUI16("spriteId"); + frameCount = sis.readUI16("frameCount"); List subTags = sis.readTagList(this, level + 1, parallel, skipUnusualTags, true, swf.gfx); if (subTags.get(subTags.size() - 1).getId() == EndTag.ID) { hasEndTag = true; diff --git a/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java b/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java index 28ed26b28..8273a5084 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java @@ -466,14 +466,14 @@ public class DefineText2Tag extends TextTag { */ public DefineText2Tag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineText2", pos, length); - characterID = sis.readUI16(); - textBounds = sis.readRECT(); - textMatrix = sis.readMatrix(); - int glyphBits = sis.readUI8(); - int advanceBits = sis.readUI8(); + characterID = sis.readUI16("characterID"); + textBounds = sis.readRECT("textBounds"); + textMatrix = sis.readMatrix("textMatrix"); + int glyphBits = sis.readUI8("glyphBits"); + int advanceBits = sis.readUI8("advanceBits"); textRecords = new ArrayList<>(); TEXTRECORD tr; - while ((tr = sis.readTEXTRECORD(true, glyphBits, advanceBits)) != null) { + while ((tr = sis.readTEXTRECORD(true, glyphBits, advanceBits, "record")) != null) { textRecords.add(tr); } } diff --git a/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java b/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java index 342665acf..38f7f22c8 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java @@ -477,14 +477,14 @@ public class DefineTextTag extends TextTag { */ public DefineTextTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineText", pos, length); - characterID = sis.readUI16(); - textBounds = sis.readRECT(); - textMatrix = sis.readMatrix(); - int glyphBits = sis.readUI8(); - int advanceBits = sis.readUI8(); + characterID = sis.readUI16("characterID"); + textBounds = sis.readRECT("textBounds"); + textMatrix = sis.readMatrix("textMatrix"); + int glyphBits = sis.readUI8("glyphBits"); + int advanceBits = sis.readUI8("advanceBits"); textRecords = new ArrayList<>(); TEXTRECORD tr; - while ((tr = sis.readTEXTRECORD(false, glyphBits, advanceBits)) != null) { + while ((tr = sis.readTEXTRECORD(false, glyphBits, advanceBits, "record")) != null) { textRecords.add(tr); } } diff --git a/src/com/jpexs/decompiler/flash/tags/DefineVideoStreamTag.java b/src/com/jpexs/decompiler/flash/tags/DefineVideoStreamTag.java index b6179bf8b..42c5435ff 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineVideoStreamTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineVideoStreamTag.java @@ -105,14 +105,14 @@ public class DefineVideoStreamTag extends CharacterTag implements BoundedTag { */ public DefineVideoStreamTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineVideoStream", pos, length); - characterID = sis.readUI16(); - numFrames = sis.readUI16(); - width = sis.readUI16(); - height = sis.readUI16(); - reserved = (int) sis.readUB(4); - videoFlagsDeblocking = (int) sis.readUB(3); - videoFlagsSmoothing = sis.readUB(1) == 1; - codecID = sis.readUI8(); + characterID = sis.readUI16("characterID"); + numFrames = sis.readUI16("numFrames"); + width = sis.readUI16("width"); + height = sis.readUI16("height"); + reserved = (int) sis.readUB(4, "reserved"); + videoFlagsDeblocking = (int) sis.readUB(3, "videoFlagsDeblocking"); + videoFlagsSmoothing = sis.readUB(1, "videoFlagsSmoothing") == 1; + codecID = sis.readUI8("codecID"); } @Override diff --git a/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java b/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java index 6c60e5ea4..b817651bf 100644 --- a/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java @@ -72,8 +72,8 @@ public class DoABCDefineTag extends Tag implements ABCContainerTag { */ public DoABCDefineTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DoABCDefine", pos, length); - flags = sis.readUI32(); - name = sis.readString(); + flags = sis.readUI32("flags"); + name = sis.readString("name"); abc = new ABC(sis, swf, this); } diff --git a/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java b/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java index 7e352f5b0..7963f06e7 100644 --- a/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java @@ -61,9 +61,9 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource { */ public DoInitActionTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DoInitAction", pos, length); - spriteId = sis.readUI16(); + spriteId = sis.readUI16("spriteId"); //actions = sis.readActionList(); - actionBytes = sis.readBytesEx(sis.available()); + actionBytes = sis.readBytesEx(sis.available(), "actionBytes"); } /** diff --git a/src/com/jpexs/decompiler/flash/tags/EnableDebugger2Tag.java b/src/com/jpexs/decompiler/flash/tags/EnableDebugger2Tag.java index adb1684d5..4cabeb5d4 100644 --- a/src/com/jpexs/decompiler/flash/tags/EnableDebugger2Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/EnableDebugger2Tag.java @@ -70,7 +70,7 @@ public class EnableDebugger2Tag extends Tag { */ public EnableDebugger2Tag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "EnableDebugger2", pos, length); - reserved = sis.readUI16(); - passwordHash = sis.readString(); + reserved = sis.readUI16("reserved"); + passwordHash = sis.readString("passwordHash"); } } diff --git a/src/com/jpexs/decompiler/flash/tags/EnableDebuggerTag.java b/src/com/jpexs/decompiler/flash/tags/EnableDebuggerTag.java index f97e72923..7c6c8fdad 100644 --- a/src/com/jpexs/decompiler/flash/tags/EnableDebuggerTag.java +++ b/src/com/jpexs/decompiler/flash/tags/EnableDebuggerTag.java @@ -64,6 +64,6 @@ public class EnableDebuggerTag extends Tag { */ public EnableDebuggerTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "EnableDebugger", pos, length); - passwordHash = sis.readString(); + passwordHash = sis.readString("passwordHash"); } } diff --git a/src/com/jpexs/decompiler/flash/tags/EnableTelemetryTag.java b/src/com/jpexs/decompiler/flash/tags/EnableTelemetryTag.java index 3811d7e77..eceffde19 100644 --- a/src/com/jpexs/decompiler/flash/tags/EnableTelemetryTag.java +++ b/src/com/jpexs/decompiler/flash/tags/EnableTelemetryTag.java @@ -73,9 +73,9 @@ public class EnableTelemetryTag extends Tag { */ public EnableTelemetryTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "", pos, length); - reserved = (int) sis.readUB(16); + reserved = (int) sis.readUB(16, "reserved"); if (sis.available() > 0) { - passwordHash = sis.readBytesEx(32); + passwordHash = sis.readBytesEx(32, "passwordHash"); } } } diff --git a/src/com/jpexs/decompiler/flash/tags/ExportAssetsTag.java b/src/com/jpexs/decompiler/flash/tags/ExportAssetsTag.java index 700226a33..a89b4f485 100644 --- a/src/com/jpexs/decompiler/flash/tags/ExportAssetsTag.java +++ b/src/com/jpexs/decompiler/flash/tags/ExportAssetsTag.java @@ -62,13 +62,13 @@ public class ExportAssetsTag extends Tag { */ public ExportAssetsTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "ExportAssets", pos, length); - int count = sis.readUI16(); + int count = sis.readUI16("count"); tags = new ArrayList<>(); names = new ArrayList<>(); for (int i = 0; i < count; i++) { - int characterId = sis.readUI16(); + int characterId = sis.readUI16("characterId"); tags.add(characterId); - String name = sis.readString(); + String name = sis.readString("name"); names.add(name); } } diff --git a/src/com/jpexs/decompiler/flash/tags/FileAttributesTag.java b/src/com/jpexs/decompiler/flash/tags/FileAttributesTag.java index 64f96dd00..26ccfbb5b 100644 --- a/src/com/jpexs/decompiler/flash/tags/FileAttributesTag.java +++ b/src/com/jpexs/decompiler/flash/tags/FileAttributesTag.java @@ -50,17 +50,17 @@ public class FileAttributesTag extends Tag { public FileAttributesTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "FileAttributes", pos, length); - reserved1 = sis.readUB(1) == 1; // reserved + reserved1 = sis.readUB(1, "reserved1") == 1; // reserved // UB[1] == 0 (reserved) - useDirectBlit = sis.readUB(1) != 0; - useGPU = sis.readUB(1) != 0; - hasMetadata = sis.readUB(1) != 0; - actionScript3 = sis.readUB(1) != 0; - noCrossDomainCache = sis.readUB(1) != 0; - reserved2 = sis.readUB(1) == 1; // reserved - useNetwork = sis.readUB(1) != 0; + useDirectBlit = sis.readUB(1, "useDirectBlit") != 0; + useGPU = sis.readUB(1, "useGPU") != 0; + hasMetadata = sis.readUB(1, "hasMetadata") != 0; + actionScript3 = sis.readUB(1, "actionScript3") != 0; + noCrossDomainCache = sis.readUB(1, "noCrossDomainCache") != 0; + reserved2 = sis.readUB(1, "reserved2") == 1; // reserved + useNetwork = sis.readUB(1, "useNetwork") != 0; // UB[24] == 0 (reserved) - reserved3 = (int) sis.readUB(24); //reserved + reserved3 = (int) sis.readUB(24, "reserved3"); //reserved } /** diff --git a/src/com/jpexs/decompiler/flash/tags/FrameLabelTag.java b/src/com/jpexs/decompiler/flash/tags/FrameLabelTag.java index f91d4927e..7c7deb8f3 100644 --- a/src/com/jpexs/decompiler/flash/tags/FrameLabelTag.java +++ b/src/com/jpexs/decompiler/flash/tags/FrameLabelTag.java @@ -38,9 +38,9 @@ public class FrameLabelTag extends Tag { public FrameLabelTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "FrameLabel", pos, length); - name = sis.readString(); + name = sis.readString("name"); if (sis.available() > 0) { - if (sis.readUI8() == 1) { + if (sis.readUI8("namedAnchor") == 1) { namedAnchor = true; } } diff --git a/src/com/jpexs/decompiler/flash/tags/ImportAssets2Tag.java b/src/com/jpexs/decompiler/flash/tags/ImportAssets2Tag.java index db98cc70b..cce8e1c86 100644 --- a/src/com/jpexs/decompiler/flash/tags/ImportAssets2Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/ImportAssets2Tag.java @@ -67,13 +67,13 @@ public class ImportAssets2Tag extends Tag implements ImportTag { super(sis.getSwf(), ID, "ImportAssets2", pos, length); tags = new ArrayList<>(); names = new ArrayList<>(); - url = sis.readString(); - reserved1 = sis.readUI8();//reserved, must be 1 - reserved2 = sis.readUI8();//reserved, must be 0 - int count = sis.readUI16(); + url = sis.readString("url"); + reserved1 = sis.readUI8("reserved1");//reserved, must be 1 + reserved2 = sis.readUI8("reserved2");//reserved, must be 0 + int count = sis.readUI16("count"); for (int i = 0; i < count; i++) { - int charId = sis.readUI16(); - String tagName = sis.readString(); + int charId = sis.readUI16("charId"); + String tagName = sis.readString("tagName"); tags.add(charId); names.add(tagName); } diff --git a/src/com/jpexs/decompiler/flash/tags/ImportAssetsTag.java b/src/com/jpexs/decompiler/flash/tags/ImportAssetsTag.java index 0109f27d8..3534ad3ae 100644 --- a/src/com/jpexs/decompiler/flash/tags/ImportAssetsTag.java +++ b/src/com/jpexs/decompiler/flash/tags/ImportAssetsTag.java @@ -60,11 +60,11 @@ public class ImportAssetsTag extends Tag implements ImportTag { super(sis.getSwf(), ID, "ImportAssets", pos, length); tags = new ArrayList<>(); names = new ArrayList<>(); - url = sis.readString(); - int count = sis.readUI16(); + url = sis.readString("url"); + int count = sis.readUI16("count"); for (int i = 0; i < count; i++) { - int charId = sis.readUI16(); - String tagName = sis.readString(); + int charId = sis.readUI16("charId"); + String tagName = sis.readString("tagName"); tags.add(charId); names.add(tagName); } diff --git a/src/com/jpexs/decompiler/flash/tags/JPEGTablesTag.java b/src/com/jpexs/decompiler/flash/tags/JPEGTablesTag.java index 124dad1dc..5deeb3f52 100644 --- a/src/com/jpexs/decompiler/flash/tags/JPEGTablesTag.java +++ b/src/com/jpexs/decompiler/flash/tags/JPEGTablesTag.java @@ -28,6 +28,6 @@ public class JPEGTablesTag extends Tag { public JPEGTablesTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "JPEGTables", pos, length); - jpegData = sis.readBytesEx(sis.available()); + jpegData = sis.readBytesEx(sis.available(), "jpegData"); } } diff --git a/src/com/jpexs/decompiler/flash/tags/MetadataTag.java b/src/com/jpexs/decompiler/flash/tags/MetadataTag.java index 39ab9ef97..3968bdafb 100644 --- a/src/com/jpexs/decompiler/flash/tags/MetadataTag.java +++ b/src/com/jpexs/decompiler/flash/tags/MetadataTag.java @@ -32,7 +32,7 @@ public class MetadataTag extends Tag { public MetadataTag(SWFInputStream sis, long pos, int length) { super(sis.getSwf(), ID, "Metadata", pos, length); try { - xmlMetadata = sis.readString(); + xmlMetadata = sis.readString("xmlMetadata"); } catch (IOException ex) { } } diff --git a/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java b/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java index 7d7cc000d..835963fa7 100644 --- a/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java @@ -220,35 +220,35 @@ public class PlaceObject2Tag extends CharacterIdTag implements Container, PlaceO */ public PlaceObject2Tag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "PlaceObject2", pos, length); - placeFlagHasClipActions = sis.readUB(1) == 1; - placeFlagHasClipDepth = sis.readUB(1) == 1; - placeFlagHasName = sis.readUB(1) == 1; - placeFlagHasRatio = sis.readUB(1) == 1; - placeFlagHasColorTransform = sis.readUB(1) == 1; - placeFlagHasMatrix = sis.readUB(1) == 1; - placeFlagHasCharacter = sis.readUB(1) == 1; - placeFlagMove = sis.readUB(1) == 1; - depth = sis.readUI16(); + placeFlagHasClipActions = sis.readUB(1, "placeFlagHasClipActions") == 1; + placeFlagHasClipDepth = sis.readUB(1, "placeFlagHasClipDepth") == 1; + placeFlagHasName = sis.readUB(1, "placeFlagHasName") == 1; + placeFlagHasRatio = sis.readUB(1, "placeFlagHasRatio") == 1; + placeFlagHasColorTransform = sis.readUB(1, "placeFlagHasColorTransform") == 1; + placeFlagHasMatrix = sis.readUB(1, "placeFlagHasMatrix") == 1; + placeFlagHasCharacter = sis.readUB(1, "placeFlagHasCharacter") == 1; + placeFlagMove = sis.readUB(1, "placeFlagMove") == 1; + depth = sis.readUI16("depth"); if (placeFlagHasCharacter) { - characterId = sis.readUI16(); + characterId = sis.readUI16("characterId"); } if (placeFlagHasMatrix) { - matrix = sis.readMatrix(); + matrix = sis.readMatrix("matrix"); } if (placeFlagHasColorTransform) { - colorTransform = sis.readCXFORMWITHALPHA(); + colorTransform = sis.readCXFORMWITHALPHA("colorTransform"); } if (placeFlagHasRatio) { - ratio = sis.readUI16(); + ratio = sis.readUI16("ratio"); } if (placeFlagHasName) { - name = sis.readString(); + name = sis.readString("name"); } if (placeFlagHasClipDepth) { - clipDepth = sis.readUI16(); + clipDepth = sis.readUI16("clipDepth"); } if (placeFlagHasClipActions) { - clipActions = sis.readCLIPACTIONS(swf, this); + clipActions = sis.readCLIPACTIONS(swf, this, "clipActions"); } } diff --git a/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java b/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java index bcab5c965..e0ce4d0b8 100644 --- a/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java @@ -304,55 +304,55 @@ public class PlaceObject3Tag extends CharacterIdTag implements Container, PlaceO */ public PlaceObject3Tag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "PlaceObject3", pos, length); - placeFlagHasClipActions = sis.readUB(1) == 1; - placeFlagHasClipDepth = sis.readUB(1) == 1; - placeFlagHasName = sis.readUB(1) == 1; - placeFlagHasRatio = sis.readUB(1) == 1; - placeFlagHasColorTransform = sis.readUB(1) == 1; - placeFlagHasMatrix = sis.readUB(1) == 1; - placeFlagHasCharacter = sis.readUB(1) == 1; - placeFlagMove = sis.readUB(1) == 1; - reserved = sis.readUB(1) == 1; - placeFlagOpaqueBackground = sis.readUB(1) == 1; //SWF11 - placeFlagHasVisible = sis.readUB(1) == 1; //SWF11 - placeFlagHasImage = sis.readUB(1) == 1; - placeFlagHasClassName = sis.readUB(1) == 1; - placeFlagHasCacheAsBitmap = sis.readUB(1) == 1; - placeFlagHasBlendMode = sis.readUB(1) == 1; - placeFlagHasFilterList = sis.readUB(1) == 1; + placeFlagHasClipActions = sis.readUB(1, "placeFlagHasClipActions") == 1; + placeFlagHasClipDepth = sis.readUB(1, "placeFlagHasClipDepth") == 1; + placeFlagHasName = sis.readUB(1, "placeFlagHasName") == 1; + placeFlagHasRatio = sis.readUB(1, "placeFlagHasRatio") == 1; + placeFlagHasColorTransform = sis.readUB(1, "placeFlagHasColorTransform") == 1; + placeFlagHasMatrix = sis.readUB(1, "placeFlagHasMatrix") == 1; + placeFlagHasCharacter = sis.readUB(1, "placeFlagHasCharacter") == 1; + placeFlagMove = sis.readUB(1, "placeFlagMove") == 1; + reserved = sis.readUB(1, "reserved") == 1; + placeFlagOpaqueBackground = sis.readUB(1, "placeFlagOpaqueBackground") == 1; //SWF11 + placeFlagHasVisible = sis.readUB(1, "placeFlagHasVisible") == 1; //SWF11 + placeFlagHasImage = sis.readUB(1, "placeFlagHasImage") == 1; + placeFlagHasClassName = sis.readUB(1, "placeFlagHasClassName") == 1; + placeFlagHasCacheAsBitmap = sis.readUB(1, "placeFlagHasCacheAsBitmap") == 1; + placeFlagHasBlendMode = sis.readUB(1, "placeFlagHasBlendMode") == 1; + placeFlagHasFilterList = sis.readUB(1, "placeFlagHasFilterList") == 1; - depth = sis.readUI16(); + depth = sis.readUI16("depth"); if (placeFlagHasClassName || (placeFlagHasImage && placeFlagHasCharacter)) { - className = sis.readString(); + className = sis.readString("className"); } if (placeFlagHasCharacter) { - characterId = sis.readUI16(); + characterId = sis.readUI16("characterId"); } if (placeFlagHasMatrix) { - matrix = sis.readMatrix(); + matrix = sis.readMatrix("matrix"); } if (placeFlagHasColorTransform) { - colorTransform = sis.readCXFORMWITHALPHA(); + colorTransform = sis.readCXFORMWITHALPHA("colorTransform"); } if (placeFlagHasRatio) { - ratio = sis.readUI16(); + ratio = sis.readUI16("ratio"); } if (placeFlagHasName) { - name = sis.readString(); + name = sis.readString("name"); } if (placeFlagHasClipDepth) { - clipDepth = sis.readUI16(); + clipDepth = sis.readUI16("clipDepth"); } if (placeFlagHasFilterList) { - surfaceFilterList = sis.readFILTERLIST(); + surfaceFilterList = sis.readFILTERLIST("surfaceFilterList"); } if (placeFlagHasBlendMode) { - blendMode = sis.readUI8(); + blendMode = sis.readUI8("blendMode"); } bitmapCacheBug = false; if (placeFlagHasCacheAsBitmap) { try { - bitmapCache = sis.readUI8(); + bitmapCache = sis.readUI8("bitmapCache"); } catch (EndOfStreamException eex) { bitmapCacheBug = true; bitmapCache = 1; @@ -360,14 +360,14 @@ public class PlaceObject3Tag extends CharacterIdTag implements Container, PlaceO } if (placeFlagHasVisible) { - visible = sis.readUI8(); + visible = sis.readUI8("visible"); } if (placeFlagOpaqueBackground) { - backgroundColor = sis.readRGBA(); + backgroundColor = sis.readRGBA("backgroundColor"); } if (placeFlagHasClipActions) { - clipActions = sis.readCLIPACTIONS(swf, this); + clipActions = sis.readCLIPACTIONS(swf, this, "clipActions"); } } diff --git a/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java b/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java index eff1c5fb1..c7c19e307 100644 --- a/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java @@ -305,55 +305,55 @@ public class PlaceObject4Tag extends CharacterIdTag implements Container, PlaceO */ public PlaceObject4Tag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "PlaceObject4", pos, length); - placeFlagHasClipActions = sis.readUB(1) == 1; - placeFlagHasClipDepth = sis.readUB(1) == 1; - placeFlagHasName = sis.readUB(1) == 1; - placeFlagHasRatio = sis.readUB(1) == 1; - placeFlagHasColorTransform = sis.readUB(1) == 1; - placeFlagHasMatrix = sis.readUB(1) == 1; - placeFlagHasCharacter = sis.readUB(1) == 1; - placeFlagMove = sis.readUB(1) == 1; - reserved = sis.readUB(1) == 1; - placeFlagOpaqueBackground = sis.readUB(1) == 1; //SWF11 - placeFlagHasVisible = sis.readUB(1) == 1; //SWF11 - placeFlagHasImage = sis.readUB(1) == 1; - placeFlagHasClassName = sis.readUB(1) == 1; - placeFlagHasCacheAsBitmap = sis.readUB(1) == 1; - placeFlagHasBlendMode = sis.readUB(1) == 1; - placeFlagHasFilterList = sis.readUB(1) == 1; + placeFlagHasClipActions = sis.readUB(1, "placeFlagHasClipActions") == 1; + placeFlagHasClipDepth = sis.readUB(1, "placeFlagHasClipDepth") == 1; + placeFlagHasName = sis.readUB(1, "placeFlagHasName") == 1; + placeFlagHasRatio = sis.readUB(1, "placeFlagHasRatio") == 1; + placeFlagHasColorTransform = sis.readUB(1, "placeFlagHasColorTransform") == 1; + placeFlagHasMatrix = sis.readUB(1, "placeFlagHasMatrix") == 1; + placeFlagHasCharacter = sis.readUB(1, "placeFlagHasCharacter") == 1; + placeFlagMove = sis.readUB(1, "placeFlagMove") == 1; + reserved = sis.readUB(1, "reserved") == 1; + placeFlagOpaqueBackground = sis.readUB(1, "placeFlagOpaqueBackground") == 1; //SWF11 + placeFlagHasVisible = sis.readUB(1, "placeFlagHasVisible") == 1; //SWF11 + placeFlagHasImage = sis.readUB(1, "placeFlagHasImage") == 1; + placeFlagHasClassName = sis.readUB(1, "placeFlagHasClassName") == 1; + placeFlagHasCacheAsBitmap = sis.readUB(1, "placeFlagHasCacheAsBitmap") == 1; + placeFlagHasBlendMode = sis.readUB(1, "placeFlagHasBlendMode") == 1; + placeFlagHasFilterList = sis.readUB(1, "placeFlagHasFilterList") == 1; - depth = sis.readUI16(); + depth = sis.readUI16("depth"); if (placeFlagHasClassName || (placeFlagHasImage && placeFlagHasCharacter)) { - className = sis.readString(); + className = sis.readString("className"); } if (placeFlagHasCharacter) { - characterId = sis.readUI16(); + characterId = sis.readUI16("characterId"); } if (placeFlagHasMatrix) { - matrix = sis.readMatrix(); + matrix = sis.readMatrix("matrix"); } if (placeFlagHasColorTransform) { - colorTransform = sis.readCXFORMWITHALPHA(); + colorTransform = sis.readCXFORMWITHALPHA("colorTransform"); } if (placeFlagHasRatio) { - ratio = sis.readUI16(); + ratio = sis.readUI16("ratio"); } if (placeFlagHasName) { - name = sis.readString(); + name = sis.readString("name"); } if (placeFlagHasClipDepth) { - clipDepth = sis.readUI16(); + clipDepth = sis.readUI16("clipDepth"); } if (placeFlagHasFilterList) { - surfaceFilterList = sis.readFILTERLIST(); + surfaceFilterList = sis.readFILTERLIST("surfaceFilterList"); } if (placeFlagHasBlendMode) { - blendMode = sis.readUI8(); + blendMode = sis.readUI8("blendMode"); } bitmapCacheBug = false; if (placeFlagHasCacheAsBitmap) { try { - bitmapCache = sis.readUI8(); + bitmapCache = sis.readUI8("bitmapCache"); } catch (EndOfStreamException eex) { bitmapCacheBug = true; bitmapCache = 1; @@ -361,16 +361,16 @@ public class PlaceObject4Tag extends CharacterIdTag implements Container, PlaceO } if (placeFlagHasVisible) { - visible = sis.readUI8(); + visible = sis.readUI8("visible"); } if (placeFlagOpaqueBackground) { - backgroundColor = sis.readRGBA(); + backgroundColor = sis.readRGBA("backgroundColor"); } if (placeFlagHasClipActions) { - clipActions = sis.readCLIPACTIONS(swf, this); + clipActions = sis.readCLIPACTIONS(swf, this, "clipActions"); } - amfData = sis.readBytesEx(sis.available()); + amfData = sis.readBytesEx(sis.available(), "amfData"); } /** diff --git a/src/com/jpexs/decompiler/flash/tags/PlaceObjectTag.java b/src/com/jpexs/decompiler/flash/tags/PlaceObjectTag.java index 84cc3e193..2306a11b0 100644 --- a/src/com/jpexs/decompiler/flash/tags/PlaceObjectTag.java +++ b/src/com/jpexs/decompiler/flash/tags/PlaceObjectTag.java @@ -106,11 +106,11 @@ public class PlaceObjectTag extends CharacterIdTag implements PlaceObjectTypeTag */ public PlaceObjectTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "PlaceObject", pos, length); - characterId = sis.readUI16(); - depth = sis.readUI16(); - matrix = sis.readMatrix(); + characterId = sis.readUI16("characterId"); + depth = sis.readUI16("depth"); + matrix = sis.readMatrix("matrix"); if (sis.available() > 0) { - colorTransform = sis.readCXFORM(); + colorTransform = sis.readCXFORM("colorTransform"); } } diff --git a/src/com/jpexs/decompiler/flash/tags/ProductInfoTag.java b/src/com/jpexs/decompiler/flash/tags/ProductInfoTag.java index f7ed26494..296ddffb1 100644 --- a/src/com/jpexs/decompiler/flash/tags/ProductInfoTag.java +++ b/src/com/jpexs/decompiler/flash/tags/ProductInfoTag.java @@ -52,7 +52,7 @@ public class ProductInfoTag extends Tag { * 2: Macromedia Flex for .NET * 3: Adobe Flex */ - productID = sis.readUI32(); + productID = sis.readUI32("productID"); /* * 0: Developer Edition @@ -63,13 +63,13 @@ public class ProductInfoTag extends Tag { * 5: Trial Edition * 6: None */ - edition = sis.readUI32(); - majorVersion = sis.readUI8(); - minorVersion = sis.readUI8(); - buildLow = sis.readUI32(); - buildHigh = sis.readUI32(); - compilationDateLow = sis.readUI32(); - compilationDateHigh = sis.readUI32(); + edition = sis.readUI32("edition"); + majorVersion = sis.readUI8("majorVersion"); + minorVersion = sis.readUI8("minorVersion"); + buildLow = sis.readUI32("buildLow"); + buildHigh = sis.readUI32("buildHigh"); + compilationDateLow = sis.readUI32("compilationDateLow"); + compilationDateHigh = sis.readUI32("compilationDateHigh"); } @Override diff --git a/src/com/jpexs/decompiler/flash/tags/ProtectTag.java b/src/com/jpexs/decompiler/flash/tags/ProtectTag.java index 98058c292..989fb13b2 100644 --- a/src/com/jpexs/decompiler/flash/tags/ProtectTag.java +++ b/src/com/jpexs/decompiler/flash/tags/ProtectTag.java @@ -65,7 +65,7 @@ public class ProtectTag extends Tag { public ProtectTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "Protect", pos, length); if (sis.available() > 0) { - passwordHash = sis.readString(); + passwordHash = sis.readString("passwordHash"); } else { passwordHash = ""; } diff --git a/src/com/jpexs/decompiler/flash/tags/RemoveObject2Tag.java b/src/com/jpexs/decompiler/flash/tags/RemoveObject2Tag.java index b63cb804a..4551922c7 100644 --- a/src/com/jpexs/decompiler/flash/tags/RemoveObject2Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/RemoveObject2Tag.java @@ -30,7 +30,7 @@ public class RemoveObject2Tag extends Tag implements RemoveTag { public RemoveObject2Tag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "RemoveObject2", pos, length); - depth = sis.readUI16(); + depth = sis.readUI16("depth"); } @Override diff --git a/src/com/jpexs/decompiler/flash/tags/RemoveObjectTag.java b/src/com/jpexs/decompiler/flash/tags/RemoveObjectTag.java index cdeeb70d5..3b34aa1a6 100644 --- a/src/com/jpexs/decompiler/flash/tags/RemoveObjectTag.java +++ b/src/com/jpexs/decompiler/flash/tags/RemoveObjectTag.java @@ -73,8 +73,8 @@ public class RemoveObjectTag extends CharacterIdTag implements RemoveTag { */ public RemoveObjectTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "RemoveObject", pos, length); - characterId = sis.readUI16(); - depth = sis.readUI16(); + characterId = sis.readUI16("characterId"); + depth = sis.readUI16("depth"); } @Override diff --git a/src/com/jpexs/decompiler/flash/tags/ScriptLimitsTag.java b/src/com/jpexs/decompiler/flash/tags/ScriptLimitsTag.java index 93ccd37bb..a16d0e309 100644 --- a/src/com/jpexs/decompiler/flash/tags/ScriptLimitsTag.java +++ b/src/com/jpexs/decompiler/flash/tags/ScriptLimitsTag.java @@ -36,8 +36,8 @@ public class ScriptLimitsTag extends Tag { public ScriptLimitsTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "ScriptLimits", pos, length); - maxRecursionDepth = sis.readUI16(); - scriptTimeoutSeconds = sis.readUI16(); + maxRecursionDepth = sis.readUI16("maxRecursionDepth"); + scriptTimeoutSeconds = sis.readUI16("scriptTimeoutSeconds"); } /** diff --git a/src/com/jpexs/decompiler/flash/tags/SetBackgroundColorTag.java b/src/com/jpexs/decompiler/flash/tags/SetBackgroundColorTag.java index 047be2784..bf0defd2f 100644 --- a/src/com/jpexs/decompiler/flash/tags/SetBackgroundColorTag.java +++ b/src/com/jpexs/decompiler/flash/tags/SetBackgroundColorTag.java @@ -30,7 +30,7 @@ public class SetBackgroundColorTag extends Tag { public SetBackgroundColorTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "SetBackgroundColor", pos, length); - backgroundColor = sis.readRGB(); + backgroundColor = sis.readRGB("backgroundColor"); } public SetBackgroundColorTag(SWF swf, RGB backgroundColor) { diff --git a/src/com/jpexs/decompiler/flash/tags/SetTabIndexTag.java b/src/com/jpexs/decompiler/flash/tags/SetTabIndexTag.java index 8581d0ad1..2322f1eaa 100644 --- a/src/com/jpexs/decompiler/flash/tags/SetTabIndexTag.java +++ b/src/com/jpexs/decompiler/flash/tags/SetTabIndexTag.java @@ -71,7 +71,7 @@ public class SetTabIndexTag extends Tag { */ public SetTabIndexTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "SetTabIndex", pos, length); - depth = sis.readUI16(); - tabIndex = sis.readUI16(); + depth = sis.readUI16("depth"); + tabIndex = sis.readUI16("tabIndex"); } } diff --git a/src/com/jpexs/decompiler/flash/tags/SoundStreamBlockTag.java b/src/com/jpexs/decompiler/flash/tags/SoundStreamBlockTag.java index 535456c75..029a7fe84 100644 --- a/src/com/jpexs/decompiler/flash/tags/SoundStreamBlockTag.java +++ b/src/com/jpexs/decompiler/flash/tags/SoundStreamBlockTag.java @@ -43,6 +43,6 @@ public class SoundStreamBlockTag extends Tag { public SoundStreamBlockTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "SoundStreamBlock", pos, length); //all data is streamSoundData - streamSoundData = sis.readBytesEx(sis.available()); + streamSoundData = sis.readBytesEx(sis.available(), "streamSoundData"); } } diff --git a/src/com/jpexs/decompiler/flash/tags/SoundStreamHead2Tag.java b/src/com/jpexs/decompiler/flash/tags/SoundStreamHead2Tag.java index eb2158ad0..2cf15c092 100644 --- a/src/com/jpexs/decompiler/flash/tags/SoundStreamHead2Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/SoundStreamHead2Tag.java @@ -143,17 +143,17 @@ public class SoundStreamHead2Tag extends CharacterIdTag implements SoundStreamHe */ public SoundStreamHead2Tag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "SoundStreamHead2", pos, length); - reserved = (int) sis.readUB(4); - playBackSoundRate = (int) sis.readUB(2); - playBackSoundSize = sis.readUB(1) == 1; - playBackSoundType = sis.readUB(1) == 1; - streamSoundCompression = (int) sis.readUB(4); - streamSoundRate = (int) sis.readUB(2); - streamSoundSize = sis.readUB(1) == 1; - streamSoundType = sis.readUB(1) == 1; - streamSoundSampleCount = sis.readUI16(); + reserved = (int) sis.readUB(4, "reserved"); + playBackSoundRate = (int) sis.readUB(2, "playBackSoundRate"); + playBackSoundSize = sis.readUB(1, "playBackSoundSize") == 1; + playBackSoundType = sis.readUB(1, "playBackSoundType") == 1; + streamSoundCompression = (int) sis.readUB(4, "streamSoundCompression"); + streamSoundRate = (int) sis.readUB(2, "streamSoundRate"); + streamSoundSize = sis.readUB(1, "streamSoundSize") == 1; + streamSoundType = sis.readUB(1, "streamSoundType") == 1; + streamSoundSampleCount = sis.readUI16("streamSoundSampleCount"); if (streamSoundCompression == 2) { - latencySeek = sis.readSI16(); + latencySeek = sis.readSI16("latencySeek"); } } diff --git a/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java b/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java index 149648b75..2014cc07f 100644 --- a/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java +++ b/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java @@ -136,17 +136,17 @@ public class SoundStreamHeadTag extends CharacterIdTag implements SoundStreamHea */ public SoundStreamHeadTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "SoundStreamHead", pos, length); - reserved = (int) sis.readUB(4); - playBackSoundRate = (int) sis.readUB(2); - playBackSoundSize = sis.readUB(1) == 1; - playBackSoundType = sis.readUB(1) == 1; - streamSoundCompression = (int) sis.readUB(4); - streamSoundRate = (int) sis.readUB(2); - streamSoundSize = sis.readUB(1) == 1; - streamSoundType = sis.readUB(1) == 1; - streamSoundSampleCount = sis.readUI16(); + reserved = (int) sis.readUB(4, "reserved"); + playBackSoundRate = (int) sis.readUB(2, "playBackSoundRate"); + playBackSoundSize = sis.readUB(1, "playBackSoundSize") == 1; + playBackSoundType = sis.readUB(1, "playBackSoundType") == 1; + streamSoundCompression = (int) sis.readUB(4, "streamSoundCompression"); + streamSoundRate = (int) sis.readUB(2, "streamSoundRate"); + streamSoundSize = sis.readUB(1, "streamSoundSize") == 1; + streamSoundType = sis.readUB(1, "streamSoundType") == 1; + streamSoundSampleCount = sis.readUI16("streamSoundSampleCount"); if (streamSoundCompression == 2) { - latencySeek = sis.readSI16(); + latencySeek = sis.readSI16("latencySeek"); } } diff --git a/src/com/jpexs/decompiler/flash/tags/StartSound2Tag.java b/src/com/jpexs/decompiler/flash/tags/StartSound2Tag.java index b87fab685..35d906387 100644 --- a/src/com/jpexs/decompiler/flash/tags/StartSound2Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/StartSound2Tag.java @@ -61,7 +61,7 @@ public class StartSound2Tag extends Tag { */ public StartSound2Tag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "StartSound2", pos, length); - soundClassName = sis.readString(); - soundInfo = sis.readSOUNDINFO(); + soundClassName = sis.readString("soundClassName"); + soundInfo = sis.readSOUNDINFO("soundInfo"); } } diff --git a/src/com/jpexs/decompiler/flash/tags/StartSoundTag.java b/src/com/jpexs/decompiler/flash/tags/StartSoundTag.java index 1ddb9c853..79e39c911 100644 --- a/src/com/jpexs/decompiler/flash/tags/StartSoundTag.java +++ b/src/com/jpexs/decompiler/flash/tags/StartSoundTag.java @@ -65,7 +65,7 @@ public class StartSoundTag extends Tag { */ public StartSoundTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "StartSound", pos, length); - soundId = sis.readUI16(); - soundInfo = sis.readSOUNDINFO(); + soundId = sis.readUI16("soundId"); + soundInfo = sis.readSOUNDINFO("soundInfo"); } } diff --git a/src/com/jpexs/decompiler/flash/tags/SymbolClassTag.java b/src/com/jpexs/decompiler/flash/tags/SymbolClassTag.java index ce87dc504..1ab6182d4 100644 --- a/src/com/jpexs/decompiler/flash/tags/SymbolClassTag.java +++ b/src/com/jpexs/decompiler/flash/tags/SymbolClassTag.java @@ -36,12 +36,12 @@ public class SymbolClassTag extends Tag { public SymbolClassTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "SymbolClass", pos, length); - int numSymbols = sis.readUI16(); + int numSymbols = sis.readUI16("numSymbols"); tags = new int[numSymbols]; names = new String[numSymbols]; for (int ii = 0; ii < numSymbols; ii++) { - int tagID = sis.readUI16(); - String className = sis.readString(); + int tagID = sis.readUI16("tagID"); + String className = sis.readString("className"); tags[ii] = tagID; names[ii] = className; } diff --git a/src/com/jpexs/decompiler/flash/tags/VideoFrameTag.java b/src/com/jpexs/decompiler/flash/tags/VideoFrameTag.java index ae7bd48ad..64fb697eb 100644 --- a/src/com/jpexs/decompiler/flash/tags/VideoFrameTag.java +++ b/src/com/jpexs/decompiler/flash/tags/VideoFrameTag.java @@ -67,8 +67,8 @@ public class VideoFrameTag extends Tag { */ public VideoFrameTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "VideoFrame", pos, length); - streamID = sis.readUI16(); - frameNum = sis.readUI16(); - videoData = sis.readBytesEx(sis.available()); //TODO: Parse video packets + streamID = sis.readUI16("streamID"); + frameNum = sis.readUI16("frameNum"); + videoData = sis.readBytesEx(sis.available(), "videoData"); //TODO: Parse video packets } } diff --git a/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java b/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java index 3f766f4c7..f29aa77cd 100644 --- a/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java +++ b/src/com/jpexs/decompiler/flash/tags/gfx/DefineCompactedFont.java @@ -91,7 +91,7 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag { public DefineCompactedFont(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineCompactedFont", pos, length); - fontId = sis.readUI16(); + fontId = sis.readUI16("fontId"); fonts = new ArrayList<>(); while (sis.available() > 0) { diff --git a/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalGradient.java b/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalGradient.java index 1f4d81405..e4fff2c83 100644 --- a/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalGradient.java +++ b/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalGradient.java @@ -71,10 +71,10 @@ public class DefineExternalGradient extends Tag { */ public DefineExternalGradient(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineExternalGradient", pos, length); - gradientId = sis.readUI16(); - bitmapsFormat = sis.readUI16(); - gradientSize = sis.readUI16(); - int fileNameLen = sis.readUI8(); - fileName = new String(sis.readBytesEx(fileNameLen)); + gradientId = sis.readUI16("gradientId"); + bitmapsFormat = sis.readUI16("bitmapsFormat"); + gradientSize = sis.readUI16("gradientSize"); + int fileNameLen = sis.readUI8("fileNameLen"); + fileName = new String(sis.readBytesEx(fileNameLen, "fileName")); } } diff --git a/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalImage.java b/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalImage.java index a79d940f8..4f898817b 100644 --- a/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalImage.java +++ b/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalImage.java @@ -73,12 +73,12 @@ public class DefineExternalImage extends Tag { */ public DefineExternalImage(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineExternalImage", pos, length); - characterId = sis.readUI16(); - bitmapFormat = sis.readUI16(); - targetWidth = sis.readUI16(); - targetHeight = sis.readUI16(); - int fileNameLen = sis.readUI8(); - fileName = new String(sis.readBytesEx(fileNameLen)); + characterId = sis.readUI16("characterId"); + bitmapFormat = sis.readUI16("bitmapFormat"); + targetWidth = sis.readUI16("targetWidth"); + targetHeight = sis.readUI16("targetHeight"); + int fileNameLen = sis.readUI8("fileNameLen"); + fileName = new String(sis.readBytesEx(fileNameLen, "fileName")); } } diff --git a/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalImage2.java b/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalImage2.java index 75f69ef60..233a5973e 100644 --- a/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalImage2.java +++ b/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalImage2.java @@ -81,16 +81,16 @@ public class DefineExternalImage2 extends Tag { */ public DefineExternalImage2(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineExternalImage2", pos, length); - characterId = sis.readUI32(); - bitmapFormat = sis.readUI16(); - targetWidth = sis.readUI16(); - targetHeight = sis.readUI16(); - int exportNameLen = sis.readUI8(); - exportName = new String(sis.readBytesEx(exportNameLen)); - int fileNameLen = sis.readUI8(); - fileName = new String(sis.readBytesEx(fileNameLen)); + characterId = sis.readUI32("characterId"); + bitmapFormat = sis.readUI16("bitmapFormat"); + targetWidth = sis.readUI16("targetWidth"); + targetHeight = sis.readUI16("targetHeight"); + int exportNameLen = sis.readUI8("exportNameLen"); + exportName = new String(sis.readBytesEx(exportNameLen, "exportName")); + int fileNameLen = sis.readUI8("fileNameLen"); + fileName = new String(sis.readBytesEx(fileNameLen, "fileName")); if (sis.available() > 0) { //there is usually one zero byte, bod knows why - extraData = sis.readBytesEx(sis.available()); + extraData = sis.readBytesEx(sis.available(), "extraData"); } } } diff --git a/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalSound.java b/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalSound.java index 0581ec9d0..0dfa7b8b2 100644 --- a/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalSound.java +++ b/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalSound.java @@ -81,17 +81,17 @@ public class DefineExternalSound extends Tag { */ public DefineExternalSound(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineExternalSound", pos, length); - characterId = sis.readUI16(); - soundFormat = sis.readUI16(); - bits = sis.readUI16(); - channels = sis.readUI16(); - sampleRate = sis.readUI32(); - sampleCount = sis.readUI32(); - seekSample = sis.readUI32(); - int exportNameLen = sis.readUI8(); - exportName = new String(sis.readBytesEx(exportNameLen)); - int fileNameLen = sis.readUI8(); - fileName = new String(sis.readBytesEx(fileNameLen)); + characterId = sis.readUI16("characterId"); + soundFormat = sis.readUI16("soundFormat"); + bits = sis.readUI16("bits"); + channels = sis.readUI16("channels"); + sampleRate = sis.readUI32("sampleRate"); + sampleCount = sis.readUI32("sampleCount"); + seekSample = sis.readUI32("seekSample"); + int exportNameLen = sis.readUI8("exportNameLen"); + exportName = new String(sis.readBytesEx(exportNameLen, "exportName")); + int fileNameLen = sis.readUI8("fileNameLen"); + fileName = new String(sis.readBytesEx(fileNameLen, "fileName")); } } diff --git a/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalStreamSound.java b/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalStreamSound.java index 516483434..5ee7dabfa 100644 --- a/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalStreamSound.java +++ b/src/com/jpexs/decompiler/flash/tags/gfx/DefineExternalStreamSound.java @@ -79,16 +79,16 @@ public class DefineExternalStreamSound extends Tag { */ public DefineExternalStreamSound(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineExternalStreamSound", pos, length); - soundFormat = sis.readUI16(); - bits = sis.readUI16(); - channels = sis.readUI16(); - sampleRate = sis.readUI32(); - sampleCount = sis.readUI32(); - seekSample = sis.readUI32(); - startFrame = sis.readUI32(); - lastFrame = sis.readUI32(); - int fileNameLen = sis.readUI8(); - fileName = new String(sis.readBytesEx(fileNameLen)); + soundFormat = sis.readUI16("soundFormat"); + bits = sis.readUI16("bits"); + channels = sis.readUI16("channels"); + sampleRate = sis.readUI32("sampleRate"); + sampleCount = sis.readUI32("sampleCount"); + seekSample = sis.readUI32("seekSample"); + startFrame = sis.readUI32("startFrame"); + lastFrame = sis.readUI32("lastFrame"); + int fileNameLen = sis.readUI8("fileNameLen"); + fileName = new String(sis.readBytesEx(fileNameLen, "fileName")); } } diff --git a/src/com/jpexs/decompiler/flash/tags/gfx/DefineGradientMap.java b/src/com/jpexs/decompiler/flash/tags/gfx/DefineGradientMap.java index 4b61458a8..34262c67e 100644 --- a/src/com/jpexs/decompiler/flash/tags/gfx/DefineGradientMap.java +++ b/src/com/jpexs/decompiler/flash/tags/gfx/DefineGradientMap.java @@ -63,10 +63,10 @@ public class DefineGradientMap extends Tag { */ public DefineGradientMap(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineGradientMap", pos, length); - int numGradients = sis.readUI16(); + int numGradients = sis.readUI16("numGradients"); indices = new int[numGradients]; for (int i = 0; i < numGradients; i++) { - indices[i] = sis.readUI16(); + indices[i] = sis.readUI16("index"); } } } diff --git a/src/com/jpexs/decompiler/flash/tags/gfx/DefineSubImage.java b/src/com/jpexs/decompiler/flash/tags/gfx/DefineSubImage.java index 37baa3ce3..c7c45ad71 100644 --- a/src/com/jpexs/decompiler/flash/tags/gfx/DefineSubImage.java +++ b/src/com/jpexs/decompiler/flash/tags/gfx/DefineSubImage.java @@ -70,11 +70,11 @@ public class DefineSubImage extends Tag { */ public DefineSubImage(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "DefineSubImage", pos, length); - characterId = sis.readUI16(); - imageCharacterId = sis.readUI16(); - x1 = sis.readUI16(); - y1 = sis.readUI16(); - x2 = sis.readUI16(); - y2 = sis.readUI16(); + characterId = sis.readUI16("characterId"); + imageCharacterId = sis.readUI16("imageCharacterId"); + x1 = sis.readUI16("x1"); + y1 = sis.readUI16("y1"); + x2 = sis.readUI16("x2"); + y2 = sis.readUI16("y2"); } } diff --git a/src/com/jpexs/decompiler/flash/tags/gfx/ExporterInfoTag.java b/src/com/jpexs/decompiler/flash/tags/gfx/ExporterInfoTag.java index 055b3709d..3f326e844 100644 --- a/src/com/jpexs/decompiler/flash/tags/gfx/ExporterInfoTag.java +++ b/src/com/jpexs/decompiler/flash/tags/gfx/ExporterInfoTag.java @@ -89,21 +89,21 @@ public class ExporterInfoTag extends Tag { */ public ExporterInfoTag(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "ExporterInfo", pos, length); - this.version = sis.readUI16(); + this.version = sis.readUI16("version"); if (this.version >= 0x10a) { - flags = sis.readUI32(); + flags = sis.readUI32("flags"); } - bitmapFormat = sis.readUI16(); - int prefixLen = sis.readUI8(); - prefix = sis.readBytesEx(prefixLen); - int swfNameLen = sis.readUI8(); - swfName = new String(sis.readBytesEx(swfNameLen)); + bitmapFormat = sis.readUI16("bitmapFormat"); + int prefixLen = sis.readUI8("prefixLen"); + prefix = sis.readBytesEx(prefixLen, "prefix"); + int swfNameLen = sis.readUI8("swfNameLen"); + swfName = new String(sis.readBytesEx(swfNameLen, "swfName")); if (sis.available() > 0) // (version >= 0x401) //? { codeOffsets = new ArrayList<>(); - int numCodeOffsets = sis.readUI16(); + int numCodeOffsets = sis.readUI16("numCodeOffsets"); for (int i = 0; i < numCodeOffsets; i++) { - codeOffsets.add(sis.readUI32()); + codeOffsets.add(sis.readUI32("codeOffset")); } } } diff --git a/src/com/jpexs/decompiler/flash/tags/gfx/FontTextureInfo.java b/src/com/jpexs/decompiler/flash/tags/gfx/FontTextureInfo.java index e8c7ee906..179272858 100644 --- a/src/com/jpexs/decompiler/flash/tags/gfx/FontTextureInfo.java +++ b/src/com/jpexs/decompiler/flash/tags/gfx/FontTextureInfo.java @@ -91,20 +91,20 @@ public class FontTextureInfo extends Tag { */ public FontTextureInfo(SWFInputStream sis, long pos, int length) throws IOException { super(sis.getSwf(), ID, "FontTextureInfo", pos, length); - textureID = sis.readUI32(); - textureFormat = sis.readUI16(); - int fileNameLen = sis.readUI8(); - fileName = new String(sis.readBytesEx(fileNameLen)); - textureWidth = sis.readUI16(); - textureHeight = sis.readUI16(); - padPixels = sis.readUI8(); - nominalGlyphSz = sis.readUI16(); - int numTexGlyphs = sis.readUI16(); + textureID = sis.readUI32("textureID"); + textureFormat = sis.readUI16("textureFormat"); + int fileNameLen = sis.readUI8("fileNameLen"); + fileName = new String(sis.readBytesEx(fileNameLen, "fileName")); + textureWidth = sis.readUI16("textureWidth"); + textureHeight = sis.readUI16("textureHeight"); + padPixels = sis.readUI8("padPixels"); + nominalGlyphSz = sis.readUI16("nominalGlyphSz"); + int numTexGlyphs = sis.readUI16("numTexGlyphs"); texGlyphs = new TEXGLYPH[numTexGlyphs]; for (int i = 0; i < numTexGlyphs; i++) { texGlyphs[i] = new TEXGLYPH(new GFxInputStream(sis.getBaseStream())); } - int numFonts = sis.readUI16(); + int numFonts = sis.readUI16("numFonts"); fonts = new FONTINFO[numFonts]; for (int i = 0; i < numFonts; i++) { fonts[i] = new FONTINFO(new GFxInputStream(sis.getBaseStream())); diff --git a/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java b/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java index 1e3988e89..828874bf0 100644 --- a/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java +++ b/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java @@ -63,22 +63,22 @@ public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem, S this.swf = swf; this.tag = tag; pos = containerOffset; - int condActionSize = sis.readUI16(); + int condActionSize = sis.readUI16("condActionSize"); isLast = condActionSize <= 0; - condIdleToOverDown = sis.readUB(1) == 1; - condOutDownToIdle = sis.readUB(1) == 1; - condOutDownToOverDown = sis.readUB(1) == 1; - condOverDownToOutDown = sis.readUB(1) == 1; - condOverDownToOverUp = sis.readUB(1) == 1; - condOverUpToOverDown = sis.readUB(1) == 1; - condOverUpToIddle = sis.readUB(1) == 1; - condIdleToOverUp = sis.readUB(1) == 1; - condKeyPress = (int) sis.readUB(7); - condOverDownToIddle = sis.readUB(1) == 1; + condIdleToOverDown = sis.readUB(1, "condIdleToOverDown") == 1; + condOutDownToIdle = sis.readUB(1, "condOutDownToIdle") == 1; + condOutDownToOverDown = sis.readUB(1, "condOutDownToOverDown") == 1; + condOverDownToOutDown = sis.readUB(1, "condOverDownToOutDown") == 1; + condOverDownToOverUp = sis.readUB(1, "condOverDownToOverUp") == 1; + condOverUpToOverDown = sis.readUB(1, "condOverUpToOverDown") == 1; + condOverUpToIddle = sis.readUB(1, "condOverUpToIddle") == 1; + condIdleToOverUp = sis.readUB(1, "condIdleToOverUp") == 1; + condKeyPress = (int) sis.readUB(7, "condKeyPress"); + condOverDownToIdle = sis.readUB(1, "condOverDownToIdle") == 1; if (condActionSize <= 0) { - actionBytes = sis.readBytesEx(sis.available()); + actionBytes = sis.readBytesEx(sis.available(), "actionBytes"); } else { - actionBytes = sis.readBytesEx(condActionSize - 4); + actionBytes = sis.readBytesEx(condActionSize - 4, "actionBytes"); } } /** @@ -127,7 +127,7 @@ public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem, S /** * OverDown to Idle */ - public boolean condOverDownToIddle; + public boolean condOverDownToIdle; /** * Actions to perform */ diff --git a/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java b/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java index 2ab1edefc..768594a69 100644 --- a/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java +++ b/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java @@ -108,17 +108,17 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem, S public CLIPACTIONRECORD(SWF swf, SWFInputStream sis, long pos, Tag tag) throws IOException { this.swf = swf; this.tag = tag; - eventFlags = sis.readCLIPEVENTFLAGS(); + eventFlags = sis.readCLIPEVENTFLAGS("eventFlags"); if (eventFlags.isClear()) { return; } - long actionRecordSize = sis.readUI32(); + long actionRecordSize = sis.readUI32("actionRecordSize"); if (eventFlags.clipEventKeyPress) { - keyCode = sis.readUI8(); + keyCode = sis.readUI8("keyCode"); actionRecordSize--; } hdrPos = sis.getPos(); - actionBytes = sis.readBytesEx(actionRecordSize); + actionBytes = sis.readBytesEx(actionRecordSize, "actionBytes"); this.pos = pos; } diff --git a/src/com/jpexs/decompiler/flash/types/sound/AdpcmDecoder.java b/src/com/jpexs/decompiler/flash/types/sound/AdpcmDecoder.java index 7fae1359c..0e0263a5e 100644 --- a/src/com/jpexs/decompiler/flash/types/sound/AdpcmDecoder.java +++ b/src/com/jpexs/decompiler/flash/types/sound/AdpcmDecoder.java @@ -205,15 +205,15 @@ public class AdpcmDecoder extends SoundDecoder { public void decode(SWFInputStream sis, OutputStream os) throws IOException { int adpcm_code_size; SWFOutputStream sos = new SWFOutputStream(os, SWF.DEFAULT_VERSION); - adpcm_code_size = (int) sis.readUB(2); + adpcm_code_size = (int) sis.readUB(2, "adpcm_code_size"); int bits_per_code = adpcm_code_size + 2; try { do { if (soundFormat.stereo) { - int initialSampleLeft = (int) sis.readSB(16); - int initialIndexLeft = (int) sis.readUB(6); - int initialSampleRight = (int) sis.readSB(16); - int initialIndexRight = (int) sis.readUB(6); + int initialSampleLeft = (int) sis.readSB(16, "initialSampleLeft"); + int initialIndexLeft = (int) sis.readUB(6, "initialIndexLeft"); + int initialSampleRight = (int) sis.readSB(16, "initialSampleRight"); + int initialIndexRight = (int) sis.readUB(6, "initialIndexRight"); AdpcmState stateLeft = new AdpcmState(); stateLeft.index = initialIndexLeft; stateLeft.sample = initialSampleLeft; @@ -221,8 +221,8 @@ public class AdpcmDecoder extends SoundDecoder { stateRight.index = initialIndexRight; stateRight.sample = initialSampleRight; for (int i = 1; (i <= 4095) && (sis.availableBits() >= bits_per_code * 2); i++) { - int codeLeft = (int) sis.readUB(bits_per_code); - int codeRight = (int) sis.readUB(bits_per_code); + int codeLeft = (int) sis.readUB(bits_per_code, "codeLeft"); + int codeRight = (int) sis.readUB(bits_per_code, "codeRight"); int valLeft = 0; int valRight = 0; switch (bits_per_code) { @@ -247,13 +247,13 @@ public class AdpcmDecoder extends SoundDecoder { sos.writeSI16(valRight); } } else { - int initialSample = (int) sis.readSB(16); - int initialIndex = (int) sis.readUB(6); + int initialSample = (int) sis.readSB(16, "initialSample"); + int initialIndex = (int) sis.readUB(6, "initialIndex"); AdpcmState state = new AdpcmState(); state.index = initialIndex; state.sample = initialSample; for (int i = 1; (i <= 4095) && (sis.availableBits() >= bits_per_code); i++) { - int code = (int) sis.readUB(bits_per_code); + int code = (int) sis.readUB(bits_per_code, "code"); int val = 0; switch (bits_per_code) { case 2: diff --git a/src/com/jpexs/decompiler/flash/types/sound/MP3Decoder.java b/src/com/jpexs/decompiler/flash/types/sound/MP3Decoder.java index b2bfeec3e..1c824dd1d 100644 --- a/src/com/jpexs/decompiler/flash/types/sound/MP3Decoder.java +++ b/src/com/jpexs/decompiler/flash/types/sound/MP3Decoder.java @@ -40,7 +40,7 @@ public class MP3Decoder extends SoundDecoder { @Override public void decode(SWFInputStream sis, OutputStream os) throws IOException { Decoder decoder = new Decoder(); - Bitstream bitstream = new Bitstream(new ByteArrayInputStream(sis.readBytesEx(sis.available()))); + Bitstream bitstream = new Bitstream(new ByteArrayInputStream(sis.readBytesEx(sis.available(), "soundStream"))); SampleBuffer buf; while ((buf = readFrame(decoder, bitstream)) != null) { short audio[] = buf.getBuffer(); diff --git a/src/com/jpexs/decompiler/flash/types/sound/MP3SOUNDDATA.java b/src/com/jpexs/decompiler/flash/types/sound/MP3SOUNDDATA.java index 89afd380e..38cffbbe8 100644 --- a/src/com/jpexs/decompiler/flash/types/sound/MP3SOUNDDATA.java +++ b/src/com/jpexs/decompiler/flash/types/sound/MP3SOUNDDATA.java @@ -35,12 +35,12 @@ public class MP3SOUNDDATA { public MP3SOUNDDATA(SWFInputStream sis, boolean raw) throws IOException { if (!raw) { - seekSamples = sis.readSI16(); + seekSamples = sis.readSI16("seekSamples"); } frames = new ArrayList<>(); MP3FRAME f; Decoder decoder = new Decoder(); - Bitstream bitstream = new Bitstream(new ByteArrayInputStream(sis.readBytesEx(sis.available()))); + Bitstream bitstream = new Bitstream(new ByteArrayInputStream(sis.readBytesEx(sis.available(), "soundStream"))); while ((f = MP3FRAME.readFrame(bitstream, decoder)) != null) { frames.add(f); } diff --git a/src/com/jpexs/decompiler/flash/types/sound/NellyMoserDecoder.java b/src/com/jpexs/decompiler/flash/types/sound/NellyMoserDecoder.java index a786cb905..3120f5521 100644 --- a/src/com/jpexs/decompiler/flash/types/sound/NellyMoserDecoder.java +++ b/src/com/jpexs/decompiler/flash/types/sound/NellyMoserDecoder.java @@ -44,7 +44,7 @@ public class NellyMoserDecoder extends SoundDecoder { int blockCount = sis.available() / NELLY_BLOCK_LEN; for (int j = 0; j < blockCount; j++) { - byte[] block = sis.readBytesEx(NELLY_BLOCK_LEN); + byte[] block = sis.readBytesEx(NELLY_BLOCK_LEN, "block"); CodecImpl.decode(state, block, audioD); short audio[] = new short[NELLY_SAMPLES]; for (int i = 0; i < audioD.length; i++) { diff --git a/src/com/jpexs/decompiler/flash/types/sound/NoDecoder.java b/src/com/jpexs/decompiler/flash/types/sound/NoDecoder.java index 048abf505..6695859a8 100644 --- a/src/com/jpexs/decompiler/flash/types/sound/NoDecoder.java +++ b/src/com/jpexs/decompiler/flash/types/sound/NoDecoder.java @@ -33,7 +33,7 @@ public class NoDecoder extends SoundDecoder { @Override public void decode(SWFInputStream sis, OutputStream os) throws IOException { - os.write(sis.readBytesEx(sis.available())); + os.write(sis.readBytesEx(sis.available(), "soundStream")); } } diff --git a/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index 06ef07967..d19f5ca68 100644 --- a/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -1440,7 +1440,7 @@ public class XFLConverter { exportFormat = "wav"; try { SWFInputStream sis = new SWFInputStream(swf, soundData); - int adpcmCodeSize = (int) sis.readUB(2); + int adpcmCodeSize = (int) sis.readUB(2, "adpcmCodeSize"); bits = 2 + adpcmCodeSize; } catch (IOException ex) { Logger.getLogger(XFLConverter.class.getName()).log(Level.SEVERE, null, ex);