mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-27 22:21:19 +00:00
xml import fixes
This commit is contained in:
@@ -57,8 +57,8 @@ import com.jpexs.decompiler.flash.abc.usages.TypeNameMultinameUsage;
|
||||
import com.jpexs.decompiler.flash.helpers.SWFDecompilerPlugin;
|
||||
import com.jpexs.decompiler.flash.helpers.collections.MyEntry;
|
||||
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
|
||||
import com.jpexs.decompiler.flash.tags.SymbolClassTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.types.annotations.Internal;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.helpers.utf8.Utf8PrintWriter;
|
||||
import java.io.IOException;
|
||||
@@ -83,15 +83,20 @@ public class ABC {
|
||||
public List<ClassInfo> class_info = new ArrayList<>();
|
||||
public List<ScriptInfo> script_info = new ArrayList<>();
|
||||
public List<MethodBody> bodies = new ArrayList<>();
|
||||
private List<Integer> bodyIdxFromMethodIdx = new ArrayList<>();
|
||||
public long[] stringOffsets;
|
||||
private Map<Integer, Integer> bodyIdxFromMethodIdx;
|
||||
private long[] stringOffsets;
|
||||
public static final int MINORwithDECIMAL = 17;
|
||||
protected Set<EventListener> listeners = new HashSet<>();
|
||||
private static final Logger logger = Logger.getLogger(ABC.class.getName());
|
||||
private final AVM2Deobfuscation deobfuscation;
|
||||
private AVM2Deobfuscation deobfuscation;
|
||||
@Internal
|
||||
public SWF swf;
|
||||
@Internal
|
||||
public ABCContainerTag parentTag;
|
||||
|
||||
/* Map from multiname index of namespace value to namespace name**/
|
||||
private Map<String, String> namespaceMap;
|
||||
|
||||
public ABC(SWF swf) {
|
||||
this.deobfuscation = null;
|
||||
this.swf = swf;
|
||||
@@ -106,14 +111,7 @@ public class ABC {
|
||||
|
||||
public int addMethodBody(MethodBody body) {
|
||||
bodies.add(body);
|
||||
if (body.method_info >= bodyIdxFromMethodIdx.size()) {
|
||||
int newlen = body.method_info + 1;
|
||||
int oldlen = bodyIdxFromMethodIdx.size();
|
||||
for (int i = oldlen; i < newlen; i++) {
|
||||
bodyIdxFromMethodIdx.add(-1);
|
||||
}
|
||||
bodyIdxFromMethodIdx.set(body.method_info, bodies.size() - 1);
|
||||
}
|
||||
bodyIdxFromMethodIdx = null;
|
||||
return bodies.size() - 1;
|
||||
}
|
||||
|
||||
@@ -268,6 +266,7 @@ public class ABC {
|
||||
Map<Integer, String> stringUsageTypes = new HashMap<>();
|
||||
informListeners("deobfuscate", "Getting usage types...");
|
||||
getStringUsageTypes(stringUsageTypes, classesOnly);
|
||||
AVM2Deobfuscation deobfuscation = getDeobfuscation();
|
||||
for (int i = 0; i < instance_info.size(); i++) {
|
||||
informListeners("deobfuscate", "class " + i + "/" + instance_info.size());
|
||||
InstanceInfo insti = instance_info.get(i);
|
||||
@@ -347,7 +346,6 @@ public class ABC {
|
||||
logger.log(Level.FINE, "ABC minor_version: {0}, major_version: {1}", new Object[]{minor_version, major_version});
|
||||
|
||||
constants = new AVM2ConstantPool();
|
||||
deobfuscation = new AVM2Deobfuscation(constants);
|
||||
ais.newDumpLevel("constant_pool", "cpool_info");
|
||||
|
||||
// constant integers
|
||||
@@ -481,10 +479,8 @@ public class ABC {
|
||||
// method info
|
||||
int methods_count = ais.readU30("methods_count");
|
||||
method_info = new ArrayList<>(methods_count); // MethodInfo[methods_count];
|
||||
bodyIdxFromMethodIdx = new ArrayList<>(methods_count);
|
||||
for (int i = 0; i < methods_count; i++) {
|
||||
method_info.add(ais.readMethodInfo("method"));
|
||||
bodyIdxFromMethodIdx.add(-1);
|
||||
}
|
||||
|
||||
// metadata info
|
||||
@@ -555,12 +551,11 @@ public class ABC {
|
||||
mb.traits = ais.readTraits("traits");
|
||||
bodies.add(mb);
|
||||
method_info.get(mb.method_info).setBody(mb);
|
||||
bodyIdxFromMethodIdx.set(mb.method_info, i);
|
||||
ais.endDumpLevel();
|
||||
|
||||
SWFDecompilerPlugin.fireMethodBodyParsed(mb, swf);
|
||||
}
|
||||
loadNamespaceMap();
|
||||
|
||||
/*for(int i=0;i<script_count;i++){
|
||||
MethodBody bod=bodies.get(bodyIdxFromMethodIdx.get(script_info.get(i).init_index));
|
||||
GraphTextWriter t=new HighlightedTextWriter(Configuration.getCodeFormatting(),false);
|
||||
@@ -689,7 +684,7 @@ public class ABC {
|
||||
if (methodInfo == -1) {
|
||||
return -1;
|
||||
}
|
||||
return bodyIdxFromMethodIdx.get(methodInfo);
|
||||
return getBodyIdxFromMethodIdx().get(methodInfo);
|
||||
}
|
||||
|
||||
public MethodBody findBodyByClassAndName(String className, String methodName) {
|
||||
@@ -791,30 +786,55 @@ public class ABC {
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Map from multiname index of namespace value to namespace name**/
|
||||
private HashMap<String, String> namespaceMap;
|
||||
|
||||
private void loadNamespaceMap() {
|
||||
namespaceMap = new HashMap<>();
|
||||
for (ScriptInfo si : script_info) {
|
||||
for (Trait t : si.traits.traits) {
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst s = ((TraitSlotConst) t);
|
||||
if (s.isNamespace()) {
|
||||
String key = constants.getNamespace(s.value_index).getName(constants, true); // assume not null
|
||||
String val = constants.getMultiname(s.name_index).getNameWithNamespace(constants, true);
|
||||
namespaceMap.put(key, val);
|
||||
private Map<String, String> getNamespaceMap() {
|
||||
if (namespaceMap == null) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
for (ScriptInfo si : script_info) {
|
||||
for (Trait t : si.traits.traits) {
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst s = ((TraitSlotConst) t);
|
||||
if (s.isNamespace()) {
|
||||
String key = constants.getNamespace(s.value_index).getName(constants, true); // assume not null
|
||||
String val = constants.getMultiname(s.name_index).getNameWithNamespace(constants, true);
|
||||
map.put(key, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
namespaceMap = map;
|
||||
}
|
||||
|
||||
return namespaceMap;
|
||||
}
|
||||
|
||||
private AVM2Deobfuscation getDeobfuscation() {
|
||||
if (deobfuscation == null) {
|
||||
deobfuscation = new AVM2Deobfuscation(constants);
|
||||
}
|
||||
|
||||
return deobfuscation;
|
||||
}
|
||||
|
||||
private Map<Integer, Integer> getBodyIdxFromMethodIdx() {
|
||||
if (bodyIdxFromMethodIdx == null) {
|
||||
Map<Integer, Integer> map = new HashMap<>(bodies.size());
|
||||
for (int i = 0; i < bodies.size(); i++) {
|
||||
MethodBody mb = bodies.get(i);
|
||||
map.put(mb.method_info, i);
|
||||
}
|
||||
|
||||
bodyIdxFromMethodIdx = map;
|
||||
}
|
||||
|
||||
return bodyIdxFromMethodIdx;
|
||||
}
|
||||
|
||||
public String nsValueToName(String value) {
|
||||
if (namespaceMap.containsKey(value)) {
|
||||
return namespaceMap.get(value);
|
||||
if (getNamespaceMap().containsKey(value)) {
|
||||
return getNamespaceMap().get(value);
|
||||
} else {
|
||||
String ns = deobfuscation.builtInNs(value);
|
||||
String ns = getDeobfuscation().builtInNs(value);
|
||||
if (ns == null) {
|
||||
return "";
|
||||
} else {
|
||||
@@ -1178,14 +1198,7 @@ public class ABC {
|
||||
removeMethodFromTraits(si.traits, index);
|
||||
}
|
||||
|
||||
if (bindex > -1) {
|
||||
for (int mi = 0; mi < bodyIdxFromMethodIdx.size(); mi++) {
|
||||
if (bodyIdxFromMethodIdx.get(mi) > bindex) {
|
||||
bodyIdxFromMethodIdx.set(mi, bodyIdxFromMethodIdx.get(mi) - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
bodyIdxFromMethodIdx.remove(index);
|
||||
bodyIdxFromMethodIdx = null;
|
||||
|
||||
method_info.remove(index);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1560,7 +1560,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
|
||||
String variableName = n.getVariableName();
|
||||
if ("this".equals(variableName) || "super".equals(variableName) || paramNames.contains(variableName) || "argmuments".equals(variableName)) {
|
||||
if ("this".equals(variableName) || "super".equals(variableName) || paramNames.contains(variableName) || "arguments".equals(variableName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
-1
@@ -23,7 +23,6 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceAIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceSIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertIIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.CallSuperAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NanAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item;
|
||||
|
||||
@@ -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.abc.types;
|
||||
|
||||
/**
|
||||
@@ -23,6 +24,9 @@ public class Decimal {
|
||||
|
||||
public byte[] data;
|
||||
|
||||
public Decimal() {
|
||||
}
|
||||
|
||||
public Decimal(byte[] data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@@ -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.abc.types;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -26,6 +27,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.Traits;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.types.annotations.SWFField;
|
||||
import com.jpexs.decompiler.graph.Graph;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
@@ -54,6 +56,7 @@ public final class MethodBody implements Cloneable {
|
||||
public int max_regs;
|
||||
public int init_scope_depth;
|
||||
public int max_scope_depth;
|
||||
@SWFField
|
||||
private byte[] codeBytes = new byte[0];
|
||||
private AVM2Code code;
|
||||
public ABCException[] exceptions = new ABCException[0];
|
||||
|
||||
@@ -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.abc.types;
|
||||
|
||||
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
|
||||
@@ -195,6 +196,9 @@ public class MethodInfo {
|
||||
return (flags & FLAG_HAS_PARAMNAMES) == FLAG_HAS_PARAMNAMES;
|
||||
}
|
||||
|
||||
public MethodInfo() {
|
||||
}
|
||||
|
||||
public MethodInfo(int[] param_types, int ret_type, int name_index, int flags, ValueKind[] optional, int[] paramNames) {
|
||||
this.param_types = param_types;
|
||||
this.ret_type = ret_type;
|
||||
|
||||
@@ -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.abc.types;
|
||||
|
||||
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
|
||||
@@ -53,6 +54,9 @@ public class Multiname {
|
||||
return cnt;
|
||||
}
|
||||
|
||||
public Multiname() {
|
||||
}
|
||||
|
||||
public Multiname(int kind, int name_index, int namespace_index, int namespace_set_index, int qname_index, List<Integer> params) {
|
||||
this.kind = kind;
|
||||
this.name_index = name_index;
|
||||
|
||||
@@ -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.abc.types;
|
||||
|
||||
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
|
||||
@@ -53,6 +54,9 @@ public class Namespace {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Namespace() {
|
||||
}
|
||||
|
||||
public Namespace(int kind, int name_index) {
|
||||
this.kind = kind;
|
||||
this.name_index = name_index;
|
||||
|
||||
@@ -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.abc.types;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
|
||||
@@ -41,6 +42,9 @@ public class ValueKind {
|
||||
public int value_index;
|
||||
public int value_kind;
|
||||
|
||||
public ValueKind() {
|
||||
}
|
||||
|
||||
public ValueKind(int value_index, int value_kind) {
|
||||
this.value_index = value_index;
|
||||
this.value_kind = value_kind;
|
||||
|
||||
Reference in New Issue
Block a user