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 


C++, Get the address of memory that a pointer points to?

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

Joined: 29 Aug 2011
Posts: 5

PostPosted: Mon Aug 29, 2011 6:33 pm    Post subject: C++, Get the address of memory that a pointer points to? Reply with quote

URL to pic:
k.min.us/jbboqd1qNLvJBN.png

These are my addresses.

I'm able to calculate the base + offset thats needed.
Now here's my problem, how do I get the address the pointer points to?

Below is code to add the address but I need to get the pointers address in code. Sorry if my explanation is bad.
Code:
#include <iostream>
#include <Windows.h>
#define base 0x0042A740
#define os1 0x14
int main()
{

   std::cout <<  (short*)(base + os1);
   Sleep(24352345);

    return 0;
}
[/url]
Back to top
View user's profile Send private message
Innovation
Grandmaster Cheater
Reputation: 12

Joined: 14 Aug 2008
Posts: 617

PostPosted: Mon Aug 29, 2011 8:49 pm    Post subject: Reply with quote

Code:
DWORD dwAddress = *(DWORD *)0x002D1120;

The above is for when you have direct access to the memory. Keep in mind that you cannot directly access the memory of another process; for that, use ReadProcessMemory and WriteProcessMemory.


Last edited by Innovation on Thu Apr 19, 2012 5:45 pm; edited 1 time in total
Back to top
View user's profile Send private message
juryben
How do I cheat?
Reputation: 0

Joined: 29 Aug 2011
Posts: 5

PostPosted: Tue Aug 30, 2011 3:43 pm    Post subject: Reply with quote

Okay thanks man I'll look into the APIs. I'm guessing ReadMemory is what I need to find what my address of the pointer points to in memory. Write memory (and so if DLL injection) is a lamer method for changing values Wink

Also sorry for the shit explanation and code I was in a hurry to post.

One last thing, If anyone has experience will game hacking and coding please message me. I just would like to discuss some stuff over Skype or something so it's not just me going solo all the time.
Back to top
View user's profile Send private message
legoblock
How do I cheat?
Reputation: 0

Joined: 01 Jun 2011
Posts: 9

PostPosted: Wed Aug 31, 2011 10:54 pm    Post subject: Reply with quote

Code:
*reinterpret_cast<PULONG_PTR>(*reinterpret_cast<PULONG_PTR>(base) + os1)
Back to top
View user's profile Send private message
empathe
How do I cheat?
Reputation: 0

Joined: 21 Sep 2011
Posts: 2

PostPosted: Wed Sep 21, 2011 9:57 pm    Post subject: Reply with quote

salut, voici qque fonction utile pour la lecture / ecriture dans la ram.
penser à me add sur hotmail si vous voulez de l'aide pour un cheat Smile

hi, i give to you more funtion for edit/write in memory

en premier on récupére le PID du processus
in first time u need PID of process

exmple of use:
Code:
 if(GetPidByName("game.dll")!=0){printf("ok\n");}
else{printf("where is game noob ?\n");Sleep(3000);exit(0);}

Code:

//define top of main
//#include <tlhelp32.h>
//DWORD GetPidByName(char *szProcName);
//using namespace std; //no need all time

//DWORD dwPID;

DWORD GetPidByName(char *szProcName){
       PROCESSENTRY32 pe = {sizeof(PROCESSENTRY32)};
       HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

       if(hSnap != INVALID_HANDLE_VALUE)
                {
                if(Process32First(hSnap, &pe))
                 {
                  do
                  {
                   if(strcmpi(pe.szExeFile, szProcName) == 0)
                   {
                    dwPID = pe.th32ProcessID;
                    break;
                   }
                  }
                 while(Process32Next(hSnap, &pe));
                 }
                CloseHandle(hSnap);
                }
       return dwPID;
      }
 


Souvant quand vous trouvez un offset vous avez trouver une dll+Hexa
voilà comment trouver la dll du processus:

if in Pointer you find: xxxx.dll+HEXA
u need this function for find DLL in process.

exemple of use:
Code:
gameDll = GetDLL("game.dll", dwPID);

Code:

//define top of main
//#include <tlhelp32.h>
//DWORD GetPidByName(char *szProcName);
//using namespace std; //no need all time
//DWORD dwPID;

