Custom prolog/epilog functions for profiling

隐身守侯 提交于 2019-12-21 05:45:12

问题


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:


  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


来源:https://stackoverflow.com/questions/949556/custom-prolog-epilog-functions-for-profiling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!