mirror of
https://github.com/zaaarf/lillero-processor.git
synced 2024-11-14 05:29:20 +01:00
fix: descriptor obfuscation now handled properly
This commit is contained in:
parent
dac2510de7
commit
d451cc3460
4 changed files with 29 additions and 13 deletions
|
@ -354,9 +354,9 @@ public class LilleroProcessor extends AbstractProcessor {
|
|||
.addMethod(constructorBuilder.build())
|
||||
.addMethod(buildStringReturnMethod("name", cl.getSimpleName().toString()))
|
||||
.addMethod(buildStringReturnMethod("reason", toGenerate.get(injName).reason))
|
||||
.addMethod(buildStringReturnMethod("targetClass", targetClass.fqn))
|
||||
.addMethod(buildStringReturnMethod("methodName", toGenerate.get(injName).target.name))
|
||||
.addMethod(buildStringReturnMethod("methodDesc", toGenerate.get(injName).target.descriptor))
|
||||
.addMethod(buildStringReturnMethod("targetClass", targetClass.fqnObf))
|
||||
.addMethod(buildStringReturnMethod("methodName", toGenerate.get(injName).target.nameObf))
|
||||
.addMethod(buildStringReturnMethod("methodDesc", toGenerate.get(injName).target.descriptorObf))
|
||||
.addMethods(generateDummies(targets))
|
||||
.addMethod(inject)
|
||||
.build();
|
||||
|
|
|
@ -127,19 +127,19 @@ public class JavaPoetUtils {
|
|||
final boolean isMethod = type == ProxyType.METHOD;
|
||||
final String builderName = var.getSimpleName().toString() + "Builder";
|
||||
|
||||
String descriptor, nameObf;
|
||||
String descriptorObf, nameObf;
|
||||
ClassContainer parent;
|
||||
Element target;
|
||||
|
||||
if(isMethod) {
|
||||
MethodContainer mc = MethodContainer.from(stub, t, f, env, mapper);
|
||||
descriptor = mc.descriptor;
|
||||
descriptorObf = mc.descriptorObf;
|
||||
nameObf = mc.nameObf;
|
||||
parent = mc.parent;
|
||||
target = mc.elem;
|
||||
} else {
|
||||
FieldContainer fc = FieldContainer.from(var, env, mapper);
|
||||
descriptor = fc.descriptor;
|
||||
descriptorObf = fc.descriptorObf;
|
||||
nameObf = fc.nameObf;
|
||||
parent = fc.parent;
|
||||
target = fc.elem;
|
||||
|
@ -172,7 +172,7 @@ public class JavaPoetUtils {
|
|||
con.addStatement(
|
||||
"$L.setDescriptor($S)",
|
||||
builderName,
|
||||
descriptor
|
||||
descriptorObf
|
||||
);
|
||||
|
||||
//build and set
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue