Add CachePathTransformer

bzip2
Graham 5 years ago
parent 4788f8314e
commit 261cc87125
  1. 44
      bundler/src/main/java/dev/openrs2/bundler/transform/CachePathTransformer.java
  2. 2
      deob/src/main/java/dev/openrs2/deob/Deobfuscator.java

@ -0,0 +1,44 @@
package dev.openrs2.bundler.transform;
import dev.openrs2.asm.classpath.ClassPath;
import dev.openrs2.asm.transform.Transformer;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.LdcInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class CachePathTransformer extends Transformer {
private static final Logger logger = LoggerFactory.getLogger(CachePathTransformer.class);
private int paths;
@Override
protected void preTransform(ClassPath classPath) {
paths = 0;
}
@Override
protected boolean transformCode(ClassNode clazz, MethodNode method) {
for (var it = method.instructions.iterator(); it.hasNext(); ) {
var insn = it.next();
if (insn.getOpcode() != Opcodes.LDC) {
continue;
}
var ldc = (LdcInsnNode) insn;
if (ldc.cst.equals(".jagex_cache_") || ldc.cst.equals(".file_store_")) {
ldc.cst = ".openrs2_cache_";
paths++;
}
}
return false;
}
@Override
protected void postTransform(ClassPath classPath) {
logger.info("Updated {} cache paths", paths);
}
}

@ -9,6 +9,7 @@ import com.google.common.collect.ImmutableList;
import dev.openrs2.asm.classpath.ClassPath; import dev.openrs2.asm.classpath.ClassPath;
import dev.openrs2.asm.classpath.Library; import dev.openrs2.asm.classpath.Library;
import dev.openrs2.asm.transform.Transformer; import dev.openrs2.asm.transform.Transformer;
import dev.openrs2.bundler.transform.CachePathTransformer;
import dev.openrs2.bundler.transform.HostCheckTransformer; import dev.openrs2.bundler.transform.HostCheckTransformer;
import dev.openrs2.bundler.transform.RightClickTransformer; import dev.openrs2.bundler.transform.RightClickTransformer;
import dev.openrs2.deob.remap.PrefixRemapper; import dev.openrs2.deob.remap.PrefixRemapper;
@ -32,6 +33,7 @@ public final class Deobfuscator {
private static final ImmutableList<Transformer> TRANSFORMERS = ImmutableList.of( private static final ImmutableList<Transformer> TRANSFORMERS = ImmutableList.of(
new OriginalNameTransformer(), new OriginalNameTransformer(),
new CachePathTransformer(),
new HostCheckTransformer(), new HostCheckTransformer(),
new RightClickTransformer(), new RightClickTransformer(),
new OpaquePredicateTransformer(), new OpaquePredicateTransformer(),

Loading…
Cancel
Save