c语言中宿主变量的定义,“确定被调用的宿主有关问题”各种语言版大征集

C/C++ code#include

void whocallme();

void fun1() {

whocallme();

}

void fun2() {

whocallme();

}

void fun3() {

fun1();

}

void whocallme() {

int *_esp,i;

__asm {

mov eax,esp

mov _esp,eax

}

printf("\nfun1,fun2,fun3,_esp=%08x,%08x,%08x,%08x\n",(int)fun1,(int)fun2,(int)fun3,(int)_esp);

for (i=0;i<100;i++) if (_esp[i]==(int)_esp) break;

if (i<100) {

printf("ret addr=%08x\n",_esp[i+2]);

if ((int)fun1<=_esp[i+2] && _esp[i+2]

if ((int)fun2<=_esp[i+2] && _esp[i+2]

}

}

void main() {

fun2();

fun1();

}

//C:\tmp\tmp\Debug>tmp

//

//fun1,fun2,fun3,_esp=00401000,00401020,00401040,0012fe84

//ret addr=0040102e

//fun2 callme

//

//fun1,fun2,fun3,_esp=00401000,00401020,00401040,0012fe84

//ret addr=0040100e

//fun1 callme

//

//C:\tmp\tmp\Debug>cd ..\release

//

//C:\tmp\tmp\Release>tmp

//

//fun1,fun2,fun3,_esp=00401000,0040100a,00401014,0012ff5c

//ret addr=00401012

//fun2 callme

//

//fun1,fun2,fun3,_esp=00401000,0040100a,00401014,0012ff5c

//ret addr=00401008

//fun1 callme

//

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值