mirror of
https://github.com/SuspiciousActivity/ProGuard-Unmapper.git
synced 2026-08-13 18:17:44 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
33830fc015 | ||
|
|
5a077134a5 |
No files matched your search
@@ -288,7 +288,7 @@ public class ClassNodeRemapper {
|
||||
private void remapInstruction(String clazz, AbstractInsnNode n) {
|
||||
if (FieldInsnNode.class.isInstance(n)) {
|
||||
FieldInsnNode node = (FieldInsnNode) n;
|
||||
node.name = getOldMemberName(new MemberData(clazz, node.desc, node.name));
|
||||
node.name = getOldMemberName(new MemberData(node.owner, node.desc, node.name));
|
||||
node.desc = getOldMemberFieldDesc(node.desc);
|
||||
node.owner = getOldClassName(node.owner);
|
||||
} else if (FrameNode.class.isInstance(n)) {
|
||||
@@ -360,7 +360,7 @@ public class ClassNodeRemapper {
|
||||
}
|
||||
} else if (MethodInsnNode.class.isInstance(n)) {
|
||||
MethodInsnNode node = (MethodInsnNode) n;
|
||||
node.name = getOldMemberName(new MemberData(clazz, node.desc, node.name));
|
||||
node.name = getOldMemberName(new MemberData(node.owner, node.desc, node.name));
|
||||
node.desc = getOldMemberMethodDesc(node.desc);
|
||||
node.owner = getOldClassName(node.owner);
|
||||
} else if (TypeInsnNode.class.isInstance(n)) {
|
||||
|
||||
@@ -19,6 +19,23 @@ public class MappingReader {
|
||||
}
|
||||
|
||||
public void load() throws IOException {
|
||||
// Read all the class mappings
|
||||
try (BufferedReader read = new BufferedReader(new FileReader(mappingFile))) {
|
||||
String s;
|
||||
|
||||
while ((s = read.readLine()) != null) {
|
||||
s = s.trim();
|
||||
|
||||
if (s.startsWith("#"))
|
||||
continue;
|
||||
|
||||
if (s.endsWith(":")) {
|
||||
parseClassMapping(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Read member mappings in a second run, we first had to read ALL class mappings
|
||||
// for this to work properly
|
||||
try (BufferedReader read = new BufferedReader(new FileReader(mappingFile))) {
|
||||
String className = null;
|
||||
String s;
|
||||
@@ -30,7 +47,7 @@ public class MappingReader {
|
||||
continue;
|
||||
|
||||
if (s.endsWith(":")) {
|
||||
className = parseClassMapping(s);
|
||||
className = getClassMapping(s);
|
||||
} else if (className != null) {
|
||||
parseClassMemberMapping(className, s);
|
||||
}
|
||||
@@ -38,7 +55,25 @@ public class MappingReader {
|
||||
}
|
||||
}
|
||||
|
||||
private String parseClassMapping(String s) {
|
||||
private void parseClassMapping(String s) {
|
||||
int splitIdx = s.indexOf("->");
|
||||
if (splitIdx < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int colonIndex = s.indexOf(':', splitIdx + 2);
|
||||
if (colonIndex < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
String originalName = s.substring(0, splitIdx).trim().replace('.', '/');
|
||||
String obfuscatedName = s.substring(splitIdx + 2, colonIndex).trim().replace('.', '/');
|
||||
|
||||
classMappings.put(obfuscatedName, originalName);
|
||||
internalReversedClassMappings.put(originalName, obfuscatedName);
|
||||
}
|
||||
|
||||
private String getClassMapping(String s) {
|
||||
int splitIdx = s.indexOf("->");
|
||||
if (splitIdx < 0) {
|
||||
return null;
|
||||
@@ -50,10 +85,6 @@ public class MappingReader {
|
||||
}
|
||||
|
||||
String originalName = s.substring(0, splitIdx).trim().replace('.', '/');
|
||||
String obfuscatedName = s.substring(splitIdx + 2, colonIndex).trim().replace('.', '/');
|
||||
|
||||
classMappings.put(obfuscatedName, originalName);
|
||||
internalReversedClassMappings.put(originalName, obfuscatedName);
|
||||
|
||||
return originalName;
|
||||
}
|
||||
@@ -110,11 +141,20 @@ public class MappingReader {
|
||||
}
|
||||
|
||||
private String getOldClassName(String name) {
|
||||
int arrayCount = 0;
|
||||
int arrayIdx = name.lastIndexOf('[');
|
||||
while (arrayIdx >= 0) {
|
||||
arrayCount++;
|
||||
name = name.substring(0, arrayIdx);
|
||||
arrayIdx = name.lastIndexOf('[');
|
||||
}
|
||||
name = name.replace('.', '/');
|
||||
String old = internalReversedClassMappings.get(name);
|
||||
if (old != null)
|
||||
return old;
|
||||
return name;
|
||||
if (old == null)
|
||||
old = name;
|
||||
for (int i = 0; i < arrayCount; i++)
|
||||
old += "[]";
|
||||
return old;
|
||||
}
|
||||
|
||||
private String convertTypeToByteCode(String type) {
|
||||
|
||||
Reference in new issue
Block a user