反汇编系列(七) struct

typedefstruct{ int a; int b; int c;}mystruct;int function(int a,int b){ unsigned char *buffer[100]; mystruct *strs=(mystruct*)buffer; int i; for(i=0;i<5;i++) { strs[i].a=0; strs[i].b=1; strs[i].c=2; } return 0;}void main(){ function(1,2);}

;哈,没有优化的代码有的地方是很可笑的!
--- c:\users\wangchao\desktop\test\test\main.cpp -------------------------------
#include "stdio.h"
typedef struct
{
    int a;
    int b;
    int c;
}mystruct;
int function(int a,int b)
{
001A3530 push ebp
001A3531 mov ebp,esp
001A3533 sub esp,270h
001A3539 push ebx
001A353A push esi
001A353B push edi
001A353C lea edi,[ebp-270h]
001A3542 mov ecx,9Ch
001A3547 mov eax,0CCCCCCCCh
001A354C rep stos dword ptr es:[edi]
    unsigned char *buffer[100];
    mystruct *strs=(mystruct*)buffer;
001A354E lea eax,[buffer]
001A3554 mov dword ptr [strs],eax
    int i;
    for(i=0;i<5;i++)
001A355A mov dword ptr [i],0
001A3564 jmp function+45h (1A3575h)
001A3566 mov eax,dword ptr [i]
001A356C add eax,1
001A356F mov dword ptr [i],eax
001A3575 cmp dword ptr [i],5
001A357C jge function+94h (1A35C4h)
    {
        strs[i].a=0;
001A357E mov eax,dword ptr [i]
001A3584 imul eax,eax,0Ch             ;eax=i*12
001A3587 mov ecx,dword ptr [strs]
001A358D mov dword ptr [ecx+eax],0    ;strs[i].a=0;
        strs[i].b=1;
001A3594 mov eax,dword ptr [i]
001A359A imul eax,eax,0Ch             ;eax=i*12
001A359D mov ecx,dword ptr [strs]
001A35A3 mov dword ptr [ecx+eax+4],1  ;strs[i].b=0;
        strs[i].c=2;
001A35AB mov eax,dword ptr [i]
001A35B1 imul eax,eax,0Ch
001A35B4 mov ecx,dword ptr [strs]
001A35BA mov dword ptr [ecx+eax+8],2
    }
001A35C2 jmp function+36h (1A3566h)
    return 0;
001A35C4 xor eax,eax
}
001A35C6 push edx
001A35C7 mov ecx,ebp
001A35C9 push eax
001A35CA lea edx,[ (1A35E0h)]
001A35D0 call @ILT+130(@_RTC_CheckStackVars@8) (1A1087h)
001A35D5 pop eax
001A35D6 pop edx
001A35D7 pop edi
001A35D8 pop esi
001A35D9 pop ebx
001A35DA mov esp,ebp
001A35DC pop ebp
001A35DD ret
001A35DE mov edi,edi
001A35E0 db 01h
001A35E1 db 00h
001A35E2 db 00h
001A35E3 db 00h
001A35E4 db e8h
001A35E5 db 35h
001A35E6 db 1ah
001A35E7 db 00h
001A35E8 db 6ch
001A35E9 db feh
001A35EA db ffh
001A35EB db ffh
001A35EC db 90h
001A35ED db 01h
001A35EE db 00h
001A35EF db 00h
001A35F0 db f4h
001A35F1 db 35h
001A35F2 db 1ah
001A35F3 db 00h
001A35F4 db 62h
001A35F5 db 75h
001A35F6 db 66h
001A35F7 db 66h
001A35F8 db 65h
001A35F9 db 72h

001A35FA db 00h

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值