Quote:
Originally Posted by ntldr32
why not just use J#. ? its Java on .Net, with it you can use C# function that used by many ppl here, i use they C# function (in *.dll compiled) along with VB.net (w/o convert), when my function look good, i compile it into *.dll so other .Net user can use it XD.
this is what i made [Only registered and activated users can see links. Click Here To Register...] write in VB, used Memfunctions and PacketSender class (C#) from interest07 [Only registered and activated users can see links. Click Here To Register...].
|
I understand what you are saying,
however I have already made those things in Java on top my underlying framework (along with plenty other functions).
sendPacket function in JIT assembly:
Code:
package pwbot.module.functions;
import jnr.x86asm.Asm;
import jnr.x86asm.Assembler;
import jnr.x86asm.SEGMENT;
import botfw.injection.AsmFunction;
import java.util.Properties;
/**
* A function for sending a packet in Perfect World International elementclient.exe
*/
public class SendPacketFunction extends AsmFunction {
/**
* The size of the buffer for packets.
*/
// Make that 1kB
public static final int BUFFER_SIZE = 1024;
/**
* The buffer that contains the packet data to send
*/
Parameter packetBuffer;
/**
* The size of the packet
*/
Parameter packetSize;
/**
* Constructs a new <code>SendPacketFunction</code> using the specified settings
* @param sendPacketAddress The address of the send packet function in memory
* @param realBaseAddress The base address
*/
public SendPacketFunction(Properties addressMap) {
super(addressMap);
packetBuffer = new Parameter("buffer", "The buffer containing the packet data", BUFFER_SIZE);
packetSize = new Parameter("size", "The size of the packet to send", 4);
}
@Override
public void assemble(Assembler assembler) {
assembler.pushad();
assembler.mov(Asm.eax, Asm.imm(addressOf("sendpacket")));
assembler.mov(Asm.ecx, Asm.dword_ptr_abs(addressOf("realbaseaddress"), 0, SEGMENT.SEGMENT_NONE));
assembler.mov(Asm.ecx, Asm.dword_ptr(Asm.ecx, 0x20));
assembler.mov(Asm.edi, Asm.imm(addressOf(packetBuffer)));
assembler.push(Asm.dword_ptr_abs(addressOf(packetSize), 0, SEGMENT.SEGMENT_NONE));
assembler.push(Asm.edi);
assembler.call(Asm.eax);
assembler.popad();
assembler.ret();
}
}
moveTo function in JIT assembly:
Code:
package pwbot.module.functions;
import botfw.injection.AsmFunction;
import jnr.x86asm.Asm;
import jnr.x86asm.Assembler;
import jnr.x86asm.Register;
import jnr.x86asm.SEGMENT;
import java.util.Properties;
/**
*
*/
public class MoveToFunction extends AsmFunction {
/**
* The destination X position
*/
Parameter destX;
/**
* The destination Y position
*/
Parameter destY;
/**
* The destination Z position
*/
Parameter destZ;
/**
* The height to fly at
*/
Parameter height;
/**
* 26625 to fly, 26624 to not fly
*/
Parameter fly1;
/**
* 256 to fly, 65536 to not fly
*/
Parameter fly2;
/**
* Constructs this <code>MoveToFunction</code>
*/
public MoveToFunction(Properties addressMap) {
super(addressMap);
// Set up parameters
destX = new Parameter("x", "The destination X coord", 4);
destY = new Parameter("y", "The destination Y coord", 4);
destZ = new Parameter("z", "The destination Z coord", 4);
height = new Parameter("height", "The height to fly at", 4);
fly1 = new Parameter("fly1", "26625 to fly, 26624 to not fly", 4);
fly2 = new Parameter("fly2", "256 to fly, 65536 to not fly", 4);
}
@Override
protected void assemble(Assembler assembler) {
// Name our registers in a way that makes sense
Register actionStruct = Asm.eax;
Register moveAction = Asm.ecx;
Register buffer = Asm.edi;
// Put the action struct address into eax register
assembler.mov(actionStruct, Asm.dword_ptr_abs(addressOf("baseaddress"), 0, SEGMENT.SEGMENT_NONE));
assembler.mov(actionStruct, Asm.dword_ptr(actionStruct, addressOf("actionbase")));
assembler.mov(actionStruct, Asm.dword_ptr(actionStruct, addressOf("actionstruct")));
// Put the move action struct into ebx
assembler.mov(moveAction, Asm.dword_ptr(actionStruct, addressOf("actionlist")));
assembler.mov(moveAction, Asm.dword_ptr(moveAction, addressOf("moveaction")));
// Specify we have not finished and that we would like to start
assembler.mov(Asm.dword_ptr(moveAction, addressOf("actionfinished")), Asm.imm(0));
assembler.mov(Asm.dword_ptr(moveAction, addressOf("actionstart")), Asm.imm(1));
// Specify the X coordinate
assembler.mov(buffer, Asm.dword_ptr_abs(addressOf(destX), 0, SEGMENT.SEGMENT_NONE));
assembler.mov(Asm.dword_ptr(moveAction, addressOf("movex")), buffer);
// Specify the Y coordinate
assembler.mov(buffer, Asm.dword_ptr_abs(addressOf(destY), 0, SEGMENT.SEGMENT_NONE));
assembler.mov(Asm.dword_ptr(moveAction, addressOf("movey")), buffer);
// Specify the Z coordinate
assembler.mov(buffer, Asm.dword_ptr_abs(addressOf(destZ), 0, SEGMENT.SEGMENT_NONE));
assembler.mov(Asm.dword_ptr(moveAction, addressOf("movez")), buffer);
// Specify the height
assembler.mov(buffer, Asm.dword_ptr_abs(addressOf(height), 0, SEGMENT.SEGMENT_NONE));
assembler.mov(Asm.dword_ptr(moveAction, addressOf("moveh")), buffer);
// Specify flight1
assembler.mov(buffer, Asm.dword_ptr_abs(addressOf(fly1), 0, SEGMENT.SEGMENT_NONE));
assembler.mov(Asm.dword_ptr(moveAction, addressOf("flyup1")), buffer);
// Specify flight2
assembler.mov(buffer, Asm.dword_ptr_abs(addressOf(fly2), 0, SEGMENT.SEGMENT_NONE));
assembler.mov(Asm.dword_ptr(moveAction, addressOf("flyup2")), buffer);
// Specify move type (always 0)
assembler.mov(buffer, Asm.imm(0));
assembler.mov(Asm.dword_ptr(moveAction, addressOf("movetype")), buffer);
// Set current action1
assembler.mov(Asm.dword_ptr(actionStruct, addressOf("currentaction1")), moveAction);
// Set current position in the action list
assembler.mov(Asm.dword_ptr(actionStruct, addressOf("actionposition")), Asm.imm(1));
// Set current action2
assembler.mov(Asm.dword_ptr(actionStruct, addressOf("currentaction2")), moveAction);
// Return
assembler.ret();
}
}
sendPacket convenience method:
Code:
/**
* Sends a packet to the server
* @param buffer The buffer containing packet data
*/
private void sendPacket(byte[] buffer) {
RemoteFunction fn = super.getFunction("sendpacket");
Memory memory = new Memory(buffer.length);
memory.write(0,buffer,0,buffer.length);
fn.setParameter("buffer", memory);
memory = new Memory(4);
memory.setInt(0, buffer.length);
fn.setParameter("size", memory);
fn.call();
}
moveTo convenience method:
Code:
/**
* Moves the player to the specified location
* @param x The X coordinate to move to
* @param y The Y coordinate to move to
* @param z The Z coordinate to move to
* @param height The height to fly at
*/
public void moveTo(float x, float y, float z, float height) {
RemoteFunction fn = super.getFunction("moveto");
Memory memory;
// Specify X
memory = new Memory(4);
memory.setFloat(0,x);
fn.setParameter("x", memory);
// Specify Y
memory = new Memory(4);
memory.setFloat(0,y);
fn.setParameter("y", memory);
// Specify Z
memory = new Memory(4);
memory.setFloat(0,z);
fn.setParameter("z", memory);
// Specify height
memory = new Memory(4);
memory.setFloat(0,height);
fn.setParameter("height", memory);
// Specify fly1
memory = new Memory(4);
memory.setInt(0,height>0?26625:26624);
fn.setParameter("fly1",memory);
// Specify fly2
memory = new Memory(4);
memory.setInt(0,height>0?256:65536);
fn.setParameter("fly2",memory);
// Call the function
fn.call();
}
Usage of sendPacket:
Code:
/**
* Picks up an item
* @param itemIndex The index of the item, some would call that the "unique id"
* @param typeId The ID of the item type to pick
*/
public void pickUp(int itemIndex, int typeId) {
ByteBuffer buffer = ByteBuffer.allocate(10);
buffer.order(ByteOrder.LITTLE_ENDIAN);
buffer.putShort(0, (short)0x6);
buffer.putInt(2, itemIndex);
buffer.putInt(6, typeId);
sendPacket(buffer.array());
}
Those things have a small creation cost but after they are made, they are pretty damn fast. I recon executing my JITed moveTo function would beat the current way of doing it in terms of performance, since I'm resolving absolutely no pointers and issuing a single write to overwrite the parameter stack, along with that I already have a suspended thread waiting to execute it (I am not creating and killing threads for every call).
It's convenient, doesn't require much more time for me to use (if at all), and has all of the features .NET has to offer.
Check this out, in-bot IDE:
[Only registered and activated users can see links. Click Here To Register...]
Annotated function:
Code:
@FuncDesc(description = "Walks (or runs) to the specified ground location")
public void walkTo(
@ParamDesc(name="x",description="The destination X coordinate",type="Number")
float x,
@ParamDesc(name="y",description="The destination Y coordinate",type="Number")
float y,
@ParamDesc(name="z",description="The destination Z coordinate",type="Number")
float z
) {
moveTo(x,y,z,-1);
}