From c9f0594620da4e4cf97aef29ff907c5308b1cd27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Fri, 5 Jul 2013 14:35:39 +0200 Subject: [PATCH] Issue #174 AS3 rename identifiers - rename getDefinitionByName parameter too --- .../com/jpexs/decompiler/flash/abc/ABC.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java index 2a6ccacdf..d643c1f55 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -21,6 +21,8 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.UnknownInstructionCode; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallPropertyIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushStringIns; import com.jpexs.decompiler.flash.abc.types.*; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitClass; @@ -232,6 +234,41 @@ public class ABC { informListeners("deobfuscate", "namespace " + i + "/" + constants.constant_namespace.length); constants.constant_namespace[i].name_index = deobfuscateNameSpace(stringUsageTypes, stringUsages, namesMap, constants.constant_namespace[i].name_index, renameType); } + + //process reflection using getDefinitionByName too + for (MethodBody body : bodies) { + for (int ip = 0; ip < body.code.code.size(); ip++) { + if (body.code.code.get(ip).definition instanceof CallPropertyIns) { + if (ip > 0) { + if (body.code.code.get(ip - 1).definition instanceof PushStringIns) { + int strIndex = body.code.code.get(ip - 1).operands[0]; + String fullname = constants.constant_string[strIndex]; + String pkg = ""; + String name = fullname; + if (fullname.contains(".")) { + pkg = fullname.substring(0, fullname.lastIndexOf(".")); + name = fullname.substring(fullname.lastIndexOf(".") + 1); + } + if (!pkg.equals("")) { + int pkgStrIndex = constants.forceGetStringId(pkg); + pkgStrIndex = deobfuscateNameSpace(stringUsageTypes, stringUsages, namesMap, pkgStrIndex, renameType); + pkg = constants.constant_string[pkgStrIndex]; + } + int nameStrIndex = constants.forceGetStringId(name); + nameStrIndex = deobfuscateName(stringUsageTypes, stringUsages, namespaceUsages, namesMap, nameStrIndex, true, renameType); + name = constants.constant_string[nameStrIndex]; + String fullChanged = ""; + if (!pkg.equals("")) { + fullChanged = pkg + "."; + } + fullChanged += name; + strIndex = constants.forceGetStringId(fullChanged); + body.code.code.get(ip - 1).operands[0] = strIndex; + } + } + } + } + } } public ABC(InputStream is) throws IOException {