Merge origin/master

This commit is contained in:
Jindra Petřík
2014-11-09 23:12:44 +01:00
151 changed files with 2787 additions and 2512 deletions

View File

@@ -139,6 +139,7 @@ import com.jpexs.decompiler.graph.GraphSourceItemContainer;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.helpers.Cache;
import com.jpexs.helpers.CancellableWorker;
import com.jpexs.helpers.Helper;
@@ -282,7 +283,7 @@ public final class SWF implements SWFContainerItem, Timelined {
max = characterId;
}
}
return max + 1;
}
@@ -294,7 +295,7 @@ public final class SWF implements SWFContainerItem, Timelined {
if (checkAll || tag.isModified()) {
Set<Integer> needed = new HashSet<>();
tag.getNeededCharacters(needed);
boolean moved = false;
boolean moved = false;
for (Integer id : needed) {
if (!addedCharacterIds.contains(id)) {
CharacterTag neededCharacter = characters.get(id);
@@ -310,7 +311,7 @@ public final class SWF implements SWFContainerItem, Timelined {
moved = true;
}
}
if (moved) {
i--;
continue;
@@ -321,7 +322,7 @@ public final class SWF implements SWFContainerItem, Timelined {
}
}
}
public void resetTimelines(Timelined timelined) {
timelined.getTimeline().reset();
for (Tag t : timelined.getTimeline().tags) {
@@ -439,7 +440,7 @@ public final class SWF implements SWFContainerItem, Timelined {
public void saveTo(OutputStream os, SWFCompression compression) throws IOException {
try {
fixCharactersOrder(false);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
sos.writeRECT(displayRect);
@@ -1065,7 +1066,7 @@ public final class SWF implements SWFContainerItem, Timelined {
}
}
}
private final HashSet<EventListener> listeners = new HashSet<>();
public final void addEventListener(EventListener listener) {
@@ -1093,15 +1094,14 @@ public final class SWF implements SWFContainerItem, Timelined {
}
public static boolean hasErrorHeader(byte[] data) {
if (data.length > 4) {
if ((data[0] & 0xff) == 0xff) {
if ((data[1] & 0xff) == 0xd9) {
if ((data[2] & 0xff) == 0xff) {
if ((data[3] & 0xff) == 0xd8) {
return true;
}
}
}
return hasErrorHeader(new ByteArrayRange(data));
}
public static boolean hasErrorHeader(ByteArrayRange data) {
if (data.getLength() > 4) {
if ((data.get(0) & 0xff) == 0xff && (data.get(1) & 0xff) == 0xd9
&& (data.get(2) & 0xff) == 0xff && (data.get(3) & 0xff) == 0xd8) {
return true;
}
}
return false;
@@ -1772,7 +1772,7 @@ public final class SWF implements SWFContainerItem, Timelined {
if (tag instanceof SymbolClassTag) {
SymbolClassTag sc = (SymbolClassTag) tag;
for (int i = 0; i < sc.names.length; i++) {
String newname = deobfuscation.deobfuscateNameWithPackage(true,sc.names[i], deobfuscated, renameType, deobfuscated);
String newname = deobfuscation.deobfuscateNameWithPackage(true, sc.names[i], deobfuscated, renameType, deobfuscated);
if (newname != null) {
sc.names[i] = newname;
}
@@ -1780,7 +1780,7 @@ public final class SWF implements SWFContainerItem, Timelined {
sc.setModified(true);
}
}
deobfuscation.deobfuscateInstanceNames(true,deobfuscated, renameType, tags, new HashMap<String, String>());
deobfuscation.deobfuscateInstanceNames(true, deobfuscated, renameType, tags, new HashMap<String, String>());
return deobfuscated.size();
}
@@ -1872,7 +1872,7 @@ public final class SWF implements SWFContainerItem, Timelined {
if (fun.calculatedFunctionName instanceof DirectValueActionItem) {
DirectValueActionItem dvf = (DirectValueActionItem) fun.calculatedFunctionName;
String fname = dvf.toStringNoH(null);
String changed = deobfuscation.deobfuscateName(false,fname, false, "method", deobfuscated, renameType, selected);
String changed = deobfuscation.deobfuscateName(false, fname, false, "method", deobfuscated, renameType, selected);
if (changed != null) {
deobfuscated.put(fname, changed);
}
@@ -1891,7 +1891,7 @@ public final class SWF implements SWFContainerItem, Timelined {
if (gti instanceof DirectValueActionItem) {
DirectValueActionItem dvf = (DirectValueActionItem) gti;
String vname = dvf.toStringNoH(null);
String changed = deobfuscation.deobfuscateName(false,vname, false, "attribute", deobfuscated, renameType, selected);
String changed = deobfuscation.deobfuscateName(false, vname, false, "attribute", deobfuscated, renameType, selected);
if (changed != null) {
deobfuscated.put(vname, changed);
}
@@ -1924,7 +1924,7 @@ public final class SWF implements SWFContainerItem, Timelined {
if (classNameParts != null) {
changedNameStr = classNameParts[classNameParts.length - 1 - pos];
}
String changedNameStr2 = deobfuscation.deobfuscateName(false,changedNameStr, pos == 0, pos == 0 ? "class" : "package", deobfuscated, renameType, selected);
String changedNameStr2 = deobfuscation.deobfuscateName(false, changedNameStr, pos == 0, pos == 0 ? "class" : "package", deobfuscated, renameType, selected);
if (changedNameStr2 != null) {
changedNameStr = changedNameStr2;
}
@@ -1948,7 +1948,7 @@ public final class SWF implements SWFContainerItem, Timelined {
if (classNameParts != null) {
changedNameStr = classNameParts[classNameParts.length - 1 - pos];
}
String changedNameStr2 = deobfuscation.deobfuscateName(false,changedNameStr, pos == 0, pos == 0 ? "class" : "package", deobfuscated, renameType, selected);
String changedNameStr2 = deobfuscation.deobfuscateName(false, changedNameStr, pos == 0, pos == 0 ? "class" : "package", deobfuscated, renameType, selected);
if (changedNameStr2 != null) {
changedNameStr = changedNameStr2;
}
@@ -1970,7 +1970,7 @@ public final class SWF implements SWFContainerItem, Timelined {
if (f.functionName.isEmpty()) { //anonymous function, leave as is
continue;
}
String changed = deobfuscation.deobfuscateName(false,f.functionName, false, "function", deobfuscated, renameType, selected);
String changed = deobfuscation.deobfuscateName(false, f.functionName, false, "function", deobfuscated, renameType, selected);
if (changed != null) {
f.replacedFunctionName = changed;
ret++;
@@ -1981,7 +1981,7 @@ public final class SWF implements SWFContainerItem, Timelined {
if (f.functionName.isEmpty()) { //anonymous function, leave as is
continue;
}
String changed = deobfuscation.deobfuscateName(false,f.functionName, false, "function", deobfuscated, renameType, selected);
String changed = deobfuscation.deobfuscateName(false, f.functionName, false, "function", deobfuscated, renameType, selected);
if (changed != null) {
f.replacedFunctionName = changed;
ret++;
@@ -2004,7 +2004,7 @@ public final class SWF implements SWFContainerItem, Timelined {
for (MyEntry<DirectValueActionItem, ConstantPool> it : allVariableNames) {
vc++;
String name = it.getKey().toStringNoH(it.getValue());
String changed = deobfuscation.deobfuscateName(false,name, false, usageTypes.get(it.getKey()), deobfuscated, renameType, selected);
String changed = deobfuscation.deobfuscateName(false, name, false, usageTypes.get(it.getKey()), deobfuscated, renameType, selected);
if (changed != null) {
boolean addNew = false;
String h = System.identityHashCode(it.getKey()) + "_" + name;
@@ -2042,7 +2042,7 @@ public final class SWF implements SWFContainerItem, Timelined {
src.setActions(actionsMap.get(src));
src.setModified();
}
deobfuscation.deobfuscateInstanceNames(false,deobfuscated, renameType, tags, selected);
deobfuscation.deobfuscateInstanceNames(false, deobfuscated, renameType, tags, selected);
return ret;
}

View File

@@ -23,5 +23,5 @@ import com.jpexs.decompiler.flash.treeitems.TreeItem;
* @author JPEXS
*/
public interface SWFContainerItem extends TreeItem {
}

View File

@@ -696,6 +696,25 @@ public class SWFInputStream implements AutoCloseable {
return ret;
}
/**
* Reads byte range from the stream
*
* @param count Number of bytes to read
* @param name
* @return ByteArrayRange object
* @throws IOException
*/
public ByteArrayRange readByteRangeEx(long count, String name) throws IOException {
if (count <= 0) {
return ByteArrayRange.EMPTY;
}
newDumpLevel(name, "bytes");
int startPos = (int) getPos();
skipBytesEx(count);
endDumpLevel();
return new ByteArrayRange(swf.uncompressedData, startPos, (int) count);
}
/**
* Reads bytes from the stream
*
@@ -718,6 +737,19 @@ public class SWFInputStream implements AutoCloseable {
return ret;
}
/**
* Skip bytes from the stream
*
* @param count Number of bytes to skip
* @throws IOException
*/
public void skipBytesEx(long count) throws IOException {
bitPos = 0;
for (int i = 0; i < count; i++) {
readNoBitReset();
}
}
/**
* Skip bytes from the stream
*
@@ -726,10 +758,7 @@ public class SWFInputStream implements AutoCloseable {
*/
public void skipBytes(long count) throws IOException {
try {
bitPos = 0;
for (int i = 0; i < count; i++) {
readNoBitReset();
}
skipBytesEx(count);
} catch (EOFException | EndOfStreamException ex) {
logger.log(Level.SEVERE, null, ex);
}
@@ -769,7 +798,7 @@ public class SWFInputStream implements AutoCloseable {
InflaterInputStream dis = new InflaterInputStream(new ByteArrayInputStream(data));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
if (count > 0) {
byte[] buf = new byte[4096];
byte[] buf = new byte[4096];
int c = 0;
while ((c = dis.read(buf)) > 0) {
baos.write(buf, 0, c);

View File

@@ -75,6 +75,7 @@ import com.jpexs.decompiler.flash.types.shaperecords.EndShapeRecord;
import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD;
import com.jpexs.decompiler.flash.types.shaperecords.StraightEdgeRecord;
import com.jpexs.decompiler.flash.types.shaperecords.StyleChangeRecord;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -131,6 +132,12 @@ public class SWFOutputStream extends OutputStream {
pos += b.length;
}
public void write(ByteArrayRange b) throws IOException {
alignByte();
os.write(b.getArray(), b.getPos(), b.getLength());
pos += b.getLength();
}
private void alignByte() throws IOException {
if (bitPos > 0) {
bitPos = 0;

View File

@@ -1712,17 +1712,16 @@ public class AVM2Code implements Cloneable {
}
}
}
/*
//undeclare registers at the end of the block?
for(int reg:nowdeclaredRegs){
declaredRegisters[reg] = false;
}
//undeclare registers at the end of the block?
for(int reg:nowdeclaredRegs){
declaredRegisters[reg] = false;
}
for(Slot s:nowdeclaredSlots){
declaredSlots.remove(s);
}*/
for(Slot s:nowdeclaredSlots){
declaredSlots.remove(s);
}*/
}
public List<GraphTargetItem> toGraphTargetItems(String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, AVM2ConstantPool constants, List<MethodInfo> method_info, MethodBody body, HashMap<Integer, String> localRegNames, ScopeStack scopeStack, boolean isStaticInitializer, List<String> fullyQualifiedNames, Traits initTraits, int staticOperation, HashMap<Integer, Integer> localRegAssigmentIps, HashMap<Integer, List<Integer>> refs) throws InterruptedException {

View File

@@ -667,7 +667,7 @@ public class AVM2Graph extends Graph {
WhileItem w = (WhileItem) loopItem;
if ((!w.expression.isEmpty()) && (w.expression.get(w.expression.size() - 1) instanceof HasNextAVM2Item)) {
HasNextAVM2Item hn=(HasNextAVM2Item)w.expression.get(w.expression.size() - 1);
HasNextAVM2Item hn = (HasNextAVM2Item) w.expression.get(w.expression.size() - 1);
if (((HasNextAVM2Item) w.expression.get(w.expression.size() - 1)).collection != null) {
if (((HasNextAVM2Item) w.expression.get(w.expression.size() - 1)).collection.getNotCoerced().getThroughRegister() instanceof FilteredCheckAVM2Item) {
//GraphTargetItem gti = ((HasNextAVM2Item) ((HasNextAVM2Item) w.expression.get(w.expression.size() - 1))).collection.getNotCoerced().getThroughRegister();
@@ -704,7 +704,7 @@ public class AVM2Graph extends Graph {
if (gti instanceof NextValueAVM2Item) {
return new ForEachInAVM2Item(w.src, w.loop, new InAVM2Item(hn.instruction, sti.getObject(), ((HasNextAVM2Item) w.expression.get(w.expression.size() - 1)).collection), w.commands);
} else if (gti instanceof NextNameAVM2Item) {
return new ForInAVM2Item(w.src, w.loop, new InAVM2Item(hn.instruction,sti.getObject(), ((HasNextAVM2Item) w.expression.get(w.expression.size() - 1)).collection), w.commands);
return new ForInAVM2Item(w.src, w.loop, new InAVM2Item(hn.instruction, sti.getObject(), ((HasNextAVM2Item) w.expression.get(w.expression.size() - 1)).collection), w.commands);
}
}
}

View File

@@ -41,10 +41,10 @@ public abstract class GetLocalTypeIns extends InstructionDefinition {
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> regAssignCount, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
int regId = getRegisterId(ins);
if(regId == 0){
if (regId == 0) {
if ((classIndex >= abc.instance_info.size()) || classIndex < 0) {
stack.push(new ScriptAVM2Item(scriptIndex));
return;
@@ -56,7 +56,7 @@ public abstract class GetLocalTypeIns extends InstructionDefinition {
}
return;
}
GraphTargetItem computedValue = localRegs.get(regId);
int assignCount = 0;
if (regAssignCount.containsKey(regId)) {

View File

@@ -40,8 +40,8 @@ public abstract class AVM2Item extends GraphTargetItem {
public AVM2Item(GraphSourceItem instruction, int precedence) {
super(instruction, precedence);
if(instruction instanceof AVM2Instruction){
this.instruction = (AVM2Instruction)instruction;
if (instruction instanceof AVM2Instruction) {
this.instruction = (AVM2Instruction) instruction;
}
}
@@ -81,11 +81,11 @@ public abstract class AVM2Item extends GraphTargetItem {
}
}
}
if (empty) {
return propertyName.toString(writer, localData);
}
if (propertyName instanceof FullMultinameAVM2Item) {
if (propertyName instanceof FullMultinameAVM2Item) {
if (((FullMultinameAVM2Item) propertyName).name != null) {
return propertyName.toString(writer, localData);
} else {
@@ -101,7 +101,7 @@ public abstract class AVM2Item extends GraphTargetItem {
public static String localRegName(HashMap<Integer, String> localRegNames, int reg) {
if (localRegNames.containsKey(reg)) {
return IdentifiersDeobfuscation.printIdentifier(true,localRegNames.get(reg));
return IdentifiersDeobfuscation.printIdentifier(true, localRegNames.get(reg));
} else {
if (reg == 0) {
return "this";

View File

@@ -18,7 +18,6 @@ package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -26,14 +25,13 @@ import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class FullMultinameAVM2Item extends AVM2Item {
public int multinameIndex;
public GraphTargetItem name;
public GraphTargetItem namespace;
public FullMultinameAVM2Item(AVM2Instruction instruction, int multinameIndex, GraphTargetItem name) {
super(instruction, PRECEDENCE_PRIMARY);
this.multinameIndex = multinameIndex;
@@ -155,10 +153,10 @@ public class FullMultinameAVM2Item extends AVM2Item {
return false;
}
return true;
}
}
@Override
public GraphTargetItem returnType() {
public GraphTargetItem returnType() {
return TypeItem.UNBOUNDED;
}

View File

@@ -34,9 +34,9 @@ public class GetLexAVM2Item extends AVM2Item {
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
String localName = propertyName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false);
srcData.put("localName",localName);
String localName = propertyName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false);
srcData.put("localName", localName);
return writer.append(propertyName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false));
}

View File

@@ -40,21 +40,21 @@ public class GetSlotAVM2Item extends AVM2Item {
return writer.append("/*UnknownSlot*/");
}
srcData.put("localName", getNameAsStr(localData));
return writer.append(slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false));
}
public String getNameAsStr(LocalData localData){
public String getNameAsStr(LocalData localData) {
return slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false);
}
public GraphTextWriter getName(GraphTextWriter writer, LocalData localData) {
public GraphTextWriter getName(GraphTextWriter writer, LocalData localData) {
if (slotName == null) {
return writer.append("/*UnknownSlot*/");
}
return writer.append(slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false));
}
@Override
public GraphTargetItem returnType() {
return TypeItem.UNBOUNDED;

View File

@@ -55,7 +55,7 @@ public class LocalRegAVM2Item extends AVM2Item {
computedResult = null;
}
}
this.computedValue = computedValue;
this.computedValue = computedValue;
}
@Override

View File

@@ -61,7 +61,7 @@ public class NewFunctionAVM2Item extends AVM2Item {
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
MethodBody body = abc.findBody(methodIndex);
writer.append("function");
writer.startMethod(methodIndex);
writer.startMethod(methodIndex);
writer.append((!functionName.isEmpty() ? " " + functionName : ""));
writer.appendNoHilight("(");
methodInfo.get(methodIndex).getParamStr(writer, constants, body, abc, fullyQualifiedNames);
@@ -71,7 +71,7 @@ public class NewFunctionAVM2Item extends AVM2Item {
writer.appendNoHilight(abc.findBodyIndex(methodIndex));
writer.newLine();
}
methodInfo.get(methodIndex).getReturnTypeStr(writer, constants, fullyQualifiedNames);
methodInfo.get(methodIndex).getReturnTypeStr(writer, constants, fullyQualifiedNames);
writer.startBlock();
if (body != null) {
if (writer instanceof NulWriter) {

View File

@@ -42,7 +42,7 @@ public class SetLocalAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assig
public SetLocalAVM2Item(AVM2Instruction instruction, int regIndex, GraphTargetItem value) {
super(instruction, PRECEDENCE_ASSIGMENT);
this.regIndex = regIndex;
this.value = value;
this.value = value;
}
@Override

View File

@@ -35,7 +35,7 @@ public class SetSlotAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assign
super(instruction, PRECEDENCE_ASSIGMENT);
this.slotName = slotName;
this.value = value;
this.scope = scope;
this.scope = scope;
}
@Override
@@ -51,11 +51,11 @@ public class SetSlotAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assign
return value.toString(writer, localData);
}
public String getNameAsStr(LocalData localData){
public String getNameAsStr(LocalData localData) {
return slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false);
}
public GraphTextWriter getName(GraphTextWriter writer, LocalData localData) {
public GraphTextWriter getName(GraphTextWriter writer, LocalData localData) {
if (slotName == null) {
return writer.append("/*UnknownSlot*/");
}

View File

@@ -33,7 +33,7 @@ public class ThisAVM2Item extends AVM2Item {
public Multiname className;
public ThisAVM2Item(GraphSourceItem instruction,Multiname className) {
public ThisAVM2Item(GraphSourceItem instruction, Multiname className) {
super(instruction, PRECEDENCE_PRIMARY);
this.className = className;
srcData.put("localName", "this");
@@ -45,7 +45,7 @@ public class ThisAVM2Item extends AVM2Item {
}
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer.append("this");
}

View File

@@ -16,7 +16,6 @@
*/
package com.jpexs.decompiler.flash.abc.avm2.model.clauses;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.CoerceAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item;
@@ -24,13 +23,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.GetSlotAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.SetLocalAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.SetSlotAVM2Item;
import com.jpexs.decompiler.flash.abc.types.InstanceInfo;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.ArrayList;
/**
*
@@ -49,38 +45,38 @@ public class DeclarationAVM2Item extends AVM2Item {
public DeclarationAVM2Item(GraphTargetItem assignment) {
this(assignment, null);
}
}
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
if(assignment instanceof LocalRegAVM2Item){ //for..in
LocalRegAVM2Item lti=(LocalRegAVM2Item)assignment;
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
if (assignment instanceof LocalRegAVM2Item) { //for..in
LocalRegAVM2Item lti = (LocalRegAVM2Item) assignment;
String localName = localRegName(localData.localRegNames, lti.regIndex);
srcData.put("localName",localName);
srcData.put("localName", localName);
srcData.put("declaration", "true");
srcData.put("declaredType", "*");
writer.append("var ");
writer.append(localName);
return writer;
}
if(assignment instanceof GetSlotAVM2Item){ //for..in
GetSlotAVM2Item sti=(GetSlotAVM2Item)assignment;
srcData.put("localName",sti.getNameAsStr(localData));
if (assignment instanceof GetSlotAVM2Item) { //for..in
GetSlotAVM2Item sti = (GetSlotAVM2Item) assignment;
srcData.put("localName", sti.getNameAsStr(localData));
srcData.put("declaration", "true");
srcData.put("declaredType", "*");
writer.append("var ");
sti.getName(writer, localData);
return writer;
}
if (assignment instanceof SetLocalAVM2Item) {
if (assignment instanceof SetLocalAVM2Item) {
SetLocalAVM2Item lti = (SetLocalAVM2Item) assignment;
String localName = localRegName(localData.localRegNames, lti.regIndex);
srcData.put("localName",localName);
srcData.put("localName", localName);
srcData.put("declaration", "true");
GraphTargetItem coerType = TypeItem.UNBOUNDED;
if (lti.value instanceof CoerceAVM2Item) {
coerType = ((CoerceAVM2Item) lti.value).typeObj;
@@ -88,23 +84,23 @@ public class DeclarationAVM2Item extends AVM2Item {
if (lti.value instanceof ConvertAVM2Item) {
coerType = ((ConvertAVM2Item) lti.value).type;
}
srcData.put("declaredType", (coerType instanceof TypeItem)?((TypeItem)coerType).fullTypeName:"*");
srcData.put("declaredType", (coerType instanceof TypeItem) ? ((TypeItem) coerType).fullTypeName : "*");
writer.append("var ");
writer.append(localName);
writer.append(":");
writer.append(":");
coerType.appendTo(writer, localData);
writer.append(" = ");
return lti.value.toString(writer, localData);
}
if (assignment instanceof SetSlotAVM2Item) {
SetSlotAVM2Item ssti = (SetSlotAVM2Item) assignment;
srcData.put("localName",ssti.getNameAsStr(localData));
srcData.put("localName", ssti.getNameAsStr(localData));
srcData.put("declaration", "true");
srcData.put("declaredType", (type instanceof TypeItem)?((TypeItem)type).fullTypeName:"*");
srcData.put("declaredType", (type instanceof TypeItem) ? ((TypeItem) type).fullTypeName : "*");
writer.append("var ");
ssti.getName(writer, localData);
writer.append(":");
writer.append(":");
type.appendTo(writer, localData);
writer.append(" = ");
return ssti.value.toString(writer, localData);

View File

@@ -79,16 +79,16 @@ public class TryAVM2Item extends AVM2Item implements Block {
writer.newLine();
writer.append("catch(");
String localName = catchExceptions.get(e).getVarName(localData.constantsAvm2, localData.fullyQualifiedNames);
Map<String,String> data=new HashMap<>();
Map<String, String> data = new HashMap<>();
data.put("localName", localName);
data.put("declaration", "true");
int eti= catchExceptions.get(e).type_index;
data.put("declaredType", eti<=0?"*":localData.constantsAvm2.constant_multiname.get(eti).getNameWithNamespace(localData.constantsAvm2, true));
writer.hilightSpecial(localName, "try.name",e,data);
int eti = catchExceptions.get(e).type_index;
data.put("declaredType", eti <= 0 ? "*" : localData.constantsAvm2.constant_multiname.get(eti).getNameWithNamespace(localData.constantsAvm2, true));
writer.hilightSpecial(localName, "try.name", e, data);
writer.append(":");
writer.hilightSpecial(catchExceptions.get(e).getTypeName(localData.constantsAvm2, localData.fullyQualifiedNames),"try.type",e);
writer.hilightSpecial(catchExceptions.get(e).getTypeName(localData.constantsAvm2, localData.fullyQualifiedNames), "try.type", e);
writer.append(")");
writer.startBlock();
List<GraphTargetItem> commands = catchCommands.get(e);

View File

@@ -350,7 +350,7 @@ public class ActionScriptParser {
name = null;
}
s = lex();
}
}
GraphTargetItem ret = null;
if (name != null) {

View File

@@ -53,11 +53,11 @@ public class InstanceInfo {
return "name_index=" + abc.constants.getMultiname(name_index).toString(abc.constants, fullyQualifiedNames) + " super_index=" + supIndexStr + " flags=" + flags + " protectedNS=" + protectedNS + " interfaces=" + Helper.intArrToString(interfaces) + " method_index=" + iinit_index + "\r\n" + instance_traits.toString(abc, fullyQualifiedNames);
}
public GraphTextWriter getClassHeaderStr(GraphTextWriter writer,ABC abc, List<String> fullyQualifiedNames, boolean allowPrivate) {
public GraphTextWriter getClassHeaderStr(GraphTextWriter writer, ABC abc, List<String> fullyQualifiedNames, boolean allowPrivate) {
String modifiers;
Namespace ns = abc.constants.getMultiname(name_index).getNamespace(abc.constants);
modifiers = ns.getPrefix(abc);
if(!allowPrivate && modifiers.equals("private")){
if (!allowPrivate && modifiers.equals("private")) {
modifiers = "";
}
if (!modifiers.isEmpty()) {
@@ -74,16 +74,14 @@ public class InstanceInfo {
if (isInterface()) {
objType = "interface ";
}
writer.appendNoHilight(modifiers + objType);
writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, new ArrayList<String>()/* No full names here*/, false),"classname");
writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, new ArrayList<String>()/* No full names here*/, false), "classname");
if (super_index > 0) {
String typeName = abc.constants.getMultiname(super_index).getNameWithNamespace(abc.constants, true);
writer.appendNoHilight(" extends ");
writer.hilightSpecial(abc.constants.getMultiname(super_index).getName(abc.constants, fullyQualifiedNames, false),"typename",typeName);
writer.hilightSpecial(abc.constants.getMultiname(super_index).getName(abc.constants, fullyQualifiedNames, false), "typename", typeName);
}
if (interfaces.length > 0) {
if (isInterface()) {
@@ -96,10 +94,10 @@ public class InstanceInfo {
writer.append(", ");
}
String typeName = abc.constants.getMultiname(interfaces[i]).getNameWithNamespace(abc.constants, true);
writer.hilightSpecial(abc.constants.getMultiname(interfaces[i]).getName(abc.constants, fullyQualifiedNames, false),"typename",typeName);
writer.hilightSpecial(abc.constants.getMultiname(interfaces[i]).getName(abc.constants, fullyQualifiedNames, false), "typename", typeName);
}
}
return writer;
}

View File

@@ -269,33 +269,32 @@ public class MethodInfo {
public GraphTextWriter getParamStr(GraphTextWriter writer, AVM2ConstantPool constants, MethodBody body, ABC abc, List<String> fullyQualifiedNames) {
Map<Integer, String> localRegNames = new HashMap<>();
if (body != null && Configuration.getLocalNamesFromDebugInfo.get()) {
localRegNames = body.getCode().getLocalRegNamesFromDebug(abc);
if (body != null && Configuration.getLocalNamesFromDebugInfo.get()) {
localRegNames = body.getCode().getLocalRegNamesFromDebug(abc);
}
Map<String,String> pdata;
Map<String, String> pdata;
for (int i = 0; i < param_types.length; i++) {
if (i > 0) {
writer.appendNoHilight(", ");
}
String ptype = "*";
if (param_types[i] > 0) {
ptype = constants.getMultiname(param_types[i]).getNameWithNamespace(constants,false);
ptype = constants.getMultiname(param_types[i]).getNameWithNamespace(constants, false);
}
pdata=new HashMap<>();
pdata.put("declaration", "true");
pdata = new HashMap<>();
pdata.put("declaration", "true");
pdata.put("declaredType", ptype);
if (!localRegNames.isEmpty()) {
pdata.put("localName", localRegNames.get(i + 1)); //assuming it is a slot
writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true,localRegNames.get(i + 1)),"paramname",i,pdata);
writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true, localRegNames.get(i + 1)), "paramname", i, pdata);
} else if ((paramNames.length > i) && (paramNames[i] != 0) && Configuration.paramNamesEnable.get()) {
pdata.put("localName", constants.getString(paramNames[i]));
writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true,constants.getString(paramNames[i])),"paramname",i,pdata);
pdata.put("localName", constants.getString(paramNames[i]));
writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true, constants.getString(paramNames[i])), "paramname", i, pdata);
} else {
pdata.put("localName","param"+(i+1));
writer.hilightSpecial("param" + (i + 1),"paramname",i,pdata);
pdata.put("localName", "param" + (i + 1));
writer.hilightSpecial("param" + (i + 1), "paramname", i, pdata);
}
writer.appendNoHilight(":");
if (param_types[i] == 0) {
@@ -323,21 +322,21 @@ public class MethodInfo {
} else {
restName = "rest";
}
pdata=new HashMap<>();
pdata = new HashMap<>();
pdata.put("declaration", "true");
pdata.put("declaredType", "*");
pdata.put("localName",restName);
pdata.put("localName", restName);
writer.append(restAdd);
writer.hilightSpecial(restName, "flag.NEED_REST",0,pdata);
writer.hilightSpecial(restName, "flag.NEED_REST", 0, pdata);
}
return writer;
}
public GraphTextWriter getReturnTypeStr(GraphTextWriter writer, AVM2ConstantPool constants, List<String> fullyQualifiedNames) {
String rname = "*";
if(ret_type>0){
rname = IdentifiersDeobfuscation.printIdentifier(true,constants.getMultiname(ret_type).getName(constants, fullyQualifiedNames, true),"void");
}
if (ret_type > 0) {
rname = IdentifiersDeobfuscation.printIdentifier(true, constants.getMultiname(ret_type).getName(constants, fullyQualifiedNames, true), "void");
}
return writer.hilightSpecial(rname, "returns");
}

View File

@@ -264,7 +264,7 @@ public class Multiname {
if ((fullyQualifiedNames != null) && fullyQualifiedNames.contains(name)) {
return getNameWithNamespace(constants, raw);
}
return (isAttribute() ? "@" : "") + (raw ? name : IdentifiersDeobfuscation.printIdentifier(true,name));
return (isAttribute() ? "@" : "") + (raw ? name : IdentifiersDeobfuscation.printIdentifier(true, name));
}
}

View File

@@ -104,7 +104,7 @@ public class Namespace {
if (raw) {
return constants.getString(name_index);
}
return IdentifiersDeobfuscation.printNamespace(true,constants.getString(name_index));
return IdentifiersDeobfuscation.printNamespace(true, constants.getString(name_index));
}
public boolean hasName(String name, AVM2ConstantPool constants) {

View File

@@ -348,7 +348,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
@Override
public GraphTextWriter toStringHeader(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
abc.instance_info.get(class_info).getClassHeaderStr(writer,abc, fullyQualifiedNames,false);
abc.instance_info.get(class_info).getClassHeaderStr(writer, abc, fullyQualifiedNames, false);
return writer;
}
@@ -447,7 +447,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
}
//class header
abc.instance_info.get(class_info).getClassHeaderStr(writer,abc, fullyQualifiedNames,false);
abc.instance_info.get(class_info).getClassHeaderStr(writer, abc, fullyQualifiedNames, false);
writer.startBlock();
int bodyIndex = abc.findBodyIndex(abc.class_info.get(class_info).cinit_index);

View File

@@ -93,7 +93,7 @@ import java.util.logging.Logger;
* Represents one ACTIONRECORD, also has some static method to work with Actions
*/
public class Action implements GraphSourceItem {
private boolean ignored = false;
/**
* Action type identifier
@@ -103,7 +103,7 @@ public class Action implements GraphSourceItem {
* Length of action data
*/
public int actionLength;
private long address;
private long address;
/**
* Names of ActionScript properties
@@ -880,7 +880,7 @@ public class Action implements GraphSourceItem {
"",
" * " + AppResources.translate("decompilationError"),
" * " + AppResources.translate("decompilationError.obfuscated"),
Helper.decompilationErrorAdd==null?null:" * "+Helper.decompilationErrorAdd,
Helper.decompilationErrorAdd == null ? null : " * " + Helper.decompilationErrorAdd,
" * " + AppResources.translate("decompilationError.errorType") + ": "
+ ex2.getClass().getSimpleName(),
""}));

View File

@@ -49,7 +49,7 @@ public class CallFunctionActionItem extends ActionItem {
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
String paramStr = "";
writer.append(IdentifiersDeobfuscation.printIdentifier(false,((DirectValueActionItem) functionName).toStringNoQuotes(localData)));
writer.append(IdentifiersDeobfuscation.printIdentifier(false, ((DirectValueActionItem) functionName).toStringNoQuotes(localData)));
writer.spaceBeforeCallParenthesies(arguments.size());
writer.append("(");
for (int t = 0; t < arguments.size(); t++) {

View File

@@ -73,7 +73,7 @@ public class CallMethodActionItem extends ActionItem {
scriptObject.toString(writer, localData);
}
writer.append(".");
writer.append(IdentifiersDeobfuscation.printIdentifier(false,methodName.toStringNoQuotes(localData)));
writer.append(IdentifiersDeobfuscation.printIdentifier(false, methodName.toStringNoQuotes(localData)));
} else {
scriptObject.toString(writer, localData);
}

View File

@@ -76,7 +76,7 @@ public class DefineLocalActionItem extends ActionItem implements SetTypeActionIt
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
writer.append("var ");
if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) && (!IdentifiersDeobfuscation.isValidName(false,((DirectValueActionItem) name).toStringNoQuotes(localData), "this", "super"))) {
if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) && (!IdentifiersDeobfuscation.isValidName(false, ((DirectValueActionItem) name).toStringNoQuotes(localData), "this", "super"))) {
writer.append(IdentifiersDeobfuscation.makeObfuscatedIdentifier(((DirectValueActionItem) name).toStringNoQuotes(localData)));
} else {
stripQuotes(name, localData, writer);

View File

@@ -83,14 +83,14 @@ public class FunctionActionItem extends ActionItem {
if (calculatedFunctionName != null) {
writer.append(" ");
String fname = calculatedFunctionName.toStringNoQuotes(localData);
if (!IdentifiersDeobfuscation.isValidName(false,fname)) {
if (!IdentifiersDeobfuscation.isValidName(false, fname)) {
writer.append(IdentifiersDeobfuscation.makeObfuscatedIdentifier(fname));
} else {
calculatedFunctionName.appendToNoQuotes(writer, localData);
}
} else if (!functionName.isEmpty()) {
writer.append(" ");
if (!IdentifiersDeobfuscation.isValidName(false,functionName)) {
if (!IdentifiersDeobfuscation.isValidName(false, functionName)) {
writer.append(IdentifiersDeobfuscation.makeObfuscatedIdentifier(functionName));
} else {
writer.append(functionName);
@@ -107,7 +107,7 @@ public class FunctionActionItem extends ActionItem {
if (pname == null || pname.isEmpty()) {
pname = new RegisterNumber(regStart + p).translate();
}
if (!IdentifiersDeobfuscation.isValidName(false,pname)) {
if (!IdentifiersDeobfuscation.isValidName(false, pname)) {
writer.append(IdentifiersDeobfuscation.makeObfuscatedIdentifier(pname));
}
writer.append(pname);

View File

@@ -50,7 +50,7 @@ public class GetMemberActionItem extends ActionItem {
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
object.toString(writer, localData);
if ((!(memberName instanceof DirectValueActionItem)) || (!((DirectValueActionItem) memberName).isString()) || (!IdentifiersDeobfuscation.isValidName(false,((DirectValueActionItem) memberName).toStringNoQuotes(localData)))) {
if ((!(memberName instanceof DirectValueActionItem)) || (!((DirectValueActionItem) memberName).isString()) || (!IdentifiersDeobfuscation.isValidName(false, ((DirectValueActionItem) memberName).toStringNoQuotes(localData)))) {
writer.append("[");
memberName.toString(writer, localData);
return writer.append("]");

View File

@@ -59,7 +59,7 @@ public class GetVariableActionItem extends ActionItem {
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) && (!IdentifiersDeobfuscation.isValidName(false,((DirectValueActionItem) name).toStringNoQuotes(localData), "this", "super"))) {
if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) && (!IdentifiersDeobfuscation.isValidName(false, ((DirectValueActionItem) name).toStringNoQuotes(localData), "this", "super"))) {
return writer.append(IdentifiersDeobfuscation.makeObfuscatedIdentifier(((DirectValueActionItem) name).toStringNoQuotes(localData)));
} else if ((!(name instanceof DirectValueActionItem)) || (!((DirectValueActionItem) name).isString())) {
writer.append("eval(");

View File

@@ -85,7 +85,7 @@ public class SetMemberActionItem extends ActionItem implements SetTypeActionItem
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
object.toString(writer, localData);
if ((!(objectName instanceof DirectValueActionItem)) || (!((DirectValueActionItem) objectName).isString()) || (!IdentifiersDeobfuscation.isValidName(false,((DirectValueActionItem) objectName).toStringNoQuotes(localData)))) {
if ((!(objectName instanceof DirectValueActionItem)) || (!((DirectValueActionItem) objectName).isString()) || (!IdentifiersDeobfuscation.isValidName(false, ((DirectValueActionItem) objectName).toStringNoQuotes(localData)))) {
writer.append("[");
objectName.toString(writer, localData);
writer.append("]");

View File

@@ -73,7 +73,7 @@ public class SetVariableActionItem extends ActionItem implements SetTypeActionIt
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) && (!IdentifiersDeobfuscation.isValidName(false,((DirectValueActionItem) name).toStringNoQuotes(localData), "this", "super"))) {
if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) && (!IdentifiersDeobfuscation.isValidName(false, ((DirectValueActionItem) name).toStringNoQuotes(localData), "this", "super"))) {
writer.append(IdentifiersDeobfuscation.makeObfuscatedIdentifier(((DirectValueActionItem) name).toStringNoQuotes(localData)));
writer.append(" = ");
return value.toString(writer, localData);

View File

@@ -193,7 +193,7 @@ public class Configuration {
public static final ConfigurationItem<Integer> decompilationTimeoutSingleMethod = null;
@ConfigurationDefaultInt(1)
public static final ConfigurationItem<Integer> lastRenameType = null;
@ConfigurationDefaultString(".")
public static final ConfigurationItem<String> lastSaveDir = null;
@@ -340,32 +340,31 @@ public class Configuration {
public static final ConfigurationItem<String> pluginPath = null;
@ConfigurationDefaultInt(55556)
@ConfigurationCategory("script")
@ConfigurationCategory("script")
public static final ConfigurationItem<Integer> debuggerPort = null;
@ConfigurationDefaultBoolean(false)
@ConfigurationCategory("script")
@ConfigurationCategory("script")
public static final ConfigurationItem<Boolean> randomDebuggerPackage = null;
@ConfigurationDefaultBoolean(true)
public static final ConfigurationItem<Boolean> displayDebuggerInfo = null;
@ConfigurationDefaultString("debugConsole")
public static final ConfigurationItem<String> lastDebuggerReplaceFunction = null;
@ConfigurationDefaultBoolean(true)
@ConfigurationCategory("script")
public static final ConfigurationItem<Boolean> getLocalNamesFromDebugInfo = null;
@ConfigurationDefaultBoolean(false)
@ConfigurationCategory("ui")
public static final ConfigurationItem<Boolean> tagTreeShowEmptyFolders = null;
public static final ConfigurationItem<Boolean> getLocalNamesFromDebugInfo = null;
@ConfigurationDefaultBoolean(false)
@ConfigurationCategory("ui")
public static final ConfigurationItem<Boolean> autoLoadEmbeddedSwfs = null;
public static final ConfigurationItem<Boolean> tagTreeShowEmptyFolders = null;
@ConfigurationDefaultBoolean(false)
@ConfigurationCategory("ui")
public static final ConfigurationItem<Boolean> autoLoadEmbeddedSwfs = null;
private enum OSId {
@@ -494,7 +493,7 @@ public class Configuration {
}
return result;
}
public static void addFontPair(String fileName, int fontId, String fontName, String installedName) {
String key = fileName + "_" + fontId + "_" + fontName;
Map<String, String> fontPairs = getFontToNameMap();

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.exporters;
import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler;
@@ -101,7 +102,7 @@ public class MovieExporter {
if ((videoStream.codecID == DefineVideoStreamTag.CODEC_VP6)
|| (videoStream.codecID == DefineVideoStreamTag.CODEC_VP6_ALPHA)) {
|| (videoStream.codecID == DefineVideoStreamTag.CODEC_VP6_ALPHA)) {
SWFInputStream sis = new SWFInputStream(swf, tag.videoData.getRangeData());
if (videoStream.codecID == DefineVideoStreamTag.CODEC_VP6_ALPHA) {
sis.readUI24("offsetToAlpha"); //offsetToAlpha
}
@@ -135,7 +136,7 @@ public class MovieExporter {
sos.writeUB(4, verticalAdjustment);
}
if (videoStream.codecID == DefineVideoStreamTag.CODEC_SORENSON_H263) {
if (videoStream.codecID == DefineVideoStreamTag.CODEC_SORENSON_H263) {
SWFInputStream sis = new SWFInputStream(swf, tag.videoData.getRangeData());
sis.readUB(17, "pictureStartCode");//pictureStartCode
sis.readUB(5, "version"); //version
sis.readUB(8, "temporalReference"); //temporalReference
@@ -162,7 +163,7 @@ public class MovieExporter {
}
}
baos.write(tag.videoData.getRangeData());
flv.writeTag(new FLVTAG((int) Math.floor(i * 1000.0f / ((float) swf.frameRate)), new VIDEODATA(frameType, videoStream.codecID, baos.toByteArray())));
}
return fos.toByteArray();

View File

@@ -139,7 +139,7 @@ public class SoundExporter {
int ms = (int) (1000.0f / ((float) ((Tag) st).getSwf().frameRate));
for (int b = 0; b < blocks.size(); b++) {
byte[] data = blocks.get(b).streamSoundData;
byte[] data = blocks.get(b).streamSoundData.getRangeData();
if (st.getSoundFormatId() == 2) { //MP3
data = Arrays.copyOfRange(data, 4, data.length);
}

View File

@@ -23,15 +23,15 @@ package com.jpexs.decompiler.flash.exporters.commonshape;
public class PointInt {
public static final PointInt MAX = new PointInt(Integer.MAX_VALUE, Integer.MAX_VALUE);
private int x;
private int y;
private final int x;
private final int y;
public PointInt(int x, int y) {
this.x = x;
this.y = y;
}
public int getX() {
return x;
}

View File

@@ -52,7 +52,7 @@ import java.util.logging.Logger;
* @author JPEXS
*/
public class AS2ScriptExporter {
public List<File> exportAS2ScriptsTimeout(final AbortRetryIgnoreHandler handler, final String outdir, final Collection<ASMSource> asms, final ScriptExportMode exportMode, final EventListener ev) throws IOException {
try {
List<File> result = CancellableWorker.call(new Callable<List<File>>() {
@@ -73,15 +73,15 @@ public class AS2ScriptExporter {
if (!outdir.endsWith(File.separator)) {
outdir += File.separator;
}
outdir += "scripts" + File.separator;
Map<String, List<String>> existingNamesMap = new HashMap<>();
AtomicInteger cnt = new AtomicInteger(1);
for (ASMSource asm : asms) {
String currentOutDir = outdir + getFilePath(asm) + File.separator;
String currentOutDir = outdir + getFilePath(asm) + File.separator;
currentOutDir = new File(currentOutDir).getParentFile().toString() + File.separator;
List<String> existingNames = existingNamesMap.get(currentOutDir);
if (existingNames == null) {
existingNames = new ArrayList<>();
@@ -102,10 +102,10 @@ public class AS2ScriptExporter {
ret.add(f);
}
}
return ret;
}
private File exportAS2Script(AbortRetryIgnoreHandler handler, String outdir, ASMSource asm, ScriptExportMode exportMode, EventListener ev, AtomicInteger index, int count, String name) throws IOException {
boolean retry;
do {
@@ -172,10 +172,10 @@ public class AS2ScriptExporter {
}
}
} while (retry);
return null;
}
// todo: honfika: get the path from the tree
private String getFilePath(ASMSource asm) {
if (asm instanceof DoInitActionTag) {
@@ -192,11 +192,11 @@ public class AS2ScriptExporter {
path += Helper.makeFileName(pathElement);
}
return path;
}
}
}
if (!(asm instanceof Tag)) {
return Helper.makeFileName(asm.getSourceTag().getExportFileName()) + File.separator + Helper.makeFileName(asm.getExportFileName());
} else {
@@ -205,13 +205,13 @@ public class AS2ScriptExporter {
if (timelined instanceof Tag) {
result += Helper.makeFileName(((Tag) timelined).getExportFileName()) + File.separator;
}
Timeline timeline = timelined.getTimeline();
int frame = timeline.getFrameForAction(asm);
if (frame != -1) {
result += "frame_" + (frame + 1) + File.separator;
}
return result + Helper.makeFileName(asm.getExportFileName());
}
}

View File

@@ -373,11 +373,11 @@ public class BitmapExporter extends ShapeExporterBase {
thickness *= Math.max(graphics.getTransform().getScaleX(), graphics.getTransform().getScaleY());
break;
}
if (thickness < 0) {
thickness = -thickness;
}
if (joinStyle == BasicStroke.JOIN_MITER) {
lineStroke = new BasicStroke((float) thickness, capStyle, joinStyle, miterLimit);
} else {

View File

@@ -71,8 +71,6 @@ public class FileTextWriter extends GraphTextWriter implements AutoCloseable {
writeToFile(str);
return this;
}
@Override
public FileTextWriter append(String str, long offset) {

View File

@@ -28,6 +28,6 @@ public class GraphSourceItemPosition {
public GraphSourceItem graphSourceItem;
public int position;
public Map<String,String> data;
public Map<String, String> data;
}

View File

@@ -52,7 +52,7 @@ public abstract class GraphTextWriter {
* @param data
* @return GraphTextWriter
*/
public GraphTextWriter startOffset(GraphSourceItem src, int pos, Map<String,String> data) {
public GraphTextWriter startOffset(GraphSourceItem src, int pos, Map<String, String> data) {
return this;
}
@@ -105,21 +105,20 @@ public abstract class GraphTextWriter {
public GraphTextWriter hilightSpecial(String text, String type) {
return hilightSpecial(text, type, "0");
}
public GraphTextWriter hilightSpecial(String text, String type, int index) {
return hilightSpecial(text, type, ""+index);
return hilightSpecial(text, type, "" + index);
}
public GraphTextWriter hilightSpecial(String text, String type, String index) {
return hilightSpecial(text, type, "0", new HashMap<String, String>());
}
public GraphTextWriter hilightSpecial(String text, String type, int index, Map<String,String> data) {
return hilightSpecial(text, type, ""+index, data);
public GraphTextWriter hilightSpecial(String text, String type, int index, Map<String, String> data) {
return hilightSpecial(text, type, "" + index, data);
}
public GraphTextWriter hilightSpecial(String text, String type, String index, Map<String,String> data) {
public GraphTextWriter hilightSpecial(String text, String type, String index, Map<String, String> data) {
return this;
}
@@ -127,8 +126,8 @@ public abstract class GraphTextWriter {
return "";
}
public abstract GraphTextWriter appendWithData(String str, Map<String,String> data);
public abstract GraphTextWriter appendWithData(String str, Map<String, String> data);
public abstract GraphTextWriter append(String str);
public abstract GraphTextWriter append(String str, long offset);

View File

@@ -73,7 +73,7 @@ public class HilightedTextWriter extends GraphTextWriter {
* @return HilightedTextWriter
*/
@Override
public HilightedTextWriter startOffset(GraphSourceItem src, int pos, Map<String,String> data) {
public HilightedTextWriter startOffset(GraphSourceItem src, int pos, Map<String, String> data) {
GraphSourceItemPosition itemPos = new GraphSourceItemPosition();
itemPos.graphSourceItem = src;
itemPos.position = pos;
@@ -157,30 +157,26 @@ public class HilightedTextWriter extends GraphTextWriter {
Map<String, String> ndata = new HashMap<>();
ndata.putAll(data);
ndata.put("subtype", type);
ndata.put("index", index);
ndata.put("index", index);
start(ndata, HilightType.SPECIAL);
appendNoHilight(text);
return end(HilightType.SPECIAL);
}
@Override
public HilightedTextWriter append(String str) {
return appendWithData(str, new HashMap<String, String>());
}
@Override
public HilightedTextWriter appendWithData(String str, Map<String,String> data) {
public HilightedTextWriter appendWithData(String str, Map<String, String> data) {
Highlighting h = null;
if (!offsets.empty()) {
GraphSourceItemPosition itemPos = offsets.peek();
GraphSourceItem src = itemPos.graphSourceItem;
int pos = itemPos.position;
if (src != null && hilight) {
Map<String,String> ndata=new HashMap<>();
Map<String, String> ndata = new HashMap<>();
ndata.putAll(itemPos.data);
ndata.putAll(data);
ndata.put("offset", Long.toString(src.getOffset() + pos + 1));

View File

@@ -109,8 +109,6 @@ public class NulWriter extends GraphTextWriter {
stringAdded = true;
return this;
}
@Override
public NulWriter append(String str) {
@@ -123,8 +121,6 @@ public class NulWriter extends GraphTextWriter {
stringAdded = true;
return this;
}
@Override
public NulWriter append(String str, long offset) {

View File

@@ -59,8 +59,6 @@ public class Highlighting implements Serializable {
return new HashMap<>(properties);
}
public String getPropertyString(String key) {
return properties.get(key);
}
@@ -72,27 +70,29 @@ public class Highlighting implements Serializable {
public static Highlighting search(List<Highlighting> list, String property, String value) {
return search(list, -1, property, value, -1, -1);
}
public static Highlighting search(List<Highlighting> list, Map<String,String> properties) {
public static Highlighting search(List<Highlighting> list, Map<String, String> properties) {
return search(list, -1, properties, -1, -1);
}
public static Highlighting search(List<Highlighting> list, String property, String value, int from, int to) {
return search(list, -1, property, value, from, to);
}
public static Highlighting search(List<Highlighting> list, Map<String,String> properties, int from, int to) {
public static Highlighting search(List<Highlighting> list, Map<String, String> properties, int from, int to) {
return search(list, -1, properties, from, to);
}
public static Highlighting search(List<Highlighting> list, long pos, String property, String value, long from, long to) {
Map<String,String> map= new HashMap<>();
Map<String, String> map = new HashMap<>();
map.put(property, value);
return search(list, pos, map, from, to);
}
public static Highlighting search(List<Highlighting> list, long pos, Map<String,String> properties, long from, long to) {
public static Highlighting search(List<Highlighting> list, long pos, Map<String, String> properties, long from, long to) {
Highlighting ret = null;
looph:for (Highlighting h : list) {
looph:
for (Highlighting h : list) {
if (from > -1) {
if (h.startPos < from) {
continue;
@@ -103,7 +103,7 @@ public class Highlighting implements Serializable {
continue;
}
}
for(String property:properties.keySet()){
for (String property : properties.keySet()) {
if (property != null) {
String v = h.getPropertyString(property);
String value = properties.get(property);
@@ -118,7 +118,7 @@ public class Highlighting implements Serializable {
}
}
}
if (pos == -1 || (pos >= h.startPos && (pos < h.startPos + h.len))) {
if (ret == null || h.startPos > ret.startPos) { //get the closest one
ret = h;
@@ -163,13 +163,13 @@ public class Highlighting implements Serializable {
continue;
}
}
if (pos == -1 ||(pos >= h.startPos && (pos < h.startPos + h.len))) {
if (pos == -1 || (pos >= h.startPos && (pos < h.startPos + h.len))) {
//if (ret == null || h.startPos > ret.startPos) { //get the closest one
ret.add(h);
ret.add(h);
//}
}
//if (pos == -1) {
// return ret;
// return ret;
//}
}

View File

@@ -85,6 +85,7 @@ public class CSMTextSettingsTag extends Tag {
/**
* Constructor
*
* @param swf
*/
public CSMTextSettingsTag(SWF swf) {

View File

@@ -58,6 +58,7 @@ public class DebugIDTag extends Tag {
/**
* Constructor
*
* @param swf
*/
public DebugIDTag(SWF swf) {

View File

@@ -48,7 +48,7 @@ public class DefineBinaryDataTag extends CharacterTag {
@Internal
public SWF innerSwf;
/**
* Gets data bytes
*
@@ -71,6 +71,7 @@ public class DefineBinaryDataTag extends CharacterTag {
/**
* Constructor
*
* @param swf
*/
public DefineBinaryDataTag(SWF swf) {
@@ -90,6 +91,7 @@ public class DefineBinaryDataTag extends CharacterTag {
SWF bswf = new SWF(new ByteArrayInputStream(binaryData), Configuration.parallelSpeedUp.get());
bswf.fileTitle = "(SWF Data)";
innerSwf = bswf;
bswf.binaryData = this;
} catch (IOException | InterruptedException ex) {
//ignore
}
@@ -100,7 +102,7 @@ public class DefineBinaryDataTag extends CharacterTag {
public int getCharacterId() {
return tag;
}
public boolean isSwfData() {
try {
if (binaryData.length > 8) {
@@ -117,7 +119,7 @@ public class DefineBinaryDataTag extends CharacterTag {
}
} catch (Exception ex) {
}
return false;
}
}

View File

@@ -39,7 +39,7 @@ public class DefineBitsJPEG2Tag extends ImageTag implements AloneTag {
public int characterID;
@SWFType(BasicType.UI8)
public byte[] imageData;
public ByteArrayRange imageData;
public static final int ID = 21;
@@ -56,9 +56,9 @@ public class DefineBitsJPEG2Tag extends ImageTag implements AloneTag {
@Override
public InputStream getImageData() {
if (SWF.hasErrorHeader(imageData)) {
return new ByteArrayInputStream(imageData, 4, imageData.length - 4);
return new ByteArrayInputStream(imageData.getArray(), imageData.getPos() + 4, imageData.getLength() - 4);
}
return new ByteArrayInputStream(imageData);
return new ByteArrayInputStream(imageData.getArray(), imageData.getPos(), imageData.getLength());
}
@Override
@@ -73,29 +73,30 @@ public class DefineBitsJPEG2Tag extends ImageTag implements AloneTag {
/**
* Constructor
*
* @param swf
*/
public DefineBitsJPEG2Tag(SWF swf) {
super(swf, ID, "DefineBitsJPEG2", null);
characterID = swf.getNextCharacterId();
imageData = new byte[0];
imageData = ByteArrayRange.EMPTY;
}
public DefineBitsJPEG2Tag(SWFInputStream sis, ByteArrayRange data) throws IOException {
super(sis.getSwf(), ID, "DefineBitsJPEG2", data);
characterID = sis.readUI16("characterID");
imageData = sis.readBytesEx(sis.available(), "imageData");
imageData = sis.readByteRangeEx(sis.available(), "imageData");
}
public DefineBitsJPEG2Tag(SWF swf, ByteArrayRange data, int characterID, byte[] imageData) throws IOException {
super(swf, ID, "DefineBitsJPEG2", data);
this.characterID = characterID;
this.imageData = imageData;
this.imageData = new ByteArrayRange(imageData);
}
@Override
public void setImage(byte[] data) {
imageData = data;
imageData = new ByteArrayRange(data);
setModified(true);
}

View File

@@ -39,7 +39,7 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag {
public int characterID;
@SWFType(BasicType.UI8)
public byte[] imageData;
public ByteArrayRange imageData;
@SWFType(BasicType.UI8)
public byte[] bitmapAlphaData;
@@ -63,7 +63,7 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag {
} else {
bitmapAlphaData = new byte[0];
}
imageData = data;
imageData = new ByteArrayRange(data);
setModified(true);
}
@@ -86,9 +86,9 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag {
try {
InputStream stream;
if (SWF.hasErrorHeader(imageData)) {
stream = new ByteArrayInputStream(imageData, 4, imageData.length - 4);
stream = new ByteArrayInputStream(imageData.getArray(), imageData.getPos() + 4, imageData.getLength() - 4);
} else {
stream = new ByteArrayInputStream(imageData);
stream = new ByteArrayInputStream(imageData.getArray(), imageData.getPos(), imageData.getLength());
}
BufferedImage image = ImageIO.read(stream);
SerializableImage img = image == null ? null : new SerializableImage(image);
@@ -112,12 +112,13 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag {
/**
* Constructor
*
* @param swf
*/
public DefineBitsJPEG3Tag(SWF swf) {
super(swf, ID, "DefineBitsJPEG3", null);
characterID = swf.getNextCharacterId();
imageData = new byte[0];
imageData = ByteArrayRange.EMPTY;
bitmapAlphaData = new byte[0];
}
@@ -125,7 +126,7 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag {
super(sis.getSwf(), ID, "DefineBitsJPEG3", data);
characterID = sis.readUI16("characterID");
long alphaDataOffset = sis.readUI32("alphaDataOffset");
imageData = sis.readBytesEx(alphaDataOffset, "imageData");
imageData = sis.readByteRangeEx(alphaDataOffset, "imageData");
bitmapAlphaData = sis.readBytesZlib(sis.available(), "bitmapAlphaData");
}
@@ -141,7 +142,7 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag {
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterID);
sos.writeUI32(imageData.length);
sos.writeUI32(imageData.getLength());
sos.write(imageData);
sos.writeBytesZlib(bitmapAlphaData);
} catch (IOException e) {

View File

@@ -47,10 +47,10 @@ public class DefineBitsJPEG4Tag extends ImageTag implements AloneTag {
public int deblockParam;
@SWFType(BasicType.UI8)
public byte[] imageData;
public ByteArrayRange imageData;
@SWFType(BasicType.UI8)
public byte[] bitmapAlphaData;
public ByteArrayRange bitmapAlphaData;
public static final int ID = 90;
@@ -70,16 +70,16 @@ public class DefineBitsJPEG4Tag extends ImageTag implements AloneTag {
@Override
public void setImage(byte[] data) {
imageData = data;
imageData = new ByteArrayRange(data);
if (ImageTag.getImageFormat(data).equals("jpg")) {
SerializableImage image = getImage();
byte[] ba = new byte[image.getWidth() * image.getHeight()];
for (int i = 0; i < ba.length; i++) {
ba[i] = (byte) 255;
}
bitmapAlphaData = ba;
bitmapAlphaData = new ByteArrayRange(ba);
} else {
bitmapAlphaData = new byte[0];
bitmapAlphaData = ByteArrayRange.EMPTY;
}
setModified(true);
}
@@ -92,16 +92,16 @@ public class DefineBitsJPEG4Tag extends ImageTag implements AloneTag {
@Override
public SerializableImage getImage() {
try {
BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageData));
BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageData.getArray(), imageData.getPos(), imageData.getLength()));
SerializableImage img = image == null ? null : new SerializableImage(image);
if (bitmapAlphaData.length == 0) {
if (bitmapAlphaData.getLength() == 0) {
return img;
}
SerializableImage img2 = new SerializableImage(img.getWidth(), img.getHeight(), SerializableImage.TYPE_INT_ARGB);
for (int y = 0; y < img.getHeight(); y++) {
for (int x = 0; x < img.getWidth(); x++) {
int val = img.getRGB(x, y);
int a = bitmapAlphaData[x + y * img.getWidth()] & 0xff;
int a = bitmapAlphaData.get(x + y * img.getWidth()) & 0xff;
val = (val & 0xffffff) | (a << 24);
img2.setRGB(x, y, colorToInt(multiplyAlpha(intToColor(val))));
}
@@ -124,7 +124,7 @@ public class DefineBitsJPEG4Tag extends ImageTag implements AloneTag {
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterID);
sos.writeUI32(imageData.length);
sos.writeUI32(imageData.getLength());
sos.writeUI16(deblockParam);
sos.write(imageData);
sos.write(bitmapAlphaData);
@@ -136,13 +136,14 @@ public class DefineBitsJPEG4Tag extends ImageTag implements AloneTag {
/**
* Constructor
*
* @param swf
*/
public DefineBitsJPEG4Tag(SWF swf) {
super(swf, ID, "DefineBitsJPEG4", null);
characterID = swf.getNextCharacterId();
imageData = new byte[0];
bitmapAlphaData = new byte[0];
imageData = ByteArrayRange.EMPTY;
bitmapAlphaData = ByteArrayRange.EMPTY;
}
/**
@@ -157,7 +158,7 @@ public class DefineBitsJPEG4Tag extends ImageTag implements AloneTag {
characterID = sis.readUI16("characterID");
long alphaDataOffset = sis.readUI32("alphaDataOffset");
deblockParam = sis.readUI16("deblockParam");
imageData = sis.readBytesEx(alphaDataOffset, "imageData");
bitmapAlphaData = sis.readBytesEx(sis.available(), "bitmapAlphaData");
imageData = sis.readByteRangeEx(alphaDataOffset, "imageData");
bitmapAlphaData = sis.readByteRangeEx(sis.available(), "bitmapAlphaData");
}
}

View File

@@ -59,7 +59,7 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag {
@Conditional(value = "bitmapFormat", options = {FORMAT_8BIT_COLORMAPPED})
public int bitmapColorTableSize;
public byte[] zlibBitmapData; //TODO: Parse ALPHACOLORMAPDATA,ALPHABITMAPDATA
public ByteArrayRange zlibBitmapData; //TODO: Parse ALPHACOLORMAPDATA,ALPHABITMAPDATA
public static final int FORMAT_8BIT_COLORMAPPED = 3;
public static final int FORMAT_32BIT_ARGB = 5;
@@ -125,13 +125,14 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag {
ByteArrayOutputStream zlibOS = new ByteArrayOutputStream();
SWFOutputStream sos2 = new SWFOutputStream(zlibOS, getVersion());
sos2.writeBytesZlib(bitmapDataOS.toByteArray());
zlibBitmapData = zlibOS.toByteArray();
zlibBitmapData = new ByteArrayRange(zlibOS.toByteArray());
decompressed = false;
setModified(true);
}
/**
* Constructor
*
* @param swf
*/
public DefineBitsLossless2Tag(SWF swf) {
@@ -140,7 +141,7 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag {
bitmapFormat = DefineBitsLossless2Tag.FORMAT_32BIT_ARGB;
bitmapWidth = 1;
bitmapHeight = 1;
zlibBitmapData = createEmptyImage();
zlibBitmapData = new ByteArrayRange(createEmptyImage());
}
public DefineBitsLossless2Tag(SWFInputStream sis, ByteArrayRange data) throws IOException {
@@ -152,7 +153,7 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag {
if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) {
bitmapColorTableSize = sis.readUI8("bitmapColorTableSize");
}
zlibBitmapData = sis.readBytesEx(sis.available(), "zlibBitmapData");
zlibBitmapData = sis.readByteRangeEx(sis.available(), "zlibBitmapData");
}
private ALPHACOLORMAPDATA colorMapData;
private ALPHABITMAPDATA bitmapData;
@@ -174,7 +175,7 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag {
private void uncompressData() {
try {
SWFInputStream sis = new SWFInputStream(swf, Helper.readStream(new InflaterInputStream(new ByteArrayInputStream(zlibBitmapData))));
SWFInputStream sis = new SWFInputStream(swf, Helper.readStream(new InflaterInputStream(new ByteArrayInputStream(zlibBitmapData.getArray(), zlibBitmapData.getPos(), zlibBitmapData.getLength()))));
if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) {
colorMapData = sis.readALPHACOLORMAPDATA(bitmapColorTableSize, bitmapWidth, bitmapHeight, "colorMapData");
}

View File

@@ -61,7 +61,7 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag {
@Conditional(value = "bitmapFormat", options = {FORMAT_8BIT_COLORMAPPED})
public int bitmapColorTableSize;
public byte[] zlibBitmapData; //TODO: Parse COLORMAPDATA,BITMAPDATA
public ByteArrayRange zlibBitmapData; //TODO: Parse COLORMAPDATA,BITMAPDATA
public static final int FORMAT_8BIT_COLORMAPPED = 3;
public static final int FORMAT_15BIT_RGB = 4;
public static final int FORMAT_24BIT_RGB = 5;
@@ -124,7 +124,7 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag {
ByteArrayOutputStream zlibOS = new ByteArrayOutputStream();
SWFOutputStream sos2 = new SWFOutputStream(zlibOS, getVersion());
sos2.writeBytesZlib(bitmapDataOS.toByteArray());
zlibBitmapData = zlibOS.toByteArray();
zlibBitmapData = new ByteArrayRange(zlibOS.toByteArray());
decompressed = false;
setModified(true);
}
@@ -192,7 +192,7 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag {
private void uncompressData() {
try {
SWFInputStream sis = new SWFInputStream(swf, Helper.readStream(new InflaterInputStream(new ByteArrayInputStream(zlibBitmapData))));
SWFInputStream sis = new SWFInputStream(swf, Helper.readStream(new InflaterInputStream(new ByteArrayInputStream(zlibBitmapData.getArray(), zlibBitmapData.getPos(), zlibBitmapData.getLength()))));
if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) {
colorMapData = sis.readCOLORMAPDATA(bitmapColorTableSize, bitmapWidth, bitmapHeight, "colorMapData");
}
@@ -206,6 +206,7 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag {
/**
* Constructor
*
* @param swf
*/
public DefineBitsLosslessTag(SWF swf) {
@@ -214,7 +215,7 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag {
bitmapFormat = DefineBitsLosslessTag.FORMAT_24BIT_RGB;
bitmapWidth = 1;
bitmapHeight = 1;
zlibBitmapData = createEmptyImage();
zlibBitmapData = new ByteArrayRange(createEmptyImage());
}
public DefineBitsLosslessTag(SWFInputStream sis, ByteArrayRange data) throws IOException {
@@ -226,7 +227,7 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag {
if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) {
bitmapColorTableSize = sis.readUI8("bitmapColorTableSize");
}
zlibBitmapData = sis.readBytesEx(sis.available(), "zlibBitmapData");
zlibBitmapData = sis.readByteRangeEx(sis.available(), "zlibBitmapData");
}
/**

View File

@@ -38,7 +38,7 @@ public class DefineBitsTag extends ImageTag {
public int characterID;
@SWFType(BasicType.UI8)
public byte[] jpegData;
public ByteArrayRange jpegData;
@Internal
private JPEGTablesTag jtt = null;
@@ -57,18 +57,19 @@ public class DefineBitsTag extends ImageTag {
/**
* Constructor
*
* @param swf
*/
public DefineBitsTag(SWF swf) {
super(swf, ID, "DefineBits", null);
characterID = swf.getNextCharacterId();
jpegData = new byte[0];
jpegData = ByteArrayRange.EMPTY;
}
public DefineBitsTag(SWFInputStream sis, ByteArrayRange data) throws IOException {
super(sis.getSwf(), ID, "DefineBits", data);
characterID = sis.readUI16("characterID");
jpegData = sis.readBytesEx(sis.available(), "jpegData");
jpegData = sis.readByteRangeEx(sis.available(), "jpegData");
}
private void getJPEGTables() {
@@ -94,10 +95,11 @@ public class DefineBitsTag extends ImageTag {
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
byte[] jttdata = jtt.jpegData;
if (jttdata.length != 0) {
baos.write(jttdata, SWF.hasErrorHeader(jttdata) ? 4 : 0, jttdata.length - (SWF.hasErrorHeader(jttdata) ? 6 : 2));
baos.write(jpegData, SWF.hasErrorHeader(jpegData) ? 6 : 2, jpegData.length - (SWF.hasErrorHeader(jttdata) ? 6 : 2));
boolean jttError = SWF.hasErrorHeader(jttdata);
baos.write(jttdata, jttError ? 4 : 0, jttdata.length - (jttError ? 6 : 2));
baos.write(jpegData.getArray(), jpegData.getPos() + (SWF.hasErrorHeader(jpegData) ? 6 : 2), jpegData.getLength() - (jttError ? 6 : 2));
} else {
baos.write(jpegData, 0, jpegData.length);
baos.write(jpegData.getArray(), jpegData.getPos(), jpegData.getLength());
}
return new SerializableImage(ImageIO.read(new ByteArrayInputStream(baos.toByteArray())));
} catch (IOException ex) {

View File

@@ -96,6 +96,7 @@ public class DefineButton2Tag extends ButtonTag implements Container {
/**
* Constructor
*
* @param swf
*/
public DefineButton2Tag(SWF swf) {

View File

@@ -60,6 +60,7 @@ public class DefineButtonCxformTag extends Tag {
/**
* Constructor
*
* @param swf
*/
public DefineButtonCxformTag(SWF swf) {

View File

@@ -100,6 +100,7 @@ public class DefineButtonSoundTag extends CharacterIdTag {
/**
* Constructor
*
* @param swf
*/
public DefineButtonSoundTag(SWF swf) {

View File

@@ -96,6 +96,7 @@ public class DefineButtonTag extends ButtonTag implements ASMSource {
/**
* Constructor
*
* @param swf
*/
public DefineButtonTag(SWF swf) {
@@ -116,13 +117,7 @@ public class DefineButtonTag extends ButtonTag implements ASMSource {
super(sis.getSwf(), ID, "DefineButton", data);
buttonId = sis.readUI16("buttonId");
characters = sis.readBUTTONRECORDList(false, "characters");
int pos = (int) sis.getPos();
byte[] bytes = sis.readBytesEx(sis.available(), "actionBytes");
if (data != null) {
actionBytes = new ByteArrayRange(data.getArray(), pos, bytes.length);
} else {
actionBytes = new ByteArrayRange(bytes, 0, bytes.length);
}
actionBytes = sis.readByteRangeEx(sis.available(), "actionBytes");
}
/**

View File

@@ -703,6 +703,7 @@ public class DefineEditTextTag extends TextTag {
/**
* Constructor
*
* @param swf
*/
public DefineEditTextTag(SWF swf) {

View File

@@ -193,6 +193,7 @@ public class DefineFont2Tag extends FontTag {
/**
* Constructor
*
* @param swf
*/
public DefineFont2Tag(SWF swf) {

View File

@@ -113,6 +113,7 @@ public class DefineFont3Tag extends FontTag {
/**
* Constructor
*
* @param swf
*/
public DefineFont3Tag(SWF swf) {

View File

@@ -50,6 +50,7 @@ public class DefineFont4Tag extends CharacterTag {
/**
* Constructor
*
* @param swf
*/
public DefineFont4Tag(SWF swf) {

View File

@@ -46,6 +46,7 @@ public class DefineFontAlignZonesTag extends Tag {
/**
* Constructor
*
* @param swf
*/
public DefineFontAlignZonesTag(SWF swf) {

View File

@@ -28,7 +28,6 @@ import com.jpexs.helpers.utf8.Utf8Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.List;
@@ -90,6 +89,7 @@ public class DefineFontInfo2Tag extends Tag {
/**
* Constructor
*
* @param swf
*/
public DefineFontInfo2Tag(SWF swf) {

View File

@@ -90,6 +90,7 @@ public class DefineFontInfoTag extends Tag {
/**
* Constructor
*
* @param swf
*/
public DefineFontInfoTag(SWF swf) {

View File

@@ -36,6 +36,7 @@ public class DefineFontNameTag extends Tag {
/**
* Constructor
*
* @param swf
*/
public DefineFontNameTag(SWF swf) {

View File

@@ -138,6 +138,7 @@ public class DefineFontTag extends FontTag {
/**
* Constructor
*
* @param swf
*/
public DefineFontTag(SWF swf) {
@@ -145,7 +146,7 @@ public class DefineFontTag extends FontTag {
fontId = swf.getNextCharacterId();
glyphShapeTable = new ArrayList<>();
}
/**
* Constructor
*

View File

@@ -152,6 +152,7 @@ public class DefineMorphShape2Tag extends CharacterTag implements MorphShapeTag
/**
* Constructor
*
* @param swf
*/
public DefineMorphShape2Tag(SWF swf) {

View File

@@ -130,6 +130,7 @@ public class DefineMorphShapeTag extends CharacterTag implements MorphShapeTag {
/**
* Constructor
*
* @param swf
*/
public DefineMorphShapeTag(SWF swf) {

View File

@@ -39,6 +39,7 @@ public class DefineScalingGridTag extends Tag {
/**
* Constructor
*
* @param swf
*/
public DefineScalingGridTag(SWF swf) {

View File

@@ -79,13 +79,14 @@ public class DefineSceneAndFrameLabelDataTag extends Tag {
/**
* Constructor
*
* @param swf
*/
public DefineSceneAndFrameLabelDataTag(SWF swf) {
super(swf, ID, "DefineSceneAndFrameLabelData", null);
sceneOffsets = new long[0];
sceneNames = new String[0];
frameNums= new long[0];
frameNums = new long[0];
frameNames = new String[0];
}

View File

@@ -60,7 +60,7 @@ public class DefineShape2Tag extends ShapeTag {
Logger.getLogger(DefineShape2Tag.class.getName()).log(Level.SEVERE, null, ex);
}
}
return shapes;
}
@@ -90,6 +90,7 @@ public class DefineShape2Tag extends ShapeTag {
/**
* Constructor
*
* @param swf
*/
public DefineShape2Tag(SWF swf) {

View File

@@ -60,7 +60,7 @@ public class DefineShape3Tag extends ShapeTag {
Logger.getLogger(DefineShape3Tag.class.getName()).log(Level.SEVERE, null, ex);
}
}
return shapes;
}
@@ -90,6 +90,7 @@ public class DefineShape3Tag extends ShapeTag {
/**
* Constructor
*
* @param swf
*/
public DefineShape3Tag(SWF swf) {

View File

@@ -68,7 +68,7 @@ public class DefineShape4Tag extends ShapeTag {
Logger.getLogger(DefineShape4Tag.class.getName()).log(Level.SEVERE, null, ex);
}
}
return shapes;
}
@@ -98,6 +98,7 @@ public class DefineShape4Tag extends ShapeTag {
/**
* Constructor
*
* @param swf
*/
public DefineShape4Tag(SWF swf) {

View File

@@ -39,7 +39,7 @@ public class DefineShapeTag extends ShapeTag {
public RECT shapeBounds;
public SHAPEWITHSTYLE shapes;
public static final int ID = 2;
private ByteArrayRange shapeData;
@Override
@@ -59,7 +59,7 @@ public class DefineShapeTag extends ShapeTag {
Logger.getLogger(DefineShapeTag.class.getName()).log(Level.SEVERE, null, ex);
}
}
return shapes;
}
@@ -84,6 +84,7 @@ public class DefineShapeTag extends ShapeTag {
/**
* Constructor
*
* @param swf
*/
public DefineShapeTag(SWF swf) {

View File

@@ -63,7 +63,7 @@ public class DefineSoundTag extends CharacterTag implements SoundTag {
@SWFType(BasicType.UI32)
public long soundSampleCount;
public byte[] soundData;
public ByteArrayRange soundData;
public static final int ID = 14;
@Override
@@ -98,12 +98,13 @@ public class DefineSoundTag extends CharacterTag implements SoundTag {
/**
* Constructor
*
* @param swf
*/
public DefineSoundTag(SWF swf) {
super(swf, ID, "DefineSound", null);
soundId = swf.getNextCharacterId();
soundData = new byte[] {0};
soundData = ByteArrayRange.EMPTY;
}
/**
@@ -121,7 +122,7 @@ public class DefineSoundTag extends CharacterTag implements SoundTag {
soundSize = sis.readUB(1, "soundSize") == 1;
soundType = sis.readUB(1, "soundType") == 1;
soundSampleCount = sis.readUI32("soundSampleCount");
soundData = sis.readBytesEx(sis.available(), "soundData");
soundData = sis.readByteRangeEx(sis.available(), "soundData");
}
@Override
@@ -290,7 +291,7 @@ public class DefineSoundTag extends CharacterTag implements SoundTag {
this.soundSize = newSoundSize;
this.soundRate = newSoundRate;
this.soundSampleCount = newSoundSampleCount;
this.soundData = newSoundData;
this.soundData = new ByteArrayRange(newSoundData);
this.soundType = newSoundType;
this.soundFormat = newSoundFormat;
setModified(true);
@@ -319,10 +320,11 @@ public class DefineSoundTag extends CharacterTag implements SoundTag {
public List<byte[]> getRawSoundData() {
List<byte[]> ret = new ArrayList<>();
if (soundFormat == SoundFormat.FORMAT_MP3) {
ret.add(Arrays.copyOfRange(soundData, 2, soundData.length));
ret.add(soundData.getRangeData(2, soundData.getLength() - 2));
return ret;
}
ret.add(soundData);
ret.add(soundData.getRangeData());
return ret;
}

View File

@@ -191,6 +191,7 @@ public class DefineSpriteTag extends CharacterTag implements Container, Drawable
/**
* Constructor
*
* @param swf
*/
public DefineSpriteTag(SWF swf) {
@@ -314,7 +315,7 @@ public class DefineSpriteTag extends CharacterTag implements Container, Drawable
public int getNumFrames() {
return frameCount;
}
private int getRealFrameCount() {
int cnt = 1;
List<Frame> frames = getTimeline().getFrames();
@@ -323,7 +324,7 @@ public class DefineSpriteTag extends CharacterTag implements Container, Drawable
cnt++;
}
}
return cnt;
}

View File

@@ -475,6 +475,7 @@ public class DefineText2Tag extends TextTag {
/**
* Constructor
*
* @param swf
*/
public DefineText2Tag(SWF swf) {

View File

@@ -436,6 +436,7 @@ public class DefineTextTag extends TextTag {
/**
* Constructor
*
* @param swf
*/
public DefineTextTag(SWF swf) {

View File

@@ -100,6 +100,7 @@ public class DefineVideoStreamTag extends CharacterTag implements BoundedTag {
/**
* Constructor
*
* @param swf
*/
public DefineVideoStreamTag(SWF swf) {

View File

@@ -67,6 +67,7 @@ public class DoABCDefineTag extends Tag implements ABCContainerTag {
/**
* Constructor
*
* @param swf
*/
public DoABCDefineTag(SWF swf) {
@@ -89,7 +90,7 @@ public class DoABCDefineTag extends Tag implements ABCContainerTag {
ABCInputStream ais = new ABCInputStream(sis.getBaseStream());
// put it to the dumpview:
sis.readBytesEx(sis.available(), "abcBytes");
sis.readByteRangeEx(sis.available(), "abcBytes");
abc = new ABC(ais, swf, this);
}
@@ -99,8 +100,6 @@ public class DoABCDefineTag extends Tag implements ABCContainerTag {
abc.swf = swf;
}
/**
* Gets data bytes
*

View File

@@ -54,6 +54,7 @@ public class DoABCTag extends Tag implements ABCContainerTag {
/**
* Constructor
*
* @param swf
*/
public DoABCTag(SWF swf) {
@@ -73,7 +74,7 @@ public class DoABCTag extends Tag implements ABCContainerTag {
ABCInputStream ais = new ABCInputStream(sis.getBaseStream());
// put it to the dumpview:
sis.readBytesEx(sis.available(), "abcBytes");
sis.readByteRangeEx(sis.available(), "abcBytes");
abc = new ABC(ais, swf, this);
}
@@ -109,6 +110,5 @@ public class DoABCTag extends Tag implements ABCContainerTag {
super.setSwf(swf);
abc.swf = swf;
}
}

View File

@@ -50,6 +50,7 @@ public class DoActionTag extends Tag implements ASMSource {
/**
* Constructor
*
* @param swf
*/
public DoActionTag(SWF swf) {
@@ -65,9 +66,7 @@ public class DoActionTag extends Tag implements ASMSource {
*/
public DoActionTag(SWFInputStream sis, ByteArrayRange data) throws IOException {
super(sis.getSwf(), ID, "DoAction", data);
int pos = (int) sis.getPos();
byte[] bytes = sis.readBytesEx(sis.available(), "actionBytes");
actionBytes = new ByteArrayRange(data.getArray(), pos, bytes.length);
actionBytes = sis.readByteRangeEx(sis.available(), "actionBytes");
}
/**

View File

@@ -56,6 +56,7 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource {
/**
* Constructor
*
* @param swf
*/
public DoInitActionTag(SWF swf) {
@@ -72,9 +73,7 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource {
public DoInitActionTag(SWFInputStream sis, ByteArrayRange data) throws IOException {
super(sis.getSwf(), ID, "DoInitAction", data);
spriteId = sis.readUI16("spriteId");
int pos = (int) sis.getPos();
byte[] bytes = sis.readBytesEx(sis.available(), "actionBytes");
actionBytes = new ByteArrayRange(data.getArray(), pos, bytes.length);
actionBytes = sis.readByteRangeEx(sis.available(), "actionBytes");
}
/**

View File

@@ -65,6 +65,7 @@ public class EnableDebugger2Tag extends Tag {
/**
* Constructor
*
* @param swf
*/
public EnableDebugger2Tag(SWF swf) {

View File

@@ -59,6 +59,7 @@ public class EnableDebuggerTag extends Tag {
/**
* Constructor
*
* @param swf
*/
public EnableDebuggerTag(SWF swf) {

View File

@@ -68,6 +68,7 @@ public class EnableTelemetryTag extends Tag {
/**
* Constructor
*
* @param swf
*/
public EnableTelemetryTag(SWF swf) {

View File

@@ -41,6 +41,7 @@ public class EndTag extends Tag {
/**
* Constructor
*
* @param swf
*/
public EndTag(SWF swf) {

View File

@@ -49,6 +49,7 @@ public class ExportAssetsTag extends Tag {
/**
* Constructor
*
* @param swf
*/
public ExportAssetsTag(SWF swf) {

View File

@@ -47,6 +47,7 @@ public class FileAttributesTag extends Tag {
/**
* Constructor
*
* @param swf
*/
public FileAttributesTag(SWF swf) {

View File

@@ -40,6 +40,7 @@ public class FrameLabelTag extends Tag {
/**
* Constructor
*
* @param swf
*/
public FrameLabelTag(SWF swf) {

View File

@@ -59,6 +59,7 @@ public class ImportAssets2Tag extends Tag implements ImportTag {
/**
* Constructor
*
* @param swf
*/
public ImportAssets2Tag(SWF swf) {

View File

@@ -52,6 +52,7 @@ public class ImportAssetsTag extends Tag implements ImportTag {
/**
* Constructor
*
* @param swf
*/
public ImportAssetsTag(SWF swf) {

View File

@@ -33,6 +33,7 @@ public class JPEGTablesTag extends Tag {
/**
* Constructor
*
* @param swf
*/
public JPEGTablesTag(SWF swf) {

View File

@@ -33,6 +33,7 @@ public class MetadataTag extends Tag {
/**
* Constructor
*
* @param swf
*/
public MetadataTag(SWF swf) {

View File

@@ -194,6 +194,7 @@ public class PlaceObject2Tag extends CharacterIdTag implements Container, PlaceO
/**
* Constructor
*
* @param swf
*/
public PlaceObject2Tag(SWF swf) {

View File

@@ -299,6 +299,7 @@ public class PlaceObject3Tag extends CharacterIdTag implements Container, PlaceO
/**
* Constructor
*
* @param swf
*/
public PlaceObject3Tag(SWF swf) {

View File

@@ -301,6 +301,7 @@ public class PlaceObject4Tag extends CharacterIdTag implements Container, PlaceO
/**
* Constructor
*
* @param swf
*/
public PlaceObject4Tag(SWF swf) {

View File

@@ -100,6 +100,7 @@ public class PlaceObjectTag extends CharacterIdTag implements PlaceObjectTypeTag
/**
* Constructor
*
* @param swf
*/
public PlaceObjectTag(SWF swf) {

Some files were not shown because too many files have changed in this diff Show More