Skip to content

Commit

Permalink
deobber: fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatGamerBlue committed Aug 26, 2020
1 parent ffce418 commit 106de31
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.ajoberstar.grgit.Grgit

buildscript {
repositories {
mavenLocal()
gradlePluginPortal()
maven(url = "https://repo.openosrs.com/repository/maven/")
maven(url = "https://raw.githubusercontent.com/open-osrs/hosting/master")
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ object ProjectVersions {

const val openosrsVersion = "3.4.2"

const val rsversion = 190
const val rsversion = 191
const val cacheversion = 165
}
6 changes: 3 additions & 3 deletions deobfuscator/deobfuscator.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,22 @@ tasks {
filteringCharset = "UTF-8"
}
// TODO: Enable assertions on all 3
register<JavaExec>("Downloader.main()") {
register<JavaExec>("Downloader\$main()") {
group = "gamepack"

classpath = project.sourceSets.main.get().runtimeClasspath
main = "net.runelite.gamepack.Downloader"
}

register<JavaExec>("Deob.main()") {
register<JavaExec>("Deob\$main()") {
group = "gamepack"

classpath = project.sourceSets.main.get().runtimeClasspath
main = "net.runelite.deob.Deob"
args = listOf(tokens["vanilla.jar"], "$buildDir/libs/deobfuscated-$version.jar")
}

register<JavaExec>("UpdateMappings.main()") {
register<JavaExec>("UpdateMappings\$main()") {
group = "gamepack"

classpath = project.sourceSets.main.get().runtimeClasspath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@
import net.runelite.asm.signature.Signature;
import net.runelite.asm.signature.util.VirtualMethods;
import net.runelite.deob.DeobAnnotations;
import static net.runelite.deob.DeobAnnotations.*;
import net.runelite.deob.Deobfuscator;
import net.runelite.deob.util.NameMappings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static net.runelite.deob.DeobAnnotations.OBFUSCATED_NAME;
import static net.runelite.deob.DeobAnnotations.OBFUSCATED_SIGNATURE;

public class Renamer implements Deobfuscator
{
Expand Down Expand Up @@ -137,7 +136,10 @@ private void renameClass(ClassGroup group, ClassFile cf, String name)

if (!method.getDescriptor().equals(newSignature))
{
method.findAnnotation(OBFUSCATED_SIGNATURE, true).setElement( "descriptor", method.getDescriptor().toString());
if (method.findAnnotation(OBFUSCATED_SIGNATURE) == null)
{
method.findAnnotation(OBFUSCATED_SIGNATURE, true).setElement("descriptor", method.getDescriptor().toString());
}
}

method.setDescriptor(newSignature);
Expand All @@ -154,7 +156,10 @@ private void renameClass(ClassGroup group, ClassFile cf, String name)
{
if (field.getType().getInternalName().equals(cf.getName()))
{
field.findAnnotation(OBFUSCATED_SIGNATURE, true).setElement("descriptor", field.getType().toString());
if (field.findAnnotation(OBFUSCATED_SIGNATURE) == null)
{
field.findAnnotation(OBFUSCATED_SIGNATURE, true).setElement("descriptor", field.getType().toString());
}
field.setType(Type.getType("L" + name + ";", field.getType().getDimensions()));
}
}
Expand All @@ -168,10 +173,16 @@ private void renameClass(ClassGroup group, ClassFile cf, String name)
private void regeneratePool(ClassGroup group)
{
for (ClassFile cf : group.getClasses())
{
for (Method m : cf.getMethods())
{
if (m.getCode() != null)
{
m.getCode().getInstructions()
.regeneratePool();
}
}
}
}

@Override
Expand Down Expand Up @@ -276,6 +287,9 @@ else if (newParams.length < 1 || index > newParams.length - 1 || Strings.isNullO

private static <T extends Annotated & Named> void addObfuscatedName(T object)
{
object.findAnnotation(OBFUSCATED_NAME, true).setElement(object.getName());
if (object.findAnnotation(OBFUSCATED_NAME) == null)
{
object.findAnnotation(OBFUSCATED_NAME, true).setElement(object.getName());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private int copyAnnotations(Annotated from, Annotated to)
{
if (isCopyable(a))
{
to.addAnnotation(a.getType(), a);
to.addAnnotation(a);
++count;
}
}
Expand Down

0 comments on commit 106de31

Please sign in to comment.