IDA逆向:结构体的逆向

源代码:

int _tmain(int argc, _TCHAR* argv[])
{
    struct v1 {
        int a;
        short b;
        char c;
        int d;
        double e;
    };
    v1* heap_struct = (v1*)malloc(sizeof(v1));
    heap_struct->a = 10;
    heap_struct->b = 20;
    heap_struct->c = 30;
    heap_struct->d = 40;
    heap_struct->e = 50;
    return 0;

}

逆向分析:

结构体中的数据字段是通过名称访问的,但编译器将名称访问转换为数字偏移
所以在反汇编中难以区别
堆分配结构体

push    24              ; Size
call    ds:__imp__malloc
add     esp, 4
cmp     esi, esp
call    j___RTC_CheckEsp
mov     [ebp+heap_struct], eax
mov     eax, [ebp+heap_struct]
mov     dword ptr [eax], 10
mov     eax, 20
mov     ecx, [ebp+heap_struct]
mov     [ecx+4], ax
mov     eax, [ebp+heap_struct]
mov     byte ptr [eax+6], 30
mov     eax, [ebp+heap_struct]
mov     dword ptr [eax+8], 40
mov     eax, [ebp+heap_struct]
fld     ds:__real@4049000000000000
fstp    qword ptr [eax+10h]
原类型     大小             偏移
int         4(dword)       0
short       2()            4
char        1byte6
int         4(dword)       8
double      8(qword)      16

  为默认4字节对齐

总结:全局和栈分配方式中的结构体 与  普通变量相似 难以区分

转载于:https://www.cnblogs.com/HsinTsao/p/6440784.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值