标签:style blog color os strong io cti ar
反汇编逆向实例_while语句反汇编
by:比方
逆向反汇编第四章, while语句反汇编
示例代码:
1 #include"stdio.h"
2 int function(int a,int b)
3 {
4 int c=a+b;
5 int i=0;
6 while(i<50)
7 {
8 c=c+i;
9 }
10 return c;
11 }
12 void main()
13 {
14 function(1,2);
15 }
反汇编代码:
1 #include "stdio.h"
2
3 int function(int a,int b)
4
5 {
00AE1A40 push ebp
00AE1A41 mov ebp,esp
00AE1A43 sub esp,0D8h
00AE1A49 push ebx
00AE1A4A push esi
00AE1A4B push edi
00AE1A4C lea edi,[ebp-0D8h]
00AE1A52 mov ecx,36h
00AE1A57 mov eax,0CCCCCCCCh
00AE1A5C rep stos dword ptr es:[edi] ;开始分配36个4字节空间,定位到edi,edi是来自[ebp-od8h],定位到缓冲区头部并初始化为CC,
00AE1A5E mov eax,dword ptr [a] ; 变量A放入到eax,
00AE1A61 add eax,dword ptr [b] ; 变量B加上个变量A ,结果放入到eax
00AE1A64 mov dword ptr [c],eax ; 变量C等于变量A+变量B,等于 C = A+B;
00AE1A67 mov dword ptr [i],0 ; 变量D等于0
00AE1A6E cmp dword ptr [i],32h ;比较变量D是否大于等于0x32h(16进制)
00AE1A72 jge function+3Fh (0AE1A7Fh) ;如果不大于等于,则指向下面语句,否则跳0x00AE1A7F
00AE1A74 mov eax,dword ptr [c] ;c = c+i
00AE1A77 add eax,dword ptr [i]
00AE1A7A mov dword ptr [c],eax
00AE1A7D jmp function+2Eh (0AE1A6Eh) 如果这里是往下跳就可以还原成if,else语句
00AE1A7F mov eax,dword ptr [c] ;把c的结果放到eax中,eax是函数返回值,所以结果就是return c;
}
00AE1A82 pop edi
00AE1A83 pop esi
00AE1A84 pop ebx
00AE1A85 mov esp,ebp
00AE1A87 pop ebp
00AE1A88 ret
该死的排版,麻烦死了
反汇编逆向实例_while语句反汇编,布布扣,bubuko.com
反汇编逆向实例_while语句反汇编
标签:style blog color os strong io cti ar
原文地址:http://www.cnblogs.com/hailunchina/p/3885208.html