Is there a compiler feature to inject custom function entry and exit code?

后端 未结 4 1823
无人及你
无人及你 2020-12-10 15:19

Currently coding on Windows with VS2005 (but wouldn\'t mind knowing if there are options for other compilers and platforms. I\'m most interested in OSX as an alternative pl

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-10 15:29

    It's Microsoft-specific, but you can hook into the _penter and _pexit functions to do something when entering and exiting a function -- you'll have to compile your project with some special flags.

    There's a little bit of a tutorial here, and you can find a few more results on how to use them on Google. Also, this blog post goes into some detail on the assembly that you need to do to avoid messing up the stack on entry and exit.

提交回复
热议问题