hlsdk

hlsdk

Jan 18th, 2010
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.50 KB | None | 0 0
  1. /*********************************************
  2. This is a very simple wallhack based on pat0's code. The difference here is the VMT hookens,
  3. which is written in the code below.
  4.  
  5. This is also known to crash on level change :(
  6. *********************************************/
  7.  
  8. ConVar metalslave_esp_enable("metalslave_esp_enable",0,0,"Displays information about other players");
  9. ConVar metalslave_wallhack_enable("metalslave_wallhack_enable","1",0,"Set to 1 to see various models through walls");
  10.  
  11. UINT32 OrigFindMaterial = NULL;
  12.  
  13.  
  14. #define FINDMATERIAL_ORANGEBAWKS 70
  15.  
  16. UINT32 thisptr;
  17. IMaterial * __stdcall FindMaterialOB( char const* pMaterialName, const char *pTextureGroupName, bool complain, const char *pComplainPrefix ) {
  18.    
  19.  
  20.     __asm {
  21.         mov thisptr, ecx
  22.     };
  23.  
  24.  
  25.     // fetch the real material
  26.     IMaterial* realmat = NULL;
  27.     int iComplain = (complain) ? 1 : 0;
  28.     __asm {
  29.         mov ecx, thisptr
  30.         push pComplainPrefix
  31.         push iComplain
  32.         push pTextureGroupName
  33.         push pMaterialName
  34.         call OrigFindMaterial
  35.         mov realmat, eax
  36.     };
  37.  
  38.     if (metalslave_wallhack_enable.GetInt() ) {
  39.             if (realmat) {
  40.                     if (
  41.                         strstr(pMaterialName,"models\\player") ||
  42.                         strstr(pMaterialName,"models\\items")  ||
  43.                         strstr(pMaterialName,"models\\flag")   ||
  44.                         strstr(pMaterialName,"models\\buildables") ||
  45.                         strstr(pMaterialName,"models\\weapons") ||
  46.                         strstr(pMaterialName,"particle") ||
  47.                         strstr(pMaterialName,"Particles")
  48.  
  49.                        
  50.                         ) {
  51.                         Msg("*** Material %s haxed. (Texture group %s)\n",pMaterialName,pTextureGroupName);
  52.                         realmat->SetMaterialVarFlag( MATERIAL_VAR_IGNOREZ, true );
  53.                         realmat->SetMaterialVarFlag( MATERIAL_VAR_ZNEARER, true );
  54.                         realmat->AlphaModulate(255.0f);
  55.                     }
  56.                     //if (strstr(pTextureGroupName, "World")) {
  57.                     //  realmat->SetMaterialVarFlag( MATERIAL_VAR_ALPHATEST, true );
  58.                     //}
  59.             } else {
  60.                     Msg("Mat %s not found\n", pMaterialName);
  61.             }
  62.     }
  63.  
  64.     return realmat;
  65. }
  66.  
  67.  
  68. void DoMatSysHooks() {
  69.     UINT32* matsystem_vtable_ptr;
  70.    
  71.  
  72.     if (!materials) {
  73.         Msg("Material system not hooked up yet!\n");
  74.         return;
  75.     }
  76.  
  77.     memcpy(&matsystem_vtable_ptr, (void*)((UINT32*)materialSystem), 4);
  78.  
  79.     OrigFindMaterial = matsystem_vtable_ptr[ FINDMATERIAL_ORANGEBAWKS ];
  80.     UINT32* hookzed_vtable = new UINT32[700];
  81.     UINT32  hookzed_vtable_ptr = (UINT32)hookzed_vtable;
  82.     memcpy(hookzed_vtable,matsystem_vtable_ptr,700);
  83.     *((UINT32*)materialSystem) = hookzed_vtable_ptr;
  84.  
  85.     // yawn
  86.     hookzed_vtable[ FINDMATERIAL_ORANGEBAWKS ] = (UINT32)FindMaterialOB;
  87. }
Add Comment
Please, Sign In to add comment