C++语言的数组在汇编代码中的实现【DEBUG】

 #include<iostream> 

int  main(){

  ; main函数,main函数保存调用main函数的函数上下文

00F64350  push        ebp   ;保存栈帧基址,将栈帧基址入栈
00F64351  mov         ebp,esp  ;设置main函数的栈帧基址,即将栈顶指针esp赋给ebp(栈帧基址寄存器)
00F64353  sub         esp,0D4h  ;设置新的栈顶 D4h = 212 ,用户初始化堆栈和存放局部变量
00F64359  push        ebx  ;保护上下文 ebx
00F6435A  push        esi  ;保护上下文 esi
00F6435B  push        edi  ;保护上下文 edi
00F6435C  lea         edi,[ebp-0D4h]   ;将edi设置为栈顶位置
00F64362  mov         ecx,35h   ;ecx为rep重复的次数
00F64367  mov         eax,0CCCCCCCCh  ; 在目的地址写入的数据
00F6436C  rep stos    dword ptr es:[edi]  ;将eax的内容写入到es:[edi]处ccccccc为int 3中断,防止意外执行了该处的内容,stos指令可参 考: http://hi.baidu.com/freeboundless/item/bbcb3408cca31e026c90482b
00F6436E  mov         eax,dword ptr ds:[00F6F0E0h]  ;此处代码用于将security_cookie 存放到堆栈帧中,security _cookie可参考: http://bbs.pediy.com/archive/index.php?t-126858.html
00F64373  xor         eax,ebp  
00F64375  mov         dword ptr [ebp-4],eax  
char cards[] = "strings";   // 定义数组并初始化为“string”,该数组为静态数组,在编译时就分配了存储空间
00F64378  mov         eax,dword ptr ds:[00F6CC70h]      ; 在内存0x 00f6cc70h 处可以看到字符串 strings\0
00F6437D  mov         dword ptr [1bf96c],eax  
4380  mov         ecx,dword ptr ds:[0F6CC74h]  
00F64386  mov         dword ptr [ebp-0Ch],ecx    ;ebp 为main函数的栈帧基址 esp指向栈帧的栈顶  ,每一个函数都有一个栈帧
return 0;
00F64389  xor         eax,eax  ; 返回值 0 使用异或运算的到返回值,将返回值保存到 eax 寄存器中返回

}

以上加红的的代码就是将堆中0x00f6cc70处的strings\0转移到了main的栈帧0x001bf96c 处,刚好转移了8个字符(包括空字符\0)




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值