问题
Is it possible, with Visual Studio compilers, to write 2 functions that get called before calling into other functions and after the functions have executed? In gcc you could do that with __cyg_profile_func_*() functions:
void __cyg_profile_func_enter(void *func_address, void *call_site )
__attribute__ ((no_instrument_function));
void __cyg_profile_func_exit (void *func_address, void *call_site )
__attribute__ ((no_instrument_function));
I need a solution that works for kernel mode software. I think Microsoft Detours may be of help, but the free edition is 32 bit only and my drivers are pure 64 bit.
I want to generate the call graph for the specific code.
Thanks.
回答1:
- You can use the /Gh /GH switch of cl to create penter/pexit hooks.
- For free hooking APIs take a look at:
2.1 easyhook
2.2 N-CodeHook
来源:https://stackoverflow.com/questions/949556/custom-prolog-epilog-functions-for-profiling