Modify src debuginfo to make stacktraces less cryptical
This commit is contained in:
@@ -66,14 +66,3 @@ val compileTestKotlin: KotlinCompile by tasks
|
|||||||
compileTestKotlin.kotlinOptions {
|
compileTestKotlin.kotlinOptions {
|
||||||
jvmTarget = "1.8"
|
jvmTarget = "1.8"
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
}
|
|
||||||
publications {
|
|
||||||
register("asd", MavenPublication::class) {
|
|
||||||
from(components["java"])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -23,6 +23,8 @@ import com.openosrs.injector.injectors.raw.RasterizerAlpha;
|
|||||||
import com.openosrs.injector.injectors.raw.RenderDraw;
|
import com.openosrs.injector.injectors.raw.RenderDraw;
|
||||||
import com.openosrs.injector.injectors.raw.ScriptVM;
|
import com.openosrs.injector.injectors.raw.ScriptVM;
|
||||||
import com.openosrs.injector.rsapi.RSApi;
|
import com.openosrs.injector.rsapi.RSApi;
|
||||||
|
import com.openosrs.injector.transformers.InjectTransformer;
|
||||||
|
import com.openosrs.injector.transformers.SourceChanger;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import net.runelite.deob.util.JarUtil;
|
import net.runelite.deob.util.JarUtil;
|
||||||
@@ -78,6 +80,8 @@ public class Injection extends InjectData implements InjectTaskHandler
|
|||||||
inject(new HidePlayerAttacks(this));
|
inject(new HidePlayerAttacks(this));
|
||||||
|
|
||||||
validate(new InjectorValidator(this));
|
validate(new InjectorValidator(this));
|
||||||
|
|
||||||
|
transform(new SourceChanger(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(File outputJar) throws IOException
|
public void save(File outputJar) throws IOException
|
||||||
@@ -113,6 +117,17 @@ public class Injection extends InjectData implements InjectTaskHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void transform(InjectTransformer transformer)
|
||||||
|
{
|
||||||
|
final String name = transformer.getName();
|
||||||
|
|
||||||
|
log.info("Starting {}", name);
|
||||||
|
|
||||||
|
transformer.transform();
|
||||||
|
|
||||||
|
log.lifecycle("{} {}", name, transformer.getCompletionMsg());
|
||||||
|
}
|
||||||
|
|
||||||
public void runChildInjector(Injector injector) throws Injexception
|
public void runChildInjector(Injector injector) throws Injexception
|
||||||
{
|
{
|
||||||
inject(injector);
|
inject(injector);
|
||||||
|
|||||||
@@ -9,14 +9,16 @@ package com.openosrs.injector;
|
|||||||
|
|
||||||
import com.openosrs.injector.injection.InjectData;
|
import com.openosrs.injector.injection.InjectData;
|
||||||
import com.openosrs.injector.rsapi.RSApi;
|
import com.openosrs.injector.rsapi.RSApi;
|
||||||
import static com.openosrs.injector.rsapi.RSApi.API_BASE;
|
|
||||||
import com.openosrs.injector.rsapi.RSApiClass;
|
import com.openosrs.injector.rsapi.RSApiClass;
|
||||||
import com.openosrs.injector.rsapi.RSApiMethod;
|
import com.openosrs.injector.rsapi.RSApiMethod;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import net.runelite.asm.ClassFile;
|
import net.runelite.asm.ClassFile;
|
||||||
import net.runelite.asm.pool.Class;
|
import net.runelite.asm.pool.Class;
|
||||||
import org.gradle.api.logging.Logger;
|
import org.gradle.api.logging.Logger;
|
||||||
import org.gradle.api.logging.Logging;
|
import org.gradle.api.logging.Logging;
|
||||||
|
import static com.openosrs.injector.rsapi.RSApi.API_BASE;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class InjectorValidator implements Validator
|
public class InjectorValidator implements Validator
|
||||||
{
|
{
|
||||||
private static final Logger log = Logging.getLogger(InjectorValidator.class);
|
private static final Logger log = Logging.getLogger(InjectorValidator.class);
|
||||||
@@ -25,11 +27,6 @@ public class InjectorValidator implements Validator
|
|||||||
|
|
||||||
private int missing = 0, okay = 0, wtf = 0;
|
private int missing = 0, okay = 0, wtf = 0;
|
||||||
|
|
||||||
InjectorValidator(InjectData inject)
|
|
||||||
{
|
|
||||||
this.inject = inject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean validate()
|
public boolean validate()
|
||||||
{
|
{
|
||||||
final RSApi rsApi = inject.getRsApi();
|
final RSApi rsApi = inject.getRsApi();
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.openosrs.injector;
|
package com.openosrs.injector;
|
||||||
|
|
||||||
public class Injexception extends Exception
|
public class Injexception extends RuntimeException
|
||||||
{
|
{
|
||||||
public Injexception(String message)
|
public Injexception(String message)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,20 +9,17 @@ package com.openosrs.injector.injectors;
|
|||||||
|
|
||||||
import com.google.common.base.Stopwatch;
|
import com.google.common.base.Stopwatch;
|
||||||
import com.openosrs.injector.injection.InjectData;
|
import com.openosrs.injector.injection.InjectData;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.gradle.api.logging.Logger;
|
import org.gradle.api.logging.Logger;
|
||||||
import org.gradle.api.logging.Logging;
|
import org.gradle.api.logging.Logging;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
public abstract class AbstractInjector implements Injector
|
public abstract class AbstractInjector implements Injector
|
||||||
{
|
{
|
||||||
protected final InjectData inject;
|
protected final InjectData inject;
|
||||||
protected final Logger log = Logging.getLogger(this.getClass());
|
protected final Logger log = Logging.getLogger(this.getClass());
|
||||||
private Stopwatch stopwatch;
|
private Stopwatch stopwatch;
|
||||||
|
|
||||||
protected AbstractInjector(InjectData inject)
|
|
||||||
{
|
|
||||||
this.inject = inject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void start()
|
public void start()
|
||||||
{
|
{
|
||||||
stopwatch = Stopwatch.createStarted();
|
stopwatch = Stopwatch.createStarted();
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020, Lucas <https://github.com/Lucwousin>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is licensed under GPL3, see the complete license in
|
||||||
|
* the LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
package com.openosrs.injector.transformers;
|
||||||
|
|
||||||
|
import com.google.common.base.Stopwatch;
|
||||||
|
import com.openosrs.injector.injection.InjectData;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import net.runelite.asm.Named;
|
||||||
|
import org.gradle.api.logging.Logger;
|
||||||
|
import org.gradle.api.logging.Logging;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public abstract class InjectTransformer implements Named
|
||||||
|
{
|
||||||
|
protected final InjectData inject;
|
||||||
|
protected final Logger log = Logging.getLogger(this.getClass());
|
||||||
|
private Stopwatch stopwatch;
|
||||||
|
|
||||||
|
public final void transform()
|
||||||
|
{
|
||||||
|
stopwatch = Stopwatch.createStarted();
|
||||||
|
transformImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract void transformImpl();
|
||||||
|
|
||||||
|
public final String getCompletionMsg()
|
||||||
|
{
|
||||||
|
return "finished in " + stopwatch.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final String getName()
|
||||||
|
{
|
||||||
|
return this.getClass().getSimpleName();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020, Lucas <https://github.com/Lucwousin>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is licensed under GPL3, see the complete license in
|
||||||
|
* the LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
package com.openosrs.injector.transformers;
|
||||||
|
|
||||||
|
import com.openosrs.injector.injection.InjectData;
|
||||||
|
import net.runelite.asm.ClassFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class changes the java source file debug information to the rs-client file name
|
||||||
|
*/
|
||||||
|
public class SourceChanger extends InjectTransformer
|
||||||
|
{
|
||||||
|
private int n = 0;
|
||||||
|
|
||||||
|
public SourceChanger(InjectData inject)
|
||||||
|
{
|
||||||
|
super(inject);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void transformImpl()
|
||||||
|
{
|
||||||
|
inject.forEachPair(this::rename);
|
||||||
|
log.info("Changed source file debug information for {} classes", n);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rename(ClassFile rsclient, ClassFile vanilla)
|
||||||
|
{
|
||||||
|
++n;
|
||||||
|
final String newSrc = rsclient.getSource();
|
||||||
|
log.debug("Changing src from {} to {}", vanilla.getSource(), newSrc);
|
||||||
|
vanilla.setSource(newSrc);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020, Lucas <https://github.com/Lucwousin>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is licensed under GPL3, see the complete license in
|
||||||
|
* the LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
package com.openosrs.injector.transformers;
|
||||||
|
|
||||||
|
import com.openosrs.injector.Injexception;
|
||||||
|
import com.openosrs.injector.injection.InjectData;
|
||||||
|
import com.openosrs.injector.injectors.Injector;
|
||||||
|
import com.openosrs.injector.transformers.srcchangeclasses.NewName;
|
||||||
|
import com.openosrs.injector.transformers.srcchangeclasses.OldName;
|
||||||
|
import java.lang.invoke.MethodHandles;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
import net.runelite.asm.ClassFile;
|
||||||
|
import net.runelite.asm.ClassGroup;
|
||||||
|
import net.runelite.asm.objectwebasm.NonloadingClassWriter;
|
||||||
|
import net.runelite.asm.visitors.ClassFileVisitor;
|
||||||
|
import org.junit.Ignore;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.objectweb.asm.ClassReader;
|
||||||
|
import org.objectweb.asm.ClassWriter;
|
||||||
|
|
||||||
|
public class SourceChangerTest
|
||||||
|
{
|
||||||
|
private static final String PACKAGE = "com.openosrs.injector.transformers.srcchangeclasses.";
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Ignore // Ignored because it's not really testing anything atm, but it works!
|
||||||
|
public void test() throws Exception
|
||||||
|
{
|
||||||
|
final ClassFileVisitor deob = new ClassFileVisitor(), vann = new ClassFileVisitor();
|
||||||
|
new ClassReader(PACKAGE + "NewName").accept(deob, ClassReader.SKIP_FRAMES);
|
||||||
|
new ClassReader(PACKAGE + "OldName").accept(vann, ClassReader.SKIP_FRAMES);
|
||||||
|
|
||||||
|
new SourceChanger(
|
||||||
|
new InjectData(new ClassGroup(), new ClassGroup(), null, null) {
|
||||||
|
public void runChildInjector(Injector injector) throws Injexception {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachPair(BiConsumer<ClassFile, ClassFile> consumer)
|
||||||
|
{
|
||||||
|
consumer.accept(deob.getClassFile(), vann.getClassFile());
|
||||||
|
}
|
||||||
|
}).transformImpl();
|
||||||
|
|
||||||
|
final ClassGroup group = new ClassGroup();
|
||||||
|
group.addClass(vann.getClassFile());
|
||||||
|
|
||||||
|
final ClassWriter cw = new NonloadingClassWriter(group, 0);
|
||||||
|
vann.getClassFile().accept(cw);
|
||||||
|
|
||||||
|
OldName obj = (OldName) MethodHandles.privateLookupIn(
|
||||||
|
NewName.class,
|
||||||
|
MethodHandles.lookup())
|
||||||
|
.defineClass(cw.toByteArray())
|
||||||
|
.getDeclaredConstructor()
|
||||||
|
.newInstance();
|
||||||
|
|
||||||
|
obj.obfMethodName();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020, Lucas <https://github.com/Lucwousin>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is licensed under GPL3, see the complete license in
|
||||||
|
* the LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
package com.openosrs.injector.transformers.srcchangeclasses;
|
||||||
|
|
||||||
|
public class NewName
|
||||||
|
{
|
||||||
|
public void deobMethodName()
|
||||||
|
{
|
||||||
|
// do something interesting
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020, Lucas <https://github.com/Lucwousin>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is licensed under GPL3, see the complete license in
|
||||||
|
* the LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
package com.openosrs.injector.transformers.srcchangeclasses;
|
||||||
|
|
||||||
|
public class OldName
|
||||||
|
{
|
||||||
|
public void obfMethodName()
|
||||||
|
{
|
||||||
|
new RuntimeException().printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user