AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Coding MM:S Plugins & SM Extensions (https://forums.alliedmods.net/forumdisplay.php?f=75)
-   -   [CS:GO] Call a function with variable argument (https://forums.alliedmods.net/showthread.php?t=332748)

kadet.89 05-30-2021 11:55

[CS:GO] Call a function with variable argument
 
I need to call this function:
void CBaseServer::SetReservationCookie( uint64 uiCookie, char const *pchReasonFormat, ... )

I have this working detour:
PHP Code:

DETOUR_DECL_MEMBER3(SetReservationCookieDetourvoiduint64uiCookiechar const *,pchReasonFormatunsigned longarg )
{
    return 
DETOUR_MEMBER_CALL(SetReservationCookieDetour)(uiCookiepchReasonFormatarg);


I use DETOUR_MEMBER_MCALL_CALLBACK to call this function. So far I tried passing va_list reference, directly or a link to an empty va_list. Tried to pass 0 or remove the argument. It always leads to crashes.

PHP Code:

    va_list empty_va_list va_list();
    
DETOUR_MEMBER_MCALL_CALLBACK(SetReservationCookieDetourg_pServer)(-602679911""empty_va_list); 

What is the correct way to call this function?

In the leaked sources this function is called in 3 places:
PHP Code:

SetReservationCookienReservationCookie"ReplyReservationRequest" );
SetReservationCookieuiReservationCookie"ReserveServerForQueuedGame: %s"szReservationPayload );
SetReservationCookie( *m_pnReservationCookieSession"[R] Connect from %s"ns_address_renderadr ).String() ); 


asherkin 05-31-2021 12:14

Re: [CS:GO] Call a function with variable argument
 
Varargs functions have a different calling convention from regular functions, and it doesn't look like CDetour implements any straightforward support for them (SourceHook does, in the form of the _vafmt suffixed macros).


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

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