逆向基础3. 结构体数组的汇编结构
结构体数组的汇编结构
在栈上的数组数据结构
测试使用结构体如下
| 1 |  | 
测试代码如下
| 1 |  | 
生成汇编如下:
| 1 |  | 
可以看出其栈如下
| rsp偏移 | 类型 | 内容 | 值 | 
|---|---|---|---|
| 0x28 | dword | objs[0].id | 1 | 
| 0x2c | dword | objs[0].count | 0x12 | 
| 0x30 | dword | objs[0].count2 | 0x23 | 
| 0x34 | dword | objs[0].count3 | 0x34 | 
| 0x38 | dword | objs[1].id | 2 | 
| 0x3c | dword | objs[1].count | 0x45 | 
| 0x40 | dword | objs[1].count2 | 0x56 | 
| 0x44 | dword | objs[1].count3 | 0x67 | 
| 0x48 | dword | objs[2].id | 3 | 
| 0x4c | dword | objs[2].count | 0x78 | 
| 0x50 | dword | objs[2].count2 | 0x89 | 
| 0x54 | dword | objs[2].count3 | 0x90 | 
| 0x68 | qword | &objs[0] | rsp + 0x28 | 
| 0x70 | qword | &objs[1] | rsp + 0x38 | 
| 0x78 | qword | &objs[2] | rsp + 0x48 | 
| 0x80 | dword | objs[0].count | |
| 0x84 | dword | objs[1].count2 | |
| 0x88 | dword | objs[2].count3 | |
| 0x8c | dword | sum | 
其取值的方式为[&arr + sizeof(obj) * offset + member_offset]
在堆上的数组取值方式
代码:
| 1 |  | 
| Warning | 此处忽略内存回收, 忽略分析创建, 仅仅研究如何取值 | 
生成汇编如下:
| 1 |  | 
对于堆上的数组, 取值为[[&arr + sizeof(obj*) * offset] + member_offset]
逆向基础3. 结构体数组的汇编结构
https://simonkimi.githubio.io/2024/07/29/逆向基础3-结构体数组的汇编结构/