Raised This Month: $13 Target: $400
 3% 

VCall Crashes upon execution


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xerox8521
Senior Member
Join Date: Sep 2011
Old 02-11-2020 , 08:27   VCall Crashes upon execution
Reply With Quote #1

Hi,

so i have this function CBaseEntity::IsPlayer (i know there are other ways to check for the player) and it crashes upon execution and I'm not sure why it crashes. I've tried to use the ArgBuffer class but that also crashes.

Offset is correct as it works just fine when i tested it directly via SDKCall.

Edit: Looks liek the crash doesnt obviously point to the Execute function. https://crash.limetech.org/7ngxvvi4ly75

SM Version

Quote:
SourceMod Version Information:
SourceMod Version: 1.10.0.6460
SourcePawn Engine: 1.10.0.6460, jit-x86 (build 1.10.0.6460)
SourcePawn API: v1 = 5, v2 = 12
Compiled on: Jan 7 2020 139:09
Built from: https://github.com/alliedmodders/sou...commit/2896435
Build ID: 6460:2896435
http://www.sourcemod.net/
Meta Version
Quote:
Metamod:Source version 1.10.7-dev
Built from: https://github.com/alliedmodders/met...commit/6c8495f
Build ID: 971:6c8495f
Loaded As: Valve Server Plugin
Compiled on: Mar 28 2019
Plugin interface version: 15:14
SourceHook version: 5:5
http://www.metamodsource.net/
PHP Code:
static cell_t Native_IsPlayer(IPluginContextpContext, const cell_tparams)
{
    
CBaseEntitypEntity GetCBaseEntity(params[1], false);
    if (!
pEntity)
    {
        return 
pContext->ThrowNativeError("Entity index %d is invalid"params[1]);
    }

    static 
ICallWrapperpWrapper nullptr;
    if (!
pWrapper)
    {
        
REGISTER_NATIVE_OFFSET("CBaseEntity::IsPlayer",
            
PassInfo retInfo;
            
retInfo.flags PASSFLAG_BYVAL; \
            
retInfo.size sizeof(bool); \
            
retInfo.type PassType_Basic; \
            
g_pBinTools->CreateVCall(offset00, &retInfonullptr0));
    }

    
//ArgBuffer<CBaseEntity*> vstk(pEntity);

    
unsigned char vstk[sizeof(CBaseEntity*)];
    
unsigned charvptr vstk;

    *(
CBaseEntity**)vptr pEntity;

    
bool bResult;
    
pWrapper->Execute(vstk, &bResult);
    return (
bResult == true) ? 0;

REGISTER_NATIVE_OFFET is defined as
PHP Code:
#define REGISTER_NATIVE_OFFSET(name, code)\
    
int offset;\
    
GET_OFFSET(name);\
    
code;\
    
g_RegNatives.Register(pWrapper); 
GET_OFFSET is defined as
PHP Code:
#define GET_OFFSET(name) \
    
if(!g_pGameConf->GetOffset(name, &offset) || !offset) \
        {\
            return 
pContext->ThrowNativeError("Failed to get offset: %s"name);\
        }\ 

Last edited by xerox8521; 02-11-2020 at 08:30. Reason: Added Link to Throttle and added Meta / SM version
xerox8521 is offline
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 02-11-2020 , 09:11   Re: VCall Crashes upon execution
Reply With Quote #2

Looks like you forgot to get the pWarpper pointer. that is the first thing I noticed, try this:
PHP Code:
static cell_t Native_IsPlayer(IPluginContextpContext, const cell_tparams)
{
    
CBaseEntitypEntity GetCBaseEntity(params[1], false);
    if (!
pEntity)
    {
        return 
pContext->ThrowNativeError("Entity index %d is invalid"params[1]);
    }

    static 
ICallWrapperpWrapper nullptr;
    if (!
pWrapper)
    {
        
REGISTER_NATIVE_OFFSET("CBaseEntity::IsPlayer",
            
PassInfo retInfo;
            
retInfo.flags PASSFLAG_BYVAL; \
            
retInfo.size sizeof(bool); \
            
retInfo.type PassType_Basic; \
            
pWrapper  g_pBinTools->CreateVCall(offset00, &retInfonullptr0));
    }

    if( !
pWrapper )
    {
         return 
pContext->ThrowNativeError("Failed to get ICallWarpper pointer");
    }

    
//ArgBuffer<CBaseEntity*> vstk(pEntity);

    
unsigned char vstk[sizeof(CBaseEntity*)];
    
unsigned charvptr vstk;

    *(
CBaseEntity**)vptr pEntity;

    
bool bResult;
    
pWrapper->Execute(vstk, &bResult);
    return (
bResult == true) ? 0;

EDIT: Ah, one more thing. don't forget to free it, I think using a List or a Vector to store the pointer and free it on extension unload is a good idea.
__________________

Last edited by TheDS1337; 02-11-2020 at 09:14.
TheDS1337 is offline
Reply


Thread Tools
Display Modes

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 10:27.


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