Greetings,
I'm trying to create the very beginning of a bot. That is just reading the X, Y, Z coördinates of the player. This is what I have at the moment:
Player.h
Code:
#define MEM_ADDR_PLAYERBASE_PTR 0x0127F13C
#define MEM_ADDR_PLAYERBASE_PTR_OFFSET1 0x30
#define MEM_ADDR_PLAYERBASE_PTR_OFFSET2 0x28
#define MEM_ADDR_PLAYERBASE_HEALTH_OFFSET 0x0
#define MEM_ADDR_PLAYERBASE_MANA_OFFSET 0x0
#define MEM_ADDR_PLAYERBASE_X_OFFSET 0x7D0
#define MEM_ADDR_PLAYERBASE_Y_OFFSET 0x7D4
#define MEM_ADDR_PLAYERBASE_Z_OFFSET 0x7D8
#define MEM_ADDR_PLAYERBASE_ROTATION_OFFSET 0x7E2
#define MEM_ADDR_PLAYERNAME_OFFSET 0x011CB348
//0127F13C
// + 30
// + 28
//= PlayerBase
//x = PlayerBase + 7D0
//y = PlayerBase + 7D4
//z = PlayerBase + 7D8
//rot = PlayerBase + 7E2
class Player
{
HANDLE hProcess;
int mana;
int health;
float posX;
float posY;
float posZ;
float rotation;
public:
int getMana();
int getHealth();
float getX();
float getY();
float getZ();
float getRotation();
void Rotate(float degrees);
void Move(float x, float y);
void Update();
unsigned int baseAddress;
Player(HANDLE hProcess);
~Player();
};
Player.cpp
Code:
#include "stdafx.h"
Player::Player(HANDLE hProcess)
{
unsigned int base_ptr1, base_ptr2, base;
this->hProcess = hProcess;
ReadProcessMemory(hProcess, (LPCVOID)(MEM_ADDR_PLAYERBASE_PTR), (LPVOID)&base_ptr1, sizeof(unsigned int), 0);
ReadProcessMemory(hProcess, (LPCVOID)(base_ptr1 + MEM_ADDR_PLAYERBASE_PTR_OFFSET1), (LPVOID)&base_ptr2, sizeof(unsigned int), 0);
ReadProcessMemory(hProcess, (LPCVOID)(base_ptr2 + MEM_ADDR_PLAYERBASE_PTR_OFFSET2), (LPVOID)&(this->baseAddress), sizeof(unsigned int), 0);
}
Player::~Player()
{
}
int Player::getMana()
{
return this->mana;
}
int Player::getHealth()
{
return this->health;
}
float Player::getX()
{
return this->posX;
}
float Player::getY()
{
return this->posY;
}
float Player::getZ()
{
return this->posZ;
}
float Player::getRotation()
{
return this->rotation;
}
void Player::Rotate(float degrees)
{
}
void Player::Move(float x, float y)
{
}
void Player::Update()
{
ReadProcessMemory(hProcess, (LPCVOID)(this->baseAddress + MEM_ADDR_PLAYERBASE_X_OFFSET), (LPVOID)&(this->posX), sizeof(float), 0);
ReadProcessMemory(hProcess, (LPCVOID)(this->baseAddress + MEM_ADDR_PLAYERBASE_Y_OFFSET), (LPVOID)&(this->posY), sizeof(float), 0);
ReadProcessMemory(hProcess, (LPCVOID)(this->baseAddress + MEM_ADDR_PLAYERBASE_Z_OFFSET), (LPVOID)&(this->posZ), sizeof(float), 0);
}
And the generated UI.
In the UI I allocate some memory for the class player when the form loads, then I use the Update() function and set the text of textbox1 to the X position of the player using the getX() function
Code:
pPlayer = new Player(hProcess);
pPlayer->Update();
this->textBox1->Text = pPlayer->getX().ToString();
this->textBox2->Text = pPlayer->getY().ToString();
this->textBox3->Text = pPlayer->getZ().ToString();
But when I try this it always says -4,316021E+08 in the textbox and I don't why.
NOTE: I'm using 3.0.9
Could anyone help me fix this?
Thanks