内联汇编的使用,函数返回值的外部调用
作者:互联网
#include "windows.h" #include "stdio.h" _declspec(naked) void Fun() { _asm { push ebp; mov ebp ,esp; sub esp ,0x40; push esi; push edi; push ecx; mov eax,0xcccccccc; mov ecx,0x10; lea edi,[ebp-0x40]; REP STOS DWORD PTR ES:[EDI]; mov eax,[ebp+0x8]; add eax,[ebp+0xc]; pop ecx; pop edi; pop esi; mov esp,ebp; pop ebp; ret; } } void main() { int arg =0; _asm { push 0x3; push 0x5; call Fun; mov DWORD ptr [arg],eax; //赋值到内存地址 add esp,0x8; //外平栈,自己恢复堆栈 } printf("res=%d\n",arg); getchar(); }
标签:汇编,esp,mov,pop,eax,ebp,返回值,push,内联 来源: https://www.cnblogs.com/admrty/p/16305066.html