Reputation: 97
void foo(int fmt, ...)
{
}
//I hook foo
static void (*original_foo)(int fmt, ...);
void replaced_foo(int fmt, ...)
{
printf("Hooking");
va_list args;
va_start(args, fmt);
//do something
va_end(args);
//But I want to call the original_foo function, //I do not know how to invoke it ...
}
//Hook Function not include ...
Hook(foo, replaced_foo, (void **)&original_foo);
Upvotes: 2
Views: 1117
Reputation: 91119
If you have a corresponding original_foo_v()
which takes a va_args
, you are lucky: you can use that.
If you don't (such as if you use DbgPrintf()
or LStrPrintf()
for interfacing with LabVIEW), you'll have to craft something on your own.
Essentially, you'll have to
va_list
you get,va_list
points to and the next stack frame,va
-aware function.Of course, you'll have to do this for each and every platform you intend to support...
Good luck and have fun.
Upvotes: 2