| View previous topic :: View next topic |
| Author |
Message |
talkerzero Grandmaster Cheater
Reputation: 1
Joined: 24 Jul 2008 Posts: 560 Location: California
|
Posted: Sun Jun 21, 2009 9:48 am Post subject: RE: [C] Writing Pointers IS FUCKING COOL I'M GOING TO STAB.. |
|
|
A while back, Irwin posted an example of a dynamic ReadPointer function, which can be found here.
Then, BanMe tried rewriting that into a WritePointer function, which can be found here.
I thought, why not just do something like this?
| Code: | #include <stdarg.h>
#define OFFSETS_END 0xDEADBEEF
__checkReturn BOOL _WritePointer(__in ULONG_PTR ulValue, __in LPCVOID lpcvBase, ...)
{
ULONG_PTR ulTemp;
va_list pArguments;
BOOL bRet;
int nOffset;
__try {
ulTemp = (ULONG_PTR)lpcvBase;
va_start(pArguments, lpcvBase);
while((nOffset = va_arg(pArguments, int)) != OFFSETS_END)
ulTemp = ((*(ULONG_PTR*)ulTemp) + nOffset);
va_end(pArguments);
*(ULONG_PTR*)ulTemp = ulValue;
bRet = TRUE;
}
__except(EXCEPTION_EXECUTE_HANDLER) {
bRet = FALSE;
}
return bRET;
}
#define WritePointer(x, y, ...) _WritePointer(x, y, __VA_ARGS__, OFFSETS_END) |
|
|
| Back to top |
|
 |
Anden100 Grandmaster Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 668
|
Posted: Sun Jun 21, 2009 10:35 am Post subject: |
|
|
I think it would . A while back i decided to re-write it, not to a better code, but just more understandable, here is my WritePoniter function, simple...:
| Code: | BOOL WritePointer(DWORD value, DWORD baseAddress, ...){
va_list VAArgs;
DWORD writeAddress;
DWORD offset;
__try{
va_start(VAArgs, baseAddress);
writeAddress = baseAddress;
while(offset = va_arg(VAArgs, DWORD))
writeAddress = *(DWORD*)writeAddress + offset;
*(DWORD*)writeAddress = value;
return TRUE;
}
__except(EXCEPTION_EXECUTE_HANDLER){
return FALSE;
}
} |
|
|
| Back to top |
|
 |
talkerzero Grandmaster Cheater
Reputation: 1
Joined: 24 Jul 2008 Posts: 560 Location: California
|
Posted: Sun Jun 21, 2009 10:42 am Post subject: |
|
|
Lol, guess you're one of the people that don't like Hungarian notation.
Why use DWORD instead of ULONG_PTR? You're losing 64-bit compatibility. |
|
| Back to top |
|
 |
Anden100 Grandmaster Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 668
|
Posted: Sun Jun 21, 2009 12:59 pm Post subject: |
|
|
| Female wrote: | Lol, guess you're one of the people that don't like Hungarian notation.
Why use DWORD instead of ULONG_PTR? You're losing 64-bit compatibility. |
Cas' ULONG_PTR keeps crashing my 64 bit anyways O.o |
|
| Back to top |
|
 |
talkerzero Grandmaster Cheater
Reputation: 1
Joined: 24 Jul 2008 Posts: 560 Location: California
|
Posted: Sun Jun 21, 2009 2:56 pm Post subject: |
|
|
| Weird. Try my code, it works fine for me, and I'm running Vista 64-bit. |
|
| Back to top |
|
 |
Anden100 Grandmaster Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 668
|
Posted: Mon Jun 22, 2009 12:36 am Post subject: |
|
|
| Female wrote: | | Weird. Try my code, it works fine for me, and I'm running Vista 64-bit. |
Windows 7 RC 64 bit = Crash... |
|
| Back to top |
|
 |
talkerzero Grandmaster Cheater
Reputation: 1
Joined: 24 Jul 2008 Posts: 560 Location: California
|
Posted: Mon Jun 22, 2009 1:52 pm Post subject: |
|
|
| Anden100 wrote: | | Female wrote: | | Weird. Try my code, it works fine for me, and I'm running Vista 64-bit. |
Windows 7 RC 64 bit = Crash... |
Oh. Well, can't help ya there bud.  |
|
| Back to top |
|
 |
|