mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-28 13:37:46 +00:00
cleanup
This commit is contained in:
192
src/com/jpexs/browsers/cache/ChunkedInputStream.java
vendored
192
src/com/jpexs/browsers/cache/ChunkedInputStream.java
vendored
@@ -1,96 +1,96 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.browsers.cache;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ChunkedInputStream extends InputStream {
|
||||
|
||||
private final InputStream is;
|
||||
private int chunkPos = 0;
|
||||
private int chunkLen = 0;
|
||||
private boolean end = false;
|
||||
private boolean first = true;
|
||||
|
||||
public ChunkedInputStream(InputStream is) {
|
||||
this.is = is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
if (end) {
|
||||
return -1;
|
||||
}
|
||||
if (chunkPos >= chunkLen) {
|
||||
if (!first) {
|
||||
if (is.read() != '\r') {
|
||||
throw new IOException("Invalid chunk");
|
||||
}
|
||||
if (is.read() != '\n') {
|
||||
throw new IOException("Invalid chunk");
|
||||
}
|
||||
}
|
||||
String lenStr = readLine();
|
||||
try {
|
||||
chunkLen = Integer.parseInt(lenStr);
|
||||
} catch (NumberFormatException nfe) {
|
||||
throw new IOException("Invalid chunk");
|
||||
}
|
||||
if (chunkLen == 0) {
|
||||
is.read(); // \r
|
||||
is.read(); // \n
|
||||
end = true;
|
||||
return -1;
|
||||
}
|
||||
chunkPos = 0;
|
||||
first = false;
|
||||
}
|
||||
|
||||
chunkPos++;
|
||||
return is.read();
|
||||
}
|
||||
|
||||
private String readLine() throws IOException {
|
||||
int i;
|
||||
boolean inr = false;
|
||||
String ret = "";
|
||||
while ((i = is.read()) > -1) {
|
||||
if (inr) {
|
||||
inr = false;
|
||||
if (i == '\n') {
|
||||
break;
|
||||
} else {
|
||||
ret += "\r";
|
||||
}
|
||||
}
|
||||
if (i == '\r') {
|
||||
inr = true;
|
||||
continue;
|
||||
}
|
||||
ret += (char) i;
|
||||
}
|
||||
if (inr) {
|
||||
ret += "\r";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.browsers.cache;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ChunkedInputStream extends InputStream {
|
||||
|
||||
private final InputStream is;
|
||||
private int chunkPos = 0;
|
||||
private int chunkLen = 0;
|
||||
private boolean end = false;
|
||||
private boolean first = true;
|
||||
|
||||
public ChunkedInputStream(InputStream is) {
|
||||
this.is = is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
if (end) {
|
||||
return -1;
|
||||
}
|
||||
if (chunkPos >= chunkLen) {
|
||||
if (!first) {
|
||||
if (is.read() != '\r') {
|
||||
throw new IOException("Invalid chunk");
|
||||
}
|
||||
if (is.read() != '\n') {
|
||||
throw new IOException("Invalid chunk");
|
||||
}
|
||||
}
|
||||
String lenStr = readLine();
|
||||
try {
|
||||
chunkLen = Integer.parseInt(lenStr);
|
||||
} catch (NumberFormatException nfe) {
|
||||
throw new IOException("Invalid chunk");
|
||||
}
|
||||
if (chunkLen == 0) {
|
||||
is.read(); // \r
|
||||
is.read(); // \n
|
||||
end = true;
|
||||
return -1;
|
||||
}
|
||||
chunkPos = 0;
|
||||
first = false;
|
||||
}
|
||||
|
||||
chunkPos++;
|
||||
return is.read();
|
||||
}
|
||||
|
||||
private String readLine() throws IOException {
|
||||
int i;
|
||||
boolean inr = false;
|
||||
StringBuilder ret = new StringBuilder();
|
||||
while ((i = is.read()) > -1) {
|
||||
if (inr) {
|
||||
inr = false;
|
||||
if (i == '\n') {
|
||||
break;
|
||||
} else {
|
||||
ret.append("\r");
|
||||
}
|
||||
}
|
||||
if (i == '\r') {
|
||||
inr = true;
|
||||
continue;
|
||||
}
|
||||
ret.append((char) i);
|
||||
}
|
||||
if (inr) {
|
||||
ret.append("\r");
|
||||
}
|
||||
return ret.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1271,7 +1271,6 @@ public class AVM2Code implements Serializable {
|
||||
}
|
||||
}
|
||||
List<GraphTargetItem> output = new ArrayList<>();
|
||||
String ret = "";
|
||||
int ip = start;
|
||||
//try {
|
||||
//int addr;
|
||||
|
||||
@@ -1,86 +1,85 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionAdd2;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaType;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.TypeItem;
|
||||
import com.jpexs.decompiler.graph.model.BinaryOpItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class AddActionItem extends BinaryOpItem {
|
||||
|
||||
boolean version2;
|
||||
|
||||
public AddActionItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide, boolean version2) {
|
||||
super(instruction, PRECEDENCE_ADDITIVE, leftSide, rightSide, "+");
|
||||
this.version2 = version2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
if (rightSide.getPrecedence() >= precedence) { //string + vs number +
|
||||
String ret = "";
|
||||
if (leftSide.getPrecedence() > precedence) {
|
||||
writer.append("(");
|
||||
leftSide.toString(writer, localData);
|
||||
writer.append(")");
|
||||
} else {
|
||||
leftSide.toString(writer, localData);
|
||||
}
|
||||
writer.append(" ");
|
||||
writer.append(operator);
|
||||
writer.append(" ");
|
||||
writer.append("(");
|
||||
rightSide.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
} else {
|
||||
return super.appendTo(writer, localData);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResult() {
|
||||
if (version2) {
|
||||
if (EcmaScript.type(leftSide.getResult()) == EcmaType.STRING || EcmaScript.type(rightSide.getResult()) == EcmaType.STRING) {
|
||||
return "" + leftSide.getResult() + rightSide.getResult();
|
||||
}
|
||||
return EcmaScript.toNumber(leftSide.getResult()) + EcmaScript.toNumber(rightSide.getResult());
|
||||
} else {
|
||||
return Action.toFloatPoint(leftSide.getResult()) + Action.toFloatPoint(rightSide.getResult());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, leftSide, rightSide, new ActionAdd2());
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem returnType() {
|
||||
return TypeItem.BOOLEAN;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionAdd2;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaType;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.TypeItem;
|
||||
import com.jpexs.decompiler.graph.model.BinaryOpItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class AddActionItem extends BinaryOpItem {
|
||||
|
||||
boolean version2;
|
||||
|
||||
public AddActionItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide, boolean version2) {
|
||||
super(instruction, PRECEDENCE_ADDITIVE, leftSide, rightSide, "+");
|
||||
this.version2 = version2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
if (rightSide.getPrecedence() >= precedence) { //string + vs number +
|
||||
if (leftSide.getPrecedence() > precedence) {
|
||||
writer.append("(");
|
||||
leftSide.toString(writer, localData);
|
||||
writer.append(")");
|
||||
} else {
|
||||
leftSide.toString(writer, localData);
|
||||
}
|
||||
writer.append(" ");
|
||||
writer.append(operator);
|
||||
writer.append(" ");
|
||||
writer.append("(");
|
||||
rightSide.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
} else {
|
||||
return super.appendTo(writer, localData);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResult() {
|
||||
if (version2) {
|
||||
if (EcmaScript.type(leftSide.getResult()) == EcmaType.STRING || EcmaScript.type(rightSide.getResult()) == EcmaType.STRING) {
|
||||
return "" + leftSide.getResult() + rightSide.getResult();
|
||||
}
|
||||
return EcmaScript.toNumber(leftSide.getResult()) + EcmaScript.toNumber(rightSide.getResult());
|
||||
} else {
|
||||
return Action.toFloatPoint(leftSide.getResult()) + Action.toFloatPoint(rightSide.getResult());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, leftSide, rightSide, new ActionAdd2());
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem returnType() {
|
||||
return TypeItem.BOOLEAN;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,12 +41,13 @@ public class ActionGetProperty extends Action {
|
||||
GraphTargetItem target = stack.pop();
|
||||
int indexInt = 0;
|
||||
if (index instanceof DirectValueActionItem) {
|
||||
if (((DirectValueActionItem) index).value instanceof Long) {
|
||||
indexInt = (int) (long) (Long) ((DirectValueActionItem) index).value;
|
||||
} else if (((DirectValueActionItem) index).value instanceof Double) {
|
||||
indexInt = (int) Math.round((Double) ((DirectValueActionItem) index).value);
|
||||
} else if (((DirectValueActionItem) index).value instanceof Float) {
|
||||
indexInt = (int) Math.round((Float) ((DirectValueActionItem) index).value);
|
||||
Object value = ((DirectValueActionItem) index).value;
|
||||
if (value instanceof Long) {
|
||||
indexInt = (int) (long) (Long) value;
|
||||
} else if (value instanceof Double) {
|
||||
indexInt = (int) Math.round((Double) value);
|
||||
} else if (value instanceof Float) {
|
||||
indexInt = (int) Math.round((Float) value);
|
||||
}
|
||||
}
|
||||
stack.push(new GetPropertyActionItem(this, target, indexInt));
|
||||
|
||||
@@ -255,31 +255,31 @@ public class ActionPush extends Action {
|
||||
}
|
||||
|
||||
public String toStringNoQ(int i) {
|
||||
String ret = "";
|
||||
String ret;
|
||||
if (values.get(i) instanceof ConstantIndex) {
|
||||
((ConstantIndex) values.get(i)).constantPool = constantPool;
|
||||
ret += ((ConstantIndex) values.get(i)).toStringNoQ();
|
||||
ret = ((ConstantIndex) values.get(i)).toStringNoQ();
|
||||
} else if (values.get(i) instanceof String) {
|
||||
ret += (String) values.get(i);
|
||||
ret = (String) values.get(i);
|
||||
} else if (values.get(i) instanceof RegisterNumber) {
|
||||
ret += ((RegisterNumber) values.get(i)).toStringNoName();
|
||||
ret = ((RegisterNumber) values.get(i)).toStringNoName();
|
||||
} else {
|
||||
ret += values.get(i).toString();
|
||||
ret = values.get(i).toString();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String toString(int i) {
|
||||
String ret = "";
|
||||
String ret;
|
||||
if (values.get(i) instanceof ConstantIndex) {
|
||||
((ConstantIndex) values.get(i)).constantPool = constantPool;
|
||||
ret += ((ConstantIndex) values.get(i)).toString();
|
||||
ret = ((ConstantIndex) values.get(i)).toString();
|
||||
} else if (values.get(i) instanceof String) {
|
||||
ret += "\"" + Helper.escapeString((String) values.get(i)) + "\"";
|
||||
ret = "\"" + Helper.escapeString((String) values.get(i)) + "\"";
|
||||
} else if (values.get(i) instanceof RegisterNumber) {
|
||||
ret += ((RegisterNumber) values.get(i)).toStringNoName();
|
||||
ret = ((RegisterNumber) values.get(i)).toStringNoName();
|
||||
} else {
|
||||
ret += values.get(i).toString();
|
||||
ret = values.get(i).toString();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -79,14 +79,12 @@ public class ActionConstantPool extends Action {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String ret = "";
|
||||
StringBuilder ret = new StringBuilder();
|
||||
ret.append("ConstantPool");
|
||||
for (int i = 0; i < constantPool.size(); i++) {
|
||||
if (i > 0) {
|
||||
ret += " ";
|
||||
}
|
||||
ret += "\"" + Helper.escapeString(constantPool.get(i)) + "\"";
|
||||
ret.append("\"").append(Helper.escapeString(constantPool.get(i))).append("\"");
|
||||
}
|
||||
return "ConstantPool " + ret;
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -46,7 +46,6 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta
|
||||
public int codeSize;
|
||||
private int version;
|
||||
public List<String> constantPool;
|
||||
private long hdrSize;
|
||||
|
||||
public ActionDefineFunction(String functionName, List<String> paramNames, int codeSize, int version) {
|
||||
super(0x9B, 0);
|
||||
@@ -59,21 +58,12 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta
|
||||
public ActionDefineFunction(int actionLength, SWFInputStream sis, int version) throws IOException {
|
||||
super(0x9B, actionLength);
|
||||
this.version = version;
|
||||
//byte[] data=sis.readBytes(actionLength);
|
||||
//sis=new SWFInputStream(new ByteArrayInputStream(data),version);
|
||||
long startPos = sis.getPos();
|
||||
functionName = sis.readString("functionName");
|
||||
int numParams = sis.readUI16("numParams");
|
||||
for (int i = 0; i < numParams; i++) {
|
||||
paramNames.add(sis.readString("paramName"));
|
||||
}
|
||||
codeSize = sis.readUI16("codeSize");
|
||||
long endPos = sis.getPos();
|
||||
//code = new ArrayList<Action>();
|
||||
hdrSize = endPos - startPos;
|
||||
//int posBef2 = (int) rri.getPos();
|
||||
//code = sis.readActionList(rri.getPos(), getFileAddress() + hdrSize, rri, codeSize);
|
||||
//rri.setPos(posBef2 + codeSize);
|
||||
}
|
||||
|
||||
public ActionDefineFunction(FlasmLexer lexer) throws IOException, ParseException {
|
||||
@@ -88,22 +78,7 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta
|
||||
|
||||
@Override
|
||||
public long getHeaderSize() {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, version);
|
||||
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
|
||||
try {
|
||||
sos.writeString(functionName);
|
||||
sos.writeUI16(paramNames.size());
|
||||
for (String s : paramNames) {
|
||||
sos.writeString(s);
|
||||
}
|
||||
sos.writeUI16(0);
|
||||
sos.close();
|
||||
|
||||
baos2.write(surroundWithAction(baos.toByteArray(), version));
|
||||
} catch (IOException e) {
|
||||
}
|
||||
return baos2.toByteArray().length;
|
||||
return getBytes(version).length;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,34 +92,15 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta
|
||||
for (String s : paramNames) {
|
||||
sos.writeString(s);
|
||||
}
|
||||
//byte[] codeBytes = Action.actionsToBytes(code, false, version);
|
||||
sos.writeUI16(codeSize); //codeBytes.length);
|
||||
sos.writeUI16(codeSize);
|
||||
sos.close();
|
||||
|
||||
baos2.write(surroundWithAction(baos.toByteArray(), version));
|
||||
//baos2.write(codeBytes);
|
||||
} catch (IOException e) {
|
||||
}
|
||||
return baos2.toByteArray();
|
||||
}
|
||||
|
||||
private long getPreLen(int version) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, version);
|
||||
try {
|
||||
sos.writeString(functionName);
|
||||
sos.writeUI16(paramNames.size());
|
||||
for (String s : paramNames) {
|
||||
sos.writeString(s);
|
||||
}
|
||||
sos.writeUI16(0);
|
||||
sos.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
|
||||
return surroundWithAction(baos.toByteArray(), version).length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getASMSource(ActionList container, List<Long> knownAddreses, ScriptExportMode exportMode) {
|
||||
StringBuilder paramStr = new StringBuilder();
|
||||
|
||||
@@ -66,7 +66,7 @@ public class ActionWith extends Action implements GraphSourceItemContainer {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, version);
|
||||
try {
|
||||
sos.writeUI16(codeSize);//codeBytes.length);
|
||||
sos.writeUI16(codeSize);
|
||||
sos.close();
|
||||
baos2.write(surroundWithAction(baos.toByteArray(), version));
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -55,10 +55,8 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont
|
||||
public boolean preloadGlobalFlag;
|
||||
public int registerCount;
|
||||
public int codeSize;
|
||||
//public List<Action> code;
|
||||
private int version;
|
||||
public List<String> constantPool;
|
||||
private long hdrSize;
|
||||
|
||||
public ActionDefineFunction2(String functionName, boolean preloadParentFlag, boolean preloadRootFlag, boolean suppressSuperFlag, boolean preloadSuperFlag, boolean suppressArgumentsFlag, boolean preloadArgumentsFlag, boolean suppressThisFlag, boolean preloadThisFlag, boolean preloadGlobalFlag, int registerCount, int codeSize, int version, List<String> paramNames, List<Integer> paramRegisters) {
|
||||
super(0x8E, 0);
|
||||
@@ -81,7 +79,6 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont
|
||||
|
||||
public ActionDefineFunction2(int actionLength, SWFInputStream sis, int version) throws IOException {
|
||||
super(0x8E, actionLength);
|
||||
long posBef = sis.getPos();
|
||||
this.version = version;
|
||||
functionName = sis.readString("functionName");
|
||||
int numParams = sis.readUI16("numParams");
|
||||
@@ -101,12 +98,6 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont
|
||||
paramNames.add(sis.readString("paramName"));
|
||||
}
|
||||
codeSize = sis.readUI16("codeSize");
|
||||
long posAfter = sis.getPos();
|
||||
hdrSize = posAfter - posBef;
|
||||
//code = new ArrayList<Action>();
|
||||
//int posBef2 = (int) rri.getPos();
|
||||
//code = sis.readActionList(rri.getPos(), getFileAddress() + hdrSize, rri, codeSize);
|
||||
//rri.setPos(posBef2 + codeSize);
|
||||
}
|
||||
|
||||
public ActionDefineFunction2(FlasmLexer lexer) throws IOException, ParseException {
|
||||
@@ -132,34 +123,7 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont
|
||||
|
||||
@Override
|
||||
public long getHeaderSize() {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, version);
|
||||
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
|
||||
try {
|
||||
sos.writeString(functionName);
|
||||
sos.writeUI16(paramNames.size());
|
||||
sos.writeUI8(registerCount);
|
||||
sos.writeUB(1, preloadParentFlag ? 1 : 0);
|
||||
sos.writeUB(1, preloadRootFlag ? 1 : 0);
|
||||
sos.writeUB(1, suppressSuperFlag ? 1 : 0);
|
||||
sos.writeUB(1, preloadSuperFlag ? 1 : 0);
|
||||
sos.writeUB(1, suppressArgumentsFlag ? 1 : 0);
|
||||
sos.writeUB(1, preloadArgumentsFlag ? 1 : 0);
|
||||
sos.writeUB(1, suppressThisFlag ? 1 : 0);
|
||||
sos.writeUB(1, preloadThisFlag ? 1 : 0);
|
||||
sos.writeUB(7, reserved);
|
||||
sos.writeUB(1, preloadGlobalFlag ? 1 : 0);
|
||||
for (int i = 0; i < paramNames.size(); i++) {
|
||||
sos.writeUI8(paramRegisters.get(i));
|
||||
|
||||
sos.writeString(paramNames.get(i));
|
||||
}
|
||||
sos.writeUI16(0);
|
||||
sos.close();
|
||||
baos2.write(surroundWithAction(baos.toByteArray(), version));
|
||||
} catch (IOException e) {
|
||||
}
|
||||
return baos2.toByteArray().length;
|
||||
return getBytes(version).length;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -179,52 +143,21 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont
|
||||
sos.writeUB(1, preloadArgumentsFlag ? 1 : 0);
|
||||
sos.writeUB(1, suppressThisFlag ? 1 : 0);
|
||||
sos.writeUB(1, preloadThisFlag ? 1 : 0);
|
||||
sos.writeUB(7, 0);
|
||||
sos.writeUB(7, reserved);
|
||||
sos.writeUB(1, preloadGlobalFlag ? 1 : 0);
|
||||
for (int i = 0; i < paramNames.size(); i++) {
|
||||
sos.writeUI8(paramRegisters.get(i));
|
||||
sos.writeString(paramNames.get(i));
|
||||
}
|
||||
//byte[] codeBytes = Action.actionsToBytes(code, false, version);
|
||||
sos.writeUI16(codeSize);//codeBytes.length);
|
||||
sos.writeUI16(codeSize);
|
||||
sos.close();
|
||||
|
||||
baos2.write(surroundWithAction(baos.toByteArray(), version));
|
||||
//baos2.write(codeBytes);
|
||||
} catch (IOException e) {
|
||||
}
|
||||
return baos2.toByteArray();
|
||||
}
|
||||
|
||||
private long getPreLen(int version) {
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, version);
|
||||
try {
|
||||
sos.writeString(functionName);
|
||||
sos.writeUI16(paramNames.size());
|
||||
sos.writeUI8(registerCount);
|
||||
sos.writeUB(1, preloadParentFlag ? 1 : 0);
|
||||
sos.writeUB(1, preloadRootFlag ? 1 : 0);
|
||||
sos.writeUB(1, suppressSuperFlag ? 1 : 0);
|
||||
sos.writeUB(1, preloadSuperFlag ? 1 : 0);
|
||||
sos.writeUB(1, suppressArgumentsFlag ? 1 : 0);
|
||||
sos.writeUB(1, preloadArgumentsFlag ? 1 : 0);
|
||||
sos.writeUB(1, suppressThisFlag ? 1 : 0);
|
||||
sos.writeUB(1, preloadThisFlag ? 1 : 0);
|
||||
sos.writeUB(7, 0);
|
||||
sos.writeUB(1, preloadGlobalFlag ? 1 : 0);
|
||||
for (int i = 0; i < paramNames.size(); i++) {
|
||||
sos.writeUI8(paramRegisters.get(i));
|
||||
sos.writeString(paramNames.get(i));
|
||||
}
|
||||
sos.writeUI16(0);
|
||||
sos.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
return surroundWithAction(baos.toByteArray(), version).length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter getASMSourceReplaced(ActionList container, List<Long> knownAddreses, ScriptExportMode exportMode, GraphTextWriter writer) {
|
||||
List<String> oldParamNames = paramNames;
|
||||
|
||||
@@ -149,44 +149,23 @@ public class ActionTry extends Action implements GraphSourceItemContainer {
|
||||
|
||||
@Override
|
||||
public String getASMSource(ActionList container, List<Long> knownAddreses, ScriptExportMode exportMode) {
|
||||
String ret = "";
|
||||
ret += "Try ";
|
||||
StringBuilder ret = new StringBuilder();
|
||||
ret.append("Try ");
|
||||
if (catchBlockFlag) {
|
||||
if (catchInRegisterFlag) {
|
||||
ret += "register" + catchRegister;
|
||||
ret.append("register").append(catchRegister);
|
||||
} else {
|
||||
ret += "\"" + Helper.escapeString(catchName) + "\"";
|
||||
ret.append("\"").append(Helper.escapeString(catchName)).append("\"");
|
||||
}
|
||||
ret += " ";
|
||||
ret.append(" ");
|
||||
}
|
||||
ret += "{";
|
||||
return ret;
|
||||
ret.append("{");
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getHeaderSize() {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, version);
|
||||
try {
|
||||
sos.writeUB(5, reserved);
|
||||
sos.writeUB(1, catchInRegisterFlag ? 1 : 0);
|
||||
sos.writeUB(1, finallyBlockFlag ? 1 : 0);
|
||||
sos.writeUB(1, catchBlockFlag ? 1 : 0);
|
||||
sos.writeUI16((int) trySize);
|
||||
sos.writeUI16((int) catchSize);
|
||||
sos.writeUI16((int) finallySize);
|
||||
if (catchInRegisterFlag) {
|
||||
sos.writeUI8(catchRegister);
|
||||
} else {
|
||||
sos.writeString(catchName == null ? "" : catchName);
|
||||
}
|
||||
/*sos.write(tryBodyBytes);
|
||||
sos.write(catchBodyBytes);
|
||||
sos.write(finallyBodyBytes);*/
|
||||
sos.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
return surroundWithAction(baos.toByteArray(), version).length;
|
||||
return getBytes(version).length;
|
||||
}
|
||||
|
||||
public long getTrySize() {
|
||||
|
||||
Reference in New Issue
Block a user