From d451cc3460fc162295874f0b8ddb2f058dadfa66 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 29 Mar 2023 12:15:36 +0200 Subject: fix: descriptor obfuscation now handled properly --- .../lll/processor/tools/containers/FieldContainer.java | 15 ++++++++++++--- .../lll/processor/tools/containers/MethodContainer.java | 13 ++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) (limited to 'src/main/java/ftbsc/lll/processor/tools/containers') diff --git a/src/main/java/ftbsc/lll/processor/tools/containers/FieldContainer.java b/src/main/java/ftbsc/lll/processor/tools/containers/FieldContainer.java index 0b39a1c..b6a98bd 100644 --- a/src/main/java/ftbsc/lll/processor/tools/containers/FieldContainer.java +++ b/src/main/java/ftbsc/lll/processor/tools/containers/FieldContainer.java @@ -4,6 +4,7 @@ import ftbsc.lll.exceptions.AmbiguousDefinitionException; import ftbsc.lll.processor.annotations.Find; import ftbsc.lll.processor.annotations.Patch; import ftbsc.lll.processor.tools.obfuscation.ObfuscationMapper; +import org.objectweb.asm.Type; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.VariableElement; @@ -11,6 +12,7 @@ import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import static ftbsc.lll.processor.tools.ASTUtils.*; +import static ftbsc.lll.processor.tools.JavaPoetUtils.descriptorFromExecutableElement; import static ftbsc.lll.processor.tools.JavaPoetUtils.descriptorFromType; /** @@ -35,6 +37,12 @@ public class FieldContainer { */ public final String nameObf; + /** + * The obfuscated descriptor of the field. + * If the mapper passed is null, then this will be identical to {@link #descriptor}. + */ + public final String descriptorObf; + /** * The {@link ClassContainer} representing the parent of this field. * May be null if the parent is a class type that can not be checked @@ -63,12 +71,13 @@ public class FieldContainer { throw new AmbiguousDefinitionException("Cannot use name-based lookups for fields of unverifiable classes!"); this.elem = null; this.name = name; - this.descriptor = mapper == null ? descriptor : mapper.obfuscateMethodDescriptor(descriptor); + this.descriptor = descriptor; + this.descriptorObf = mapper == null ? this.descriptor : mapper.obfuscateType(Type.getType(this.descriptor)).getDescriptor(); } else { this.elem = (VariableElement) findMember(parent, name, descriptor, descriptor != null, true); this.name = this.elem.getSimpleName().toString(); - String validatedDescriptor = descriptorFromType(this.elem.asType()); - this.descriptor = mapper == null ? descriptor : mapper.obfuscateMethodDescriptor(validatedDescriptor); + this.descriptor = descriptorFromType(this.elem.asType()); + this.descriptorObf = mapper == null ? this.descriptor : mapper.obfuscateType(Type.getType(this.descriptor)).getDescriptor(); } this.nameObf = findMemberName(parent.fqnObf, name, descriptor, mapper); } diff --git a/src/main/java/ftbsc/lll/processor/tools/containers/MethodContainer.java b/src/main/java/ftbsc/lll/processor/tools/containers/MethodContainer.java index d8ab04f..7f328d6 100644 --- a/src/main/java/ftbsc/lll/processor/tools/containers/MethodContainer.java +++ b/src/main/java/ftbsc/lll/processor/tools/containers/MethodContainer.java @@ -38,6 +38,12 @@ public class MethodContainer { */ public final String nameObf; + /** + * The obfuscated descriptor of the field. + * If the mapper passed is null, then this will be identical to {@link #descriptor}. + */ + public final String descriptorObf; + /** * The {@link ClassContainer} representing the parent of this method. * May be null if the parent is a class type that can not be checked @@ -67,12 +73,13 @@ public class MethodContainer { throw new AmbiguousDefinitionException("Cannot use name-based lookups for methods of unverifiable classes!"); this.elem = null; this.name = name; - this.descriptor = mapper == null ? descriptor : mapper.obfuscateMethodDescriptor(descriptor); + this.descriptor = descriptor; + this.descriptorObf = mapper == null ? this.descriptor : mapper.obfuscateMethodDescriptor(this.descriptor); } else { this.elem = (ExecutableElement) findMember(parent, name, descriptor, descriptor != null && strict, false); this.name = this.elem.getSimpleName().toString(); - String validatedDescriptor = descriptorFromExecutableElement(this.elem); - this.descriptor = mapper == null ? descriptor : mapper.obfuscateMethodDescriptor(validatedDescriptor); + this.descriptor = descriptorFromExecutableElement(this.elem); + this.descriptorObf = mapper == null ? this.descriptor : mapper.obfuscateMethodDescriptor(this.descriptor); } this.nameObf = findMemberName(parent.fqnObf, name, descriptor, mapper); } -- cgit v1.2.3-56-ga3b1