zoukankan      html  css  js  c++  java
  • 【IDA分析学习 0x01】 return返回机制

    在加密与解密上看到的return返回值的汇编分析和自己用IDA打开的有所不同,但是基本差不多,做个记录:

    _main函数略过,就是把参数按_stdcall标准传递进去,具体进入调用的函数:

     1 .text:00401013 sub_401013      proc near               ; CODE XREF: _main+7p
     2 .text:00401013
     3 .text:00401013 var_4           = dword ptr -4
     4 .text:00401013 arg_0           = dword ptr  8
     5 .text:00401013 arg_4           = dword ptr  0Ch
     6 .text:00401013
     7 .text:00401013                 push    ebp
     8 .text:00401014                 mov     ebp, esp        ; ebp暂存函数进入时的栈顶位置
     9 .text:00401016                 push    ecx             ; 分配一个局部变量 4字节
    10 .text:00401017                 mov     eax, [ebp+arg_0] ; 取得第一个参数
    11 .text:0040101A                 add     eax, [ebp+arg_4] ; 取得第二个参数并和另外一个相加
    12 .text:0040101D                 mov     [ebp+var_4], eax ; 结果保存在局部变量中
    13 .text:00401020                 mov     eax, [ebp+var_4] ; 局部变量的值返回到eax中
    14 .text:00401023                 mov     esp, ebp        ; 恢复esp
    15 .text:00401025                 pop     ebp
    16 .text:00401026                 retn
    17 .text:00401026 sub_401013      endp

    这里是用的

    mov ebp,esp 暂存esp

    push ecx 来分配局部变量

    ...

    mov esp,ebp 最后再恢复

    另外书上的方式是:

    mov ebp,esp 暂存esp

    sub esp,4 控制esp的值分配空间

    ...

    mov esp,ebp

    add esp,4

  • 相关阅读:
    ZooKeeper系列
    CST和GMT时间的区别
    ZooKeeper系列之二:Zookeeper常用命令
    分布式服务框架 Zookeeper -- 管理分布式环境中的数据
    ZooKeeper资料
    分布式选举算法
    初识ZooKeeper与集群搭建实例
    原子广播
    Apache ZooKeeper
    工作流引擎
  • 原文地址:https://www.cnblogs.com/driedfish/p/5428427.html
Copyright © 2011-2022 走看看