现在的位置: 首页 > 综合 > 正文

反汇编系列(六) switchcase

2014年01月30日 ⁄ 综合 ⁄ 共 1775字 ⁄ 字号 评论关闭
#include"stdio.h"
int function(int a,int b)
{
    int c=a+b;
    
    switch(c)
    {
        case 0:
            printf("c>0");
        case 1:
            printf("c>10&&c<100");
            break;
        default:
            printf("c>10&&c<100");
    }
    return c;
}
void main()
{
    function(1,2);
}

 


--- c:\users\wangchao\desktop\test\test\main.cpp -------------------------------
#include "stdio.h"
int function(int a,int b)
{
00EA2FE0 push ebp
00EA2FE1 mov ebp,esp
00EA2FE3 sub esp,0D0h
00EA2FE9 push ebx
00EA2FEA push esi
00EA2FEB push edi
00EA2FEC lea edi,[ebp-0D0h]
00EA2FF2 mov ecx,34h
00EA2FF7 mov eax,0CCCCCCCCh
00EA2FFC rep stos dword ptr es:[edi]
    int c=a+b;
00EA2FFE mov eax,dword ptr [a]
00EA3001 add eax,dword ptr [b]
00EA3004 mov dword ptr [c],eax
   
    switch(c)
00EA3007 mov eax,dword ptr [c]
00EA300A mov dword ptr [ebp-0D0h],eax
00EA3010 cmp dword ptr [ebp-0D0h],0
00EA3017 je function+44h (0EA3024h)
00EA3019 cmp dword ptr [ebp-0D0h],1
00EA3020 je function+5Bh (0EA303Bh)
00EA3022 jmp function+74h (0EA3054h)
    {
        case 0:
            printf("c>0");
00EA3024 mov esi,esp
00EA3026 push offset string "c>0" (0EA573Ch)
00EA302B call dword ptr [__imp__printf (0EA82B8h)]
00EA3031 add esp,4
00EA3034 cmp esi,esp
00EA3036 call @ILT+315(__RTC_CheckEsp) (0EA1140h)
        case 1:
            printf("c>10&&c<100");
00EA303B mov esi,esp
00EA303D push offset string "c>10&&c<100" (0EA57A0h)
00EA3042 call dword ptr [__imp__printf (0EA82B8h)]
00EA3048 add esp,4
00EA304B cmp esi,esp
00EA304D call @ILT+315(__RTC_CheckEsp) (0EA1140h)
            break;
00EA3052 jmp function+8Bh (0EA306Bh)
        default:
            printf("c>10&&c<100");
00EA3054 mov esi,esp
00EA3056 push offset string "c>10&&c<100" (0EA57A0h)
00EA305B call dword ptr [__imp__printf (0EA82B8h)]
00EA3061 add esp,4
00EA3064 cmp esi,esp
00EA3066 call @ILT+315(__RTC_CheckEsp) (0EA1140h)
    }
    return c;
00EA306B mov eax,dword ptr [c]
}
00EA306E pop edi
00EA306F pop esi
00EA3070 pop ebx
00EA3071 add esp,0D0h
00EA3077 cmp ebp,esp
00EA3079 call @ILT+315(__RTC_CheckEsp) (0EA1140h)
00EA307E mov esp,ebp
00EA3080 pop ebp

00EA3081 ret

抱歉!评论已关闭.