IDA Pro 入门 寄存器
程序源码
1 |
|
使用 IDA 载入
定位到 add
函数
汇编代码如下:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22.text:00000000004015CF ; =============== S U B R O U T I N E =======================================
.text:00000000004015CF
.text:00000000004015CF ; Attributes: bp-based frame
.text:00000000004015CF
.text:00000000004015CF ; int __cdecl add(int a, int b)
.text:00000000004015CF public add
.text:00000000004015CF add proc near ; CODE XREF: main+17↑p
.text:00000000004015CF ; DATA XREF: .pdata:000000000040A078↓o ...
.text:00000000004015CF
.text:00000000004015CF a = dword ptr 10h
.text:00000000004015CF b = dword ptr 18h
.text:00000000004015CF
.text:00000000004015CF push rbp
.text:00000000004015D0 mov rbp, rsp
.text:00000000004015D3 mov [rbp+a], ecx
.text:00000000004015D6 mov [rbp+b], edx
.text:00000000004015D9 mov edx, [rbp+a]
.text:00000000004015DC mov eax, [rbp+b]
.text:00000000004015DF add eax, edx
.text:00000000004015E1 pop rbp
.text:00000000004015E2 retn
.text:00000000004015E2 add endp
栈和堆
栈 (stack)
- 编译器自动分配释放, 存放函数的参数值, 局部变量的值等
- 系统自动分配
堆 (heap)
- 一般是由程序员分配释放
- C 中使用函数
malloc
分配空间, 用 free 释放, C++ 用 new 分配, 用 delete 释放
区别讲解可参考 栈和堆的区别
常用寄存器表
sp/esp/rsp (16bit/32bit/64bit) 栈寄存器 —— 指向栈顶
bp/edp/rbp 栈基址寄存器 —— 指向栈底
ip/eip/rip 程序指令寄存器 —— 指向下一条待指定命令
Register | Accumulator | Counter | Data | Base | Stack Pointer | Stack Base Pointer | Source | Destination | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
64-bit | RAX | RCX | RDX | RBX | RSP | RBP | RSI | RDI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
32-bit | EAX | ECX | EDX | EBX | ESP | EBP | ESI | EDI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
16-bit | AX | CX | DX | BX | SP | BP | SI | DI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
8-bit | AH | AL | CH | CL | DH | DL | BH | BL | SPL | BPL | SIL | DIL |
中英对照
En | Zh |
---|---|
Accumulator | 累加器 |
Counter | 计数寄存器 |
Data | 数据寄存器 |
Base | 堆栈基址针 |
Stack Pointer | 堆栈顶指针 |
Stack Base Pointer | 堆栈基指针 |
Source | 源索引寄存器 |
Destination | 目的地索引寄存器 |
Source 与 Destination 也称为 变址寄存器
汇编跳转逻辑
jmp
无条件跳转 (jump)
je/jz
结果为0跳转 (jump zero)
jnz/jne
结果不为0跳转 (jump not zero)
js
结果为负跳转 (Jump if sign)
jns
结果为正跳转(Jump if not sign)
jb
小于则跳转(Jump below)
jnb
大于或等于则跳转(Jump not below)
All articles in this blog adopt the CC BY-SA 4.0 agreement unless otherwise stated. Please indicate the source for reprinting!