#989 Rename invalid idetifiers -Type - classes get lost if name exists: check existing constants in all abc tags

This commit is contained in:
honfika@gmail.com
2015-07-21 19:57:04 +02:00
parent e2038501a0
commit 2e5ae046a6
3 changed files with 24 additions and 8 deletions

View File

@@ -1829,6 +1829,19 @@ public final class SWF implements SWFContainerItem, Timelined {
getVariables(variables, actionsMap, functions, strings, usageTypes, asm, path);
}
public boolean as3StringConstantExists(String str) {
for (ABCContainerTag abcTag : getAbcList()) {
ABC abc = abcTag.getABC();
for (int i = 1; i < abc.constants.getStringCount(); i++) {
if (abc.constants.getString(i).equals(str)) {
return true;
}
}
}
return false;
}
public void fixAS3Code() {
for (ABCContainerTag abcTag : getAbcList()) {
ABC abc = abcTag.getABC();

View File

@@ -837,7 +837,7 @@ public class ABC {
private AVM2Deobfuscation getDeobfuscation() {
if (deobfuscation == null) {
deobfuscation = new AVM2Deobfuscation(constants);
deobfuscation = new AVM2Deobfuscation(getSwf(), constants);
}
return deobfuscation;

View File

@@ -16,6 +16,7 @@
*/
package com.jpexs.decompiler.flash.abc.avm2;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.abc.RenameType;
import com.jpexs.decompiler.graph.DottedChain;
import java.util.ArrayList;
@@ -53,6 +54,8 @@ public class AVM2Deobfuscation {
public static final String FOO_JOIN_CHARACTERS = "aeiouy";
private final SWF swf;
private final AVM2ConstantPool constants;
private final Map<String, Integer> usageTypesCount = new HashMap<>();
@@ -61,7 +64,8 @@ public class AVM2Deobfuscation {
public static final DottedChain BUILTIN = new DottedChain("-");
public AVM2Deobfuscation(AVM2ConstantPool constants) {
public AVM2Deobfuscation(SWF swf, AVM2ConstantPool constants) {
this.swf = swf;
this.constants = constants;
}
@@ -148,12 +152,11 @@ public class AVM2Deobfuscation {
ret = sb.toString();
}
for (int i = 1; i < constants.getStringCount(); i++) {
if (constants.getString(i).equals(ret)) {
exists = true;
rndSize += 1;
continue loopfoo;
}
if (swf.as3StringConstantExists(ret)) {
exists = true;
rndSize += 1;
continue loopfoo;
}
if (isReserved(ret)) {
exists = true;