usinig sets for known addresses, some deepcopy call modified to clone() call

This commit is contained in:
2014-11-12 23:52:42 +01:00
parent 0f2e06398a
commit 4bca4746f6
38 changed files with 273 additions and 203 deletions
@@ -2987,14 +2987,13 @@ public class AVM2Code implements Cloneable {
return 1;
}*/
@SuppressWarnings("unchecked")
@Override
public Object clone() throws CloneNotSupportedException {
public AVM2Code clone() throws CloneNotSupportedException {
AVM2Code ret = (AVM2Code) super.clone();
if (code != null) {
List<AVM2Instruction> codeCopy = new ArrayList<>(code.size());
for (AVM2Instruction ins : code) {
codeCopy.add((AVM2Instruction) ins.clone());
codeCopy.add(ins.clone());
}
ret.code = codeCopy;
}
@@ -137,28 +137,28 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem {
s.add(constants.getString(operands[i]));
break;
case AVM2Code.DAT_INT_INDEX:
s.add(Long.valueOf(constants.getInt(operands[i])));
s.add(constants.getInt(operands[i]));
break;
case AVM2Code.DAT_UINT_INDEX:
s.add(new Long(constants.getUInt(operands[i])));
s.add(constants.getUInt(operands[i]));
break;
case AVM2Code.DAT_DOUBLE_INDEX:
s.add(Double.valueOf(constants.getDouble(operands[i])));
s.add(constants.getDouble(operands[i]));
break;
case AVM2Code.DAT_OFFSET:
s.add(new Long(offset + operands[i] + getBytes().length));
s.add(offset + operands[i] + getBytes().length);
break;
case AVM2Code.DAT_CASE_BASEOFFSET:
s.add(new Long(offset + operands[i]));
s.add(offset + operands[i]);
break;
case AVM2Code.OPT_CASE_OFFSETS:
s.add(new Long(operands[i]));
s.add((long) operands[i]);
for (int j = i + 1; j < operands.length; j++) {
s.add(offset + operands[j]);
}
break;
default:
s.add(new Long(operands[i]));
s.add((long) operands[i]);
}
}
@@ -367,7 +367,7 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem {
}
@Override
public Object clone() throws CloneNotSupportedException {
public AVM2Instruction clone() throws CloneNotSupportedException {
AVM2Instruction ret = (AVM2Instruction) super.clone();
if (operands != null) {
ret.operands = Arrays.copyOf(operands, operands.length);
@@ -46,7 +46,7 @@ import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class MethodBody implements Cloneable {
public final class MethodBody implements Cloneable {
public boolean deleted;
boolean debugMode = false;
@@ -236,7 +236,7 @@ public class MethodBody implements Cloneable {
}
public MethodBody convertMethodBody(String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, Trait trait, AVM2ConstantPool constants, List<MethodInfo> method_info, ScopeStack scopeStack, boolean isStaticInitializer, List<String> fullyQualifiedNames, Traits initTraits) throws InterruptedException {
MethodBody b = (MethodBody) clone();
MethodBody b = clone();
AVM2Code deobfuscated = b.getCode();
deobfuscated.markMappedOffsets();
if (Configuration.autoDeobfuscate.get()) {
@@ -252,25 +252,17 @@ public class MethodBody implements Cloneable {
}
@Override
public Object clone() {
public MethodBody clone() {
try {
MethodBody ret = (MethodBody) super.clone();
if (code != null) {
ret.code = (AVM2Code) code.clone();
ret.code = code.clone();
}
ret.codeBytes = codeBytes;
ret.exceptions = exceptions;
ret.max_regs = max_regs;
ret.max_scope_depth = max_scope_depth;
ret.max_stack = max_stack;
ret.method_info = method_info;
ret.init_scope_depth = init_scope_depth;
ret.traits = traits; //maybe deep clone
//maybe deep clone traits
return ret;
} catch (CloneNotSupportedException ex) {
Logger.getLogger(MethodBody.class.getName()).log(Level.SEVERE, null, ex);
throw new RuntimeException();
}
return null;
}
public boolean autoFillStats(ABC abc, int initScope, boolean hasThis) {