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

Passing a reference parameter to CreateVCall


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 03-16-2019 , 11:19   Passing a reference parameter to CreateVCall
Reply With Quote #1

Hello guys, I'm trying to call the function CorpseGib from CBaseCombatCharacter with this code
PHP Code:
bool CorpseGib(CBaseEntity *clientEntity, const CTakeDamageInfoHack &damageInfo)
{
    
CONSOLE_DEBUGGER("Call started!");

    static 
ICallWrapper *pCallWrapper nullptr;

    if( !
pCallWrapper )
    {
        
PassInfo info[2];

        
info[0].flags PASSFLAG_BYREF PASSFLAG_OCTOR PASSFLAG_OCOPYCTOR;
        
info[0].size sizeof(CTakeDamageInfoHack);
        
info[0].type PassType_Object;
        
info[1].type PassType_Basic;
        
info[1].flags PASSFLAG_BYVAL;
        
info[1].size sizeof(bool);

        
pCallWrapper g_pExtension->m_pBinTools->CreateVCall(31000, &info[1], info1);

        if( !
pCallWrapper )
        {
            
CONSOLE_DEBUGGER("Failed to create a call to CBaseCombatCharacter:CorpseGib");
            return 
false;
        }

        
g_pExtension->m_pBinCallWrappers.push_back(pCallWrapper);
    }

    
unsigned char params[sizeof(CBaseEntity *) + sizeof(CTakeDamageInfoHack)];
    
unsigned char *vparams params;

    *(
CBaseEntity **) vparams clientEntityvparams += sizeof(CBaseEntity *);
    
memcpy(vparams, &damageInfosizeof(CTakeDamageInfoHack));

    
bool gibbed false;
    
pCallWrapper->Execute(params, &gibbed);

    
CONSOLE_DEBUGGER("Call ended!");

    return 
gibbed;

As you can see, the reference is making things a bit harder and I took a look at SDKTools's AcceptEntityInput, it is the only one using PassType_Object (apart from the ValveCaller);

The offset is: 310, and just to be sure I tested both 309 and 311. Although 310 seems the 'only' one giving gibbed = true as a result, I am confused, I mean the function is probably getting called but nothing is happening?

PS: I'm using the takedamageinfohack header and source file from SDKHooks to wrap around CTakeDamageInfo

Last edited by TheDS1337; 03-16-2019 at 11:21.
TheDS1337 is offline
 



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 02:29.


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