View Single Post
Zeisen
Member
Join Date: Nov 2016
Location: Republic of Korea
Old 10-02-2018 , 22:15   Re: how do i detour the function has variable argument?
Reply With Quote #2

I'm still figuring out this. added va_list, but still crash. and buffer prints obstruction string.

Code:
DETOUR_DECL_MEMBER2(PrintIfWatched, void, char *, format, va_list *, args)
{
	CBaseEntity *pBot = (CBaseEntity *)this;

	size_t len;
	va_list ap;

	char buffer[1024];
	va_start(ap, format);
	vsprintf(buffer, format, ap);
	va_end(ap);

	g_SMAPI->ConPrintf("buffer : %s\n", buffer);

	cell_t result = g_BotController.OnPrintIfWatched(pBot, buffer);
	if (result == Pl_Handled || result == Pl_Stop)
		return;

	g_SMAPI->ConPrintf("Calling..\n");

	DETOUR_MEMBER_CALL(PrintIfWatched)(format, args);
}
Zeisen is offline