| View previous topic :: View next topic |
| Author |
Message |
iRiot Master Cheater
Reputation: 0
Joined: 03 Jul 2007 Posts: 395 Location: Aka RIOT
|
Posted: Thu Aug 21, 2008 11:04 pm Post subject: [help]Using pointers with offsets in (c++) |
|
|
So I was wondering how would I use a pointer with a offset I found in a game and code it into c++.... if any of you know how can you me what to do?
2nd question... once u change a value to a address... does it stay that value the whole time (freeze) or does it happen to change ... even though your hack on your program is on... Iam using a dll and I was wondering since i dont have timers or w/e to keep that address at the same value... if it does change is there any way i could freeze that address?
_________________
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Thu Aug 21, 2008 11:56 pm Post subject: |
|
|
A pointer points to base address' value + offset.
As for the second question, if nothing writes to that pointer then it wouldn't change, "freezing" is bescially writing the same value constantly.
Create a thread and "freeze" your addresses.
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Fri Aug 22, 2008 1:40 am Post subject: |
|
|
For the offset, just dereference the pointer then add the offset and you then will have the current dynamic address of that buffer or whatever.
For the second question, as Symbol says, create a new thread and do it there and it would be smart to add some Sleep to it too. You can actually do it in your main thread if you don't have any other functions to your application.
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Fri Aug 22, 2008 3:28 am Post subject: |
|
|
| He can also do it in the main thread without freezing the window by letting the code execute, you can simulate "sleep" using GetTickCount/timeGetTime to see how much time passed and if X milliseconds passed, just write the value again.
|
|
| Back to top |
|
 |
WafflesFTW Expert Cheater
Reputation: 0
Joined: 21 Mar 2008 Posts: 131
|
Posted: Fri Aug 22, 2008 7:00 am Post subject: |
|
|
| Slugsnack wrote: | For the offset, just dereference the pointer then add the offset and you then will have the current dynamic address of that buffer or whatever.
For the second question, as Symbol says, create a new thread and do it there and it would be smart to add some Sleep to it too. You can actually do it in your main thread if you don't have any other functions to your application. |
No, you dereference the pointer after adding the offset.
|
|
| Back to top |
|
 |
DeviantGeek Newbie cheater
Reputation: 0
Joined: 30 Apr 2006 Posts: 20 Location: 127.0.0.1
|
Posted: Fri Aug 22, 2008 8:22 am Post subject: |
|
|
well say the offset you found was to a DWORD this is how you would change it in c++
| Code: | | *(DWORD*)0x00abcdef = 1; |
just change DWORD to whatever type it is your changing. change 0x00abcdef to whatever your offset is, and change 1 to whatever you want the value to be at that offset.
im not a fan of constantly writing to an address if something else is trying to change it back. i would stick a debugger on the game and find out whats writing to it and nop them.
|
|
| Back to top |
|
 |
iRiot Master Cheater
Reputation: 0
Joined: 03 Jul 2007 Posts: 395 Location: Aka RIOT
|
Posted: Fri Aug 22, 2008 10:00 am Post subject: |
|
|
@deviant geek
what u said about the offset well i understand that but where is it directing it to? would i need to do something like this?
| Code: | *(DWORD)0x00123456 = 0x12345678;
*(DWORD*)0x00abcdef = 1;
|
doesn't seem right but correct me if its wrong which i know it is...
_________________________________________________________
for my second questions could i make a thread that will like scan the addresses value and if its not that value change it bak to the value i want it to?
_________________
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Fri Aug 22, 2008 10:25 am Post subject: |
|
|
| iRiot wrote: | | for my second questions could i make a thread that will like scan the addresses value and if its not that value change it bak to the value i want it to? |
No. This is completely forbidden by various laws of quantum mechanics and thermodynamics. In fact the LHC is running in a few weeks just to prove this theory.
.. of course you can, do whatever the fuck you want.
|
|
| Back to top |
|
 |
