 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
logicallysynced Newbie cheater
Reputation: 0
Joined: 30 Mar 2016 Posts: 16
|
Posted: Sat Apr 02, 2016 10:00 am Post subject: [C#] Weird results when adding offsets to pointer |
|
|
Hi all,
I'm having a bit of an odd encounter with one of my pointer calculations. Basically what is happening is that I'm trying to add 2 offsets to an address to return my pointer.
The base address is FEA1D75 and I'm fetching that correctly within my C# application.
Now when I add this address manually in Cheat Engine as a pointer and add the offsets 8 and 0 to it, it returns the value of 03B99B88. Which is the value I need.
However when I try to replicate this in my C# application, when I add the first offset the value jumps all the way to C5048DFF and then when I add the second, it seems to just give me a return value of 0.
The C# code in case it's useful is:
| Code: |
//the variable `season_ptr` returns FEA1D75
IntPtr ptrv_2 = (IntPtr)BitConverter.ToInt32(ReadMemory(myProcess, IntPtr.Add(season_ptr, 0x08), 4, out bytesRead), 0); //returns C5048DFF (should return 03B99B80)
IntPtr ptrv_3 = (IntPtr)BitConverter.ToInt32(ReadMemory(myProcess, IntPtr.Add(ptrv_2, 0x0), 4, out bytesRead), 0); //returns 0 (should return 03B99B88)
|
I use the same code format for all my other pointers and don't seem to have any problems with it, they all return values correctly except for this one.
Any help would be much appreciated.
|
|
| Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat Apr 02, 2016 10:08 am Post subject: |
|
|
Is this a 64-bit game?
What does CE say the second address on the jump is?
|
|
| Back to top |
|
 |
logicallysynced Newbie cheater
Reputation: 0
Joined: 30 Mar 2016 Posts: 16
|
Posted: Sat Apr 02, 2016 11:30 am Post subject: |
|
|
| Zanzer wrote: | Is this a 64-bit game?
What does CE say the second address on the jump is? |
I believe the game runs as x86.
CE tells me the address pointer is:
| Code: |
FEA1D75 = FEA1D75
FEA1D75+8 = 03B99B80
03B99B88+0 = 03B99B88
|
Which is the correct values.
But in C# I'm getting something like:
| Code: |
FEA1D75 = FEA1D75
FEA1D75+8 = C5048DFF
C5048DFF+0 = 0
|
|
|
| Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat Apr 02, 2016 11:55 am Post subject: |
|
|
Judging by the values you posted from CE, it looks like the correct address is:
But your code is retrieving:
Try:
| Code: | IntPtr ptrv_2 = (IntPtr)BitConverter.ToInt32(ReadMemory(myProcess, IntPtr.Add(season_ptr, 0x0), 4, out bytesRead), 0);
IntPtr ptrv_3 = (IntPtr)BitConverter.ToInt32(ReadMemory(myProcess, IntPtr.Add(ptrv_2, 0x8), 4, out bytesRead), 0); |
|
|
| Back to top |
|
 |
logicallysynced Newbie cheater
Reputation: 0
Joined: 30 Mar 2016 Posts: 16
|
Posted: Sat Apr 02, 2016 7:18 pm Post subject: |
|
|
| Zanzer wrote: | Judging by the values you posted from CE, it looks like the correct address is:
But your code is retrieving:
Try:
| Code: | IntPtr ptrv_2 = (IntPtr)BitConverter.ToInt32(ReadMemory(myProcess, IntPtr.Add(season_ptr, 0x0), 4, out bytesRead), 0);
IntPtr ptrv_3 = (IntPtr)BitConverter.ToInt32(ReadMemory(myProcess, IntPtr.Add(ptrv_2, 0x8), 4, out bytesRead), 0); |
|
If I reverse them like you mentioned, I get the following invalid values:
| Code: | FC1D75 -> FC1D75
FC1D75+0 -> 47737C4
47737C4+8 -> 3771228 |
|
|
| Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat Apr 02, 2016 9:50 pm Post subject: |
|
|
| Post a screenshot of CE's pointer definition and the results of your C# code.
|
|
| Back to top |
|
 |
logicallysynced Newbie cheater
Reputation: 0
Joined: 30 Mar 2016 Posts: 16
|
Posted: Sat Apr 02, 2016 10:23 pm Post subject: |
|
|
| Zanzer wrote: | | Post a screenshot of CE's pointer definition and the results of your C# code. |
Alright I'm pretty sure this is what you want. Sorry for the paint mix and match, it's the best I had to work with. I provided the results and code of both offset arrangements too.
| Description: |
|
| Filesize: |
24.28 KB |
| Viewed: |
6302 Time(s) |

|
| Description: |
|
| Filesize: |
65.74 KB |
| Viewed: |
6302 Time(s) |

|
|
|
| Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat Apr 02, 2016 10:27 pm Post subject: |
|
|
| Code: | IntPtr ptrv_2 = (IntPtr)BitConverter.ToInt32(ReadMemory(myProcess, IntPtr.Add(season_ptr, 0x0), 4, out bytesRead), 0);
IntPtr ptrv_3 = (IntPtr)BitConverter.ToInt32(ReadMemory(myProcess, IntPtr.Add(ptrv_2, 0x0), 4, out bytesRead), 0);
IntPtr ptrv_4 = IntPtr.Add(ptrv_3, 0x8); |
|
|
| Back to top |
|
 |
logicallysynced Newbie cheater
Reputation: 0
Joined: 30 Mar 2016 Posts: 16
|
Posted: Sat Apr 02, 2016 10:43 pm Post subject: |
|
|
| Zanzer wrote: | | Code: | IntPtr ptrv_2 = (IntPtr)BitConverter.ToInt32(ReadMemory(myProcess, IntPtr.Add(season_ptr, 0x0), 4, out bytesRead), 0);
IntPtr ptrv_3 = (IntPtr)BitConverter.ToInt32(ReadMemory(myProcess, IntPtr.Add(ptrv_2, 0x0), 4, out bytesRead), 0);
IntPtr ptrv_4 = IntPtr.Add(ptrv_3, 0x8); |
|
Excellent. You are amazing! Thank you that works great
|
|
| Back to top |
|
 |
|
|
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
|
|