View Single Post
donrevan
AlliedModders Donor
Join Date: Jul 2010
Old 10-30-2014 , 15:35   Re: Hooking BaseEntity Functions in CSGO
Reply With Quote #16

This is what I've now:
PHP Code:
DETOUR_DECL_STATIC10(Detour_FXFireBulletsvoidVector const&, vOriginQAngle const&, vAnglesintweaponIdintmodeintseedfloatflSpreadfloata9floata10floata11inta12)
{
    
int iPlayerId;
    
__asm mov iPlayerIdecx
    int definitionIndex
;
    
__asm mov definitionIndexedx

    
// Trick the compiler into thinking that we're using ESI(to preserve it - just to be sure).
    
__asm mov esiesi;

    
printf("playerID: %d\n"iPlayerId);
    
printf("definitionIndex: %d\n"definitionIndex);
    
printf("wpnId: %d\n"weaponId);
    
printf("mode: %d\n"mode);
    
printf("seed: %d\n"seed);
    
printf("spread: %f\n"flSpread);

    
/* Call original function.
     * I had to manually 'construct' this call because the compiler was destroying register content while pushing the args. */
    
void *addr DETOUR_STATIC_CALL(Detour_FXFireBullets);
    
__asm {
        
push a12
        push a11
        push a10
        push a9
        push flSpread
        push seed
        push mode
        push weaponId
        push vAngles
        push vOrigin
        mov edx
definitionIndex
        mov ecx
iPlayerId
        call addr
        add esp
0x28
    
}

Excuse the huge mess but I had to use inline assembly to call the function because the compiler would destroy the contents of edx, ecx if I call it via DETOUR_STATIC_CALL..

If you remove the call to the original function no bullets/shots will be networked, however you can still kill people with knife/nades.

iPlayerID has correct values, dunno about definitionIndex

Last edited by donrevan; 10-30-2014 at 15:39.
donrevan is offline