@Test @Ignore public void testRun() throws InjectionException { Inject instance = new Inject(deob, vanilla); instance.run(); InjectorValidator iv = new InjectorValidator(vanilla); iv.validate(); }
public void run() throws InjectionException { Map<ClassFile, java.lang.Class> implemented = new HashMap<>(); for (ClassFile cf : deobfuscated.getClasses()) { Annotations an = cf.getAnnotations(); if (an == null || an.size() == 0) { continue; } String obfuscatedName = DeobAnnotations.getObfuscatedName(an); if (obfuscatedName == null) { obfuscatedName = cf.getName(); } ClassFile other = vanilla.findClass(obfuscatedName); assert other != null : "unable to find vanilla class from obfuscated name: " + obfuscatedName; java.lang.Class implementingClass = injectInterface(cf, other); implemented.put(cf, implementingClass); } mixinInjector.inject(); construct.inject(implemented); for (ClassFile cf : deobfuscated.getClasses()) { java.lang.Class implementingClass = implemented.get(cf); Annotations an = cf.getAnnotations(); if (an == null || an.size() == 0) { continue; } String obfuscatedName = DeobAnnotations.getObfuscatedName(an); if (obfuscatedName == null) { obfuscatedName = cf.getName(); } ClassFile other = vanilla.findClass(obfuscatedName); assert other != null : "unable to find vanilla class from obfuscated name: " + obfuscatedName; for (Field f : cf.getFields()) { an = f.getAnnotations(); if (an == null || an.find(DeobAnnotations.EXPORT) == null) { continue; } Annotation exportAnnotation = an.find(DeobAnnotations.EXPORT); String exportedName = exportAnnotation.getElement().getString(); obfuscatedName = DeobAnnotations.getObfuscatedName(an); Annotation getterAnnotation = an.find(DeobAnnotations.OBFUSCATED_GETTER); Number getter = null; if (getterAnnotation != null) { getter = (Number) getterAnnotation.getElement().getValue(); } Type obType = getFieldType(f); Field otherf = other.findField(obfuscatedName, obType); assert otherf != null; assert f.isStatic() == otherf.isStatic(); ClassFile targetClass = f.isStatic() ? vanilla.findClass("client") : other; java.lang.Class targetApiClass = f.isStatic() ? CLIENT_CLASS : implementingClass; if (targetApiClass == null) { assert !f.isStatic(); logger.debug("Non static exported field {} on non exported interface", exportedName); continue; } java.lang.reflect.Method apiMethod = findImportMethodOnApi(targetApiClass, exportedName, true); if (apiMethod != null) { Number setter = null; if (getter != null) { setter = DMath.modInverse(getter); } setters.injectSetter(targetClass, targetApiClass, otherf, exportedName, setter); } apiMethod = findImportMethodOnApi(targetApiClass, exportedName, false); if (apiMethod == null) { logger.debug("Unable to find import method on api class {} with imported name {}, not injecting getter", targetApiClass, exportedName); continue; } Type fieldType = otherf.getType(); Type returnType = classToType(apiMethod.getReturnType()); if (!validateTypeIsConvertibleTo(fieldType, returnType)) { throw new InjectionException("Type " + fieldType + " is not convertable to " + returnType + " for getter " + apiMethod); } getters.injectGetter(targetClass, apiMethod, otherf, getter); } for (Method m : cf.getMethods()) { hookMethod.process(m); invokes.process(m, other, implementingClass); } } logger.info("Injected {} getters, {} settters, {} invokers", getters.getInjectedGetters(), setters.getInjectedSetters(), invokes.getInjectedInvokers()); drawAfterWidgets.inject(); scriptVM.inject(); }
Inject { public void run() throws InjectionException { Map<ClassFile, java.lang.Class> implemented = new HashMap<>(); for (ClassFile cf : deobfuscated.getClasses()) { Annotations an = cf.getAnnotations(); if (an == null || an.size() == 0) { continue; } String obfuscatedName = DeobAnnotations.getObfuscatedName(an); if (obfuscatedName == null) { obfuscatedName = cf.getName(); } ClassFile other = vanilla.findClass(obfuscatedName); assert other != null : "unable to find vanilla class from obfuscated name: " + obfuscatedName; java.lang.Class implementingClass = injectInterface(cf, other); implemented.put(cf, implementingClass); } mixinInjector.inject(); construct.inject(implemented); for (ClassFile cf : deobfuscated.getClasses()) { java.lang.Class implementingClass = implemented.get(cf); Annotations an = cf.getAnnotations(); if (an == null || an.size() == 0) { continue; } String obfuscatedName = DeobAnnotations.getObfuscatedName(an); if (obfuscatedName == null) { obfuscatedName = cf.getName(); } ClassFile other = vanilla.findClass(obfuscatedName); assert other != null : "unable to find vanilla class from obfuscated name: " + obfuscatedName; for (Field f : cf.getFields()) { an = f.getAnnotations(); if (an == null || an.find(DeobAnnotations.EXPORT) == null) { continue; } Annotation exportAnnotation = an.find(DeobAnnotations.EXPORT); String exportedName = exportAnnotation.getElement().getString(); obfuscatedName = DeobAnnotations.getObfuscatedName(an); Annotation getterAnnotation = an.find(DeobAnnotations.OBFUSCATED_GETTER); Number getter = null; if (getterAnnotation != null) { getter = (Number) getterAnnotation.getElement().getValue(); } Type obType = getFieldType(f); Field otherf = other.findField(obfuscatedName, obType); assert otherf != null; assert f.isStatic() == otherf.isStatic(); ClassFile targetClass = f.isStatic() ? vanilla.findClass("client") : other; java.lang.Class targetApiClass = f.isStatic() ? CLIENT_CLASS : implementingClass; if (targetApiClass == null) { assert !f.isStatic(); logger.debug("Non static exported field {} on non exported interface", exportedName); continue; } java.lang.reflect.Method apiMethod = findImportMethodOnApi(targetApiClass, exportedName, true); if (apiMethod != null) { Number setter = null; if (getter != null) { setter = DMath.modInverse(getter); } setters.injectSetter(targetClass, targetApiClass, otherf, exportedName, setter); } apiMethod = findImportMethodOnApi(targetApiClass, exportedName, false); if (apiMethod == null) { logger.debug("Unable to find import method on api class {} with imported name {}, not injecting getter", targetApiClass, exportedName); continue; } Type fieldType = otherf.getType(); Type returnType = classToType(apiMethod.getReturnType()); if (!validateTypeIsConvertibleTo(fieldType, returnType)) { throw new InjectionException("Type " + fieldType + " is not convertable to " + returnType + " for getter " + apiMethod); } getters.injectGetter(targetClass, apiMethod, otherf, getter); } for (Method m : cf.getMethods()) { hookMethod.process(m); invokes.process(m, other, implementingClass); } } logger.info("Injected {} getters, {} settters, {} invokers", getters.getInjectedGetters(), setters.getInjectedSetters(), invokes.getInjectedInvokers()); drawAfterWidgets.inject(); scriptVM.inject(); } }
Inject { public void run() throws InjectionException { Map<ClassFile, java.lang.Class> implemented = new HashMap<>(); for (ClassFile cf : deobfuscated.getClasses()) { Annotations an = cf.getAnnotations(); if (an == null || an.size() == 0) { continue; } String obfuscatedName = DeobAnnotations.getObfuscatedName(an); if (obfuscatedName == null) { obfuscatedName = cf.getName(); } ClassFile other = vanilla.findClass(obfuscatedName); assert other != null : "unable to find vanilla class from obfuscated name: " + obfuscatedName; java.lang.Class implementingClass = injectInterface(cf, other); implemented.put(cf, implementingClass); } mixinInjector.inject(); construct.inject(implemented); for (ClassFile cf : deobfuscated.getClasses()) { java.lang.Class implementingClass = implemented.get(cf); Annotations an = cf.getAnnotations(); if (an == null || an.size() == 0) { continue; } String obfuscatedName = DeobAnnotations.getObfuscatedName(an); if (obfuscatedName == null) { obfuscatedName = cf.getName(); } ClassFile other = vanilla.findClass(obfuscatedName); assert other != null : "unable to find vanilla class from obfuscated name: " + obfuscatedName; for (Field f : cf.getFields()) { an = f.getAnnotations(); if (an == null || an.find(DeobAnnotations.EXPORT) == null) { continue; } Annotation exportAnnotation = an.find(DeobAnnotations.EXPORT); String exportedName = exportAnnotation.getElement().getString(); obfuscatedName = DeobAnnotations.getObfuscatedName(an); Annotation getterAnnotation = an.find(DeobAnnotations.OBFUSCATED_GETTER); Number getter = null; if (getterAnnotation != null) { getter = (Number) getterAnnotation.getElement().getValue(); } Type obType = getFieldType(f); Field otherf = other.findField(obfuscatedName, obType); assert otherf != null; assert f.isStatic() == otherf.isStatic(); ClassFile targetClass = f.isStatic() ? vanilla.findClass("client") : other; java.lang.Class targetApiClass = f.isStatic() ? CLIENT_CLASS : implementingClass; if (targetApiClass == null) { assert !f.isStatic(); logger.debug("Non static exported field {} on non exported interface", exportedName); continue; } java.lang.reflect.Method apiMethod = findImportMethodOnApi(targetApiClass, exportedName, true); if (apiMethod != null) { Number setter = null; if (getter != null) { setter = DMath.modInverse(getter); } setters.injectSetter(targetClass, targetApiClass, otherf, exportedName, setter); } apiMethod = findImportMethodOnApi(targetApiClass, exportedName, false); if (apiMethod == null) { logger.debug("Unable to find import method on api class {} with imported name {}, not injecting getter", targetApiClass, exportedName); continue; } Type fieldType = otherf.getType(); Type returnType = classToType(apiMethod.getReturnType()); if (!validateTypeIsConvertibleTo(fieldType, returnType)) { throw new InjectionException("Type " + fieldType + " is not convertable to " + returnType + " for getter " + apiMethod); } getters.injectGetter(targetClass, apiMethod, otherf, getter); } for (Method m : cf.getMethods()) { hookMethod.process(m); invokes.process(m, other, implementingClass); } } logger.info("Injected {} getters, {} settters, {} invokers", getters.getInjectedGetters(), setters.getInjectedSetters(), invokes.getInjectedInvokers()); drawAfterWidgets.inject(); scriptVM.inject(); } Inject(ClassGroup deobfuscated, ClassGroup vanilla); }
Inject { public void run() throws InjectionException { Map<ClassFile, java.lang.Class> implemented = new HashMap<>(); for (ClassFile cf : deobfuscated.getClasses()) { Annotations an = cf.getAnnotations(); if (an == null || an.size() == 0) { continue; } String obfuscatedName = DeobAnnotations.getObfuscatedName(an); if (obfuscatedName == null) { obfuscatedName = cf.getName(); } ClassFile other = vanilla.findClass(obfuscatedName); assert other != null : "unable to find vanilla class from obfuscated name: " + obfuscatedName; java.lang.Class implementingClass = injectInterface(cf, other); implemented.put(cf, implementingClass); } mixinInjector.inject(); construct.inject(implemented); for (ClassFile cf : deobfuscated.getClasses()) { java.lang.Class implementingClass = implemented.get(cf); Annotations an = cf.getAnnotations(); if (an == null || an.size() == 0) { continue; } String obfuscatedName = DeobAnnotations.getObfuscatedName(an); if (obfuscatedName == null) { obfuscatedName = cf.getName(); } ClassFile other = vanilla.findClass(obfuscatedName); assert other != null : "unable to find vanilla class from obfuscated name: " + obfuscatedName; for (Field f : cf.getFields()) { an = f.getAnnotations(); if (an == null || an.find(DeobAnnotations.EXPORT) == null) { continue; } Annotation exportAnnotation = an.find(DeobAnnotations.EXPORT); String exportedName = exportAnnotation.getElement().getString(); obfuscatedName = DeobAnnotations.getObfuscatedName(an); Annotation getterAnnotation = an.find(DeobAnnotations.OBFUSCATED_GETTER); Number getter = null; if (getterAnnotation != null) { getter = (Number) getterAnnotation.getElement().getValue(); } Type obType = getFieldType(f); Field otherf = other.findField(obfuscatedName, obType); assert otherf != null; assert f.isStatic() == otherf.isStatic(); ClassFile targetClass = f.isStatic() ? vanilla.findClass("client") : other; java.lang.Class targetApiClass = f.isStatic() ? CLIENT_CLASS : implementingClass; if (targetApiClass == null) { assert !f.isStatic(); logger.debug("Non static exported field {} on non exported interface", exportedName); continue; } java.lang.reflect.Method apiMethod = findImportMethodOnApi(targetApiClass, exportedName, true); if (apiMethod != null) { Number setter = null; if (getter != null) { setter = DMath.modInverse(getter); } setters.injectSetter(targetClass, targetApiClass, otherf, exportedName, setter); } apiMethod = findImportMethodOnApi(targetApiClass, exportedName, false); if (apiMethod == null) { logger.debug("Unable to find import method on api class {} with imported name {}, not injecting getter", targetApiClass, exportedName); continue; } Type fieldType = otherf.getType(); Type returnType = classToType(apiMethod.getReturnType()); if (!validateTypeIsConvertibleTo(fieldType, returnType)) { throw new InjectionException("Type " + fieldType + " is not convertable to " + returnType + " for getter " + apiMethod); } getters.injectGetter(targetClass, apiMethod, otherf, getter); } for (Method m : cf.getMethods()) { hookMethod.process(m); invokes.process(m, other, implementingClass); } } logger.info("Injected {} getters, {} settters, {} invokers", getters.getInjectedGetters(), setters.getInjectedSetters(), invokes.getInjectedInvokers()); drawAfterWidgets.inject(); scriptVM.inject(); } Inject(ClassGroup deobfuscated, ClassGroup vanilla); Type getFieldType(Field f); Signature getMethodSignature(Method m); static Type classToType(java.lang.Class<?> c); Signature javaMethodToSignature(java.lang.reflect.Method method); void run(); java.lang.reflect.Method findImportMethodOnApi(java.lang.Class<?> clazz, String name, Boolean setter); Instruction createLoadForTypeIndex(Instructions instructions, Type type, int index); ClassFile toObClass(ClassFile deobClass); ClassGroup getDeobfuscated(); ClassGroup getVanilla(); }
Inject { public void run() throws InjectionException { Map<ClassFile, java.lang.Class> implemented = new HashMap<>(); for (ClassFile cf : deobfuscated.getClasses()) { Annotations an = cf.getAnnotations(); if (an == null || an.size() == 0) { continue; } String obfuscatedName = DeobAnnotations.getObfuscatedName(an); if (obfuscatedName == null) { obfuscatedName = cf.getName(); } ClassFile other = vanilla.findClass(obfuscatedName); assert other != null : "unable to find vanilla class from obfuscated name: " + obfuscatedName; java.lang.Class implementingClass = injectInterface(cf, other); implemented.put(cf, implementingClass); } mixinInjector.inject(); construct.inject(implemented); for (ClassFile cf : deobfuscated.getClasses()) { java.lang.Class implementingClass = implemented.get(cf); Annotations an = cf.getAnnotations(); if (an == null || an.size() == 0) { continue; } String obfuscatedName = DeobAnnotations.getObfuscatedName(an); if (obfuscatedName == null) { obfuscatedName = cf.getName(); } ClassFile other = vanilla.findClass(obfuscatedName); assert other != null : "unable to find vanilla class from obfuscated name: " + obfuscatedName; for (Field f : cf.getFields()) { an = f.getAnnotations(); if (an == null || an.find(DeobAnnotations.EXPORT) == null) { continue; } Annotation exportAnnotation = an.find(DeobAnnotations.EXPORT); String exportedName = exportAnnotation.getElement().getString(); obfuscatedName = DeobAnnotations.getObfuscatedName(an); Annotation getterAnnotation = an.find(DeobAnnotations.OBFUSCATED_GETTER); Number getter = null; if (getterAnnotation != null) { getter = (Number) getterAnnotation.getElement().getValue(); } Type obType = getFieldType(f); Field otherf = other.findField(obfuscatedName, obType); assert otherf != null; assert f.isStatic() == otherf.isStatic(); ClassFile targetClass = f.isStatic() ? vanilla.findClass("client") : other; java.lang.Class targetApiClass = f.isStatic() ? CLIENT_CLASS : implementingClass; if (targetApiClass == null) { assert !f.isStatic(); logger.debug("Non static exported field {} on non exported interface", exportedName); continue; } java.lang.reflect.Method apiMethod = findImportMethodOnApi(targetApiClass, exportedName, true); if (apiMethod != null) { Number setter = null; if (getter != null) { setter = DMath.modInverse(getter); } setters.injectSetter(targetClass, targetApiClass, otherf, exportedName, setter); } apiMethod = findImportMethodOnApi(targetApiClass, exportedName, false); if (apiMethod == null) { logger.debug("Unable to find import method on api class {} with imported name {}, not injecting getter", targetApiClass, exportedName); continue; } Type fieldType = otherf.getType(); Type returnType = classToType(apiMethod.getReturnType()); if (!validateTypeIsConvertibleTo(fieldType, returnType)) { throw new InjectionException("Type " + fieldType + " is not convertable to " + returnType + " for getter " + apiMethod); } getters.injectGetter(targetClass, apiMethod, otherf, getter); } for (Method m : cf.getMethods()) { hookMethod.process(m); invokes.process(m, other, implementingClass); } } logger.info("Injected {} getters, {} settters, {} invokers", getters.getInjectedGetters(), setters.getInjectedSetters(), invokes.getInjectedInvokers()); drawAfterWidgets.inject(); scriptVM.inject(); } Inject(ClassGroup deobfuscated, ClassGroup vanilla); Type getFieldType(Field f); Signature getMethodSignature(Method m); static Type classToType(java.lang.Class<?> c); Signature javaMethodToSignature(java.lang.reflect.Method method); void run(); java.lang.reflect.Method findImportMethodOnApi(java.lang.Class<?> clazz, String name, Boolean setter); Instruction createLoadForTypeIndex(Instructions instructions, Type type, int index); ClassFile toObClass(ClassFile deobClass); ClassGroup getDeobfuscated(); ClassGroup getVanilla(); static final java.lang.Class<?> CLIENT_CLASS; static final String API_PACKAGE_BASE; static final String RL_API_PACKAGE_BASE; }