views:

230

answers:

1

Hello,

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.

+3  A: 
  1. You can use the /Gh /GH switch of cl to create penter/pexit hooks.
  2. For free hooking APIs take a look at:
    2.1 easyhook
    2.2 N-CodeHook
Shay Erlichmen
Thanks a lot. /Gh /GH are exactly what I need.
Terminus