Some injecting classes now works
This commit is contained in:
@@ -295,4 +295,9 @@ public class ClassFile
|
|||||||
{
|
{
|
||||||
return (this.access_flags & ACC_FINAL) != 0;
|
return (this.access_flags & ACC_FINAL) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearFinal()
|
||||||
|
{
|
||||||
|
this.access_flags &= ~ACC_FINAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package net.runelite.deob.injection;
|
package net.runelite.deob.injection;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -118,6 +119,17 @@ public class Inject
|
|||||||
if (implementingClass == null)
|
if (implementingClass == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
InjectReplace ij = new InjectReplace(cf, other);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ij.run();
|
||||||
|
}
|
||||||
|
catch (ClassNotFoundException | IOException ex)
|
||||||
|
{
|
||||||
|
ex.printStackTrace();
|
||||||
|
assert false;
|
||||||
|
}
|
||||||
|
|
||||||
for (Field f : cf.getFields().getFields())
|
for (Field f : cf.getFields().getFields())
|
||||||
{
|
{
|
||||||
an = f.getAttributes().getAnnotations();
|
an = f.getAttributes().getAnnotations();
|
||||||
|
|||||||
@@ -74,12 +74,13 @@ public class InjectReplace
|
|||||||
|
|
||||||
// set parent
|
// set parent
|
||||||
classToInject.setParentClass(vanilla.getPoolClass());
|
classToInject.setParentClass(vanilla.getPoolClass());
|
||||||
assert !vanilla.isFinal();
|
vanilla.clearFinal(); // can't be final anymore now that we inherit from it
|
||||||
|
|
||||||
injectConstructors(classToInject);
|
injectConstructors(classToInject);
|
||||||
|
|
||||||
overideMethods(classToInject);
|
overideMethods(classToInject);
|
||||||
|
|
||||||
|
// find all classes which inherit from 'vanilla'. replace with classToInject
|
||||||
replaceSuperclass(classToInject);
|
replaceSuperclass(classToInject);
|
||||||
|
|
||||||
replaceNew(classToInject);
|
replaceNew(classToInject);
|
||||||
@@ -228,11 +229,12 @@ public class InjectReplace
|
|||||||
|
|
||||||
private void replaceSuperclass(ClassFile classToInject)
|
private void replaceSuperclass(ClassFile classToInject)
|
||||||
{
|
{
|
||||||
// find all classes which inherit from 'vanilla'. replace with classToInject
|
|
||||||
|
|
||||||
for (ClassFile cf : vanilla.getGroup().getClasses())
|
for (ClassFile cf : vanilla.getGroup().getClasses())
|
||||||
if (cf.getParentClass().equals(vanilla.getPoolClass()))
|
if (cf.getParentClass().equals(vanilla.getPoolClass()))
|
||||||
{
|
{
|
||||||
|
if (cf == classToInject) // of course this inherits from it.
|
||||||
|
continue;
|
||||||
|
|
||||||
cf.setParentClass(classToInject.getPoolClass());
|
cf.setParentClass(classToInject.getPoolClass());
|
||||||
|
|
||||||
// adjust constructors
|
// adjust constructors
|
||||||
@@ -275,11 +277,13 @@ public class InjectReplace
|
|||||||
// new vanilla -> new classToInject
|
// new vanilla -> new classToInject
|
||||||
|
|
||||||
for (ClassFile cf : vanilla.getGroup().getClasses())
|
for (ClassFile cf : vanilla.getGroup().getClasses())
|
||||||
if (cf.getParentClass().equals(vanilla.getPoolClass()))
|
|
||||||
{
|
|
||||||
for (Method m : cf.getMethods().getMethods())
|
for (Method m : cf.getMethods().getMethods())
|
||||||
{
|
{
|
||||||
Code code = m.getCode();
|
Code code = m.getCode();
|
||||||
|
|
||||||
|
if (code == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
Instructions ins = code.getInstructions();
|
Instructions ins = code.getInstructions();
|
||||||
|
|
||||||
boolean seen = false, isConstructor = m.getName().equals("<init>");
|
boolean seen = false, isConstructor = m.getName().equals("<init>");
|
||||||
@@ -319,4 +323,3 @@ public class InjectReplace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package net.runelite.deob.injection;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import net.runelite.deob.ClassGroup;
|
import net.runelite.deob.ClassGroup;
|
||||||
import net.runelite.deob.runeloader.MappingImporter;
|
|
||||||
import net.runelite.deob.util.JarUtil;
|
import net.runelite.deob.util.JarUtil;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|||||||
Reference in New Issue
Block a user