Compare commits

..
12 changed files with 160 additions and 38 deletions

No files matched your search

@@ -120,7 +120,9 @@ public final class TransformationPlan {
} }
ClassNode classNode = new ClassNode(); ClassNode classNode = new ClassNode();
new ClassReader(classBytecode).accept(classNode, 0); // Expanded frames are required to derive the stack map frames of inserted branch targets
// without loading any class (see FrameCapture). The writer compresses them again.
new ClassReader(classBytecode).accept(classNode, ClassReader.EXPAND_FRAMES);
return this.transform(internalClassName, classNode, classBytecode, rules); return this.transform(internalClassName, classNode, classBytecode, rules);
} }
@@ -83,7 +83,7 @@ public final class TransformerBootstrapSupport {
} }
public static byte[] toByteArray(ClassNode classNode) { public static byte[] toByteArray(ClassNode classNode) {
ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES); ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS);
classNode.accept(classWriter); classNode.accept(classWriter);
return classWriter.toByteArray(); return classWriter.toByteArray();
} }
@@ -0,0 +1,97 @@
package customskinloader.bootstrap.transformer.patch;
import java.util.ArrayList;
import java.util.List;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.commons.AnalyzerAdapter;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.FrameNode;
import org.objectweb.asm.tree.MethodNode;
/**
* Computes the operand stack / local variable state around a given instruction without loading any
* class. Only usable when the method already carries expanded (F_NEW) stack map frames, which is
* the case for the byte array based transformation paths. Platforms that recompute frames (e.g.
* ModLauncher) hand over compressed frames; callers must then fall back to letting the platform
* compute the frames.
*/
final class FrameCapture {
final Object[] localsBefore;
final Object[] stackBefore;
final Object[] localsAfter;
final Object[] stackAfter;
private FrameCapture(Object[] localsBefore, Object[] stackBefore, Object[] localsAfter, Object[] stackAfter) {
this.localsBefore = localsBefore;
this.stackBefore = stackBefore;
this.localsAfter = localsAfter;
this.stackAfter = stackAfter;
}
static FrameCapture capture(String owner, MethodNode methodNode, AbstractInsnNode target) {
if (!hasExpandedFrames(methodNode)) {
return null;
}
AnalyzerAdapter analyzer = new AnalyzerAdapter(owner, methodNode.access, methodNode.name, methodNode.desc, null);
for (AbstractInsnNode instruction = methodNode.instructions.getFirst(); instruction != null; instruction = instruction.getNext()) {
if (instruction == target) {
Object[] localsBefore = toFrameTypes(analyzer.locals);
Object[] stackBefore = toFrameTypes(analyzer.stack);
if (localsBefore == null || stackBefore == null) {
return null;
}
instruction.accept(analyzer);
Object[] localsAfter = toFrameTypes(analyzer.locals);
Object[] stackAfter = toFrameTypes(analyzer.stack);
if (localsAfter == null || stackAfter == null) {
return null;
}
return new FrameCapture(localsBefore, stackBefore, localsAfter, stackAfter);
}
instruction.accept(analyzer);
}
return null;
}
private static boolean hasExpandedFrames(MethodNode methodNode) {
for (AbstractInsnNode instruction : methodNode.instructions) {
if (instruction instanceof FrameNode && ((FrameNode) instruction).type != Opcodes.F_NEW) {
return false;
}
}
return true;
}
/**
* Converts the slot based lists maintained by {@link AnalyzerAdapter} into the expanded frame
* format expected by {@link FrameNode}. Long and double values occupy two slots but only one
* frame entry, so the implicit {@code TOP} following them must be dropped.
*/
private static Object[] toFrameTypes(List<Object> slots) {
if (slots == null) {
return null;
}
List<Object> types = new ArrayList<>(slots.size());
for (int index = 0; index < slots.size(); index++) {
Object slot = slots.get(index);
if (!(slot instanceof String) && !(slot instanceof Integer)) {
// Uninitialized types are represented by analyzer owned labels that cannot be mapped
// back to labels of the method being transformed.
return null;
}
types.add(slot);
if (slot instanceof Integer && (slot.equals(Opcodes.LONG) || slot.equals(Opcodes.DOUBLE))) {
index++;
}
}
return types.toArray();
}
}
@@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import customskinloader.bootstrap.BootstrapLogger;
import customskinloader.bootstrap.transformer.ClassTransformationContext;
import customskinloader.bootstrap.transformer.TransformationRule; import customskinloader.bootstrap.transformer.TransformationRule;
import customskinloader.bootstrap.transformer.TransformationRuleProvider; import customskinloader.bootstrap.transformer.TransformationRuleProvider;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
@@ -207,12 +209,13 @@ abstract class PatchSupport implements TransformationRuleProvider, Opcodes {
return current; return current;
} }
protected void replaceInstructionSafely(MethodNode methodNode, AbstractInsnNode original, AbstractInsnNode replacement) { protected void replaceInstructionSafely(ClassTransformationContext context, MethodNode methodNode, AbstractInsnNode original, AbstractInsnNode replacement) {
this.replaceInstructionSafely(methodNode, new InsnNode(ICONST_1), IFNE, original, replacement); this.replaceInstructionSafely(context, methodNode, new InsnNode(ICONST_1), IFNE, original, replacement);
} }
protected void replaceInstructionSafely(MethodNode methodNode, AbstractInsnNode condition, int jumpOpcode, AbstractInsnNode original, AbstractInsnNode replacement) { protected void replaceInstructionSafely(ClassTransformationContext context, MethodNode methodNode, AbstractInsnNode condition, int jumpOpcode, AbstractInsnNode original, AbstractInsnNode replacement) {
LabelNode label0 = new LabelNode(), label1 = new LabelNode(); LabelNode label0 = new LabelNode();
LabelNode label1 = new LabelNode();
InsnList before = new InsnList(); InsnList before = new InsnList();
before.add(condition); before.add(condition);
@@ -220,15 +223,29 @@ abstract class PatchSupport implements TransformationRuleProvider, Opcodes {
before.add(new LdcInsnNode("Modified by CustomSkinLoader.")); before.add(new LdcInsnNode("Modified by CustomSkinLoader."));
before.add(new InsnNode(POP)); before.add(new InsnNode(POP));
methodNode.instructions.insertBefore(original, before);
// The original instruction is kept as dead code so later Mixin / coremod transformations
// can still locate it. Both branch targets therefore need a real stack map frame: the
// replacement starts with the state the original instruction would have seen, and the
// merge point continues with the state the original instruction would have produced.
FrameCapture frames = FrameCapture.capture(context.getInternalClassName(), methodNode, original);
if (frames == null) {
BootstrapLogger.LOGGER.debug("Could not derive stack map frames for " + methodNode.name + methodNode.desc + "; the inserted branch targets carry no frame");
}
InsnList after = new InsnList(); InsnList after = new InsnList();
after.add(new JumpInsnNode(GOTO, label1)); after.add(new JumpInsnNode(GOTO, label1));
after.add(label0); after.add(label0);
after.add(new FrameNode(F_SAME, 0, null, 0, null)); if (frames != null) {
after.add(new FrameNode(F_NEW, frames.localsBefore.length, frames.localsBefore, frames.stackBefore.length, frames.stackBefore));
}
after.add(replacement); after.add(replacement);
after.add(label1); after.add(label1);
after.add(new FrameNode(F_SAME, 0, null, 0, null)); if (frames != null) {
after.add(new FrameNode(F_NEW, frames.localsAfter.length, frames.localsAfter, frames.stackAfter.length, frames.stackAfter));
}
methodNode.instructions.insertBefore(original, before);
methodNode.instructions.insert(original, after); methodNode.instructions.insert(original, after);
} }
} }
@@ -88,7 +88,7 @@ public final class RenderPatch extends PatchSupport {
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction; MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
if (remappedOwner.equals(methodInsnNode.owner) && remappedName.equals(methodInsnNode.name) && "()Z".equals(methodInsnNode.desc)) { if (remappedOwner.equals(methodInsnNode.owner) && remappedName.equals(methodInsnNode.name) && "()Z".equals(methodInsnNode.desc)) {
this.replaceInstructionSafely(methodNode, instruction, new MethodInsnNode(INVOKESTATIC, OBJECTS, "nonNull", "(" + objectDesc(OBJECT) + ")Z")); this.replaceInstructionSafely(context, methodNode, instruction, new MethodInsnNode(INVOKESTATIC, OBJECTS, "nonNull", "(" + objectDesc(OBJECT) + ")Z"));
modified = true; modified = true;
} }
} }
@@ -113,7 +113,7 @@ public final class RenderPatch extends PatchSupport {
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction; MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
if (remappedOwner.equals(methodInsnNode.owner) && originalName.equals(methodInsnNode.name) && remappedDesc.equals(methodInsnNode.desc)) { if (remappedOwner.equals(methodInsnNode.owner) && originalName.equals(methodInsnNode.name) && remappedDesc.equals(methodInsnNode.desc)) {
this.replaceInstructionSafely(methodNode, instruction, new MethodInsnNode(INVOKESTATIC, remappedOwner, replacementName, remappedDesc, false)); this.replaceInstructionSafely(context, methodNode, instruction, new MethodInsnNode(INVOKESTATIC, remappedOwner, replacementName, remappedDesc, false));
modified = true; modified = true;
} }
} }
@@ -7,6 +7,7 @@ import org.objectweb.asm.Handle;
import org.objectweb.asm.Type; import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AbstractInsnNode; import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.FieldInsnNode; import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.FrameNode;
import org.objectweb.asm.tree.InsnList; import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.InsnNode; import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.InvokeDynamicInsnNode; import org.objectweb.asm.tree.InvokeDynamicInsnNode;
@@ -67,17 +68,17 @@ public final class SkinManagerPatch extends PatchSupport {
// 19w37a- (1.14.4-) // 19w37a- (1.14.4-)
this.rule("skin-manager.register-skins.v1", SKIN_MANAGER, "[,553]", context -> this.rule("skin-manager.register-skins.v1", SKIN_MANAGER, "[,553]", context ->
this.replaceExecutorProfileLoadAtInvocation( this.replaceExecutorProfileLoadAtInvocation(
context.findMethod(SKIN_MANAGER, "registerSkins", "(" + objectDesc(GAME_PROFILE) + objectDesc(SKIN_MANAGER_SKIN_TEXTURE_CALLBACK) + "Z)V"), context, context.findMethod(SKIN_MANAGER, "registerSkins", "(" + objectDesc(GAME_PROFILE) + objectDesc(SKIN_MANAGER_SKIN_TEXTURE_CALLBACK) + "Z)V"),
EXECUTOR_SERVICE, "submit", "(" + objectDesc(RUNNABLE) + ")" + objectDesc(FUTURE))); EXECUTOR_SERVICE, "submit", "(" + objectDesc(RUNNABLE) + ")" + objectDesc(FUTURE)));
// 19w38a ~ 1.18-exp7 (1.15 ~ 1.17.1) // 19w38a ~ 1.18-exp7 (1.15 ~ 1.17.1)
this.rule("skin-manager.register-skins.v2", SKIN_MANAGER, "[554,756],[801,803],[0x40000001,0x4000002F]+[2205,2831]", context -> this.rule("skin-manager.register-skins.v2", SKIN_MANAGER, "[554,756],[801,803],[0x40000001,0x4000002F]+[2205,2831]", context ->
this.replaceExecutorProfileLoadAtInvocation( this.replaceExecutorProfileLoadAtInvocation(
context.findMethod(SKIN_MANAGER, "registerSkins", "(" + objectDesc(GAME_PROFILE) + objectDesc(SKIN_MANAGER_SKIN_TEXTURE_CALLBACK) + "Z)V"), context, context.findMethod(SKIN_MANAGER, "registerSkins", "(" + objectDesc(GAME_PROFILE) + objectDesc(SKIN_MANAGER_SKIN_TEXTURE_CALLBACK) + "Z)V"),
EXECUTOR, "execute", "(" + objectDesc(RUNNABLE) + ")V")); EXECUTOR, "execute", "(" + objectDesc(RUNNABLE) + ")V"));
// 21w37a ~ 1.20.1 (1.18 ~ 1.20.1) // 21w37a ~ 1.20.1 (1.18 ~ 1.20.1)
this.rule("skin-manager.register-skins.v3", SKIN_MANAGER, "[757,763],[0x40000029,0x4000008E]+[2834,3465]", context -> this.rule("skin-manager.register-skins.v3", SKIN_MANAGER, "[757,763],[0x40000029,0x4000008E]+[2834,3465]", context ->
this.replaceExecutorProfileLoadAtInvocation( this.replaceExecutorProfileLoadAtInvocation(
context.findMethod(SKIN_MANAGER, "registerSkins", "(" + objectDesc(GAME_PROFILE) + objectDesc(SKIN_MANAGER_SKIN_TEXTURE_CALLBACK) + "Z)V"), context, context.findMethod(SKIN_MANAGER, "registerSkins", "(" + objectDesc(GAME_PROFILE) + objectDesc(SKIN_MANAGER_SKIN_TEXTURE_CALLBACK) + "Z)V"),
EXECUTOR_SERVICE, "execute", "(" + objectDesc(RUNNABLE) + ")V")); EXECUTOR_SERVICE, "execute", "(" + objectDesc(RUNNABLE) + ")V"));
this.rule("skin-manager.get-insecure-skin-information", SKIN_MANAGER, "[,763],[801,803],[0x40000001,0x4000008E]", context -> { this.rule("skin-manager.get-insecure-skin-information", SKIN_MANAGER, "[,763],[801,803],[0x40000001,0x4000008E]", context -> {
@@ -89,13 +90,14 @@ public final class SkinManagerPatch extends PatchSupport {
injection.add(new VarInsnNode(ALOAD, 1)); injection.add(new VarInsnNode(ALOAD, 1));
injection.add(new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "loadSkinFromCache", "(" + objectDesc(GAME_PROFILE) + ")" + objectDesc(MAP), false)); injection.add(new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "loadSkinFromCache", "(" + objectDesc(GAME_PROFILE) + ")" + objectDesc(MAP), false));
injection.add(new InsnNode(ARETURN)); injection.add(new InsnNode(ARETURN));
injection.add(new FrameNode(F_SAME, 0, null, 0, null));
methodNode.instructions.insert(injection); methodNode.instructions.insert(injection);
return true; return true;
}); });
// 1.13.2 ~ 1.20.1 // 1.13.2 ~ 1.20.1
this.rule("skin-manager.lambda-register-skins-4", SKIN_MANAGER, "[404,763],[801,803],[0x40000001,0x4000008E]", context -> this.rule("skin-manager.lambda-register-skins-4", SKIN_MANAGER, "[404,763],[801,803],[0x40000001,0x4000008E]", context ->
this.replaceGetTexturesWithFakeUserProfile(context.findMethod(SKIN_MANAGER, "lambda$registerSkins$4", this.replaceGetTexturesWithFakeUserProfile(context, context.findMethod(SKIN_MANAGER, "lambda$registerSkins$4",
"(" + objectDesc(GAME_PROFILE) + "Z" + objectDesc(SKIN_MANAGER_SKIN_TEXTURE_CALLBACK) + ")V"))); "(" + objectDesc(GAME_PROFILE) + "Z" + objectDesc(SKIN_MANAGER_SKIN_TEXTURE_CALLBACK) + ")V")));
// 23w42a ~ 25w33a (1.20.3 ~ 1.21.8) // 23w42a ~ 25w33a (1.20.3 ~ 1.21.8)
@@ -141,7 +143,7 @@ public final class SkinManagerPatch extends PatchSupport {
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction; MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
if (MINECRAFT_SESSION_SERVICE.equals(methodInsnNode.owner) && "getTextures".equals(methodInsnNode.name) if (MINECRAFT_SESSION_SERVICE.equals(methodInsnNode.owner) && "getTextures".equals(methodInsnNode.name)
&& ("(" + objectDesc(GAME_PROFILE) + "Z)" + objectDesc(MAP)).equals(methodInsnNode.desc)) { && ("(" + objectDesc(GAME_PROFILE) + "Z)" + objectDesc(MAP)).equals(methodInsnNode.desc)) {
this.replaceInstructionSafely(methodNode, instruction, new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "loadSkinFromCache", "(" + objectDesc(OBJECT) + objectDesc(GAME_PROFILE) + "Z)" + objectDesc(MAP), false)); this.replaceInstructionSafely(context, methodNode, instruction, new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "loadSkinFromCache", "(" + objectDesc(OBJECT) + objectDesc(GAME_PROFILE) + "Z)" + objectDesc(MAP), false));
modified = true; modified = true;
} }
} }
@@ -162,7 +164,7 @@ public final class SkinManagerPatch extends PatchSupport {
// 1.12.2- // 1.12.2-
this.rule("skin-manager-3.get-user-profile", SKIN_MANAGER_3, "[,340]", context -> this.rule("skin-manager-3.get-user-profile", SKIN_MANAGER_3, "[,340]", context ->
this.replaceGetTexturesWithFakeUserProfile(context.findMethod(SKIN_MANAGER_3, "run", "()V"))); this.replaceGetTexturesWithFakeUserProfile(context, context.findMethod(SKIN_MANAGER_3, "run", "()V")));
// 23w31a+ (1.20.2+) // 23w31a+ (1.20.2+)
this.rule("skin-manager-cache-key.access", SKIN_MANAGER_CACHE_KEY, "[764,800],[804,0x40000000],[0x40000090,]", context -> { this.rule("skin-manager-cache-key.access", SKIN_MANAGER_CACHE_KEY, "[764,800],[804,0x40000000],[0x40000090,]", context -> {
@@ -316,7 +318,7 @@ public final class SkinManagerPatch extends PatchSupport {
return false; return false;
} }
private boolean replaceExecutorProfileLoadAtInvocation(MethodNode methodNode, String owner, String name, String desc) { private boolean replaceExecutorProfileLoadAtInvocation(ClassTransformationContext context, MethodNode methodNode, String owner, String name, String desc) {
if (methodNode == null) { if (methodNode == null) {
return false; return false;
} }
@@ -332,7 +334,7 @@ public final class SkinManagerPatch extends PatchSupport {
continue; continue;
} }
this.replaceInstructionSafely(methodNode, instruction, methodInsnNode = new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "loadProfileTextures", "(" + objectDesc(OBJECT) + objectDesc(RUNNABLE) + ")V", false)); this.replaceInstructionSafely(context, methodNode, instruction, methodInsnNode = new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "loadProfileTextures", "(" + objectDesc(OBJECT) + objectDesc(RUNNABLE) + ")V", false));
if (!desc.endsWith("V")) { if (!desc.endsWith("V")) {
methodNode.instructions.insert(methodInsnNode, new InsnNode(ACONST_NULL)); methodNode.instructions.insert(methodInsnNode, new InsnNode(ACONST_NULL));
} }
@@ -342,7 +344,7 @@ public final class SkinManagerPatch extends PatchSupport {
return modified; return modified;
} }
private boolean replaceGetTexturesWithFakeUserProfile(MethodNode methodNode) { private boolean replaceGetTexturesWithFakeUserProfile(ClassTransformationContext context, MethodNode methodNode) {
if (methodNode == null) { if (methodNode == null) {
return false; return false;
} }
@@ -358,7 +360,7 @@ public final class SkinManagerPatch extends PatchSupport {
continue; continue;
} }
this.replaceInstructionSafely(methodNode, instruction, new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "getUserProfile", "(" + objectDesc(OBJECT) + objectDesc(GAME_PROFILE) + "Z)" + objectDesc(MAP), false)); this.replaceInstructionSafely(context, methodNode, instruction, new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_MANAGER, "getUserProfile", "(" + objectDesc(OBJECT) + objectDesc(GAME_PROFILE) + "Z)" + objectDesc(MAP), false));
modified = true; modified = true;
} }
return modified; return modified;
@@ -384,14 +386,20 @@ public final class SkinManagerPatch extends PatchSupport {
continue; continue;
} }
AbstractInsnNode newNode = this.findPreviousTypeInstruction(methodInsnNode, NEW, owner);
AbstractInsnNode dupNode = this.nextRealInstruction(newNode);
if (newNode == null || dupNode == null || dupNode.getOpcode() != DUP) {
continue;
}
methodNode.instructions.remove(newNode);
methodNode.instructions.remove(dupNode);
InsnList replacement = new InsnList(); InsnList replacement = new InsnList();
replacement.add(new InsnNode(DUP2_X2));
replacement.add(new InsnNode(POP2));
replacement.add(new InsnNode(POP2));
replacement.add(new VarInsnNode(ALOAD, 1)); replacement.add(new VarInsnNode(ALOAD, 1));
MethodInsnNode createFakeCacheKey = new MethodInsnNode(INVOKESTATIC, FAKE_CACHE_KEY, "createFakeCacheKey", replacementDesc, false); replacement.add(new MethodInsnNode(INVOKESTATIC, FAKE_CACHE_KEY, "createFakeCacheKey", replacementDesc, false));
this.replaceInstructionSafely(methodNode, methodInsnNode, createFakeCacheKey); methodNode.instructions.insertBefore(methodInsnNode, replacement);
methodNode.instructions.insertBefore(createFakeCacheKey, replacement); methodNode.instructions.remove(methodInsnNode);
modified = true; modified = true;
} }
@@ -44,7 +44,7 @@ public final class SkinTexturePatch extends PatchSupport {
load.instructions.insertBefore(instruction, new VarInsnNode(ALOAD, 0)); load.instructions.insertBefore(instruction, new VarInsnNode(ALOAD, 0));
load.instructions.insertBefore(instruction, new FieldInsnNode(GETFIELD, owner, processTaskField, objectDesc(RUNNABLE))); load.instructions.insertBefore(instruction, new FieldInsnNode(GETFIELD, owner, processTaskField, objectDesc(RUNNABLE)));
MethodInsnNode processLegacySkin = new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_BUFFER, "processLegacySkin", replacementDesc, false); MethodInsnNode processLegacySkin = new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_BUFFER, "processLegacySkin", replacementDesc, false);
this.replaceInstructionSafely(load, new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_BUFFER, "shouldProcessLegacySkin", conditionDesc, false), IFNE, instruction, processLegacySkin); this.replaceInstructionSafely(context, load, new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_BUFFER, "shouldProcessLegacySkin", conditionDesc, false), IFNE, instruction, processLegacySkin);
InsnList injection = new InsnList(); InsnList injection = new InsnList();
if (methodInsnNode.getOpcode() == INVOKESTATIC) { if (methodInsnNode.getOpcode() == INVOKESTATIC) {
@@ -120,7 +120,7 @@ public final class SkinTexturePatch extends PatchSupport {
MethodInsnNode methodInsnNode = (MethodInsnNode) instruction; MethodInsnNode methodInsnNode = (MethodInsnNode) instruction;
if (methodInsnNode.getOpcode() == INVOKESTATIC && owner.equals(methodInsnNode.owner) && originalName.equals(methodInsnNode.name) && originalDesc.equals(methodInsnNode.desc)) { if (methodInsnNode.getOpcode() == INVOKESTATIC && owner.equals(methodInsnNode.owner) && originalName.equals(methodInsnNode.name) && originalDesc.equals(methodInsnNode.desc)) {
this.replaceInstructionSafely(methodNode, instruction, new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_BUFFER, "processLegacySkin", originalDesc, false)); this.replaceInstructionSafely(context, methodNode, instruction, new MethodInsnNode(INVOKESTATIC, FAKE_SKIN_BUFFER, "processLegacySkin", originalDesc, false));
modified = true; modified = true;
} }
} }
@@ -40,11 +40,11 @@ public final class MixinConfigPlugin implements IMixinConfigPlugin {
@Override @Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
TransformerBootstrap.transformTargetClass(targetClassName, targetClass);
} }
@Override @Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
TransformerBootstrap.transformTargetClass(targetClassName, targetClass);
} }
} }
@@ -74,8 +74,6 @@ final class TransformerBootstrap {
Method addMixinMethod = ReflectionUtils.findMethod(ClassInfo.class, "addMixin", mixinInfoClass); Method addMixinMethod = ReflectionUtils.findMethod(ClassInfo.class, "addMixin", mixinInfoClass);
for (String targetClassName : SUPPORT.getTargetClassNames()) { for (String targetClassName : SUPPORT.getTargetClassNames()) {
//applyMixinTarget(mixinConfig, DUMMY_MIXIN, targetClassName);
boolean applied = false; boolean applied = false;
for (Object mixinInfo : (List<?>) mixinsField.get(mixinConfig)) { for (Object mixinInfo : (List<?>) mixinsField.get(mixinConfig)) {
String currentMixinName = ((IMixinInfo) mixinInfo).getClassName(); String currentMixinName = ((IMixinInfo) mixinInfo).getClassName();
@@ -5,7 +5,7 @@ import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
import java.util.Map; import java.util.Map;
@IFMLLoadingPlugin.Name("CustomSkinLoaderBootstrap") @IFMLLoadingPlugin.Name("CustomSkinLoaderBootstrap")
@IFMLLoadingPlugin.SortingIndex(900) @IFMLLoadingPlugin.SortingIndex(1010)
@IFMLLoadingPlugin.TransformerExclusions("customskinloader.bootstrap.") @IFMLLoadingPlugin.TransformerExclusions("customskinloader.bootstrap.")
public final class LoadingPlugin implements IFMLLoadingPlugin { public final class LoadingPlugin implements IFMLLoadingPlugin {
@Override @Override
@@ -65,7 +65,7 @@ final class TransformerBootstrap implements ITransformer<ClassNode> {
@Override @Override
public ClassNode transform(ClassNode input, ITransformerVotingContext context) { public ClassNode transform(ClassNode input, ITransformerVotingContext context) {
String internalClassName = context.getClassName().replace('.', '/'); String internalClassName = input.name;
ClassTransformationReport report = SUPPORT.transform(internalClassName, input); ClassTransformationReport report = SUPPORT.transform(internalClassName, input);
if (report.isModified()) { if (report.isModified()) {
LOGGER.info("Transformed ModLauncher target " + internalClassName + " with " + report.getAppliedRuleNames()); LOGGER.info("Transformed ModLauncher target " + internalClassName + " with " + report.getAppliedRuleNames());
@@ -27,8 +27,8 @@ final class TransformerBootstrap implements ClassProcessor {
} }
@Override @Override
public Set<ProcessorName> runsAfter() { public Set<ProcessorName> runsBefore() {
return Collections.singleton(ClassProcessorIds.SIMPLE_PROCESSORS_GROUP); return Collections.singleton(ClassProcessorIds.MIXIN);
} }
@Override @Override
@@ -53,6 +53,6 @@ final class TransformerBootstrap implements ClassProcessor {
@Override @Override
public OrderingHint orderingHint() { public OrderingHint orderingHint() {
return OrderingHint.LATE; return OrderingHint.EARLY;
} }
} }