Raised This Month: $7 Target: $400
 1% 

Copyback Vector


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Accelerator
Senior Member
Join Date: Dec 2010
Location: Russia
Old 11-18-2018 , 10:03   Copyback Vector
Reply With Quote #1

Hello. I am trying to call a function that, after executing get a position in a variable:
PHP Code:
cell_t L4D2_GetRandomSpawnPosition(IPluginContext *pContext, const cell_t *params)
{
    if (
g_pZombieManager == NULL)
    {
        return 
pContext->ThrowNativeError("ZombieManager unsupported or not available; file a bug report");
    }

    static 
ICallWrapper *pWrapper NULL;

    if (!
pWrapper)
    {
        
REGISTER_NATIVE_ADDR("GetRandomSpawnPosition"
            
PassInfo pass[4]; \
            
pass[0].flags PASSFLAG_BYVAL; \
            
pass[0].size sizeof(ZombieClassType); \
            
pass[0].type PassType_Basic; \
            
pass[1].flags PASSFLAG_BYVAL; \
            
pass[1].size sizeof(int); \
            
pass[1].type PassType_Basic; \
            
pass[2].flags PASSFLAG_BYVAL; \
            
pass[2].size sizeof(CBaseEntity *); \
            
pass[2].type PassType_Basic; \
            
pass[3].flags PASSFLAG_BYVAL; \
            
pass[3].size sizeof(Vector*); \
            
pass[3].type PassType_Basic; \
            
pWrapper g_pBinTools->CreateCall(addrCallConv_ThisCallNULLpass4));
    }

    
int client params[3];
    
CBaseEntity pClient NULL;
    if (
client != -1)
    {
        
pClient UTIL_GetCBaseEntity(clienttrue);
        if(
pClient == NULL
        {
            return 
pContext->ThrowNativeError("Invalid client entity");        
        }
    }

    
Vector vector;
    
vector[0] = sp_ctof(0.0);
    
vector[1] = sp_ctof(0.0);
    
vector[2] = sp_ctof(0.0);

    
unsigned char vstksizeof(void*) + sizeof(ZombieClassType) + sizeof(int) + sizeof(CBaseEntity *) + sizeof(Vector*) ];
    
unsigned char *vptr vstk;

    *(
void **)vptr g_pZombieManager;
    
vptr += sizeof(void *);
    
    *(
cell_t*)vptr params[1];
    
vptr += sizeof(ZombieClassType);

    *(
int *)vptr params[2];
    
vptr += sizeof(int *);

    *(
CBaseEntity **)vptr pClient;
    
vptr += sizeof(CBaseEntity *);

    *(
Vector**)vptr = &vector;

    
pWrapper->Execute(vstkNULL);

    const 
void *buffer = (const unsigned char *)vstk pWrapper->GetParamInfo(3)->offset;

    
Vector *NULL;
    
= *(Vector**)buffer;

    
cell_taddr;
    
pContext->LocalToPhysAddr(params[4], &addr);

    
addr[0]=sp_ftoc(v->x);
    
addr[1]=sp_ftoc(v->y);
    
addr[2]=sp_ftoc(v->z);
    return 
0;

It works in linux, but in windows I get a server crash on pWrapper->Execute(vstk, NULL);... How can I assign a different solution so that after the call, the function returns an updated variable (like for example VENCODE_FLAG_COPYBACK in sdktools)?
__________________

Last edited by Accelerator; 11-18-2018 at 10:07.
Accelerator is online now
gubka
Veteran Member
Join Date: Jan 2012
Location: Russia
Old 12-20-2018 , 05:39   Re: Copyback Vector
Reply With Quote #2

Like i uderstand, some calls like even Terminate require some __asm work, maybe the issue in that particular function is similar?
__________________
gubka is offline
Send a message via ICQ to gubka
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 06:08.


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