AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Coding MM:S Plugins & SM Extensions (https://forums.alliedmods.net/forumdisplay.php?f=75)
-   -   VCall Crashes upon execution (https://forums.alliedmods.net/showthread.php?t=321450)

xerox8521 02-11-2020 08:27

VCall Crashes upon execution
 
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 13:39: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);\
        }\ 


TheDS1337 02-11-2020 09:11

Re: VCall Crashes upon execution
 
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.


All times are GMT -4. The time now is 17:18.

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