Help with c++ pointer validation

Discussions Related to Game Hacking and Memory Hacking Software

Moderators: g3nuin3, SpeedWing, WhiteHat, mezzo

Help with c++ pointer validation

Postby slointe » Thu Jul 16, 2009 12:32 pm

I am sort of at a loss on how to check this....


I have a pointer that is valid on only certain screens of a game. It doesn't go NULL but actually contains data, just junk data that doesn't evaluate to the rest of my pointers.

Code: Select all
players->local->myplayer->goodie;


The 'goodie' is an integer. When I am in certain screens ie the menu screen, this is '0'

When I leave the menu 'players' is valid but 'local' dies and turns to garbage thus breaking the link to 'goodie'.

I can't check for NULL since it isn't NULL. IsBadReadPtr doesn't seem to evaluate the whole 'tree' either. Anyone have a good method to check from base all the way to desired variable?
slointe
Hackleberry Fin
 
Posts: 28
Joined: Tue Jul 10, 2007 11:25 am

Postby L. Spiro » Thu Jul 16, 2009 7:52 pm

Use ::IsBadReadPtr() on every pointer up the tree.


L. Spiro
Our songs remind you of songs you’ve never heard.
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan

Postby slointe » Fri Jul 17, 2009 3:00 am

L. Spiro wrote:Use ::IsBadReadPtr() on every pointer up the tree.


L. Spiro


something like? (untested):

Code: Select all
if(!IsBadReadPtr(players, sizeof(players)))
      {
         if(!IsBadReadPtr(players->info_t, sizeof(players->info_t)))
         {
            if(!IsBadReadPtr(players->info_t->actors, sizeof(players->info_t->actors)))
            {
               int current = players->info_t->actors->localsettings_t->gameserver_t->local->player1->altcostume;

               if(current == 0)
               {
                  players->info_t->actors->localsettings_t->gameserver_t->local->player1->altcostume = 1;
                  players->info_t->actors->localsettings_t->gameserver_t->local->player2->altcostume = 1;
               }
            }
         }
      }
slointe
Hackleberry Fin
 
Posts: 28
Joined: Tue Jul 10, 2007 11:25 am

Postby L. Spiro » Fri Jul 17, 2009 8:05 am

Something like that.


L. Spiro
Our songs remind you of songs you’ve never heard.
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan


Return to General Related Discussions

Who is online

Users browsing this forum: No registered users and 0 guests