Commit f5f170940d59792cd0a9747d7e03c9fd323774dc
1 parent
b8f2dade
LiteLoader 1.6.4_02 - experimental - banish CallableJVMFlags override an use ASM instead
Showing
5 changed files
with
72 additions
and
57 deletions
.classpath
... | ... | @@ -7,10 +7,15 @@ |
7 | 7 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
8 | 8 | <classpathentry exported="true" kind="lib" path="/Client/jars/libraries/org/lwjgl/lwjgl/lwjgl/2.9.0/lwjgl-2.9.0.jar"/> |
9 | 9 | <classpathentry kind="lib" path="/Client/jars/libraries/com/google/code/gson/gson/2.2.2/gson-2.2.2.jar"/> |
10 | - <classpathentry kind="lib" path="/Client/jars/libraries/com/google/guava/guava/14.0/guava-14.0.jar"/> | |
10 | + <classpathentry kind="lib" path="/Client/jars/libraries/com/google/guava/guava/14.0/guava-14.0.jar"> | |
11 | + <attributes> | |
12 | + <attribute name="javadoc_location" value="jar:platform:/resource/LiteLoader/javadoc/guava-14.0.1-javadoc.jar!/"/> | |
13 | + </attributes> | |
14 | + </classpathentry> | |
11 | 15 | <classpathentry kind="lib" path="/Client/jars/libraries/commons-io/commons-io/2.4/commons-io-2.4.jar"/> |
12 | 16 | <classpathentry exported="true" kind="lib" path="lib/launchwrapper-1.8.jar"/> |
13 | 17 | <classpathentry kind="lib" path="lib/jopt-simple-4.5.jar"/> |
14 | 18 | <classpathentry kind="lib" path="lib/launcher.jar"/> |
19 | + <classpathentry exported="true" kind="lib" path="lib/asm-debug-all-4.1.jar"/> | |
15 | 20 | <classpathentry kind="output" path="bin"/> |
16 | 21 | </classpath> | ... | ... |
java/com/mumfrey/liteloader/launch/LiteLoaderTransformer.java
1 | 1 | package com.mumfrey.liteloader.launch; |
2 | 2 | |
3 | +import java.util.ListIterator; | |
4 | + | |
3 | 5 | import net.minecraft.launchwrapper.IClassTransformer; |
4 | 6 | |
7 | +import org.objectweb.asm.ClassReader; | |
8 | +import org.objectweb.asm.ClassWriter; | |
9 | +import org.objectweb.asm.Opcodes; | |
10 | +import org.objectweb.asm.tree.AbstractInsnNode; | |
11 | +import org.objectweb.asm.tree.ClassNode; | |
12 | +import org.objectweb.asm.tree.InsnList; | |
13 | +import org.objectweb.asm.tree.MethodInsnNode; | |
14 | +import org.objectweb.asm.tree.MethodNode; | |
15 | +import org.objectweb.asm.tree.VarInsnNode; | |
16 | + | |
5 | 17 | public class LiteLoaderTransformer implements IClassTransformer |
6 | 18 | { |
7 | 19 | private static final String classMappingRenderLightningBolt = "net.minecraft.src.RenderLightningBolt"; |
20 | + private static final String classMappingCallableJVMFlags = "net.minecraft.src.CallableJVMFlags"; | |
8 | 21 | |
9 | 22 | // TODO Obfuscation 1.6.4 |
10 | 23 | private static final String classMappingRenderLightningBoltObf = "bha"; |
24 | + private static final String classMappingCallableJVMFlagsObf = "h"; | |
11 | 25 | |
12 | 26 | private static boolean postInit = false; |
13 | 27 | |
... | ... | @@ -21,6 +35,58 @@ public class LiteLoaderTransformer implements IClassTransformer |
21 | 35 | LiteLoaderTweaker.postInit(); |
22 | 36 | } |
23 | 37 | |
38 | + if (classMappingCallableJVMFlags.equals(name) || classMappingCallableJVMFlagsObf.equals(name)) | |
39 | + { | |
40 | + try | |
41 | + { | |
42 | + return this.transformCallableJVMFlags(basicClass); | |
43 | + } | |
44 | + catch (Exception ex) {} | |
45 | + } | |
46 | + | |
24 | 47 | return basicClass; |
25 | 48 | } |
49 | + | |
50 | + /** | |
51 | + * Inject the additional callback for populating the crash report into the CallableJVMFlags class | |
52 | + * | |
53 | + * @param basicClass basic class | |
54 | + * @return transformed class | |
55 | + */ | |
56 | + private byte[] transformCallableJVMFlags(byte[] basicClass) | |
57 | + { | |
58 | + ClassReader classReader = new ClassReader(basicClass); | |
59 | + ClassNode classNode = new ClassNode(); | |
60 | + classReader.accept(classNode, ClassReader.EXPAND_FRAMES); | |
61 | + | |
62 | + for (MethodNode method : classNode.methods) | |
63 | + { | |
64 | + if ("<init>".equals(method.name)) | |
65 | + { | |
66 | + this.transformCallableJVMFlagsConstructor(method); | |
67 | + } | |
68 | + } | |
69 | + | |
70 | + ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); | |
71 | + classNode.accept(writer); | |
72 | + return writer.toByteArray(); | |
73 | + } | |
74 | + | |
75 | + /** | |
76 | + * @param ctor | |
77 | + */ | |
78 | + public void transformCallableJVMFlagsConstructor(MethodNode ctor) | |
79 | + { | |
80 | + InsnList code = new InsnList(); | |
81 | + code.add(new VarInsnNode(Opcodes.ALOAD, 1)); | |
82 | + code.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "com/mumfrey/liteloader/core/LiteLoader", "populateCrashReport", "(Ljava/lang/Object;)V")); | |
83 | + | |
84 | + ListIterator<AbstractInsnNode> insns = ctor.instructions.iterator(); | |
85 | + while (insns.hasNext()) | |
86 | + { | |
87 | + AbstractInsnNode insnNode = insns.next(); | |
88 | + if (insnNode.getOpcode() == Opcodes.RETURN) | |
89 | + ctor.instructions.insertBefore(insnNode, code); | |
90 | + } | |
91 | + } | |
26 | 92 | } | ... | ... |
java/net/minecraft/src/CallableJVMFlags.java deleted
100644 โ 0
1 | -package net.minecraft.src; | |
2 | - | |
3 | -import java.lang.management.ManagementFactory; | |
4 | -import java.lang.management.RuntimeMXBean; | |
5 | -import java.util.Iterator; | |
6 | -import java.util.List; | |
7 | -import java.util.concurrent.Callable; | |
8 | - | |
9 | -import com.mumfrey.liteloader.core.LiteLoader; | |
10 | - | |
11 | -class CallableJVMFlags implements Callable<String> | |
12 | -{ | |
13 | - /** Reference to the CrashReport object. */ | |
14 | - final CrashReport theCrashReport; | |
15 | - | |
16 | - CallableJVMFlags(CrashReport par1CrashReport) | |
17 | - { | |
18 | - this.theCrashReport = par1CrashReport; | |
19 | - LiteLoader.populateCrashReport(par1CrashReport); | |
20 | - } | |
21 | - | |
22 | - /** | |
23 | - * Returns the number of JVM Flags along with the passed JVM Flags. | |
24 | - */ | |
25 | - public String getJVMFlagsAsString() | |
26 | - { | |
27 | - RuntimeMXBean var1 = ManagementFactory.getRuntimeMXBean(); | |
28 | - List<String> var2 = var1.getInputArguments(); | |
29 | - int var3 = 0; | |
30 | - StringBuilder var4 = new StringBuilder(); | |
31 | - Iterator<String> var5 = var2.iterator(); | |
32 | - | |
33 | - while (var5.hasNext()) | |
34 | - { | |
35 | - String var6 = var5.next(); | |
36 | - | |
37 | - if (var6.startsWith("-X")) | |
38 | - { | |
39 | - if (var3++ > 0) | |
40 | - { | |
41 | - var4.append(" "); | |
42 | - } | |
43 | - | |
44 | - var4.append(var6); | |
45 | - } | |
46 | - } | |
47 | - | |
48 | - return String.format("%d total; %s", new Object[] {Integer.valueOf(var3), var4.toString()}); | |
49 | - } | |
50 | - | |
51 | - @Override | |
52 | - public String call() | |
53 | - { | |
54 | - return this.getJVMFlagsAsString(); | |
55 | - } | |
56 | -} |
javadoc/guava-14.0.1-javadoc.jar
0 โ 100644
No preview for this file type
lib/asm-debug-all-4.1.jar
0 โ 100644
No preview for this file type