Need Help - Uninitialized Local Variable?

Having problem with my code I will post below. In the RPM/WPM section I used to have (LocalPlayerBasePointer + AmmoOffset) when I had this instead of (RifleAmmoAddress) the code would work.

But when I try to make it simple and easier to read by creating a new variable: DWORD RifleAmmoAddress = LocalPlayerBasePointer + AmmoOffset and use it as shown below in the RPM/WPM it won't work using the new simplified variable.

Anyone know what I'm doing wrong can you please help me thanks? I been trying to figure out for days and cannot find what is wrong.
=========================================================================


// Address Findings //
DWORD AmmoOffset = 0x150;
DWORD ClientBaseAddress = 0x400000;
DWORD ClientOffset = 0x109b74;

// STORED VALUES //
int LocalPlayerBasePointer;
int CurrentAmmo;
int NewAmmovalue;

// FINAL DECLARATIONS //
DWORD ClientAddress = ClientBaseAddress + ClientOffset;
DWORD RifleAmmoAddress = LocalPlayerBaseAddress + AmmoOffset;



DWORD Process_ID;
GetWindowThreadProcessId(hWnd, &Process_ID);
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, Process_ID);

if (!hProcess)

{
MessageBox(NULL, "Cannot Find Process", "Error", MB_OK + MB_ICONERROR);
}


{
ReadProcessMemory(hProcess, (LPCVOID*)(ClientAddress), &LocalPlayerBasePointer, sizeof(LocalPlayerBasePointer), NULL);
cout << "This is the address of ClientBaseAddress + ClientOffset = " << LocalPlayerBasePointer << endl;
system("PAUSE");
// Text current disabled only enable for testing
}

{ cout << "=================================================================== " << endl;
cout << "WELCOME TO THE ASSAULT CUBE CONSOLE TRAINER " << endl;
cout << "=================================================================== " << endl;

ReadProcessMemory(hProcess, (LPCVOID*)(RifleAmmoAddress), &CurrentAmmo, sizeof(CurrentAmmo), NULL);
cout << "This is your Current Ammo = " << CurrentAmmo << endl;
system("PAUSE");

cout << "BEFORE AMMO HACK IS ENABLED ENTER THE AMOUNT AMMO YOU WANT: " << endl;
system("PAUSE");
cin >> NewAmmovalue;


WriteProcessMemory(hProcess, (VOID*)(RifleAmmoAddress), &NewAmmovalue, sizeof(NewAmmovalue), NULL);
cout << "This is the Ammo Hack that will be written. " << NewAmmovalue << endl;
Last edited on
I used to have (LocalPlayerBasePointer + AmmoOffset)

Now you have
 
DWORD RifleAmmoAddress = ClientAddress + AmmoOffset; 
@Peter87: Yes I know I was trying that aswell don’t worry about ClientAddress. Forgot to remove it.

EDITED: Fixed
Last edited on
Note that if LocalPlayerBaseAddress or AmmoOffset is updated you need to also update RifleAmmoAddress otherwise it will keep its old value that it had from the start.
RifleAmmoAddress has no value. It is to make to other variable more simpler. RifleAmmoAddress = LocalPlayerBaseAddress (this is what is stored from the first RPM) + AmmoOffset.

Please have a look at my code.
The way you've show your code above, you set RifleAmmoAddress too early, before LocalPlayerBaseAddress has a value. You need to set RifleAmmoAddress after you read LocalPlayerBaseAddress from the process.
tpb


So does that mean I have to move RifleAmmoAddress = LocalPlayerBasePointer+AmmoOffset down more after the read process memory? Or what to do?
Last edited on
Topic archived. No new replies allowed.