Reputation: 11
I'm trying to intercept(hook) a function that uses a list of arguments to get the result, and then call the old function.
// int __cdecl Ordinal578(char *a1, unsigned int a2, int a3, char a4) (HEXRAYS)
typedef int(__cdecl *Ordinal578)(char *a1, unsigned int a2, const char * a3, ...);
Ordinal578 Ordinal578org = nullptr;
Ordinal578 Ordinal578ptr = nullptr;
int __cdecl Ordinal578my(char *a1, unsigned int a2, const char * a3, ...)
{
int result = 0;
va_list args;
va_start(args, a3);
result = Ordinal578ptr(a1, a2, a3, args); // if replace this on "vsnprintf_s(a1, a2, a2, a3, args);" it works 5-10 min and then crash!
va_end(args);
return result;
}
Program crashes after call: Ordinal578ptr (a1, a2, a3, args)
How to set the hook on these functions?
Upvotes: 1
Views: 357
Reputation: 45684
va_list
instead.__builtin_apply_args ()
and friends.Upvotes: 2