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 


Adress VS Pointer Values

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

Joined: 02 Aug 2016
Posts: 6
Location: New York

PostPosted: Tue Aug 02, 2016 7:04 pm    Post subject: Adress VS Pointer Values Reply with quote

first i would like to apologize if the title seems wrong but i couldn't really think of what to call this.

So i have a question that i have been trying to figure out for a while now but i just cant seem to find the answer, i have address with an offset that i am using as a pointer.

140000000+46E26A8 yields the memory address 7FF5A07141C0 which is what i need however if i place that in the address section it gives me:
2691776960 which is the same thing that my c++ memory reader is giving me how can i get c++ to get the address and not the random number value.

Thanks in advance
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Tue Aug 02, 2016 8:46 pm    Post subject: Reply with quote

Stop using an int to represent a 64-bit address. Use a long.
Code:
2,691,776,960 == 0000A07141C0
---------------->7FF5A07141C0
Back to top
View user's profile Send private message
searay330
How do I cheat?
Reputation: 0

Joined: 02 Aug 2016
Posts: 6
Location: New York

PostPosted: Tue Aug 02, 2016 8:53 pm    Post subject: Reply with quote

i guess i should have posted the code i am using, I am using DWORD_PTR's which are longs.

Code:

                SIZE_T size = 2;
                DWORD_PTR startAddress = 0x140000000;
            DWORD_PTR finishAddress = 0;
           DWORD_PTR pointer1, pointer2;
            DWORD_PTR Offset0 = 0x46E26A8;
           DWORD_PTR Offset1 = 0x454;
      int done = ReadProcessMemory(hProc, (LPVOID)(startAddress + Offset0) , &pointer1, sizeof(pointer1), &size);
      done = ReadProcessMemory(hProc, (LPVOID)(pointer1 + Offset1) , &pointer2, sizeof(pointer2), &size);
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Tue Aug 02, 2016 10:08 pm    Post subject: Reply with quote

Incorrect.
DWORD is 32 bit. An int.
QWORD is 64 bit. A long.
You should be using IntPtr.
Back to top
View user's profile Send private message
searay330
How do I cheat?
Reputation: 0

Joined: 02 Aug 2016
Posts: 6
Location: New York

PostPosted: Tue Aug 02, 2016 10:11 pm    Post subject: Reply with quote

well then microsoft lied to me or i misunderstood the documentation

i cant post links to the doc so heres a quote

A DWORD_PTR is an unsigned long type used for pointer precision. It is used when casting a pointer to an unsigned long type to perform pointer arithmetic. DWORD_PTR is also commonly used for general 32-bit parameters that have been extended to 64 bits in 64-bit Windows. <--quote


Last edited by searay330 on Tue Aug 02, 2016 10:40 pm; edited 2 times in total
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Tue Aug 02, 2016 10:29 pm    Post subject: Reply with quote

Are you compiling your trainer as a 64-bit application? Smile
Either way, it's clearly truncating your supposed 64-bit value.
Print the value of "sizeof(pointer1)". Is it 4 or 8?

I guess you could have the wrong definition for ReadProcessMemory.
The second argument isn't defined to hold a 64-bit value.
A cast to LPVOID may be causing the truncation?
Back to top
View user's profile Send private message
searay330
How do I cheat?
Reputation: 0

Joined: 02 Aug 2016
Posts: 6
Location: New York

PostPosted: Tue Aug 02, 2016 10:40 pm    Post subject: Reply with quote

i just changed them form DWORD_PTR's to unsigned long long int's and that fixed the problem thank you and from now on i will take the microsoft docs with a pinch of salt. Laughing

and yes ParkourPenguin that was what i thinking of im a bit rusty.


Last edited by searay330 on Tue Aug 02, 2016 10:42 pm; edited 1 time in total
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4703

PostPosted: Tue Aug 02, 2016 10:40 pm    Post subject: Reply with quote

It says "32-bit parameters" right there.

A word is 2 bytes. A dword (double word) is twice that, 4 bytes. A qword is twice that, 8 bytes. DWORD_PTR means you're pointing to a dword.
source

The "long" type takes up 4 bytes of space. You're thinking of the "long long" type which takes up 8 bytes.
source

If you're interested in the history of this:
http://queue.acm.org/detail.cfm?id=1165766

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Tue Aug 02, 2016 10:49 pm    Post subject: Reply with quote

Meh, I'm a Java developer. Where the longs are longs and the ints are ints. Smile
Back to top
View user's profile Send private message
searay330
How do I cheat?
Reputation: 0

Joined: 02 Aug 2016
Posts: 6
Location: New York

PostPosted: Tue Aug 02, 2016 10:50 pm    Post subject: Reply with quote

yes the land of c where true can false, false can be true, and int's cant be whatever the hell they want to be.
_________________
Can You Imagine What I Would Do If I Could Do All I Can?
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 Gamehacking 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