mirror of
https://github.com/SuspiciousActivity/ProGuard-Unmapper.git
synced 2026-08-13 18:17:44 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
964e264bdb |
No files matched your search
@@ -1,6 +1,5 @@
|
|||||||
package me.Unmapper;
|
package me.Unmapper;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@@ -43,6 +42,8 @@ public class ClassNodeRemapper {
|
|||||||
cn.name = getOldClassName(cn.name);
|
cn.name = getOldClassName(cn.name);
|
||||||
cn.superName = getOldClassName(cn.superName);
|
cn.superName = getOldClassName(cn.superName);
|
||||||
cn.signature = getOldSignature(cn.signature);
|
cn.signature = getOldSignature(cn.signature);
|
||||||
|
if (Main.fakeJava8)
|
||||||
|
cn.version = 52;
|
||||||
if (!cn.interfaces.isEmpty()) {
|
if (!cn.interfaces.isEmpty()) {
|
||||||
List<String> newInterfaces = new ArrayList<String>();
|
List<String> newInterfaces = new ArrayList<String>();
|
||||||
for (String s : cn.interfaces) {
|
for (String s : cn.interfaces) {
|
||||||
@@ -65,8 +66,6 @@ public class ClassNodeRemapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int ACC_STATIC = 0x0008;
|
|
||||||
|
|
||||||
private void remapMethods(ClassNode cn) {
|
private void remapMethods(ClassNode cn) {
|
||||||
if (cn.methods == null)
|
if (cn.methods == null)
|
||||||
return;
|
return;
|
||||||
@@ -84,19 +83,15 @@ public class ClassNodeRemapper {
|
|||||||
mn.exceptions = newExceptions;
|
mn.exceptions = newExceptions;
|
||||||
}
|
}
|
||||||
if (mn.localVariables != null && !mn.localVariables.isEmpty()) {
|
if (mn.localVariables != null && !mn.localVariables.isEmpty()) {
|
||||||
Iterator<LocalVariableNode> lvns = mn.localVariables.iterator();
|
if (Main.removeLocals) {
|
||||||
while (lvns.hasNext()) {
|
mn.localVariables.clear();
|
||||||
LocalVariableNode lvn = lvns.next();
|
} else {
|
||||||
if (Main.removeLocals) {
|
Iterator<LocalVariableNode> lvns = mn.localVariables.iterator();
|
||||||
if ((mn.access & ACC_STATIC) == 0 && lvn.index == 0) { // "this" for non-static methods
|
while (lvns.hasNext()) {
|
||||||
lvn.name = "this"; // should always be "this"
|
LocalVariableNode lvn = lvns.next();
|
||||||
} else if (!isAscii(lvn.name)) {
|
lvn.desc = getOldMemberFieldDesc(lvn.desc);
|
||||||
lvns.remove();
|
lvn.signature = getOldSignature(lvn.signature);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
lvn.desc = getOldMemberFieldDesc(lvn.desc);
|
|
||||||
lvn.signature = getOldSignature(lvn.signature);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mn.tryCatchBlocks != null && !mn.tryCatchBlocks.isEmpty()) {
|
if (mn.tryCatchBlocks != null && !mn.tryCatchBlocks.isEmpty()) {
|
||||||
@@ -122,14 +117,6 @@ public class ClassNodeRemapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAscii(String s) {
|
|
||||||
for (char c : s.toCharArray()) {
|
|
||||||
if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getOldClassName(String name) {
|
private String getOldClassName(String name) {
|
||||||
if (name == null)
|
if (name == null)
|
||||||
return null;
|
return null;
|
||||||
@@ -337,20 +324,7 @@ public class ClassNodeRemapper {
|
|||||||
Object o = node.bsmArgs[i];
|
Object o = node.bsmArgs[i];
|
||||||
if (o instanceof Type) {
|
if (o instanceof Type) {
|
||||||
Type type = (Type) o;
|
Type type = (Type) o;
|
||||||
try {
|
node.bsmArgs[i] = Type.getType(getOldSignature(type.getDescriptor()));
|
||||||
Field f_off = Type.class.getDeclaredField("off");
|
|
||||||
f_off.setAccessible(true);
|
|
||||||
Field f_len = Type.class.getDeclaredField("len");
|
|
||||||
f_len.setAccessible(true);
|
|
||||||
Field f_buf = Type.class.getDeclaredField("buf");
|
|
||||||
f_buf.setAccessible(true);
|
|
||||||
String buf = new String((char[]) f_buf.get(type));
|
|
||||||
String oldBuf = getOldClassName(buf);
|
|
||||||
f_buf.set(type, oldBuf.toCharArray());
|
|
||||||
f_len.set(type, oldBuf.length());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
} else if (o instanceof Handle) {
|
} else if (o instanceof Handle) {
|
||||||
Handle h = (Handle) o;
|
Handle h = (Handle) o;
|
||||||
node.bsmArgs[i] = new Handle(h.getTag(), getOldClassName(h.getOwner()),
|
node.bsmArgs[i] = new Handle(h.getTag(), getOldClassName(h.getOwner()),
|
||||||
@@ -373,20 +347,7 @@ public class ClassNodeRemapper {
|
|||||||
LdcInsnNode node = (LdcInsnNode) n;
|
LdcInsnNode node = (LdcInsnNode) n;
|
||||||
if (node.cst instanceof Type) {
|
if (node.cst instanceof Type) {
|
||||||
Type type = (Type) node.cst;
|
Type type = (Type) node.cst;
|
||||||
try {
|
node.cst = Type.getType(getOldSignature(type.getDescriptor()));
|
||||||
Field f_off = Type.class.getDeclaredField("off");
|
|
||||||
f_off.setAccessible(true);
|
|
||||||
Field f_len = Type.class.getDeclaredField("len");
|
|
||||||
f_len.setAccessible(true);
|
|
||||||
Field f_buf = Type.class.getDeclaredField("buf");
|
|
||||||
f_buf.setAccessible(true);
|
|
||||||
String buf = new String((char[]) f_buf.get(type));
|
|
||||||
String oldBuf = getOldClassName(buf);
|
|
||||||
f_buf.set(type, oldBuf.toCharArray());
|
|
||||||
f_len.set(type, oldBuf.length());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-2
@@ -23,17 +23,30 @@ public class Main implements Opcodes {
|
|||||||
private static MappingReader mapping;
|
private static MappingReader mapping;
|
||||||
|
|
||||||
public static boolean removeLocals = false;
|
public static boolean removeLocals = false;
|
||||||
|
public static boolean fakeJava8 = false;
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
if (args.length < 3) {
|
if (args.length < 3) {
|
||||||
System.out.println("Syntax: input.jar mapping.txt output.jar (-l)");
|
System.out.println("Syntax: input.jar mapping.txt output.jar (-l)");
|
||||||
System.out.println("\t-l\tRemoves local variables which are not ASCII");
|
System.out.println("\t-l\tRemoves local variables which are not ASCII");
|
||||||
System.out.println("\t\t\t(let the decompilers generate better names)");
|
System.out.println("\t\t\t(let the decompilers generate better names)");
|
||||||
|
System.out.println("\t-j\tFake Java 8 class version");
|
||||||
|
System.out.println("\t\t\t(JDGUI doesn't really work without this)");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
if (args.length > 3) {
|
if (args.length > 3) {
|
||||||
removeLocals = args[3].equalsIgnoreCase("-l");
|
for (int i = 3; i < args.length; i++) {
|
||||||
System.out.println("Enabled local variable removal.");
|
switch (args[i].toLowerCase()) {
|
||||||
|
case "-l":
|
||||||
|
removeLocals = true;
|
||||||
|
System.out.println("Enabled local variable removal.");
|
||||||
|
break;
|
||||||
|
case "-j":
|
||||||
|
fakeJava8 = true;
|
||||||
|
System.out.println("Enabled fake Java 8.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
load(new File(args[0]));
|
load(new File(args[0]));
|
||||||
map(new File(args[1]));
|
map(new File(args[1]));
|
||||||
|
|||||||
Reference in new issue
Block a user