反汇编逆向实例_dowhile语句反汇编
by:比方
示例代码如下:
1 #include"stdio.h" 2 int function(int a,int b) 3 { 4 int c=a+b; 5 int i=0; 6 do 7 { 8 c=c+i; 9 }while(i<50); 10 return c; 11 } 12 void main() 13 { 14 function(1,2); 15 }
反汇编代码
1 #include "stdio.h" 2 3 4 int function(int a,int b) 5 6 {
012E1A40 push ebp
012E1A41 mov ebp,esp
012E1A43 sub esp,0D8h
012E1A49 push ebx ;保存环境
012E1A4A push esi
012E1A4B push edi
012E1A4C lea edi,[ebp-0D8h] ;初始化为0xCC
012E1A52 mov ecx,36h
012E1A57 mov eax,0CCCCCCCCh
012E1A5C rep stos dword ptr es:[edi]
1 int c=a+b;
012E1A5E mov eax,dword ptr [a]
012E1A61 add eax,dword ptr [b]
012E1A64 mov dword ptr [c],eax
1 int i=0;
012E1A67 mov dword ptr [i],0
do { c=c+i;
012E1A6E mov eax,dword ptr [c] ;进过前面的两章讲解,对于这样的结构相比已经很熟习了吧
012E1A71 add eax,dword ptr [i]
012E1A74 mov dword ptr [c],eax
1 }while(i<50);
012E1A77 cmp dword ptr [i],32h ; 比较是否大于50,如果小于则往上跳
012E1A7B jl function+2Eh (12E1A6Eh)
1 return c;
012E1A7D mov eax,dword ptr [c]
}
012E1A80 pop edi
012E1A81 pop esi
012E1A82 pop ebx
012E1A83 mov esp,ebp
012E1A85 pop ebp
012E1A86 ret
总结:do while的循环相对来说容易识别很多
do_Begin
..
...
jxx do_Begin ;这里有一个往上跳的过程
;先执行语句块,在做比较,当条件成立时,会继续执行语句快,
反汇编逆向实例_dowhile语句反汇编