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 


[Working Code C++] Get address your looking for from ptrs

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
zonemikel
Newbie cheater
Reputation: 0

Joined: 20 Dec 2007
Posts: 18

PostPosted: Fri Dec 21, 2007 7:41 pm    Post subject: [Working Code C++] Get address your looking for from ptrs Reply with quote

I wrote this so it will return the address you are looking for use it like this

Code:
   int offsets[5] = {0,0x1A4,0x364,0x338,777}; // 777 to stop so we dont gotta count array
   GetPointer((game.exe+0x016AB730),offsets);

where game.exe is whatever the "base address" of your game is, for example when you have ce in your game click memory view and that address you see at the top is the base address. This is the function sorry i couldnt figure out how to count the array (easily) so just add 777 to the last element in your offsets array.
Code:

int GetPointer(int base, int offsets[])
{
   char Testing[200];
   int Address0 = 0;
   int Address1 = 0;
   int i = 0;

   Address0 = *(int *)(base) + offsets[0];
   //sprintf(Testing, "Number %d: %X",i,Address0);
   //MessageBox (0, Testing, WinTitle, MB_ICONINFORMATION);
   for(i=1; i < 10; i++)
   {
      if (offsets[i] == 777){break;}
      Address1 = *(int *)(Address0) + offsets[i];
      Address0 = Address1;
      // for testing output
      //sprintf(Testing, "Number %d: %X",i,Address0);
      //MessageBox (0, Testing, WinTitle, MB_ICONINFORMATION);
   }
   return(Address0);

}


This will return the address you are looking for, uncomment the msgboxes to see it go through them
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Fri Dec 21, 2007 8:10 pm    Post subject: Re: [Working Code C++] Get address your looking for from ptr Reply with quote

I fixed it. I know you can get rid of some of the brackets, but it looks neater this way.

Edit: Made a tiny change.

First one:

Code:
DWORD GetPointer(DWORD dwBase, DWORD * dwOffsets, int nOffsets)
{
   DWORD * dwAddr;
   __try {
        dwAddr = dwBase + *dwOffsets;
        for(i=1, dwOffsets+=4; i < (nOffsets+1); i++, dwOffsets+=4) {
            dwAddr = *dwAddr + *dwOffsets;
        }
    } __except(EXCEPTION_EXECUTE_HANDLER) {
        return -1;
    }
   return dwAddr;
}


Editted one:

Code:
DWORD GetPointer(DWORD * dwBase, DWORD * dwOffsets, int nOffsets)
{
   __try {
        for(nOffsets=(int)(dwOffsets + (nOffsets*4)); dwOffsets <= (DWORD)nOffsets; dwOffsets+=4) {
            dwBase = *dwBase + *dwOffsets;
        }
    } __except(EXCEPTION_EXECUTE_HANDLER) {
        return -1;
    }
   return dwBase;
}
Back to top
View user's profile Send private message
zonemikel
Newbie cheater
Reputation: 0

Joined: 20 Dec 2007
Posts: 18

PostPosted: Fri Dec 21, 2007 8:59 pm    Post subject: Reply with quote

That looks nice but i dont get how you would send arguments to it could you post a example ? I just dont get the offsets part are you still sending it a array ?
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Fri Dec 21, 2007 9:32 pm    Post subject: Reply with quote

Code:
int main()
{
    DWORD base = 0x13371337;
    DWORD lol[] = { 0x00000001, 0x00000002 };
    GetPointer(&base, lol /*&lol also works*/, 2);
    return 0;
}


Alternatively, for the size, you could do this:

Code:
sizeof(lol)/sizeof(DWORD)
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