SRL Archive - Reflection Help

Finding Reflection Hooks?


ZaSz

2009-01-16 14:35:51

Someone please tell me how so I can update hooks on my own. + it will help me understand more about how rs works.

almost

2009-01-16 14:57:02

I would like to know how to do this also.
I asked around and I was told to ask Method about how to do this.
I think everything would be easier if we could update hooks ourselves, maybe I could even make a script to do it?

ZaSz

2009-01-16 15:02:05

From: almost
maybe I could even make a script to do it?


Thats what i was wanting to do also.

sirlaughsalot

2009-01-16 15:15:18

Method has a script that does it but it is on his computer which is bitch at him atm… although i think it is unwise for only him to have it =/

almost

2009-01-16 15:46:56

He has a script to do it!?
Why is this not a script that comes with reflection?
This is actually something typical for SRL…

sirlaughsalot

2009-01-16 16:03:29

im not sure if it is a script or what exactly it is but yes he has an updater…

Method

2009-01-16 16:43:08

From: Markus
Meh it's basically a script which rips it from RSBot nothing special on its own.


No it's not. Please don't give them false information without knowing the background behind things.

It's a java application that looks in the RuneScape client for classes and fields that follow specific patterns from build to build. Like sirlaughsalot said, I unfortunately don't have access to my computer right now, but I'm working on fixing whatever the problem is.

ZaSz

2009-01-16 17:57:18

Where are the hooks in rsbot? I looked and couldnt find.

almost

2009-01-16 18:16:41

Doesn't RSBot have something for their users to update the hooks?
Our method is a bit slow and painful.

noidea

2009-01-16 20:38:29

From: almost
Doesn't RSBot have something for their users to update the hooks?
Our method is a bit slow and painful.


I think not. I have to update my RSBot via SVN every time rs updates.

almost

2009-01-16 20:47:52

Well then I'm thinking we need multiple people who can get the SVN updated.
I haven't been able to work on my scripts once since last night.

NiCbaZ

2009-01-16 21:11:37

From: almost
Well then I'm thinking we need multiple people who can get the SVN updated.
I haven't been able to work on my scripts once since last night.


How so , i made a reflection PC for Scar, using the RSbot debuging system?

I can update the SNV, mehtod doesnt like to share the Hook updater, he proberly has a very good reason.

turbobk

2009-01-16 21:15:02

If you cbf waiting, use a program that can decompile and read .class files (DJ Java Decompiler) and copy the Hooks from RsBot when it updates.

I see that reflection is broken right now, ill go see if I can find the hooks.

almost

2009-01-16 21:28:10

How so , i made a reflection PC for Scar, using the RSbot debuging system?

What do you mean?
If you're talking about how I haven't been able to use my scripts, that would be because reflection has been broken the whole time.

I can update the SNV, mehtod doesnt like to share the Hook updater, he proberly has a very good reason.

Could be.
Really doubt it though.

Widget

2009-01-17 01:19:07

From: Markus
Meh it's basically a script which rips it from RSBot nothing special on its own.


Nope, that's this one (Written by BenLand100):
import java.io.*;
import java.util.*;
import java.util.zip.*;
import org.apache.bcel.classfile.*;
import org.apache.bcel.generic.*;

/**
* Parses RSBot's rs.jar file looking for specified methods in specific
* interfaces via bytecode manipulation, in order to convert the fields to SMART
* format paths. Figure it out, its simple and self explanatory...
* @author BenLand100
*/

