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 


RE: [C] Writing Pointers IS FUCKING COOL I'M GOING TO STAB..

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Sun Jun 21, 2009 9:48 am    Post subject: RE: [C] Writing Pointers IS FUCKING COOL I'M GOING TO STAB.. Reply with quote

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
View user's profile Send private message Visit poster's website
Anden100
Grandmaster Cheater
Reputation: 0

Joined: 20 Apr 2007
Posts: 668

PostPosted: Sun Jun 21, 2009 10:35 am    Post subject: Reply with quote

I think it would Wink. 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
View user's profile Send private message
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Sun Jun 21, 2009 10:42 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Anden100
Grandmaster Cheater
Reputation: 0

Joined: 20 Apr 2007
Posts: 668

PostPosted: Sun Jun 21, 2009 12:59 pm    Post subject: Reply with quote

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
View user's profile Send private message
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Sun Jun 21, 2009 2:56 pm    Post subject: Reply with quote

Weird. Try my code, it works fine for me, and I'm running Vista 64-bit.
Back to top
View user's profile Send private message Visit poster's website
Anden100
Grandmaster Cheater
Reputation: 0

Joined: 20 Apr 2007
Posts: 668

PostPosted: Mon Jun 22, 2009 12:36 am    Post subject: Reply with quote

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
View user's profile Send private message
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Mon Jun 22, 2009 1:52 pm    Post subject: Reply with quote

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. Smile
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming 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