Instance Variables with Applet Reflection
Hey guys, so I have a problem with hooking using reflection, the software I have was built so it can get methods from the applet. However I do not know how to grab instance variables.
This is the Class that Loads the applet and puts the main class into an interface called Client.
Code Java:
Client hook;
public void a() {
try {
ClassThing b1 = new ClassThing();
byte abyte0[] = a("http://applet.com/appletlinkgoeshere", "Starting up");
if (abyte0 == null)
throw new Exception("Client download failed");
b1.a = new ClientClassLoader(abyte0);
Class class1 = b1.loadClass("sign.signlink");
class1.getField("mainapp").set(null, this);
Class class2 = b1.loadClass("client");
reflectObject = class2.newInstance();
_fldfor = (Applet) reflectObject;
_fldfor.init();
_fldfor.start();
setClient((Client) _fldfor);
/*java.lang.reflect.Field[] fields = class2.getFields();
for (int i=0; i<fields.length;i++) {
System.out.println(fields[i]);
}*/
} catch (Exception exception) {
String s = exception.getMessage();
if (s == null)
s = "null";
a(s);
exception.printStackTrace();
}
}
public void setClient(Client c) {
hook = c;
}
This is the client interface with all the methods from within the applet
Code Java:
package com.bsbot.hooks;
import java.awt.*;
public interface Client extends RSApplet {
public String getUsername();
public String getPassword();
public Component getGameComponentHook(int a);
public Npc[] getNpcs();
public int getBaseX();
public int getBaseY();
public Player getMyPlayer();
public int getPlayerId();
public int getTime();
public int[] getMaxStats();
public int[] getCurrentStats();
public int[] getExperience();
public boolean isLoggedIn();
public Player[] getPlayers();
public String getLoginMessage2();
public boolean isMenuOpen();
public String[] getMenuActionNames();
public int getMenuActionRow();
int getMenuOffsetX();
int getMenuOffsetY();
String[] getChatMessages();
int getMinimapInt1();
int getMinimapInt2();
int getMinimapInt3();
int getXCameraCurve();
int getYCameraCurve();
int getXCameraPos();
int getYCameraPos();
int getZCameraPos();
int getPlane();
public void setLoginIndex(int i);
public int getLoginIndex();
int getOpenTab();
int[][][] getGroundIntArray();
byte[][][] getGroundByteArray();
GameInterface[][] getInterfaceCache();
public String getSelectedItemName();
public ItemDef getForId(int id);
public ObjectDef getForIdObject(int id);
int getMouseX();
int getMouseY();
public NodeList[][][] getGroundArray();
public WorldController getWorldController();
}
So my question is how can I get and use an instance variable that already exists in the applet? For example, in the applet there is: public String eN;
How can I get the value of eN to use in my reflection program?
Help is VERY appreciated, because I've spent some time banging my head against my desk.
Re: Instance Variables with Applet Reflection
Look at the Field class and the Class class methods that get them.
Re: Instance Variables with Applet Reflection
I understand how to use the Field class to get the data but I just need help putting it all together so its inside the interface.
Each of the methods inside that Client class just returns the instance variables I want to get, but I can't do it though the getter methods, I need to obtain it directly using the Field stuff.
Re: Instance Variables with Applet Reflection
Can you post code that shows the problem? Something that compiles and executes.
Re: Instance Variables with Applet Reflection
Quote:
Originally Posted by
Norm
Can you post code that shows the problem? Something that compiles and executes.
It's basically a bot program that grabs information from the game client using the methods such as getUsername(). Since I can't have getUsername() return a field in the client (jar reflection) because it is an interface, I need a way to do this. The bot scripts that I have written uses this hook to grab the information using methods such as getUsername().
Re: Instance Variables with Applet Reflection
Can you make a small program that shows the problem, not the whole program that will have lots of things not related to this problem.