 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Adr990 How do I cheat?
Reputation: 0
Joined: 04 Jun 2009 Posts: 4 Location: The Netherlands
|
Posted: Sun Nov 04, 2012 10:12 am Post subject: C# Problem reading from a pointer with multiple offsets |
|
|
Hey guys,
After finding out about the ProcessMemoryReaderLib for C# and even some spinoff's, I am still having problems with reading from pointers with multiple offsets.
So far this is my code:
| Code: |
//Public declaration
ProcessMemoryReaderLib.ProcessMemoryReader preader = new ProcessMemoryReaderLib.ProcessMemoryReader();
//------------------------
int byteswritten;
int bytesread;
int valueAmmo, valueHP, value0, value1,value2;
int pointerbase;
byte[] memory;
Process[] myprocess = Process.GetProcessesByName("ac_client");
if (myprocess.Length != 0)
{
preader.ReadProcess = myprocess[0];
preader.OpenProcess();
//--------------------------------
//begin checkboxes
if (checkBox2.Checked == true)
{
memory = preader.ReadProcessMemory((IntPtr)0x004DF73C, 4, out bytesread);
pointerbase = BitConverter.ToInt32(memory, 0);
pointerbase += 0x00;
memory = preader.ReadProcessMemory((IntPtr)pointerbase, 4, out bytesread);
value0 = BitConverter.ToInt32(memory, 0);
value0 += 0x14;
memory = preader.ReadProcessMemory((IntPtr)value0, 4, out bytesread);
value1 = BitConverter.ToInt32(memory, 0);
value1 += 0x378;
memory = preader.ReadProcessMemory((IntPtr)value1, 4, out bytesread);
value2 = BitConverter.ToInt32(memory, 0);
//The follow commented code can write:
//valueAmmo = 100;
//memory = BitConverter.GetBytes(valueAmmo);
//preader.WriteProcessMemory((IntPtr)value2, memory, out byteswritten);
label7.Text = value2.ToString(); |
So basically storing a variable, converting it, adding an offset to it, and storing it back again.
Repeating it for the amount of offsets I have.
Because simply doing:
| Code: | pointerbase = BitConverter.ToInt32(memory, 0);
pointerbase += 0x00;
pointerbase += 0x14;
pointerbase += 0x378;
|
Ofcourse is just resulting in the pointerbase to count the offsets up together to one 'memory'.
With only one offset it works fine though:
| Code: | memory = preader.ReadProcessMemory((IntPtr)0x004DF73C, 4, out bytesread);
pointerbase = BitConverter.ToInt32(memory, 0);
pointerbase += 0xF4;
memory = preader.ReadProcessMemory((IntPtr)pointerbase, 4, out bytesread);
valueHP = BitConverter.ToInt32(memory, 0);
label8.Text = valueHP.ToString(); |
There have been other topics about this, but these don't seem to have anything to add or to fix about my code and reading the multiple offsets problem.
I hope that this topic will short out this problem for good.
Thanks in advance!
Cheers,
Adr
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Fri Nov 09, 2012 12:11 am Post subject: |
|
|
Your best bet is to debug your code and find out where in the pointer path it's failing or becoming invalid.
_________________
- Retired. |
|
| Back to top |
|
 |
Adr990 How do I cheat?
Reputation: 0
Joined: 04 Jun 2009 Posts: 4 Location: The Netherlands
|
Posted: Sun Jan 13, 2013 9:55 am Post subject: |
|
|
Hey guys,
After a long break I still can't figure it out.
I did debug the code, and it seems the pointer base uses a address of 7 chars long instead of 6. (excluding the 2 zero's ofcrouse at the beginning)
Here is a picture of what is going on:
Tiny url . com / axr2pf4
(I can't post url's yet..)
The trainer program is in the up right, the game in the left, and Cheat engine is running showing the addresses and memory address and working pointer.
So I'm totally doing something wrong here... Anyone used a multi level pointer in C# before?
Thanks in advance!
Edit:
I think I almost got it now, also the reason why I thought the base address was longer was because it was converted to Int, I totally forgot about that.
Still, if you guys have any input, pleas help, I still haven't figured it out.
Also,
My Ammo pointer is this:
Base address: 004DF73C
Offsets: 0x00, 0x14, 0x378
Can the 0x378 offset be the problem somehow?
Because it's not a standard "0x00" format I believe?
Any thoughts on this?
|
|
| Back to top |
|
 |
Pingo Grandmaster Cheater
Reputation: 8
Joined: 12 Jul 2007 Posts: 571
|
Posted: Sun Jan 13, 2013 5:14 pm Post subject: |
|
|
Here try this.. It's as simple as i could make it.
It wont work for codeshifting or other modules but it should work for what you need.
| Code: | public int Pointer(string ProcessName, int Base, int[] Offsets)
{
Process[] P;
if ((P = Process.GetProcessesByName(ProcessName)).Length == 0) return -1;
byte[] buff = new byte[4];
ReadProcessMemory(P[0].Handle, Base, buff, 4, 0);
Base = BitConverter.ToInt32(buff, 0);
for (int i = 0; i < Offsets.Length; i++)
{
ReadProcessMemory(P[0].Handle, Base + Offsets[i], buff, 4, 0);
Base = i != (Offsets.Length - 1) ? BitConverter.ToInt32(buff, 0) : Base += Offsets[i];
}
return Base;
} |
Your pointer would look like this
| Code: | | int PointerBase = Pointer("ac_client", 0x4DF73C, new int[] { 0, 0x14, 0x378 }); |
See if this works any better for ya.
_________________
|
|
| Back to top |
|
 |
Adr990 How do I cheat?
Reputation: 0
Joined: 04 Jun 2009 Posts: 4 Location: The Netherlands
|
Posted: Mon Jan 14, 2013 3:20 pm Post subject: |
|
|
Thanks for the help.
tiny url . com / ayusdv2
(can't post url's yet.)
But as you can see in the above image, with your code I can't even get the 1level pointer to work, so I must be doing something wrong I think.
I thought that this was what I had to do with ReadProcessMemory... But I was not sure.
|
|
| Back to top |
|
 |
Pingo Grandmaster Cheater
Reputation: 8
Joined: 12 Jul 2007 Posts: 571
|
Posted: Mon Jan 14, 2013 4:13 pm Post subject: |
|
|
The hp address is correct
24808628 dec = 17A8CB4 hex
Its probably my function. I just coded without testing.
The ammo one is wrong though.
Edit:
The function works ok on my oend using a level 3 pointer.
Is the base for the ammo 0x4DF73C?
_________________
|
|
| Back to top |
|
 |
Adr990 How do I cheat?
Reputation: 0
Joined: 04 Jun 2009 Posts: 4 Location: The Netherlands
|
Posted: Tue Jan 15, 2013 6:33 am Post subject: |
|
|
Yep, for both HP and Ammo the base should be 0x004DF73C
In the Youtube video here:
(C++ HOW TO HACK any game TUTORIAL Pt 3 Pointers continued)
Tiny url . com / acdt847
This guy gets the same values, and has the same base pointer, etc.
Cheat engine is also displaying and changing the values with this, so it should be okay.
Which Process Memory Reader class are you using?
Maybe we aren't using the same code, though they are all spins offs, I think.
|
|
| 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
|
|