自定义prolog/epilog函数用于分析

Ter*_*nus 4 profiling kernel visual-studio

使用Visual Studio编译器,是否可以编写在调用其他函数之前和函数执行之后调用的2个函数?在gcc中你可以用__cyg_profile_func_*()函数做到这一点:

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));
Run Code Online (Sandbox Code Playgroud)

我需要一个适用于内核模式软件的解决方案.我认为微软Detours可能会有所帮助,但免费版只有32位,我的驱动程序是纯64位.

我想为特定代码生成调用图.

谢谢.

Sha*_*men 5

  1. 您可以使用cl 的/ Gh / GH开关创建penter/pexit挂钩.
  2. 对于免费挂钩API,请查看:
    2.1 easyhook
    2.2 N-CodeHook