public class SMART_RSBot_Parser {

/**
* Expand this with what you need, once again, easy to undestand.
*/
private static final Interface[] stuff = new Interface[] {
new Interface("com.speljohan.rsbot.accessors.Client",
"getPlane=BaseLayer",
"getBaseX=BaseX",
"getBaseY=BaseY",
"getCamPosX=CamX",
"getCamPosY=CamY",
"getCamPosZ=CamZ",
"getCameraCurveX=CamYaw",
"getCameraCurveY=CamPitch",
"getMinimapInt1=CompassAngle",
"getSkillLevels=CurrentLevels",
"getSkillExperiences=Experiences",
"getDestX=FlagX",
"getDestY=FlagY",
"getGroundIntArray=GroundHeights",
"getGroundByteArray=GroundSettings",
"getLoopCycle=LoopCycle",
"getLoginIndex=LoginIndex",
"getMinimapInt2=MapOffsetAngle",
"getSkillLevelMaxes=MaxLevels",
"getMyPlayer=MyPlayer",
"getNPCArray=NPCArray",
"getNPCCount=NPCCount",
"getNPCIndexArray=NPCIndexArray",
"getPlayerArray=PlayerArray",
"getPlayerCount=PlayerCount",
"getPlayerIndexArray=PlayerIndArray",
"getChatMessages=ChatMessages",
"getChatNames=ChatNames",
"getChatTypes=ChatTypes",
"getSettingArray=SettingsArray"),
new Interface("com.speljohan.rsbot.accessors.Character",
"getAnimation=CharAnim",
"isMoving=CharMotion",
"getX=CurrentX",
"getY=CurrentY",
"getHeight=CharHeight",
"getHPRatio=CharHPRatio",
"getLoopCycleStatus=LoopCycleStatus",
"getTurnDirection=TurnDirection",
"getInteracting {one won't work}=CharInteracting",
"getInteracting {one won't work}=SelfInteracting"),
new Interface("com.speljohan.rsbot.accessors.Player",
"getName=CharName",
"getPrayerHeadIcon=PrayerIcon",
"getLevel=CharLevel"),
new Interface("com.speljohan.rsbot.accessors.NPC",
"getNPCDef=NPCDef"),
new Interface("com.speljohan.rsbot.accessors.NPCDef",
"getName=NPCName",
"getType=NPCType"),
new Interface("com.speljohan.rsbot.accessors.RSString",
"getBytes=StringBytes"),
new Interface("com.speljohan.rsbot.accessors.Ground",
"getObject1=Object1",
"getObject2=Object2",
"getObject3=Object3",
"getObject4=Object4",
"getObject5Array=Object5Array"),
};

/**
* Simple class to hold interface information
*/
private static class Interface {
public String name; //Name of the interface implemented
public String[] data; //Refactoring, MethodName=HookName
public Interface(String name, String... data) {
this.name = name;
this.data = data;
}
};

/**
* Does the work, should not have to mess with this, unless you want to make
* it "user friendly"
* @param args
*/
public static void main(String[] args) {
try {
LinkedList<ClassGen> gens = getClassGens(new File("C:/Documents and Settings/Administrator/Desktop/RsBot/rs.jar")); // CHANGE THIS!!
HashMap<String,Interface> imap = new HashMap<String,Interface>();
System.out.println("const");
for (Interface i : stuff)
imap.put(i.name, i);
for (ClassGen gen : gens) {
String[] inters = gen.getInterfaceNames();
for (String inter : inters) {
if (imap.containsKey(inter)) {
Interface i = imap.remove(inter);
System.out.println(" // " + inter.split("accessors.")[1]);
HashMap<String,String> hooks = new HashMap<String,String>();
for (String data : i.data) {
String[] parts = data.split("\\=");
hooks.put(parts[0], parts[1]);
}
ConstantPoolGen cpg = gen.getConstantPool();
for (Method m : gen.getMethods()) {
String name = m.getName();
if (hooks.containsKey(name)) {
String hook = hooks.remove(name);
MethodGen mg = new MethodGen(m, gen.getClassName(), cpg);
InstructionList il = mg.getInstructionList();
Instruction[] ins = il.getInstructions();
String field = "";
if (ins[0] instanceof GETSTATIC) {
GETSTATIC get = (GETSTATIC)ins[0];
field = get.getClassName(cpg) + "." + get.getFieldName(cpg);
System.out.println(" " + hook + " = '" + field + "';");
} else {
GETFIELD get = (GETFIELD)ins[1];
field = get.getFieldName(cpg);
System.out.println(" " + hook + " = '" + field + "';");
}
//System.out.println(" " + hook + " = " + field + "");
}
}
System.out.println();
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}

/**
* Returns all ClassGens found in the rs.jar
* @param jar rs.jar file
* @return LinkedList of ClassGen
* @throws java.io.IOException
*/
private static LinkedList< ClassGen> getClassGens(File jar) throws IOException {
ZipInputStream zis = new ZipInputStream(new FileInputStream(jar));
LinkedList<ClassGen> gens = new LinkedList<ClassGen>();
byte buf[] = new byte[0xFFFF];
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
String name = entry.getName();
if (!name.endsWith(".class"))
continue;
name = name.replace(".class", "");
ByteArrayOutputStream bos = new ByteArrayOutputStream();
int len;
while ((len = zis.read(buf, 0, buf.length)) != -1) {
bos.write(buf, 0, len);
}
gens.add(new ClassGen(new ClassParser(new ByteArrayInputStream(bos.toByteArray()), name).parse()));
}
return gens;
}

}

It's outdated, feel free to update the fields. ObjectUIDs have to be done by hand though

ZaSz

2009-01-17 02:24:56

What field need to be updated?

NiCbaZ

2009-01-17 04:47:58

Seems Objects are not working.