Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


SOLVED: Able to read string in CE, cannot read with program

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
AC_Player
How do I cheat?
Reputation: 0

Joined: 06 Jun 2018
Posts: 2

PostPosted: Wed Jun 06, 2018 4:21 am    Post subject: SOLVED: Able to read string in CE, cannot read with program Reply with quote

OMFG! I finally got it!!!

Code:

#include <Windows.h>
#include <iostream>
#include <string>

#define _PLAYER_NICKNAME 0x125

int main()
{

   HANDLE gameProcess;
   LPCSTR gameName = "AssaultCube";
   DWORD gamePID;
   LPDWORD pGamePID = &gamePID;

   HWND gameWindow = FindWindow(NULL, gameName);
   GetWindowThreadProcessId(gameWindow, pGamePID);


   gameProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, gamePID);


   uintptr_t localplayeraddr = 0x509B74;
   uintptr_t playerInCH = 0x0501C38;
   uintptr_t playeraddr = 0;
   int health = 0;
   std::string playerInCrosshairs = "aaaaaaaaaaaaaaa";
   SIZE_T bytesread;

   char myString[16] = { 0 };

   if (!gameProcess)
   {
      std::cout << "OpenProcess Failed." << std::endl;
   }

   if (ReadProcessMemory(gameProcess, (LPCVOID)(localplayeraddr), &playeraddr, sizeof(uintptr_t), &bytesread))
   {
      std::cout << "Player Address Read " << std::uppercase << std::hex << playeraddr << std::endl;
   }
   else
   {
      std::cout << "Couldn`t read address" << std::endl;
   }

   if (ReadProcessMemory(gameProcess, (LPCVOID)(playeraddr + 0xF8), &health, sizeof(int), &bytesread))
   {
      std::cout << "Player Health Read " << std::dec << health << std::endl;
   }
   else
   {
      std::cout << "Couldn`t read health" << std::endl;
   }

   
   if (ReadProcessMemory(gameProcess, (LPCVOID)(playerInCH), &myString, 15, &bytesread))
   {
      std::string temp = myString;
      std::cout << "Player In Crosshairs  " << temp << std::endl;
   }
   else
   {
      std::cout << "Couldn`t read player in crosshairs" << std::endl;
   }
   


   system("pause");

   CloseHandle(gameProcess);

   return 0;
}




Original Post:

I don't understand this. I am able to find the string I want using CE. It's a static address, so every time I open/close/open the game the string is still readable/editable by CE but when I tried to read it from my program using READPROCESSMEMORY I can't.

I am able to read and write to other values in the game with the same program. I am just unable to read this one. 0x0501C38

I am also getting an exception when trying to use this code trying to read the string into cout.

Code:

#include <Windows.h>
#include <iostream>
#include <string>


int main()
{

   HANDLE gameProcess;
   LPCSTR gameName = "AssaultCube";
   DWORD gamePID;
   LPDWORD pGamePID = &gamePID;

   HWND gameWindow = FindWindow(NULL, gameName);
   GetWindowThreadProcessId(gameWindow, pGamePID);


   gameProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, gamePID);


   uintptr_t localplayeraddr = 0x509B74;
   uintptr_t playerInCH = 0x0501C38;
   uintptr_t playeraddr = 0;
   int health = 0;
   std::string playerInCrosshairs = "";
   SIZE_T bytesread;

   if (!gameProcess)
   {
      std::cout << "OpenProcess Failed." << std::endl;
   }

   if (ReadProcessMemory(gameProcess, (LPCVOID)(localplayeraddr), &playeraddr, sizeof(uintptr_t), &bytesread))
   {
      std::cout << "Player Address Read " << std::uppercase << std::hex << playeraddr << std::endl;
   }
   else
   {
      std::cout << "Couldn`t read address" << std::endl;
   }

   if (ReadProcessMemory(gameProcess, (LPCVOID)(playeraddr + 0xF8), &health, sizeof(int), &bytesread))
   {
      std::cout << "Player Health Read " << std::dec << health << std::endl;
   }
   else
   {
      std::cout << "Couldn`t read health" << std::endl;
   }

   if (ReadProcessMemory(gameProcess, (LPCVOID)(playerInCH), &playerInCrosshairs, sizeof(std::string), &bytesread))
   {
      std::cout << "Player In Crosshairs  " << playerInCrosshairs << std::endl;
   }
   else
   {
      std::cout << "Couldn`t read player in crosshairs" << std::endl;
   }

   system("pause");

   CloseHandle(gameProcess);

   return 0;
}
Code:


Last edited by AC_Player on Wed Jun 06, 2018 5:33 am; edited 1 time in total
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25291
Location: The netherlands

PostPosted: Wed Jun 06, 2018 5:25 am    Post subject: Reply with quote

Are you sure the address is 0501C38 and not assaultcube.exe+0501C38 ?

Is your program running as administrator ?

You may also need to obtain the SE_DEBUG_PRIVILEGE security token for your process

And compile your program in the same architecture as the target as you use pointersize reads

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
AC_Player
How do I cheat?
Reputation: 0

Joined: 06 Jun 2018
Posts: 2

PostPosted: Wed Jun 06, 2018 8:25 am    Post subject: Reply with quote

Edit: The ghost in the machine is just angry. I compiled it AGAIN in a new project no problem. Maybe because I named my source main.cpp


Dark Byte wrote:
Are you sure the address is 0501C38 and not assaultcube.exe+0501C38 ?

Is your program running as administrator ?

You may also need to obtain the SE_DEBUG_PRIVILEGE security token for your process

And compile your program in the same architecture as the target as you use pointersize reads



Yes. The address is 0501C38. This is the address from CE. It can read the information just fine. The problem is that my source DID work but now I am getting errors when trying to compile...

I had just used it and it accessed the information just fine and now its not.

4 unresolved externals
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites