十、switch语句逆向代码
...
1 #include "stdafx.h" 2 3 4 int _tmain(int argc, _TCHAR* argv[]) 5 { 6 004113B0 push ebp 7 004113B1 mov ebp,esp 8 004113B3 sub esp,0D0h 9 004113B9 push ebx 10 004113BA push esi 11 004113BB push edi 12 004113BC lea edi,[ebp-0D0h] 13 004113C2 mov ecx,34h 14 004113C7 mov eax,0CCCCCCCCh 15 004113CC rep stos dword ptr es:[edi] 16 int c; 17 printf("input number\n"); 18 004113CE mov esi,esp 19 004113D0 push offset string "input number\n" (415770h) 20 004113D5 call dword ptr [__imp__printf (4182BCh)] 21 004113DB add esp,4 22 004113DE cmp esi,esp 23 004113E0 call @ILT+325(__RTC_CheckEsp) (41114Ah) 24 scanf("%d",&c); 25 004113E5 mov esi,esp 26 004113E7 lea eax,[c] 27 004113EA push eax 28 004113EB push offset string "%d" (41576Ch) 29 004113F0 call dword ptr [__imp__scanf (4182C4h)] 30 004113F6 add esp,8 31 004113F9 cmp esi,esp 32 004113FB call @ILT+325(__RTC_CheckEsp) (41114Ah) 33 c=c/10; 34 00411400 mov eax,dword ptr [c] 35 00411403 cdq 36 00411404 mov ecx,0Ah 37 00411409 idiv eax,ecx 38 0041140B mov dword ptr [c],eax 39 switch(c) 40 0041140E mov eax,dword ptr [c] 41 00411411 mov dword ptr [ebp-0D0h],eax 42 00411417 cmp dword ptr [ebp-0D0h],0 43 0041141E je wmain+7Bh (41142Bh) 44 00411420 cmp dword ptr [ebp-0D0h],1 45 00411427 je wmain+94h (411444h) 46 00411429 jmp wmain+0ADh (41145Dh) 47 { 48 case 0: 49 printf("c>0 && c<10"); 50 0041142B mov esi,esp 51 0041142D push offset string "c>0 && c<10" (41575Ch) 52 00411432 call dword ptr [__imp__printf (4182BCh)] 53 00411438 add esp,4 54 0041143B cmp esi,esp 55 0041143D call @ILT+325(__RTC_CheckEsp) (41114Ah) 56 break; 57 00411442 jmp wmain+0C4h (411474h) 58 case 1: 59 printf("c>10 && c<20"); 60 00411444 mov esi,esp 61 00411446 push offset string "c>10 && c<100" (41574Ch) 62 0041144B call dword ptr [__imp__printf (4182BCh)] 63 00411451 add esp,4 64 00411454 cmp esi,esp 65 00411456 call @ILT+325(__RTC_CheckEsp) (41114Ah) 66 break; 67 0041145B jmp wmain+0C4h (411474h) 68 default: 69 printf("c<0 || c>20"); 70 0041145D mov esi,esp 71 0041145F push offset string "a<0 || a>100" (41573Ch) 72 00411464 call dword ptr [__imp__printf (4182BCh)] 73 0041146A add esp,4 74 0041146D cmp esi,esp 75 0041146F call @ILT+325(__RTC_CheckEsp) (41114Ah) 76 break; 77 } 78 return 0; 79 00411474 xor eax,eax 80 } 81 00411476 push edx 82 00411477 mov ecx,ebp 83 00411479 push eax 84 0041147A lea edx,[ (41149Ch)] 85 00411480 call @ILT+135(@_RTC_CheckStackVars@8) (41108Ch) 86 00411485 pop eax 87 00411486 pop edx 88 00411487 pop edi 89 00411488 pop esi 90 00411489 pop ebx 91 0041148A add esp,0D0h 92 00411490 cmp ebp,esp 93 00411492 call @ILT+325(__RTC_CheckEsp) (41114Ah) 94 00411497 mov esp,ebp 95 00411499 pop ebp 96 0041149A ret
下面是对应的c++代码:
1 #include "stdafx.h" 2 3 4 int _tmain(int argc, _TCHAR* argv[]) 5 { 6 int c; 7 printf("input number\n"); 8 scanf("%d",&c); 9 c=c/10; 10 switch(c) 11 { 12 case 0: 13 printf("c>0 && c<10"); 14 break; 15 case 1: 16 printf("c>10 && c<20"); 17 break; 18 default: 19 printf("c<0 || c>20"); 20 break; 21 } 22 return 0; 23 }
................................