DWORD GetDLL(char* DllName, DWORD tPid){
   HANDLE snapMod;
   MODULEENTRY32 me32;
   if (tPid == 0) return 0;
   snapMod = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, tPid);
   me32.dwSize = sizeof(MODULEENTRY32);

   if (Module32First(snapMod, &me32)){
      do{
         if (strcmp(DllName,me32.szModule) == 0){
            CloseHandle(snapMod);
            return (DWORD) me32.modBaseAddr;
         }
      }while(Module32Next(snapMod,&me32));
   }
   CloseHandle(snapMod);
   return 0;
}




Maintenant, ecrire / lire dans la ram.
now write/chek value in ram.

Code:

#include <iostream>
#include <windows.h>
#include <tlhelp32.h>
#include <math.h>
#include <string>

DWORD dwPID;
int gameDll;
DWORD GetDLL(char* DllName, DWORD tPid);
DWORD GetPidByName(char *szProcName);
HANDLE phandle;
HANDLE h_Read_Process;

int main()
{
    system("@color 0A");
    if(GetPidByName("My_Game.exe")!=0)
   {
    gameDll = GetDLL("NameDll.dll", dwPID);//if you have :)
   }else{exit(0);}

    h_Read_Process = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, dwPID);
    phandle = OpenProcess(PROCESS_ALL_ACCESS, 0, dwPID);


[b]//READ / LECTURE[/b]
float monX;//float for exemple
ReadProcessMemory(h_Read_Process,(LPCVOID)(gameDll+0x12345678), &monX, sizeof(monX), NULL);
printf("monX=%.0f\n");//float

int monY;//int for exemple
ReadProcessMemory(h_Read_Process,(LPCVOID)(gameDll+0x12345678), &monX, sizeof(monX), NULL);
printf("monX=%d\n");//int



//Read with 2 Pointer!
//lire avec 2 pointer!
int offset;
ReadProcessMemory(h_Read_Process,(LPCVOID)(gameDll+0x12345678), &offset, sizeof(monX), NULL);
ReadProcessMemory(h_Read_Process,(LPCVOID)(offset+0x2A), &monX, sizeof(monX), NULL);
printf("monX=%d\n");//int

//more pointer ?
ReadProcessMemory(h_Read_Process,(LPCVOID)(gameDll+0x12345678), &offset, sizeof(offset), NULL);
ReadProcessMemory(h_Read_Process,(LPCVOID)(offset+0x2A), &offset, sizeof(offset), NULL);
ReadProcessMemory(h_Read_Process,(LPCVOID)(offset+0x5), &offset, sizeof(offset), NULL);
ReadProcessMemory(h_Read_Process,(LPCVOID)(offset+0x404), &offset, sizeof(offset), NULL);
ReadProcessMemory(h_Read_Process,(LPCVOID)(offset+0x0), &offset, sizeof(offset), NULL);
offReadProcessMemory(h_Read_Process,(LPCVOID)(offset+0x0), &monX, sizeof(monX), NULL);
printf("monX=%d\n");//int



//WRITE / ECRITURE
monX=10;
WriteProcessMemory(phandle, (LPVOID)(gameDll) , &monX, sizeof(monX), 0);//siteof > auto detect if is float/int...
monY=10;
WriteProcessMemory(phandle, (LPVOID)(gameDll) , &monY, sizeof(monY), 0);//u can write: sizeof(int) or sizeof(float)

//write with Pointer !?
//you need to read first time, and write.
int finalOffset;
ReadProcessMemory(h_Read_Process,(LPCVOID)(gameDll+0x12345678), &offset, sizeof(offset), NULL);
ReadProcessMemory(h_Read_Process,(LPCVOID)(offset+0x4), &offset, sizeof(offset), NULL);
ReadProcessMemory(h_Read_Process,(LPCVOID)(offset+0xA5E), &finalOffset, sizeof(offset), NULL);
//and now write>
monY=10;
WriteProcessMemory(phandle, (LPVOID)(finalOffset) , &monY, sizeof(monY), 0);//u can write: sizeof(int) or sizeof(float)


return 0;
}



ok i u need help, [email protected] add me and i create tutorial in this forum for you.

_________________
i find dev for new radar DAoC (2012)
already> find other player in memory and x,y,z

add me: [email protected] (je suis fr)
Back to top
View user's profile Send private message MSN Messenger
FLiNG
Newbie cheater
Reputation: 0

Joined: 09 Apr 2011
Posts: 19

PostPosted: Thu Sep 22, 2011 10:01 am    Post subject: Reply with quote

Code:
      int pAddress = 0x002D1120;
      ReadProcessMemory(pHandle,(LPVOID)pAddress,&pAddress,4,NULL);
      pAddress += 0x14;

This is the codes to find the address that a pointer points to.
In order to do that, you need to get the process handle first.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming 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