Dearest community!
Im stuck at trying to code a simple dll for teleport functions in AssaultCube!
What Im trying to do is:
- attach my dll to assaultcube client
- If pressed a key (for example Page Up: VK_PRIOR) a function which saves the
current XYZ location of my player
- If pressed a key (for example Page Down: VK_NEXT)a function which writes
the saved XYZ location of my player
I have coded a console application which works fine, it teleports perfect.
But with this DLL (attached with Winject or Injectamonkey) simply nothing happens! I have no idea what im doing wrong..
I searched for all the offsets and the base address using Tsearch,CheatEngine.
I have Windows XP PRO, Microsoft Visual C++ 2010 Express.
Im new to coding so sorry for dumb unclean coding..
Here's the code:
main.cpp:
Code:
#include "player.h"
#include <Windows.h>
cPlayer *local;
void teleport()
{
//if page up is pressed call the functions add_offset() and save_XYZCoord(parameters: long &iaXCoord, long &iaYCoord, long &iaZCoord)
if(GetAsyncKeyState(VK_PRIOR)){
local->add_offset();
local->save_XYZCoord(local->iaXCoord,local->iaYCoord,local->iaZCoord);
}
//if page down is pressed call the function copy_XYZCoord(parameters: long &viXCoord, long &viYCoord, long &viZCoord)
if(GetAsyncKeyState(VK_NEXT)){
local->copy_XYZCoord(local->viXCoord,local->viYCoord,local->viZCoord);
}
}
BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpReserved )
{
if( dwReason == DLL_PROCESS_ATTACH )
{
CreateThread( NULL, NULL, (LPTHREAD_START_ROUTINE)teleport, NULL, NULL, NULL);
}
return TRUE;
}
player.h:
Code:
class cPlayer;
class cPlayer
{
public:
//Offsets and bases
long iBase; //0x004df73c
long iXCoord_offset; //0x34
long iYCoord_offset; //0x3c
long iZCoord_offset; //0x38
//addition of base and offset
long iaXCoord;
long iaYCoord;
long iaZCoord;
//temporary value to save the coordinate
long viXCoord;
long viYCoord;
long viZCoord;
//the function to add offset to the base
void add_offset(){
iBase = 0x004df73c;
iXCoord_offset = 0x34;
iYCoord_offset = 0x3c;
iZCoord_offset = 0x38;
iaXCoord = iBase+iXCoord_offset;
iaYCoord = iBase+iYCoord_offset;
iaZCoord = iBase+iZCoord_offset;
}
//the function to save the coordinates
void save_XYZCoord(long &iaXCoord, long &iaYCoord, long &iaZCoord){
viXCoord = iaXCoord;
viYCoord = iaYCoord;
viZCoord = iaZCoord;
}
//the function to write the saved location
void copy_XYZCoord(long &viXCoord, long &viYCoord, long &viZCoord){
iaXCoord = viXCoord;
iaYCoord = viYCoord;
iaZCoord = viZCoord;
}
};
Help would be much appreciated!