Raised This Month: $51 Target: $400
 12% 

L4d2 Signature CTerrorGun::Holster


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 02-16-2021 , 03:21   L4d2 Signature CTerrorGun::Holster
Reply With Quote #1

The title is self explanatory. I'm looking for l4d2 windows signature for the weapon holster function. I tried to look up in the binary, but there are no strings or references.

PHP Code:
CTerrorGun::Holster 
I've a candidate, but it just doesn't really have a unique signature. Wondering, if any of you have any good ideas?
__________________
Spirit_12 is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 02-16-2021 , 04:30   Re: L4d2 Signature CTerrorGun::Holster
Reply With Quote #2

It is a virtual function, you can use offsets to call it or hook it.
if you need the signiture for patching reasons i can look later today
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 02-16-2021 , 04:52   Re: L4d2 Signature CTerrorGun::Holster
Reply With Quote #3

It took me awhile since I just started finding sigs on my own a few days ago, but I *think* I found it.

PHP Code:
Signature for sub_103DA5D0:
55 8B EC 56 8B F1 80 BE DD 17 00 00 00 74 
\
x55\x8B\xEC\x56\x8B\xF1\x80\xBE\xDD\x17\x00\x00\x00\x74\x2A 
Here's how I did it:

1. I checked inside the function that is being returned:
PHP Code:
int __cdecl CTerrorGun::Holster(CTerrorGun *thisCBaseCombatWeapon *a2)
{
  
CBaseEdict *v2// eax

  
if ( *((_BYTE *)this 6113) && *((_BYTE *)this 6112) != )
  {
    if ( *((
_BYTE *)this 108) )
    {
      *((
_BYTE *)this 112) |= 1u;
      *((
_BYTE *)this 6112) = 1;
    }
    else
    {
      
v2 = (CBaseEdict *)*((_DWORD *)this 12);
      if ( 
v2 )
      {
        *(
_DWORD *)v2 |= 0x101u;
        *(
_WORD *)(CBaseEdict::GetChangeAccessor(v2) + 2) = 0;
      }
      *((
_BYTE *)this 6112) = 1;
    }
  }
  return 
CTerrorWeapon::Holster(thisa2); // Check this function...

2. I checked the function that is being returned in that function:
PHP Code:
int __cdecl CTerrorWeapon::Holster(CTerrorWeapon *thisCBaseCombatWeapon *a2)
{
  
int v2// ecx

  
if ( *((_BYTE *)this 5496) )
  {
    
v2 = *((_DWORD *)this 1506);
    *((
_BYTE *)this 5496) = 0;
    (*(
void (__cdecl **)(CTerrorWeapon *, bool))(*(_DWORD *)this 1760))(thisv2 0);
  }
  return 
CWeaponCSBase::Holster(thisa2); // Check this function...

3. I checked the function that is being returned in that function:
PHP Code:
int __cdecl CWeaponCSBase::Holster(CWeaponCSBase *thisCBaseCombatWeapon *a2)
{
  
CBasePlayer *v2// eax
  
CCSPlayer *v3// ebx

  
v2 = (CBasePlayer *)CWeaponCSBase::GetPlayerOwner(this);
  
v3 v2;
  if ( !
v2 )
    return 
0;
  
CBasePlayer::SetFOV(v2v200.00);
  
CCSPlayer::SetShieldDrawnState(v30);
  return 
CBaseCombatWeapon::Holster(thisa2); // Check this function...

4. Finally... I found a unique string ("BaseCombatWeapon_HideThink") in that function:
PHP Code:
int __usercall CBaseCombatWeapon::Holster@<eax>(long double a1@<st0>, CBaseCombatWeapon *this)
{
  
CBaseEntity *v2// esi
  
CBaseEdict *v3// eax
  
int v4// edi
  
float v5// xmm0_4
  
int v7// edi
  
CStudioHdr *v8// eax
  
CBaseEdict *v9// eax
  
int v11// [esp+8h] [ebp-40h]
  
int v12// [esp+Ch] [ebp-3Ch]
  
float v13// [esp+10h] [ebp-38h]
  
const char *v14// [esp+14h] [ebp-34h]
  
float v15// [esp+20h] [ebp-28h]
  
float v16// [esp+24h] [ebp-24h]
  
char v17[32]; // [esp+28h] [ebp-20h] BYREF

  
v2 mdlcache;
  (*(
void (__cdecl **)(CBaseEntity *))(*(_DWORD *)mdlcache 104))(mdlcache);
  if ( *((
_BYTE *)this 5209) )
  {
    if ( *((
_BYTE *)this 108) )
    {
      *((
_BYTE *)this 112) |= 1u;
    }
    else
    {
      
v3 = (CBaseEdict *)*((_DWORD *)this 12);
      if ( 
v3 )
      {
        *(
_DWORD *)v3 |= 0x101u;
        *(
_WORD *)(CBaseEdict::GetChangeAccessor(v3) + 2) = 0;
      }
    }
    *((
_BYTE *)this 5209) = 0;
  }
  
CBaseCombatWeapon::QueueAttack(this0);
  
CBaseEntity::ThinkSet(v17);
  (*(
void (__cdecl **)(CBaseCombatWeapon *, int_DWORD_DWORD_DWORD_DWORD))(*(_DWORD *)this 1008))(
    
this,
    
182,
    
0,
    
0,
    
0,
    
0);
  
v16 0.0;
  if ( *((
_DWORD *)this 1298) == 182 )
  {
    
v7 = *((_DWORD *)this 293);
    if ( !*((
_DWORD *)this 1272) && CBaseEntity::GetModel(this) )
      
CBaseAnimating::LockStudioHdr(this);
    
v8 = (CStudioHdr *)*((_DWORD *)this 1272);
    if ( 
v8 && !*(_DWORD *)v8 )
      
v8 0;
    
CBaseAnimating::SequenceDuration(thisv8v7);
    
v16 a1;
  }
  
v4 CBaseCombatWeapon::GetOwner(this);
  if ( 
v4 )
  {
    
v15 v16 + *(float *)(gpGlobals 12);
    if ( 
v15 != *(float *)(v4 6108) )
    {
      if ( *(
_BYTE *)(v4 108) )
      {
        *(
_BYTE *)(v4 112) |= 1u;
      }
      else
      {
        
v9 = *(CBaseEdict **)(v4 48);
        if ( 
v9 )
        {
          *(
_DWORD *)v9 |= 0x101u;
          *(
_WORD *)(CBaseEdict::GetChangeAccessor(v9) + 2) = 0;
        }
      }
      *(
float *)(v4 6108) = v15;
    }
  }
  if ( 
v16 == 0.0 )
  {
    (*(
void (__cdecl **)(CBaseCombatWeapon *, _DWORD))(*(_DWORD *)this 1072))(this0);
  }
  else
  {
    
v14 "BaseCombatWeapon_HideThink"// Use this unique string...
    
v11 1521;
    
v12 0;
    
v13 v16 + *(float *)(gpGlobals 12);
    
CBaseEntity::ThinkSet(v17);
  }
  
v5 = *((float *)this 1315);
  if ( 
v5 != 0.0 && v5 > *(float *)(gpGlobals 12) )
  {
    if ( *((
_BYTE *)this 5252) )
      (*(
void (__cdecl **)(CBaseCombatWeapon *, CBaseCombatWeapon *, intintfloat, const char *))(*(_DWORD *)this 988))(
        
this,
        
this,
        
v11,
        
v12,
        
COERCE_FLOAT(LODWORD(v13)),
        
v14);
    if ( *((
_BYTE *)this 5253) )
      (*(
void (__cdecl **)(CBaseCombatWeapon *))(*(_DWORD *)this 1000))(this);
  }
  (*(
void (__cdecl **)(CBaseEntity *))(*(_DWORD *)v2 108))(v2);
  return 
1;

5. Once you search for that string, just do some backtracking. Eventually, I ended up with a list of function calls and I just checked each one to see which of them shares a similar set of instructions to the one in the Linux binaries.

Linux:
PHP Code:
int __cdecl CTerrorGun::Holster(CTerrorGun *thisCBaseCombatWeapon *a2)
{
  
CBaseEdict *v2// eax

  
if ( *((_BYTE *)this 6113) && *((_BYTE *)this 6112) != )
  {
    if ( *((
_BYTE *)this 108) )
    {
      *((
_BYTE *)this 112) |= 1u;
      *((
_BYTE *)this 6112) = 1;
    }
    else
    {
      
v2 = (CBaseEdict *)*((_DWORD *)this 12);
      if ( 
v2 )
      {
        *(
_DWORD *)v2 |= 0x101u;
        *(
_WORD *)(CBaseEdict::GetChangeAccessor(v2) + 2) = 0;
      }
      *((
_BYTE *)this 6112) = 1;
    }
  }
  return 
CTerrorWeapon::Holster(thisa2);

Windows:
PHP Code:
char __thiscall sub_103DA5D0(int thisint a2)
{
  
_DWORD *v3// ecx

  
if ( *(_BYTE *)(this 6109) && *(_BYTE *)(this 6108) != )
  {
    if ( *(
_BYTE *)(this 100) )
    {
      *(
_BYTE *)(this 104) |= 1u;
    }
    else
    {
      
v3 = *(_DWORD **)(this 40);
      if ( 
v3 )
      {
        *
v3 |= 0x101u;
        *(
_WORD *)(sub_100EBBB0() + 2) = 0;
      }
    }
    *(
_BYTE *)(this 6108) = 1;
  }
  return 
sub_103DF1A0((_BYTE *)thisa2);

__________________
Psyk0tik is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 02-16-2021 , 20:36   Re: L4d2 Signature CTerrorGun::Holster
Reply With Quote #4

Thank you Crasher, beautiful work. Here is why I needed it.

https://forums.alliedmods.net/showthread.php?t=330703

Would appreciate, if you guys can help test it.
__________________
Spirit_12 is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 02-21-2021 , 14:43   Re: L4d2 Signature CTerrorGun::Holster
Reply With Quote #5

Quote:
Originally Posted by Crasher
It took me awhile since I just started finding sigs on my own a few days ago, but I *think* I found it.

55 8B EC 56 8B F1 80 BE DD 17 00 00 00 74 ?
Quote:
74 34 jz short loc_103D9C73
short jump offset doesn't change unless the code of this function will change in the new binary build.

Also, "?" as a last char in sig has no sense. It's the same as without it.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 02-21-2021 , 19:24   Re: L4d2 Signature CTerrorGun::Holster
Reply With Quote #6

Quote:
Originally Posted by Dragokas View Post
short jump offset doesn't change unless the code of this function will change in the new binary build.

Also, "?" as a last char in sig has no sense. It's the same as without it.
Yes, after a week of sigscanning, I was able to figure these out and understand all this now. Thank you nonetheless.
__________________
Psyk0tik is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:23.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode