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.
2009-01-16 14:35:51
2009-01-16 14:57:02
2009-01-16 15:02:05
From: almost
maybe I could even make a script to do it?
2009-01-16 15:15:18
2009-01-16 15:46:56
2009-01-16 16:03:29
2009-01-16 16:43:08
From: Markus
Meh it's basically a script which rips it from RSBot nothing special on its own.
2009-01-16 17:57:18
2009-01-16 18:16:41
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.
2009-01-16 20:47:52
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.
2009-01-16 21:15:02
2009-01-16 21:28:10
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.
2009-01-17 01:19:07
From: Markus
Meh it's basically a script which rips it from RSBot nothing special on its own.
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;
}
}2009-01-17 02:24:56
2009-01-17 04:47:58