汇编中push 0x*** retn表示跳转到某个地址继续执行
#pragma comment(linker,"/SECTION:.text,ERW") //编译器允许代码可写 #include <iostream> #include <Windows.h> //游戏功能函数 void func1() { MessageBoxA(0, "正常消息", "提示", MB_OK); } void hookedproc() { MessageBoxA(0, "hook消息", "提示", MB_OK); } void hookedproc1() { BYTE* lpfunc1 = (BYTE*)func1; lpfunc1[0] = 0x68; *(ULONG_PTR*)&lpfunc1[1] = (ULONG_PTR)hookedproc; lpfunc1[5] = 0xc3; } int main() { hookedproc1(); func1(); return 0; }View Code