Hooking function with varargs parameter

May 14, 2010 at 11:24 AM
I'm trying to use EasyHook to hook a function that is using a varargs parameter, i.e. something similar to printf from the standard library. I want to do this from managed code but there doesn't seem to be any way to do this using EasyHook. C# supports the (undocumented) __arglist which can be used with PInvoke to call such a function but unfortunately you cannot declare a delegate that takes an __arglist parameter. C++/CLI doesn't appear to allow this either and complains 'Error C2217: '...' requires __cdecl', which makes sense but when I specify __cdecl it just tells me I cannot specify an explicit calling convention for a delegate. I suppose I could write an unmanaged hook that does this but I rather not if it is at all possible to do from managed code. Any ideas?