Raised This Month: $ Target: $400

[CS:GO] Call a function with variable argument

Post New Thread Reply   
Thread Tools Display Modes
Author Message
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 05-30-2021 , 12:55   [CS:GO] Call a function with variable argument
Reply With Quote #1

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 )

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();
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() ); 

Last edited by kadet.89; 05-30-2021 at 12:57.
kadet.89 is offline
Send a message via Skype™ to kadet.89
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 05-31-2021 , 13:14   Re: [CS:GO] Call a function with variable argument
Reply With Quote #2

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).
asherkin is offline

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 09:42.

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