在进入任何函数之前会自动调用的函数
from MSDN
Visual C++ 编译器选项/Gh(启用 _penter 挂钩函数),导致在每个方法或函数的开头调用 _penter 函数。
_penter 函数不是任何库的组成部分,由您负责提供 _penter 的定义。
当用 /Gh 编译时,以下代码显示如何两次调用 _penter;一次是在进入函数 main 时,一次是在进入函数 x 时。
// Gh_compiler_option.cpp
// compile with: /Gh
// processor: x86
#include <stdio.h>
void x() {}
int main() {
x();
}
extern "C" void __declspec(naked) _cdecl _penter( void ) {
_asm {
push eax
push ebx
push ecx
push edx
push ebp
push edi
push esi
}
printf_s("\nIn a function!");
_asm {
pop esi
pop edi
pop ebp
pop edx
pop ecx
pop ebx
pop eax
ret
}
}
输出:
In a function! In a function!


_asm
浙公网安备 33010602011771号