Pushok

Wallhack Function

Mar 9th, 2012
468
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.09 KB | None | 0 0
  1. bool HOOK_IsDrawingLoadingImage( void )
  2. {
  3.     __asm pushad;
  4.  
  5.     static bool bOnce = true;
  6.     static bool bOffsetsFound = true;
  7.  
  8.     if( bOnce )
  9.     {
  10.         std::for_each( namesMap.begin( ), namesMap.end( ), []( pair< const char*, DWORD > curelem )
  11.             {
  12.                 if( curelem.second == -1 )
  13.                 {
  14.                     Warning( "Could not get offset from %s\n", curelem.first );
  15.  
  16.                     bOffsetsFound = false;
  17.                 }
  18.                 else
  19.                 {
  20.                     Msg( "Prop :%s | Offset :%x\n", curelem.first, curelem.second );
  21.                 }
  22.             }
  23.         );
  24.  
  25.         bOnce = false;
  26.     }
  27.  
  28.     if( g_pClientEngine->IsInGame( ) )
  29.     {
  30.  
  31.         if( !bOffsetsFound )
  32.         {
  33.             goto Label;
  34.         }
  35.  
  36.         int iLocalIndex = -1;
  37.         int iLocalTeam = -1;
  38.  
  39.         void* pLocalEntity = g_pClientEntityList->GetClientEntity( g_pClientEngine->GetLocalPlayer( ) )->GetBaseEntity( );
  40.  
  41.         for( int i = 0; i <= g_pClientEngine->GetMaxClients( ); i++ )
  42.         {
  43.             IClientEntity *pClientEntity = g_pClientEntityList->GetClientEntity( i );
  44.  
  45.             if( pClientEntity )
  46.             {
  47.                 if( pClientEntity->GetBaseEntity( ) == pLocalEntity )
  48.                 {
  49.                     iLocalIndex = i;
  50.  
  51.                     break;
  52.                 }
  53.             }
  54.         }
  55.  
  56.         GR_Fn GetRes = nullptr;
  57.         void* pRadarList = nullptr;
  58.  
  59.         for( int i = 0; i < sizeof( sigList ) / sizeof( Signatures ); i++ )
  60.         {
  61.             if( !strcmp( sigList[i].name, "GetGameResources" ) )
  62.             {
  63.                 GetRes = (GR_Fn)sigList[i].offset;
  64.             }
  65.  
  66.             if( !strcmp( sigList[i].name, "m_pRadarList" ) )
  67.             {
  68.                 if( sigList[i].offset != nullptr && sigList[i].offset != (void*)-1 )
  69.                 {
  70.                     pRadarList = *(void**)((DWORD)sigList[i].offset+0x2);
  71.                 }
  72.             }
  73.         }
  74.  
  75.         if( pRadarList != nullptr )
  76.         {
  77.             void* mapPlayers = *(void**)pRadarList;
  78.  
  79.             for( int i = 1; i < g_pClientEngine->GetMaxClients( ); i++ )
  80.             {
  81.                 IClientEntity *pEntity = g_pClientEntityList->GetClientEntity( i );
  82.  
  83.                 if( !pEntity )
  84.                 {
  85.                     continue;
  86.                 }
  87.  
  88.                 void* pBaseEntity = g_pClientEntityList->GetClientEntity( i );
  89.  
  90.                 if( *READ_OFFS( int, mapPlayers, i * 0x140 + HEALTH_OFFSET ) != 0 )
  91.                 {
  92.                     Vector vecOrigin;
  93.                     Vector vecMins( -20, -20, 0 );
  94.                     Vector vecMaxs( 20, 20, 75);
  95.                    
  96.                     QAngle angRot( 0, 0, 0 );
  97.  
  98.                     int iHealth = *READ_OFFS( int, mapPlayers, i*0x140 + HEALTH_OFFSET );
  99.                    
  100.                     if( iHealth == 0 )
  101.                     {
  102.                         continue;
  103.                     }
  104.  
  105.                     int iTeam = *READ_OFFS( int, mapPlayers, i * 0x140 +TEAM_OFFSET );
  106.                     char* szName = READ_OFFS( char, mapPlayers, i * 0x140 + NAME_OFFSET );
  107.  
  108.                     if( pEntity->IsDormant( ) )//READ_PTR( int, pBaseEntity, m_PlayerFog.m_hCtrl, 0 ) == 0 )
  109.                     {
  110.                         vecOrigin = pEntity->GetAbsOrigin( );
  111.                     }
  112.                     else
  113.                     {
  114.                         vecOrigin = *READ_OFFS( Vector, mapPlayers, i * 0x140 + ORIGIN_OFFSET );
  115.                     }
  116.  
  117.                     if( iTeam > 1 )
  118.                     {
  119.                         char szFormatName[64];
  120.  
  121.                         sprintf( szFormatName, "%s\n--[%d]--", szName, iHealth );
  122.  
  123.                         g_pDbgOverlay->AddEntityTextOverlay( i + 1, 0, 0.01, iTeam == 2 ? 255 : 0, 0, iTeam == 3 ? 255 : 0, 255, szFormatName );
  124.                         g_pDbgOverlay->AddBoxOverlay( vecOrigin, vecMins, vecMaxs, angRot, iTeam == 2 ? 255 : 0, 0, iTeam == 3 ? 255 : 0, 30, 0.07 );
  125.                     }
  126.                 }
  127.             }
  128.         }
  129.     }
  130.  
  131.     Label:
  132.     __asm popad;
  133.     __asm call p_fnOldFunction;
  134. }
Add Comment
Please, Sign In to add comment