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

(by Paolo Cancedda)
This commit is contained in:
Jindra Petk
2012-01-02 10:02:51 +01:00
parent 5107213517
commit a32835dd2f
42 changed files with 841 additions and 150 deletions

View File

@@ -440,6 +440,8 @@ public class Main {
* @param args the command line arguments
*/
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();
loadReplacements();
if (args.length < 1) {

View File

@@ -135,20 +135,21 @@ public class SWF {
throw new IOException("Invalid SWF file");
}
version = is.read();
SWFInputStream sis = new SWFInputStream(is, version);
SWFInputStream sis = new SWFInputStream(is, version, 4);
fileSize = sis.readUI32();
if (hdr[0] == 'C') {
sis = new SWFInputStream(new InflaterInputStream(is), version);
sis = new SWFInputStream(new InflaterInputStream(is), version, 8);
compressed = true;
}
displayRect = sis.readRECT();
sis.readUI8();
// FIXED8 (16 bit fixed point) frameRate
int tmpFirstByetOfFrameRate = sis.readUI8();
frameRate = sis.readUI8();
frameCount = sis.readUI16();
tags = sis.readTagList();
tags = sis.readTagList(0);
}

View File

@@ -17,33 +17,178 @@
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.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
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
*
* @author JPEXS
*/
public class SWFInputStream extends InputStream {
private InputStream is;
private InputStream is;
private Stack<Integer> margedPos = new Stack<Integer>();
private long pos = 0;
private long pos;
private int version;
/**
@@ -52,9 +197,20 @@ public class SWFInputStream extends InputStream {
* @param is Existing inputstream
* @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.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();
}
@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() {
bitPos = 0;
}
@@ -395,17 +559,46 @@ public class SWFInputStream extends InputStream {
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.
*
* @return List of tags
* @throws IOException
*/
public List<Tag> readTagList() throws IOException {
public List<Tag> readTagList(int level) throws IOException {
List<Tag> tags = new ArrayList<Tag>();
Tag tag;
while ((tag = readTag()) != null) {
while (true) {
long pos = getPos();
tag = readTag(level, pos);
if (tag == null) {
break;
}
tags.add(tag);
if (Main.DUMP_TAGS && level == 0) {
dumpTag(System.out, version, tag, level);
}
}
return tags;
}
@@ -416,7 +609,7 @@ public class SWFInputStream extends InputStream {
* @return Tag or null when End tag
* @throws IOException
*/
public Tag readTag() throws IOException {
public Tag readTag(int level, long pos) throws IOException {
int tagIDTagLength = readUI16();
int tagID = (tagIDTagLength) >> 6;
if (tagID == 0) {
@@ -432,109 +625,109 @@ public class SWFInputStream extends InputStream {
Tag ret;
switch (tagID) {
case 82:
ret = new DoABCTag(data, version);
ret = new DoABCTag(data, version, pos);
break;
case 12:
ret = new DoActionTag(data, version);
ret = new DoActionTag(data, version, pos);
break;
case 59:
ret = new DoInitActionTag(data, version);
ret = new DoInitActionTag(data, version, pos);
break;
case 39:
ret = new DefineSpriteTag(data, version);
ret = new DefineSpriteTag(data, version, level, pos);
break;
case 1:
ret = new ShowFrameTag();
ret = new ShowFrameTag(pos);
break;
case 26:
ret = new PlaceObject2Tag(data, version);
ret = new PlaceObject2Tag(data, version, pos);
break;
case 56:
ret = new ExportAssetsTag(data, version);
ret = new ExportAssetsTag(data, version, pos);
break;
case 70:
ret = new PlaceObject3Tag(data, version);
ret = new PlaceObject3Tag(data, version, pos);
break;
case 7:
ret = new DefineButtonTag(data, version);
ret = new DefineButtonTag(data, version, pos);
break;
case 34:
ret = new DefineButton2Tag(data, version);
ret = new DefineButton2Tag(data, version, pos);
break;
case 69:
ret = new FileAttributes(data);
ret = new FileAttributes(data, version, pos);
break;
case 77:
ret = new Metadata(data);
ret = new Metadata(data, pos);
break;
case 65:
ret = new ScriptLimits(data, version);
ret = new ScriptLimits(data, version, pos);
break;
case 9:
ret = new SetBackgroundColor(data);
ret = new SetBackgroundColor(data, pos);
break;
case 41:
ret = new ProductInfo(data, version);
ret = new ProductInfo(data, version, pos);
break;
case 43:
ret = new FrameLabel(data, version);
ret = new FrameLabel(data, version, pos);
break;
case 36:
ret = new DefineBitsLossless2(data, version);
ret = new DefineBitsLossless2(data, version, pos);
break;
case 76:
ret = new SymbolClass(data, version);
ret = new SymbolClass(data, version, pos);
break;
case 32:
ret = new DefineShape3(data, version);
ret = new DefineShape3(data, version, pos);
break;
case 28:
ret = new RemoveObject2(data, version);
ret = new RemoveObject2(data, version, pos);
break;
case 78:
ret = new DefineScalingGrid(data, version);
ret = new DefineScalingGrid(data, version, pos);
break;
case 2:
ret = new DefineShape(data, version);
ret = new DefineShape(data, version, pos);
break;
case 22:
ret = new DefineShape2(data, version);
ret = new DefineShape2(data, version, pos);
break;
case 83:
ret = new DefineShape4(data, version);
ret = new DefineShape4(data, version, pos);
break;
case 20:
ret = new DefineBitsLossless(data, version);
ret = new DefineBitsLossless(data, version, pos);
break;
case 35:
ret = new DefineBitsJPEG3(data, version);
ret = new DefineBitsJPEG3(data, version, pos);
break;
case 87:
ret = new DefineBinaryData(data, version);
ret = new DefineBinaryData(data, version, pos);
break;
case 8:
ret = new JPEGTables(data);
ret = new JPEGTables(data, pos);
break;
case 6:
ret = new DefineBits(data, version);
ret = new DefineBits(data, version, pos);
break;
case 21:
ret = new DefineBitsJPEG2(data, version);
ret = new DefineBitsJPEG2(data, version, pos);
break;
case 75:
ret = new DefineFont3(data, version);
ret = new DefineFont3(data, version, pos);
break;
case 73:
ret = new DefineFontAlignZones(data, version);
ret = new DefineFontAlignZones(data, version, pos);
break;
case 88:
ret = new DefineFontName(data, version);
break;
ret = new DefineFontName(data, version, pos);
break;
case 91:
ret = new DefineFont4(data, version);
ret = new DefineFont4(data, version, pos);
break;
default:
ret = new Tag(tagID, data);
ret = new Tag(tagID, data, pos);
}
ret.forceWriteAsLong = readLong;
return ret;

View File

@@ -17,16 +17,33 @@
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.IOException;
import java.io.OutputStream;
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
*
@@ -342,7 +359,12 @@ public class SWFOutputStream extends OutputStream {
*/
public void writeTags(List<Tag> tags) throws IOException {
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
}
}

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;
public class DefineBinaryData extends Tag {
public DefineBinaryData(byte[] data, int version) {
super(87, data);
public DefineBinaryData(byte[] data, int version, long pos) {
super(87, data, pos);
// TODO Auto-generated constructor stub
}

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;
public class DefineBits extends Tag {
public DefineBits(byte[] data, int version) {
super(6, data);
public DefineBits(byte[] data, int version, long pos) {
super(6, data, pos);
// TODO Auto-generated constructor stub
}

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;
public class DefineBitsJPEG2 extends Tag {
public DefineBitsJPEG2(byte[] data, int version) {
super(21, data);
public DefineBitsJPEG2(byte[] data, int version, long pos) {
super(21, data, pos);
// TODO Auto-generated constructor stub
}

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;
public class DefineBitsJPEG3 extends Tag {
public DefineBitsJPEG3(byte[] data, int version) {
super(35, data);
public DefineBitsJPEG3(byte[] data, int version, long pos) {
super(35, data, pos);
// TODO Auto-generated constructor stub
}

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;
public class DefineBitsLossless extends Tag {
public DefineBitsLossless(byte[] data, int version) {
super(20, data);
public DefineBitsLossless(byte[] data, int version, long pos) {
super(20, data, pos);
// TODO Auto-generated constructor stub
}

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;
import java.io.IOException;
public class DefineBitsLossless2 extends Tag {
public DefineBitsLossless2(byte[] data, int version) throws IOException {
super(36, data);
public DefineBitsLossless2(byte[] data, int version, long pos) throws IOException {
super(36, data, pos);
// TODO Auto-generated constructor stub
}

View File

@@ -66,8 +66,8 @@ public class DefineButton2Tag extends Tag implements Container {
* @param version SWF version
* @throws IOException
*/
public DefineButton2Tag(byte data[], int version) throws IOException {
super(34, data);
public DefineButton2Tag(byte data[], int version, long pos) throws IOException {
super(34, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
buttonId = sis.readUI16();
sis.readUB(7); //reserved
@@ -138,7 +138,7 @@ public class DefineButton2Tag extends Tag implements Container {
sos.writeBUTTONCONDACTIONList(actions);
sos.close();
} catch (IOException e) {
e.printStackTrace();
}
return baos.toByteArray();
}

View File

@@ -64,8 +64,8 @@ public class DefineButtonTag extends Tag implements ASMSource {
* @param version SWF version
* @throws IOException
*/
public DefineButtonTag(byte[] data, int version) throws IOException {
super(7, data);
public DefineButtonTag(byte[] data, int version, long pos) throws IOException {
super(7, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
buttonId = sis.readUI16();
characters = sis.readBUTTONRECORDList(false);
@@ -127,7 +127,7 @@ public class DefineButtonTag extends Tag implements ASMSource {
try {
actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
} catch (IOException ex) {
ex.printStackTrace();
}
return Action.actionsToString(actions, null, version);
}

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;
public class DefineFont3 extends Tag {
public DefineFont3(byte[] data, int version) {
super(75, data);
public DefineFont3(byte[] data, int version, long pos) {
super(75, data, pos);
// TODO Auto-generated constructor stub
}

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;
public class DefineFont4 extends Tag {
public DefineFont4(byte[] data, int version) {
super(91, data);
public DefineFont4(byte[] data, int version, long pos) {
super(91, data, pos);
// TODO Auto-generated constructor stub
}

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;
public class DefineFontAlignZones extends Tag {
public DefineFontAlignZones(byte[] data, int version) {
super(73, data);
public DefineFontAlignZones(byte[] data, int version, long pos) {
super(73, data, pos);
// TODO Auto-generated constructor stub
}

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;
import java.io.ByteArrayInputStream;
@@ -11,8 +28,8 @@ public class DefineFontName extends Tag {
private String fontName;
private String fontCopyright;
public DefineFontName(byte[] data, int version) throws IOException {
super(88, data);
public DefineFontName(byte[] data, int version, long pos) throws IOException {
super(88, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
fontId = sis.readUI16();
fontName = sis.readString();

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;
import java.io.ByteArrayInputStream;
@@ -11,8 +28,8 @@ public class DefineScalingGrid extends Tag {
private int characterId;
private RECT splitter;
public DefineScalingGrid(byte[] data, int version) throws IOException {
super(78, data);
public DefineScalingGrid(byte[] data, int version, long pos) throws IOException {
super(78, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
characterId = sis.readUI16();
splitter = sis.readRECT();

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;
import java.io.IOException;
public class DefineShape extends Tag {
public DefineShape(byte[] data, int version) throws IOException {
super(2, data);
public DefineShape(byte[] data, int version, long pos) throws IOException {
super(2, data, pos);
// TODO Auto-generated constructor stub
}

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;
import java.io.IOException;
public class DefineShape2 extends Tag {
public DefineShape2(byte[] data, int version) throws IOException {
super(22, data);
public DefineShape2(byte[] data, int version, long pos) throws IOException {
super(22, data, pos);
// TODO Auto-generated constructor stub
}

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;
import java.io.IOException;
public class DefineShape3 extends Tag {
public DefineShape3(byte[] data, int version) throws IOException {
super(32, data);
public DefineShape3(byte[] data, int version, long pos) throws IOException {
super(32, data, pos);
// TODO Auto-generated constructor stub
}

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;
public class DefineShape4 extends Tag {
public DefineShape4(byte[] data, int version) {
super(83, data);
public DefineShape4(byte[] data, int version, long pos) {
super(83, data, pos);
}
@Override

View File

@@ -51,6 +51,8 @@ public class DefineSpriteTag extends Tag implements Container {
*/
public List<ExportAssetsTag> exportAssetsTags = new ArrayList<ExportAssetsTag>();
private int level;
/**
* Constructor
*
@@ -58,12 +60,12 @@ public class DefineSpriteTag extends Tag implements Container {
* @param version SWF version
* @throws IOException
*/
public DefineSpriteTag(byte[] data, int version) throws IOException {
super(39, data);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
public DefineSpriteTag(byte[] data, int version, int level, long pos) throws IOException {
super(39, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version, pos);
spriteId = 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() {
return subTags.size();
}
@Override
public boolean hasSubTags() {
return true;
}
@Override
public List<Tag> getSubTags() {
return subTags;
}
}

View File

@@ -66,8 +66,8 @@ public class DoABCTag extends Tag {
* @param version SWF version
* @throws IOException
*/
public DoABCTag(byte[] data, int version) throws IOException {
super(82, data);
public DoABCTag(byte[] data, int version, long pos) throws IOException {
super(82, data, pos);
InputStream is = new ByteArrayInputStream(data);
SWFInputStream sis = new SWFInputStream(is, version);
flags = sis.readUI32();

View File

@@ -45,15 +45,15 @@ public class DoActionTag extends Tag implements ASMSource {
* @param version SWF version
* @throws IOException
*/
public DoActionTag(byte[] data, int version) {
super(12, data);
public DoActionTag(byte[] data, int version, long pos) {
super(12, data, pos);
try {
ByteArrayInputStream bais = new ByteArrayInputStream(data);
SWFInputStream sis = new SWFInputStream(bais, version);
//actions = sis.readActionList();
actionBytes=sis.readBytes(sis.available());
} catch (IOException e) {
e.printStackTrace();
}
}
@@ -79,7 +79,7 @@ public class DoActionTag extends Tag implements ASMSource {
try {
actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
} catch (IOException ex) {
ex.printStackTrace();
}
return Action.actionsToString(actions, null, version);
}
@@ -108,6 +108,7 @@ public class DoActionTag extends Tag implements ASMSource {
try {
return (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
} catch (IOException ex) {
ex.printStackTrace();
return new ArrayList<Action>();
}
}

View File

@@ -50,8 +50,8 @@ public class DoInitActionTag extends Tag implements ASMSource {
* @param version SWF version
* @throws IOException
*/
public DoInitActionTag(byte[] data, int version) throws IOException {
super(59, data);
public DoInitActionTag(byte[] data, int version, long pos) throws IOException {
super(59, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
spriteId = sis.readUI16();
//actions = sis.readActionList();
@@ -116,7 +116,7 @@ public class DoInitActionTag extends Tag implements ASMSource {
try {
actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
} catch (IOException ex) {
ex.printStackTrace();
}
return Action.actionsToString(actions, null, version);
}
@@ -125,6 +125,7 @@ public class DoInitActionTag extends Tag implements ASMSource {
try {
return (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
} catch (IOException ex) {
ex.printStackTrace();
return new ArrayList<Action>();
}
}

View File

@@ -41,8 +41,8 @@ public class ExportAssetsTag extends Tag {
* @param version SWF version
* @throws IOException
*/
public ExportAssetsTag(byte[] data, int version) throws IOException {
super(56, data);
public ExportAssetsTag(byte[] data, int version, long pos) throws IOException {
super(56, data, pos);
assets = new HashMap<Integer, String>();
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
int count = sis.readUI16();

View File

@@ -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;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import com.jpexs.asdec.SWFInputStream;
public class FileAttributes extends Tag {
private boolean useDirectBlit;
@@ -8,15 +30,17 @@ public class FileAttributes extends Tag {
private boolean actionScript3;
private boolean useNetwork;
public FileAttributes(byte[] data) {
super(69, data);
public FileAttributes(byte[] data, int version, long pos) throws IOException {
super(69, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
sis.readUB(1); // reserved
// UB[1] == 0 (reserved)
useDirectBlit = (data[0] & 0x40) != 0;
useGPU = (data[0] & 0x20) != 0;
hasMetadata = (data[0] & 0x10) != 0;
actionScript3 = (data[0] & 0x08) != 0;
// UB[2] == 0 (reserved)
useNetwork = (data[0] & 0x01) != 0;
useDirectBlit = sis.readUB(1) != 0;
useGPU = sis.readUB(1) != 0;
hasMetadata = sis.readUB(1) != 0;
actionScript3 = sis.readUB(1) != 0;
sis.readUB(2); // reserved
useNetwork = sis.readUB(1) != 0;
// UB[24] == 0 (reserved)
}

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;
import java.io.ByteArrayInputStream;
@@ -9,8 +26,8 @@ public class FrameLabel extends Tag {
private String name;
public FrameLabel(byte[] data, int version) throws IOException {
super(43, data);
public FrameLabel(byte[] data, int version, long pos) throws IOException {
super(43, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
name = sis.readString();
}

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;
import java.io.IOException;
public class JPEGTables extends Tag {
public JPEGTables(byte[] data) throws IOException {
super(8, data);
public JPEGTables(byte[] data, long pos) throws IOException {
super(8, data, pos);
// TODO Auto-generated constructor stub
}

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;
import java.io.UnsupportedEncodingException;
@@ -6,8 +23,8 @@ public class Metadata extends Tag {
private String xmlMetadata;
public Metadata(byte[] data) {
super(77, data);
public Metadata(byte[] data, long pos) {
super(77, data, pos);
try {
xmlMetadata = new String(data, "UTF-8");
} catch (UnsupportedEncodingException e) {

View File

@@ -166,8 +166,8 @@ public class PlaceObject2Tag extends Tag implements Container {
* @param version SWF version
* @throws IOException
*/
public PlaceObject2Tag(byte data[], int version) throws IOException {
super(26, data);
public PlaceObject2Tag(byte data[], int version, long pos) throws IOException {
super(26, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
placeFlagHasClipActions = sis.readUB(1) == 1;
placeFlagHasClipDepth = sis.readUB(1) == 1;

View File

@@ -150,6 +150,8 @@ public class PlaceObject3Tag extends Tag implements Container {
* If PlaceFlagHasClipActions, Clip Actions Data
*/
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);
}
if (placeFlagHasCacheAsBitmap) {
sos.writeUI8(bitmapCache);
if (!bitmapCacheBug) {
sos.writeUI8(bitmapCache);
}
}
if (placeFlagHasClipActions) {
sos.writeCLIPACTIONS(clipActions);
@@ -230,8 +234,8 @@ public class PlaceObject3Tag extends Tag implements Container {
* @param version SWF version
* @throws IOException
*/
public PlaceObject3Tag(byte data[], int version) throws IOException {
super(70, data);
public PlaceObject3Tag(byte data[], int version, long pos) throws IOException {
super(70, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
placeFlagHasClipActions = sis.readUB(1) == 1;
placeFlagHasClipDepth = sis.readUB(1) == 1;
@@ -276,8 +280,14 @@ public class PlaceObject3Tag extends Tag implements Container {
if (placeFlagHasBlendMode) {
blendMode = sis.readUI8();
}
bitmapCacheBug = false;
if (placeFlagHasCacheAsBitmap) {
bitmapCache = sis.readUI8();
if (bitmapCache == -1) {
// EOF
bitmapCacheBug = true;
bitmapCache = 1;
}
}
if (placeFlagHasClipActions) {
clipActions = sis.readCLIPACTIONS();

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;
import java.io.ByteArrayInputStream;
@@ -15,8 +32,8 @@ public class ProductInfo extends Tag {
private long buildHigh;
private long compilationDate;
public ProductInfo(byte[] data, int version) throws IOException {
super(41, data);
public ProductInfo(byte[] data, int version, long pos) throws IOException {
super(41, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
/*
* 0: Unknown

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;
import java.io.ByteArrayInputStream;
@@ -9,10 +26,9 @@ public class RemoveObject2 extends Tag {
private int depth;
public RemoveObject2(byte[] data, int version) throws IOException {
super(28, data);
ByteArrayInputStream bais = new ByteArrayInputStream(data);
SWFInputStream sis = new SWFInputStream(bais, version);
public RemoveObject2(byte[] data, int version, long pos) throws IOException {
super(28, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
depth = sis.readUI16();
}

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;
import java.io.ByteArrayInputStream;
@@ -10,8 +27,8 @@ public class ScriptLimits extends Tag {
private int maxRecursionDepth;
private int scriptTimeoutSeconds;
public ScriptLimits(byte[] data, int version) throws IOException {
super(65, data);
public ScriptLimits(byte[] data, int version, long pos) throws IOException {
super(65, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
maxRecursionDepth = sis.readUI16();
scriptTimeoutSeconds = sis.readUI16();

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;
import com.jpexs.asdec.types.RGB;
@@ -6,8 +23,8 @@ public class SetBackgroundColor extends Tag {
private RGB backgroundColor;
public SetBackgroundColor(byte[] data) {
super(9, data);
public SetBackgroundColor(byte[] data, long pos) {
super(9, data, pos);
backgroundColor = new RGB();
backgroundColor.red = data[0] & 0xff;
backgroundColor.green = data[1] & 0xff;

View File

@@ -26,8 +26,8 @@ public class ShowFrameTag extends Tag {
/**
* Constructor
*/
public ShowFrameTag() {
super(1, new byte[0]);
public ShowFrameTag(long pos) {
super(1, new byte[0], pos);
}
/**

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;
import java.io.ByteArrayInputStream;
@@ -9,8 +26,8 @@ public class SymbolClass extends Tag {
private int tagIDs[];
private String classNames[];
public SymbolClass(byte[] data, int version) throws IOException {
super(76, data);
public SymbolClass(byte[] data, int version, long pos) throws IOException {
super(76, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version);
int numSymbols = sis.readUI16();
tagIDs = new int[numSymbols];

View File

@@ -17,6 +17,8 @@
package com.jpexs.asdec.tags;
import java.util.List;
/**
* Represents Tag inside SWF file
*/
@@ -35,6 +37,8 @@ public class Tag {
*/
public boolean forceWriteAsLong = false;
private final long pos;
/**
* Returns identifier of tag type
*
@@ -50,9 +54,10 @@ public class Tag {
* @param id Tag type identifier
* @param data Bytes of data
*/
public Tag(int id, byte[] data) {
public Tag(int id, byte[] data, long pos) {
this.id = id;
this.data = data;
this.pos = pos;
}
/**
@@ -79,4 +84,15 @@ public class Tag {
return data.length;
}
public boolean hasSubTags() {
return false;
}
public List<Tag> getSubTags() {
return null;
}
public long getPos() {
return pos;
}
}

View File

@@ -117,7 +117,7 @@ public class BUTTONCONDACTION implements ASMSource {
try {
actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
} catch (IOException ex) {
ex.printStackTrace();
}
return Action.actionsToString(actions, null, version);
}
@@ -140,6 +140,7 @@ public class BUTTONCONDACTION implements ASMSource {
try {
return (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
} catch (IOException ex) {
ex.printStackTrace();
return new ArrayList<Action>();
}
}

View File

@@ -82,7 +82,7 @@ public class CLIPACTIONRECORD implements ASMSource {
try {
actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
} catch (IOException ex) {
ex.printStackTrace();
}
return Action.actionsToString(actions, null, version);
}
@@ -101,6 +101,7 @@ public class CLIPACTIONRECORD implements ASMSource {
try {
return (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
} catch (IOException ex) {
ex.printStackTrace();
return new ArrayList<Action>();
}
}

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;
/**