DeviantGeek Newbie cheater
Reputation: 0
Joined: 30 Apr 2006 Posts: 20 Location: 127.0.0.1
|
Posted: Fri Aug 22, 2008 12:38 pm Post subject: |
|
|
| Code: | | *(DWORD)0x00123456 = 0x12345678; |
im pretty sure this will cause a compile error since your dereferencing a pointer which isnt a pointer but a regular DWORD
say the offset of your health was at 0x0045de3b in memory. you know its stored as an unsigned int. you inject a dll into the game to mess with it. here is how you would change it in that dll:
| Code: | | *(unsigned int*)0x0045de3b = 10000; |
the first thing this does is takes 0x0045de3b and tells the compiler to treat it as an unsigned int*. so 0x0045de3b is pointing to an address of where our health is. then after that you dereference the pointer by sticking * in front of it allowing us access to what its pointing to. then we set the value at 0x0045de3b to 10000. this is the short way to do it cause your not setting a variable name or anything. you could always do:
| Code: | unsigned int* puiMyHealth = 0x0045de3b;
*puiMyHealth = 10000; |
and it will accomplish the same thing. but thats more code you dont need. the only real use is if this address for some odd reason changes alot. then this method would be best. but i usually do:
| Code: | #define puiMyHealth *(unsigned int*)0x0045de3b
puiMyHealth = 10000;
| or something similar
and yes you can make a thread to check the address to see if its changed:
| Code: | #define puiMyHealth *(unsigned int*)0x0045de3b
bool bMonitor = true;
CreateThread(NULL, 0, &MonitorHealth, NULL, 0, NULL);
DWORD WINAPI MonitorHealth(void* ptr)
{
while(bMonitor)
{
if (puiMyHealth != 10000)
{
puiMyHealth = 10000;
}
Sleep(100);
}
return 0;
} |
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Fri Aug 22, 2008 12:52 pm Post subject: |
|
|
| Quote: | | A pointer points to base address's value + offset. |
| Code: | DWORD Pointer = *(DWORD*)Address; //You got the base address's value
//now, add the offset:
Pointer += Offset;
//Now, Pointer's value is the address the pointer points to
*(DWORD*)Pointer = 1000; |
Or in one simple step:
| Code: | | *(DWORD*)((*(DWORD*)Address) + Offset) = 1000; |
You can also do this:
| Code: | BYTE* Pointer = *(DWORD*)Address;
Pointer += Offset; |
You can do the same with DWORD, but remember that when you add to a DWORD*, the value added is multipied by sizeof(DWORD), (4) so you can simply divide the value by 4, unless the value divided by 4 isn't round.
|
|
| Back to top |
|
 |
DeviantGeek Newbie cheater
Reputation: 0
Joined: 30 Apr 2006 Posts: 20 Location: 127.0.0.1
|
Posted: Fri Aug 22, 2008 1:06 pm Post subject: |
|
|
yea that would work if its offset from a base address but you could simplify that
| Code: | | *(DWORD*)(Address + Offset) = 1000; |
or if you wanna mess with more than one offset from the base address you can set up a struct:
| Code: | typedef struct _char_info
{
unsigned int uiHealth; /* + 0x00 from base */
unsigned int uiMana; /* + 0x04 */
BYTE unknown[0x4]; /* + 0x08 */
unsigned int uiLevel; /* + 0x0C */
} CHAR_INFO, *PCHAR_INFO;
CHAR_INFO* pCharInfo = (CHAR_INFO*)0x0045de3b;
pCharInfo->uiHealth = 10000;
pCharInfo->uiMana = 10000;
pCharInfo->uiLevel = 99; |
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sat Aug 23, 2008 12:45 am Post subject: |
|
|
| DeviantGeek wrote: | yea that would work if its offset from a base address but you could simplify that
| Code: | | *(DWORD*)(Address + Offset) = 1000; |
|
No, it won't work, you need the base address's value, not address.
|
|
| Back to top |
|
 |
DeviantGeek Newbie cheater
Reputation: 0
Joined: 30 Apr 2006 Posts: 20 Location: 127.0.0.1
|
Posted: Sat Aug 23, 2008 5:25 am Post subject: |
|
|
thats what i said, you even quoted it......i just wrote "address" in my code? and that code works. ive been doing it for years. here
| Code: | | *(DWORD*)(Base Address + offset) = 1000; | now it says "Base Address"
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sat Aug 23, 2008 9:31 am Post subject: |
|
|
Ofcourse it works, but it doesn't modify memory to the address pointed by the pointer.
Let's take for example, the address 0x50 holds the value 0x100, the pointer 0x50+5 will point to 0x105, but your code would modify the address 0x55.
The only good thing you can do with that, is modifying an address by using the module name to get the module base address, for example:
game.exe+0x50, instead 0x1050.
|
|
| Back to top |
|
 |
igoticecream Grandmaster Cheater Supreme
Reputation: 0
Joined: 23 Apr 2006 Posts: 1807 Location: 0x00400000
|
Posted: Sat Aug 23, 2008 3:24 pm Post subject: |
|
|
I see a lot of people here does not know what pointer are... please read this http://forum.cheatengine.org/viewtopic.php?t=79 and you'll conclude on this:
| Code: | | unsigned long pointer = (*(DWORD*)base)+offset; |
if you want to express the value of the pointer on 4 bytes do:
| Code: | | unsigned long value = *(DWORD*)(*(DWORD*)base)+offset; |
_________________
+~ |
|
| Back to top |
|
 |
|