Keep track of tag position in SWF file. Added code to dump tag infos.

(by Paolo Cancedda)
This commit is contained in:
Jindra Pet��k
2012-01-02 10:02:51 +01:00
parent 5107213517
commit a32835dd2f
42 changed files with 841 additions and 150 deletions
+2
View File
@@ -440,6 +440,8 @@ public class Main {
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
//updateLicenseInDir(new File("src/")); System.exit(0); //For automatic update of lincense in source files
View.setWinLookAndFeel(); View.setWinLookAndFeel();
loadReplacements(); loadReplacements();
if (args.length < 1) { if (args.length < 1) {
+5 -4
View File
@@ -135,20 +135,21 @@ public class SWF {
throw new IOException("Invalid SWF file"); throw new IOException("Invalid SWF file");
} }
version = is.read(); version = is.read();
SWFInputStream sis = new SWFInputStream(is, version); SWFInputStream sis = new SWFInputStream(is, version, 4);
fileSize = sis.readUI32(); fileSize = sis.readUI32();
if (hdr[0] == 'C') { if (hdr[0] == 'C') {
sis = new SWFInputStream(new InflaterInputStream(is), version); sis = new SWFInputStream(new InflaterInputStream(is), version, 8);
compressed = true; compressed = true;
} }
displayRect = sis.readRECT(); displayRect = sis.readRECT();
sis.readUI8(); // FIXED8 (16 bit fixed point) frameRate
int tmpFirstByetOfFrameRate = sis.readUI8();
frameRate = sis.readUI8(); frameRate = sis.readUI8();
frameCount = sis.readUI16(); frameCount = sis.readUI16();
tags = sis.readTagList(); tags = sis.readTagList(0);
} }
+246 -53
View File
@@ -17,33 +17,178 @@
package com.jpexs.asdec; package com.jpexs.asdec;
import com.jpexs.asdec.action.Action;
import com.jpexs.asdec.action.swf3.*;
import com.jpexs.asdec.action.swf4.*;
import com.jpexs.asdec.action.swf5.*;
import com.jpexs.asdec.action.swf6.*;
import com.jpexs.asdec.action.swf7.*;
import com.jpexs.asdec.tags.*;
import com.jpexs.asdec.types.*;
import com.jpexs.asdec.types.filters.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Stack; import java.util.Stack;
import com.jpexs.asdec.action.Action;
import com.jpexs.asdec.action.swf3.ActionGetURL;
import com.jpexs.asdec.action.swf3.ActionGoToLabel;
import com.jpexs.asdec.action.swf3.ActionGotoFrame;
import com.jpexs.asdec.action.swf3.ActionNextFrame;
import com.jpexs.asdec.action.swf3.ActionPlay;
import com.jpexs.asdec.action.swf3.ActionPrevFrame;
import com.jpexs.asdec.action.swf3.ActionSetTarget;
import com.jpexs.asdec.action.swf3.ActionStop;
import com.jpexs.asdec.action.swf3.ActionStopSounds;
import com.jpexs.asdec.action.swf3.ActionToggleQuality;
import com.jpexs.asdec.action.swf3.ActionWaitForFrame;
import com.jpexs.asdec.action.swf4.ActionAdd;
import com.jpexs.asdec.action.swf4.ActionAnd;
import com.jpexs.asdec.action.swf4.ActionAsciiToChar;
import com.jpexs.asdec.action.swf4.ActionCall;
import com.jpexs.asdec.action.swf4.ActionCharToAscii;
import com.jpexs.asdec.action.swf4.ActionCloneSprite;
import com.jpexs.asdec.action.swf4.ActionDivide;
import com.jpexs.asdec.action.swf4.ActionEndDrag;
import com.jpexs.asdec.action.swf4.ActionEquals;
import com.jpexs.asdec.action.swf4.ActionGetProperty;
import com.jpexs.asdec.action.swf4.ActionGetTime;
import com.jpexs.asdec.action.swf4.ActionGetURL2;
import com.jpexs.asdec.action.swf4.ActionGetVariable;
import com.jpexs.asdec.action.swf4.ActionGotoFrame2;
import com.jpexs.asdec.action.swf4.ActionIf;
import com.jpexs.asdec.action.swf4.ActionJump;
import com.jpexs.asdec.action.swf4.ActionLess;
import com.jpexs.asdec.action.swf4.ActionMBAsciiToChar;
import com.jpexs.asdec.action.swf4.ActionMBCharToAscii;
import com.jpexs.asdec.action.swf4.ActionMBStringExtract;
import com.jpexs.asdec.action.swf4.ActionMBStringLength;
import com.jpexs.asdec.action.swf4.ActionMultiply;
import com.jpexs.asdec.action.swf4.ActionNot;
import com.jpexs.asdec.action.swf4.ActionOr;
import com.jpexs.asdec.action.swf4.ActionPop;
import com.jpexs.asdec.action.swf4.ActionPush;
import com.jpexs.asdec.action.swf4.ActionRandomNumber;
import com.jpexs.asdec.action.swf4.ActionRemoveSprite;
import com.jpexs.asdec.action.swf4.ActionSetProperty;
import com.jpexs.asdec.action.swf4.ActionSetTarget2;
import com.jpexs.asdec.action.swf4.ActionSetVariable;
import com.jpexs.asdec.action.swf4.ActionStartDrag;
import com.jpexs.asdec.action.swf4.ActionStringAdd;
import com.jpexs.asdec.action.swf4.ActionStringEquals;
import com.jpexs.asdec.action.swf4.ActionStringExtract;
import com.jpexs.asdec.action.swf4.ActionStringLength;
import com.jpexs.asdec.action.swf4.ActionStringLess;
import com.jpexs.asdec.action.swf4.ActionSubtract;
import com.jpexs.asdec.action.swf4.ActionToInteger;
import com.jpexs.asdec.action.swf4.ActionTrace;
import com.jpexs.asdec.action.swf4.ActionWaitForFrame2;
import com.jpexs.asdec.action.swf5.ActionAdd2;
import com.jpexs.asdec.action.swf5.ActionBitAnd;
import com.jpexs.asdec.action.swf5.ActionBitLShift;
import com.jpexs.asdec.action.swf5.ActionBitOr;
import com.jpexs.asdec.action.swf5.ActionBitRShift;
import com.jpexs.asdec.action.swf5.ActionBitURShift;
import com.jpexs.asdec.action.swf5.ActionBitXor;
import com.jpexs.asdec.action.swf5.ActionCallFunction;
import com.jpexs.asdec.action.swf5.ActionCallMethod;
import com.jpexs.asdec.action.swf5.ActionConstantPool;
import com.jpexs.asdec.action.swf5.ActionDecrement;
import com.jpexs.asdec.action.swf5.ActionDefineFunction;
import com.jpexs.asdec.action.swf5.ActionDefineLocal;
import com.jpexs.asdec.action.swf5.ActionDefineLocal2;
import com.jpexs.asdec.action.swf5.ActionDelete;
import com.jpexs.asdec.action.swf5.ActionDelete2;
import com.jpexs.asdec.action.swf5.ActionEnumerate;
import com.jpexs.asdec.action.swf5.ActionEquals2;
import com.jpexs.asdec.action.swf5.ActionGetMember;
import com.jpexs.asdec.action.swf5.ActionIncrement;
import com.jpexs.asdec.action.swf5.ActionInitArray;
import com.jpexs.asdec.action.swf5.ActionInitObject;
import com.jpexs.asdec.action.swf5.ActionLess2;
import com.jpexs.asdec.action.swf5.ActionModulo;
import com.jpexs.asdec.action.swf5.ActionNewMethod;
import com.jpexs.asdec.action.swf5.ActionNewObject;
import com.jpexs.asdec.action.swf5.ActionPushDuplicate;
import com.jpexs.asdec.action.swf5.ActionReturn;
import com.jpexs.asdec.action.swf5.ActionSetMember;
import com.jpexs.asdec.action.swf5.ActionStackSwap;
import com.jpexs.asdec.action.swf5.ActionStoreRegister;
import com.jpexs.asdec.action.swf5.ActionTargetPath;
import com.jpexs.asdec.action.swf5.ActionToNumber;
import com.jpexs.asdec.action.swf5.ActionToString;
import com.jpexs.asdec.action.swf5.ActionTypeOf;
import com.jpexs.asdec.action.swf5.ActionWith;
import com.jpexs.asdec.action.swf6.ActionEnumerate2;
import com.jpexs.asdec.action.swf6.ActionGreater;
import com.jpexs.asdec.action.swf6.ActionInstanceOf;
import com.jpexs.asdec.action.swf6.ActionStrictEquals;
import com.jpexs.asdec.action.swf6.ActionStringGreater;
import com.jpexs.asdec.action.swf7.ActionCastOp;
import com.jpexs.asdec.action.swf7.ActionDefineFunction2;
import com.jpexs.asdec.action.swf7.ActionExtends;
import com.jpexs.asdec.action.swf7.ActionImplementsOp;
import com.jpexs.asdec.action.swf7.ActionThrow;
import com.jpexs.asdec.action.swf7.ActionTry;
import com.jpexs.asdec.helpers.Helper;
import com.jpexs.asdec.tags.DefineBinaryData;
import com.jpexs.asdec.tags.DefineBits;
import com.jpexs.asdec.tags.DefineBitsJPEG2;
import com.jpexs.asdec.tags.DefineBitsJPEG3;
import com.jpexs.asdec.tags.DefineBitsLossless;
import com.jpexs.asdec.tags.DefineBitsLossless2;
import com.jpexs.asdec.tags.DefineButton2Tag;
import com.jpexs.asdec.tags.DefineButtonTag;
import com.jpexs.asdec.tags.DefineFont3;
import com.jpexs.asdec.tags.DefineFont4;
import com.jpexs.asdec.tags.DefineFontAlignZones;
import com.jpexs.asdec.tags.DefineFontName;
import com.jpexs.asdec.tags.DefineScalingGrid;
import com.jpexs.asdec.tags.DefineShape;
import com.jpexs.asdec.tags.DefineShape2;
import com.jpexs.asdec.tags.DefineShape3;
import com.jpexs.asdec.tags.DefineShape4;
import com.jpexs.asdec.tags.DefineSpriteTag;
import com.jpexs.asdec.tags.DoABCTag;
import com.jpexs.asdec.tags.DoActionTag;
import com.jpexs.asdec.tags.DoInitActionTag;
import com.jpexs.asdec.tags.ExportAssetsTag;
import com.jpexs.asdec.tags.FileAttributes;
import com.jpexs.asdec.tags.FrameLabel;
import com.jpexs.asdec.tags.JPEGTables;
import com.jpexs.asdec.tags.Metadata;
import com.jpexs.asdec.tags.PlaceObject2Tag;
import com.jpexs.asdec.tags.PlaceObject3Tag;
import com.jpexs.asdec.tags.ProductInfo;
import com.jpexs.asdec.tags.RemoveObject2;
import com.jpexs.asdec.tags.ScriptLimits;
import com.jpexs.asdec.tags.SetBackgroundColor;
import com.jpexs.asdec.tags.ShowFrameTag;
import com.jpexs.asdec.tags.SymbolClass;
import com.jpexs.asdec.tags.Tag;
import com.jpexs.asdec.types.BUTTONCONDACTION;
import com.jpexs.asdec.types.BUTTONRECORD;
import com.jpexs.asdec.types.CLIPACTIONRECORD;
import com.jpexs.asdec.types.CLIPACTIONS;
import com.jpexs.asdec.types.CLIPEVENTFLAGS;
import com.jpexs.asdec.types.CXFORMWITHALPHA;
import com.jpexs.asdec.types.MATRIX;
import com.jpexs.asdec.types.RECT;
import com.jpexs.asdec.types.RGBA;
import com.jpexs.asdec.types.filters.BEVELFILTER;
import com.jpexs.asdec.types.filters.BLURFILTER;
import com.jpexs.asdec.types.filters.COLORMATRIXFILTER;
import com.jpexs.asdec.types.filters.CONVOLUTIONFILTER;
import com.jpexs.asdec.types.filters.DROPSHADOWFILTER;
import com.jpexs.asdec.types.filters.FILTER;
import com.jpexs.asdec.types.filters.GLOWFILTER;
import com.jpexs.asdec.types.filters.GRADIENTBEVELFILTER;
import com.jpexs.asdec.types.filters.GRADIENTGLOWFILTER;
/** /**
* Class for reading data from SWF file * Class for reading data from SWF file
* *
* @author JPEXS * @author JPEXS
*/ */
public class SWFInputStream extends InputStream { public class SWFInputStream extends InputStream {
private InputStream is; private InputStream is;
private Stack<Integer> margedPos = new Stack<Integer>(); private Stack<Integer> margedPos = new Stack<Integer>();
private long pos = 0; private long pos;
private int version; private int version;
/** /**
@@ -52,9 +197,20 @@ public class SWFInputStream extends InputStream {
* @param is Existing inputstream * @param is Existing inputstream
* @param version Version of SWF to read * @param version Version of SWF to read
*/ */
public SWFInputStream(InputStream is, int version) { public SWFInputStream(InputStream is, int version, long startingPos) {
this.version = version; this.version = version;
this.is = is; this.is = is;
pos = startingPos;
}
/**
* Constructor
*
* @param is Existing inputstream
* @param version Version of SWF to read
*/
public SWFInputStream(InputStream is, int version) {
this(is, version, 0L);
} }
/** /**
@@ -79,6 +235,14 @@ public class SWFInputStream extends InputStream {
return is.read(); return is.read();
} }
@Override
public int read(byte[] b, int off, int len) throws IOException {
int bytesRead = super.read(b, off, len);
bitPos = 0;
pos += bytesRead;
return bytesRead;
}
private void alignByte() { private void alignByte() {
bitPos = 0; bitPos = 0;
} }
@@ -395,17 +559,46 @@ public class SWFInputStream extends InputStream {
return ret; return ret;
} }
private static void dumpTag(PrintStream out, int version, Tag tag, int level) {
StringBuilder sb = new StringBuilder();
sb.append(Helper.formatHex((int)tag.getPos(), 8));
sb.append(": ");
sb.append(Helper.indent(level, ""));
sb.append(Helper.format(tag.toString(), 25 - 2*level));
sb.append(" tagId=");
sb.append(Helper.formatInt(tag.getId(), 3));
sb.append(" len=");
sb.append(Helper.formatInt((int)tag.getOrigDataLength(), 8));
sb.append(" ");
sb.append(Helper.bytesToHexString(64, tag.getData(version), 0));
out.println(sb.toString());
// out.println(Utils.formatHex((int)tag.getPos(), 8) + ": " + Utils.indent(level, "") + Utils.format(tag.toString(), 25 - 2*level) + " tagId="+tag.getId()+" len="+tag.getOrigDataLength()+": "+Utils.bytesToHexString(64, tag.getData(version), 0));
if (tag.hasSubTags()) {
for (Tag subTag: tag.getSubTags()) {
dumpTag(out, version, subTag, level + 1);
}
}
}
/** /**
* Reads list of tags from the stream. Reading ends with End tag(=0) or end of the stream. * Reads list of tags from the stream. Reading ends with End tag(=0) or end of the stream.
* *
* @return List of tags * @return List of tags
* @throws IOException * @throws IOException
*/ */
public List<Tag> readTagList() throws IOException { public List<Tag> readTagList(int level) throws IOException {
List<Tag> tags = new ArrayList<Tag>(); List<Tag> tags = new ArrayList<Tag>();
Tag tag; Tag tag;
while ((tag = readTag()) != null) { while (true) {
long pos = getPos();
tag = readTag(level, pos);
if (tag == null) {
break;
}
tags.add(tag); tags.add(tag);
if (Main.DUMP_TAGS && level == 0) {
dumpTag(System.out, version, tag, level);
}
} }
return tags; return tags;
} }
@@ -416,7 +609,7 @@ public class SWFInputStream extends InputStream {
* @return Tag or null when End tag * @return Tag or null when End tag
* @throws IOException * @throws IOException
*/ */
public Tag readTag() throws IOException { public Tag readTag(int level, long pos) throws IOException {
int tagIDTagLength = readUI16(); int tagIDTagLength = readUI16();
int tagID = (tagIDTagLength) >> 6; int tagID = (tagIDTagLength) >> 6;
if (tagID == 0) { if (tagID == 0) {
@@ -432,109 +625,109 @@ public class SWFInputStream extends InputStream {
Tag ret; Tag ret;
switch (tagID) { switch (tagID) {
case 82: case 82:
ret = new DoABCTag(data, version); ret = new DoABCTag(data, version, pos);
break; break;
case 12: case 12:
ret = new DoActionTag(data, version); ret = new DoActionTag(data, version, pos);
break; break;
case 59: case 59:
ret = new DoInitActionTag(data, version); ret = new DoInitActionTag(data, version, pos);
break; break;
case 39: case 39:
ret = new DefineSpriteTag(data, version); ret = new DefineSpriteTag(data, version, level, pos);
break; break;
case 1: case 1:
ret = new ShowFrameTag(); ret = new ShowFrameTag(pos);
break; break;
case 26: case 26:
ret = new PlaceObject2Tag(data, version); ret = new PlaceObject2Tag(data, version, pos);
break; break;
case 56: case 56:
ret = new ExportAssetsTag(data, version); ret = new ExportAssetsTag(data, version, pos);
break; break;
case 70: case 70:
ret = new PlaceObject3Tag(data, version); ret = new PlaceObject3Tag(data, version, pos);
break; break;
case 7: case 7:
ret = new DefineButtonTag(data, version); ret = new DefineButtonTag(data, version, pos);
break; break;
case 34: case 34:
ret = new DefineButton2Tag(data, version); ret = new DefineButton2Tag(data, version, pos);
break; break;
case 69: case 69:
ret = new FileAttributes(data); ret = new FileAttributes(data, version, pos);
break; break;
case 77: case 77:
ret = new Metadata(data); ret = new Metadata(data, pos);
break; break;
case 65: case 65:
ret = new ScriptLimits(data, version); ret = new ScriptLimits(data, version, pos);
break; break;
case 9: case 9:
ret = new SetBackgroundColor(data); ret = new SetBackgroundColor(data, pos);
break; break;
case 41: case 41:
ret = new ProductInfo(data, version); ret = new ProductInfo(data, version, pos);
break; break;
case 43: case 43:
ret = new FrameLabel(data, version); ret = new FrameLabel(data, version, pos);
break; break;
case 36: case 36:
ret = new DefineBitsLossless2(data, version); ret = new DefineBitsLossless2(data, version, pos);
break; break;
case 76: case 76:
ret = new SymbolClass(data, version); ret = new SymbolClass(data, version, pos);
break; break;
case 32: case 32:
ret = new DefineShape3(data, version); ret = new DefineShape3(data, version, pos);
break; break;
case 28: case 28:
ret = new RemoveObject2(data, version); ret = new RemoveObject2(data, version, pos);
break; break;
case 78: case 78:
ret = new DefineScalingGrid(data, version); ret = new DefineScalingGrid(data, version, pos);
break; break;
case 2: case 2:
ret = new DefineShape(data, version); ret = new DefineShape(data, version, pos);
break; break;
case 22: case 22:
ret = new DefineShape2(data, version); ret = new DefineShape2(data, version, pos);
break; break;
case 83: case 83:
ret = new DefineShape4(data, version); ret = new DefineShape4(data, version, pos);
break; break;
case 20: case 20:
ret = new DefineBitsLossless(data, version); ret = new DefineBitsLossless(data, version, pos);
break; break;
case 35: case 35:
ret = new DefineBitsJPEG3(data, version); ret = new DefineBitsJPEG3(data, version, pos);
break; break;
case 87: case 87:
ret = new DefineBinaryData(data, version); ret = new DefineBinaryData(data, version, pos);
break; break;
case 8: case 8:
ret = new JPEGTables(data); ret = new JPEGTables(data, pos);
break; break;
case 6: case 6:
ret = new DefineBits(data, version); ret = new DefineBits(data, version, pos);
break; break;
case 21: case 21:
ret = new DefineBitsJPEG2(data, version); ret = new DefineBitsJPEG2(data, version, pos);
break; break;
case 75: case 75:
ret = new DefineFont3(data, version); ret = new DefineFont3(data, version, pos);
break; break;
case 73: case 73:
ret = new DefineFontAlignZones(data, version); ret = new DefineFontAlignZones(data, version, pos);
break; break;
case 88: case 88:
ret = new DefineFontName(data, version); ret = new DefineFontName(data, version, pos);
break; break;
case 91: case 91:
ret = new DefineFont4(data, version); ret = new DefineFont4(data, version, pos);
break; break;
default: default:
ret = new Tag(tagID, data); ret = new Tag(tagID, data, pos);
} }
ret.forceWriteAsLong = readLong; ret.forceWriteAsLong = readLong;
return ret; return ret;
+28 -6
View File
@@ -17,16 +17,33 @@
package com.jpexs.asdec; package com.jpexs.asdec;
import com.jpexs.asdec.action.Action;
import com.jpexs.asdec.tags.Tag;
import com.jpexs.asdec.types.*;
import com.jpexs.asdec.types.filters.*;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.List; import java.util.List;
import com.jpexs.asdec.abc.NotSameException;
import com.jpexs.asdec.helpers.Helper;
import com.jpexs.asdec.tags.Tag;
import com.jpexs.asdec.types.BUTTONCONDACTION;
import com.jpexs.asdec.types.BUTTONRECORD;
import com.jpexs.asdec.types.CLIPACTIONRECORD;
import com.jpexs.asdec.types.CLIPACTIONS;
import com.jpexs.asdec.types.CLIPEVENTFLAGS;
import com.jpexs.asdec.types.CXFORMWITHALPHA;
import com.jpexs.asdec.types.MATRIX;
import com.jpexs.asdec.types.RECT;
import com.jpexs.asdec.types.RGBA;
import com.jpexs.asdec.types.filters.BEVELFILTER;
import com.jpexs.asdec.types.filters.BLURFILTER;
import com.jpexs.asdec.types.filters.COLORMATRIXFILTER;
import com.jpexs.asdec.types.filters.CONVOLUTIONFILTER;
import com.jpexs.asdec.types.filters.DROPSHADOWFILTER;
import com.jpexs.asdec.types.filters.FILTER;
import com.jpexs.asdec.types.filters.GLOWFILTER;
import com.jpexs.asdec.types.filters.GRADIENTBEVELFILTER;
import com.jpexs.asdec.types.filters.GRADIENTGLOWFILTER;
/** /**
* Class for writing data into SWF file * Class for writing data into SWF file
* *
@@ -342,7 +359,12 @@ public class SWFOutputStream extends OutputStream {
*/ */
public void writeTags(List<Tag> tags) throws IOException { public void writeTags(List<Tag> tags) throws IOException {
for (Tag tag : tags) { for (Tag tag : tags) {
writeTag(tag); //try {
writeTag(tag);
/*} catch (NotSameException nse) {
throw new RuntimeException("error in tag "+tag+" at pos "+Helper.formatHex((int)tag.getPos(), 8), nse);
}*/
//NotSameException must be processed in order to catch it elsewhere
} }
} }
@@ -1,9 +1,26 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
public class DefineBinaryData extends Tag { public class DefineBinaryData extends Tag {
public DefineBinaryData(byte[] data, int version) { public DefineBinaryData(byte[] data, int version, long pos) {
super(87, data); super(87, data, pos);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
+19 -2
View File
@@ -1,9 +1,26 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
public class DefineBits extends Tag { public class DefineBits extends Tag {
public DefineBits(byte[] data, int version) { public DefineBits(byte[] data, int version, long pos) {
super(6, data); super(6, data, pos);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
@@ -1,9 +1,26 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
public class DefineBitsJPEG2 extends Tag { public class DefineBitsJPEG2 extends Tag {
public DefineBitsJPEG2(byte[] data, int version) { public DefineBitsJPEG2(byte[] data, int version, long pos) {
super(21, data); super(21, data, pos);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
@@ -1,9 +1,26 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
public class DefineBitsJPEG3 extends Tag { public class DefineBitsJPEG3 extends Tag {
public DefineBitsJPEG3(byte[] data, int version) { public DefineBitsJPEG3(byte[] data, int version, long pos) {
super(35, data); super(35, data, pos);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
@@ -1,9 +1,26 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
public class DefineBitsLossless extends Tag { public class DefineBitsLossless extends Tag {
public DefineBitsLossless(byte[] data, int version) { public DefineBitsLossless(byte[] data, int version, long pos) {
super(20, data); super(20, data, pos);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
@@ -1,11 +1,28 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
import java.io.IOException; import java.io.IOException;
public class DefineBitsLossless2 extends Tag { public class DefineBitsLossless2 extends Tag {
public DefineBitsLossless2(byte[] data, int version) throws IOException { public DefineBitsLossless2(byte[] data, int version, long pos) throws IOException {
super(36, data); super(36, data, pos);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
@@ -66,8 +66,8 @@ public class DefineButton2Tag extends Tag implements Container {
* @param version SWF version * @param version SWF version
* @throws IOException * @throws IOException
*/ */
public DefineButton2Tag(byte data[], int version) throws IOException { public DefineButton2Tag(byte data[], int version, long pos) throws IOException {
super(34, data); super(34, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
buttonId = sis.readUI16(); buttonId = sis.readUI16();
sis.readUB(7); //reserved sis.readUB(7); //reserved
@@ -138,7 +138,7 @@ public class DefineButton2Tag extends Tag implements Container {
sos.writeBUTTONCONDACTIONList(actions); sos.writeBUTTONCONDACTIONList(actions);
sos.close(); sos.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace();
} }
return baos.toByteArray(); return baos.toByteArray();
} }
@@ -64,8 +64,8 @@ public class DefineButtonTag extends Tag implements ASMSource {
* @param version SWF version * @param version SWF version
* @throws IOException * @throws IOException
*/ */
public DefineButtonTag(byte[] data, int version) throws IOException { public DefineButtonTag(byte[] data, int version, long pos) throws IOException {
super(7, data); super(7, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
buttonId = sis.readUI16(); buttonId = sis.readUI16();
characters = sis.readBUTTONRECORDList(false); characters = sis.readBUTTONRECORDList(false);
@@ -127,7 +127,7 @@ public class DefineButtonTag extends Tag implements ASMSource {
try { try {
actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList(); actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace();
} }
return Action.actionsToString(actions, null, version); return Action.actionsToString(actions, null, version);
} }
@@ -1,9 +1,26 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
public class DefineFont3 extends Tag { public class DefineFont3 extends Tag {
public DefineFont3(byte[] data, int version) { public DefineFont3(byte[] data, int version, long pos) {
super(75, data); super(75, data, pos);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
@@ -1,9 +1,26 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
public class DefineFont4 extends Tag { public class DefineFont4 extends Tag {
public DefineFont4(byte[] data, int version) { public DefineFont4(byte[] data, int version, long pos) {
super(91, data); super(91, data, pos);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
@@ -1,9 +1,26 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
public class DefineFontAlignZones extends Tag { public class DefineFontAlignZones extends Tag {
public DefineFontAlignZones(byte[] data, int version) { public DefineFontAlignZones(byte[] data, int version, long pos) {
super(73, data); super(73, data, pos);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
@@ -1,3 +1,20 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@@ -11,8 +28,8 @@ public class DefineFontName extends Tag {
private String fontName; private String fontName;
private String fontCopyright; private String fontCopyright;
public DefineFontName(byte[] data, int version) throws IOException { public DefineFontName(byte[] data, int version, long pos) throws IOException {
super(88, data); super(88, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
fontId = sis.readUI16(); fontId = sis.readUI16();
fontName = sis.readString(); fontName = sis.readString();
@@ -1,3 +1,20 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@@ -11,8 +28,8 @@ public class DefineScalingGrid extends Tag {
private int characterId; private int characterId;
private RECT splitter; private RECT splitter;
public DefineScalingGrid(byte[] data, int version) throws IOException { public DefineScalingGrid(byte[] data, int version, long pos) throws IOException {
super(78, data); super(78, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
characterId = sis.readUI16(); characterId = sis.readUI16();
splitter = sis.readRECT(); splitter = sis.readRECT();
@@ -1,11 +1,28 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
import java.io.IOException; import java.io.IOException;
public class DefineShape extends Tag { public class DefineShape extends Tag {
public DefineShape(byte[] data, int version) throws IOException { public DefineShape(byte[] data, int version, long pos) throws IOException {
super(2, data); super(2, data, pos);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
@@ -1,11 +1,28 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
import java.io.IOException; import java.io.IOException;
public class DefineShape2 extends Tag { public class DefineShape2 extends Tag {
public DefineShape2(byte[] data, int version) throws IOException { public DefineShape2(byte[] data, int version, long pos) throws IOException {
super(22, data); super(22, data, pos);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
@@ -1,11 +1,28 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
import java.io.IOException; import java.io.IOException;
public class DefineShape3 extends Tag { public class DefineShape3 extends Tag {
public DefineShape3(byte[] data, int version) throws IOException { public DefineShape3(byte[] data, int version, long pos) throws IOException {
super(32, data); super(32, data, pos);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
@@ -1,9 +1,26 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
public class DefineShape4 extends Tag { public class DefineShape4 extends Tag {
public DefineShape4(byte[] data, int version) { public DefineShape4(byte[] data, int version, long pos) {
super(83, data); super(83, data, pos);
} }
@Override @Override
@@ -51,6 +51,8 @@ public class DefineSpriteTag extends Tag implements Container {
*/ */
public List<ExportAssetsTag> exportAssetsTags = new ArrayList<ExportAssetsTag>(); public List<ExportAssetsTag> exportAssetsTags = new ArrayList<ExportAssetsTag>();
private int level;
/** /**
* Constructor * Constructor
* *
@@ -58,12 +60,12 @@ public class DefineSpriteTag extends Tag implements Container {
* @param version SWF version * @param version SWF version
* @throws IOException * @throws IOException
*/ */
public DefineSpriteTag(byte[] data, int version) throws IOException { public DefineSpriteTag(byte[] data, int version, int level, long pos) throws IOException {
super(39, data); super(39, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version, pos);
spriteId = sis.readUI16(); spriteId = sis.readUI16();
frameCount = sis.readUI16(); frameCount = sis.readUI16();
subTags = sis.readTagList(); subTags = sis.readTagList(level + 1);
} }
@@ -130,4 +132,14 @@ public class DefineSpriteTag extends Tag implements Container {
public int getItemCount() { public int getItemCount() {
return subTags.size(); return subTags.size();
} }
@Override
public boolean hasSubTags() {
return true;
}
@Override
public List<Tag> getSubTags() {
return subTags;
}
} }
+2 -2
View File
@@ -66,8 +66,8 @@ public class DoABCTag extends Tag {
* @param version SWF version * @param version SWF version
* @throws IOException * @throws IOException
*/ */
public DoABCTag(byte[] data, int version) throws IOException { public DoABCTag(byte[] data, int version, long pos) throws IOException {
super(82, data); super(82, data, pos);
InputStream is = new ByteArrayInputStream(data); InputStream is = new ByteArrayInputStream(data);
SWFInputStream sis = new SWFInputStream(is, version); SWFInputStream sis = new SWFInputStream(is, version);
flags = sis.readUI32(); flags = sis.readUI32();
@@ -45,15 +45,15 @@ public class DoActionTag extends Tag implements ASMSource {
* @param version SWF version * @param version SWF version
* @throws IOException * @throws IOException
*/ */
public DoActionTag(byte[] data, int version) { public DoActionTag(byte[] data, int version, long pos) {
super(12, data); super(12, data, pos);
try { try {
ByteArrayInputStream bais = new ByteArrayInputStream(data); ByteArrayInputStream bais = new ByteArrayInputStream(data);
SWFInputStream sis = new SWFInputStream(bais, version); SWFInputStream sis = new SWFInputStream(bais, version);
//actions = sis.readActionList(); //actions = sis.readActionList();
actionBytes=sis.readBytes(sis.available()); actionBytes=sis.readBytes(sis.available());
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace();
} }
} }
@@ -79,7 +79,7 @@ public class DoActionTag extends Tag implements ASMSource {
try { try {
actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList(); actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace();
} }
return Action.actionsToString(actions, null, version); return Action.actionsToString(actions, null, version);
} }
@@ -108,6 +108,7 @@ public class DoActionTag extends Tag implements ASMSource {
try { try {
return (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList(); return (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace();
return new ArrayList<Action>(); return new ArrayList<Action>();
} }
} }
@@ -50,8 +50,8 @@ public class DoInitActionTag extends Tag implements ASMSource {
* @param version SWF version * @param version SWF version
* @throws IOException * @throws IOException
*/ */
public DoInitActionTag(byte[] data, int version) throws IOException { public DoInitActionTag(byte[] data, int version, long pos) throws IOException {
super(59, data); super(59, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
spriteId = sis.readUI16(); spriteId = sis.readUI16();
//actions = sis.readActionList(); //actions = sis.readActionList();
@@ -116,7 +116,7 @@ public class DoInitActionTag extends Tag implements ASMSource {
try { try {
actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList(); actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace();
} }
return Action.actionsToString(actions, null, version); return Action.actionsToString(actions, null, version);
} }
@@ -125,6 +125,7 @@ public class DoInitActionTag extends Tag implements ASMSource {
try { try {
return (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList(); return (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace();
return new ArrayList<Action>(); return new ArrayList<Action>();
} }
} }
@@ -41,8 +41,8 @@ public class ExportAssetsTag extends Tag {
* @param version SWF version * @param version SWF version
* @throws IOException * @throws IOException
*/ */
public ExportAssetsTag(byte[] data, int version) throws IOException { public ExportAssetsTag(byte[] data, int version, long pos) throws IOException {
super(56, data); super(56, data, pos);
assets = new HashMap<Integer, String>(); assets = new HashMap<Integer, String>();
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
int count = sis.readUI16(); int count = sis.readUI16();
@@ -1,5 +1,27 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import com.jpexs.asdec.SWFInputStream;
public class FileAttributes extends Tag { public class FileAttributes extends Tag {
private boolean useDirectBlit; private boolean useDirectBlit;
@@ -8,15 +30,17 @@ public class FileAttributes extends Tag {
private boolean actionScript3; private boolean actionScript3;
private boolean useNetwork; private boolean useNetwork;
public FileAttributes(byte[] data) { public FileAttributes(byte[] data, int version, long pos) throws IOException {
super(69, data); super(69, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
sis.readUB(1); // reserved
// UB[1] == 0 (reserved) // UB[1] == 0 (reserved)
useDirectBlit = (data[0] & 0x40) != 0; useDirectBlit = sis.readUB(1) != 0;
useGPU = (data[0] & 0x20) != 0; useGPU = sis.readUB(1) != 0;
hasMetadata = (data[0] & 0x10) != 0; hasMetadata = sis.readUB(1) != 0;
actionScript3 = (data[0] & 0x08) != 0; actionScript3 = sis.readUB(1) != 0;
// UB[2] == 0 (reserved) sis.readUB(2); // reserved
useNetwork = (data[0] & 0x01) != 0; useNetwork = sis.readUB(1) != 0;
// UB[24] == 0 (reserved) // UB[24] == 0 (reserved)
} }
+19 -2
View File
@@ -1,3 +1,20 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@@ -9,8 +26,8 @@ public class FrameLabel extends Tag {
private String name; private String name;
public FrameLabel(byte[] data, int version) throws IOException { public FrameLabel(byte[] data, int version, long pos) throws IOException {
super(43, data); super(43, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
name = sis.readString(); name = sis.readString();
} }
+19 -2
View File
@@ -1,11 +1,28 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
import java.io.IOException; import java.io.IOException;
public class JPEGTables extends Tag { public class JPEGTables extends Tag {
public JPEGTables(byte[] data) throws IOException { public JPEGTables(byte[] data, long pos) throws IOException {
super(8, data); super(8, data, pos);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
+19 -2
View File
@@ -1,3 +1,20 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
@@ -6,8 +23,8 @@ public class Metadata extends Tag {
private String xmlMetadata; private String xmlMetadata;
public Metadata(byte[] data) { public Metadata(byte[] data, long pos) {
super(77, data); super(77, data, pos);
try { try {
xmlMetadata = new String(data, "UTF-8"); xmlMetadata = new String(data, "UTF-8");
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
@@ -166,8 +166,8 @@ public class PlaceObject2Tag extends Tag implements Container {
* @param version SWF version * @param version SWF version
* @throws IOException * @throws IOException
*/ */
public PlaceObject2Tag(byte data[], int version) throws IOException { public PlaceObject2Tag(byte data[], int version, long pos) throws IOException {
super(26, data); super(26, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
placeFlagHasClipActions = sis.readUB(1) == 1; placeFlagHasClipActions = sis.readUB(1) == 1;
placeFlagHasClipDepth = sis.readUB(1) == 1; placeFlagHasClipDepth = sis.readUB(1) == 1;
@@ -150,6 +150,8 @@ public class PlaceObject3Tag extends Tag implements Container {
* If PlaceFlagHasClipActions, Clip Actions Data * If PlaceFlagHasClipActions, Clip Actions Data
*/ */
public CLIPACTIONS clipActions; public CLIPACTIONS clipActions;
// FIXME bug found in ecoDrive.swf,
private boolean bitmapCacheBug;
/** /**
@@ -211,7 +213,9 @@ public class PlaceObject3Tag extends Tag implements Container {
sos.writeUI8(blendMode); sos.writeUI8(blendMode);
} }
if (placeFlagHasCacheAsBitmap) { if (placeFlagHasCacheAsBitmap) {
sos.writeUI8(bitmapCache); if (!bitmapCacheBug) {
sos.writeUI8(bitmapCache);
}
} }
if (placeFlagHasClipActions) { if (placeFlagHasClipActions) {
sos.writeCLIPACTIONS(clipActions); sos.writeCLIPACTIONS(clipActions);
@@ -230,8 +234,8 @@ public class PlaceObject3Tag extends Tag implements Container {
* @param version SWF version * @param version SWF version
* @throws IOException * @throws IOException
*/ */
public PlaceObject3Tag(byte data[], int version) throws IOException { public PlaceObject3Tag(byte data[], int version, long pos) throws IOException {
super(70, data); super(70, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
placeFlagHasClipActions = sis.readUB(1) == 1; placeFlagHasClipActions = sis.readUB(1) == 1;
placeFlagHasClipDepth = sis.readUB(1) == 1; placeFlagHasClipDepth = sis.readUB(1) == 1;
@@ -276,8 +280,14 @@ public class PlaceObject3Tag extends Tag implements Container {
if (placeFlagHasBlendMode) { if (placeFlagHasBlendMode) {
blendMode = sis.readUI8(); blendMode = sis.readUI8();
} }
bitmapCacheBug = false;
if (placeFlagHasCacheAsBitmap) { if (placeFlagHasCacheAsBitmap) {
bitmapCache = sis.readUI8(); bitmapCache = sis.readUI8();
if (bitmapCache == -1) {
// EOF
bitmapCacheBug = true;
bitmapCache = 1;
}
} }
if (placeFlagHasClipActions) { if (placeFlagHasClipActions) {
clipActions = sis.readCLIPACTIONS(); clipActions = sis.readCLIPACTIONS();
@@ -1,3 +1,20 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@@ -15,8 +32,8 @@ public class ProductInfo extends Tag {
private long buildHigh; private long buildHigh;
private long compilationDate; private long compilationDate;
public ProductInfo(byte[] data, int version) throws IOException { public ProductInfo(byte[] data, int version, long pos) throws IOException {
super(41, data); super(41, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
/* /*
* 0: Unknown * 0: Unknown
@@ -1,3 +1,20 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@@ -9,10 +26,9 @@ public class RemoveObject2 extends Tag {
private int depth; private int depth;
public RemoveObject2(byte[] data, int version) throws IOException { public RemoveObject2(byte[] data, int version, long pos) throws IOException {
super(28, data); super(28, data, pos);
ByteArrayInputStream bais = new ByteArrayInputStream(data); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
SWFInputStream sis = new SWFInputStream(bais, version);
depth = sis.readUI16(); depth = sis.readUI16();
} }
@@ -1,3 +1,20 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@@ -10,8 +27,8 @@ public class ScriptLimits extends Tag {
private int maxRecursionDepth; private int maxRecursionDepth;
private int scriptTimeoutSeconds; private int scriptTimeoutSeconds;
public ScriptLimits(byte[] data, int version) throws IOException { public ScriptLimits(byte[] data, int version, long pos) throws IOException {
super(65, data); super(65, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
maxRecursionDepth = sis.readUI16(); maxRecursionDepth = sis.readUI16();
scriptTimeoutSeconds = sis.readUI16(); scriptTimeoutSeconds = sis.readUI16();
@@ -1,3 +1,20 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
import com.jpexs.asdec.types.RGB; import com.jpexs.asdec.types.RGB;
@@ -6,8 +23,8 @@ public class SetBackgroundColor extends Tag {
private RGB backgroundColor; private RGB backgroundColor;
public SetBackgroundColor(byte[] data) { public SetBackgroundColor(byte[] data, long pos) {
super(9, data); super(9, data, pos);
backgroundColor = new RGB(); backgroundColor = new RGB();
backgroundColor.red = data[0] & 0xff; backgroundColor.red = data[0] & 0xff;
backgroundColor.green = data[1] & 0xff; backgroundColor.green = data[1] & 0xff;
@@ -26,8 +26,8 @@ public class ShowFrameTag extends Tag {
/** /**
* Constructor * Constructor
*/ */
public ShowFrameTag() { public ShowFrameTag(long pos) {
super(1, new byte[0]); super(1, new byte[0], pos);
} }
/** /**
@@ -1,3 +1,20 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@@ -9,8 +26,8 @@ public class SymbolClass extends Tag {
private int tagIDs[]; private int tagIDs[];
private String classNames[]; private String classNames[];
public SymbolClass(byte[] data, int version) throws IOException { public SymbolClass(byte[] data, int version, long pos) throws IOException {
super(76, data); super(76, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
int numSymbols = sis.readUI16(); int numSymbols = sis.readUI16();
tagIDs = new int[numSymbols]; tagIDs = new int[numSymbols];
+17 -1
View File
@@ -17,6 +17,8 @@
package com.jpexs.asdec.tags; package com.jpexs.asdec.tags;
import java.util.List;
/** /**
* Represents Tag inside SWF file * Represents Tag inside SWF file
*/ */
@@ -35,6 +37,8 @@ public class Tag {
*/ */
public boolean forceWriteAsLong = false; public boolean forceWriteAsLong = false;
private final long pos;
/** /**
* Returns identifier of tag type * Returns identifier of tag type
* *
@@ -50,9 +54,10 @@ public class Tag {
* @param id Tag type identifier * @param id Tag type identifier
* @param data Bytes of data * @param data Bytes of data
*/ */
public Tag(int id, byte[] data) { public Tag(int id, byte[] data, long pos) {
this.id = id; this.id = id;
this.data = data; this.data = data;
this.pos = pos;
} }
/** /**
@@ -79,4 +84,15 @@ public class Tag {
return data.length; return data.length;
} }
public boolean hasSubTags() {
return false;
}
public List<Tag> getSubTags() {
return null;
}
public long getPos() {
return pos;
}
} }
@@ -117,7 +117,7 @@ public class BUTTONCONDACTION implements ASMSource {
try { try {
actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList(); actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace();
} }
return Action.actionsToString(actions, null, version); return Action.actionsToString(actions, null, version);
} }
@@ -140,6 +140,7 @@ public class BUTTONCONDACTION implements ASMSource {
try { try {
return (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList(); return (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace();
return new ArrayList<Action>(); return new ArrayList<Action>();
} }
} }
@@ -82,7 +82,7 @@ public class CLIPACTIONRECORD implements ASMSource {
try { try {
actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList(); actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace();
} }
return Action.actionsToString(actions, null, version); return Action.actionsToString(actions, null, version);
} }
@@ -101,6 +101,7 @@ public class CLIPACTIONRECORD implements ASMSource {
try { try {
return (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList(); return (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace();
return new ArrayList<Action>(); return new ArrayList<Action>();
} }
} }
+17
View File
@@ -1,3 +1,20 @@
/*
* Copyright (C) 2010-2011 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.asdec.types; package com.jpexs.asdec.types;
/** /**