23.03.2013 Views

Quick introduction to reverse engineering for beginners

Quick introduction to reverse engineering for beginners

Quick introduction to reverse engineering for beginners

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

.text:00541114 mov edi, 7 ; loop 1 counter is initial state 7<br />

.text:00541119<br />

.text:00541119 loc_541119:<br />

.text:00541119 xor esi, esi ; loop 2 counter<br />

.text:0054111B<br />

.text:0054111B loc_54111B:<br />

.text:0054111B mov al, [ebx+esi] ; get byte from internal array<br />

.text:0054111E push eax<br />

.text:0054111F push edi ; loop 1 counter<br />

.text:00541120 push esi ; loop 2 counter<br />

.text:00541121 push ebp ; arg_0<br />

.text:00541122 call set_bit<br />

.text:00541127 add esp, 10h<br />

.text:0054112A inc esi ; increment loop 2 counter<br />

.text:0054112B cmp esi, 8<br />

.text:0054112E jl short loc_54111B<br />

.text:00541130 dec edi ; decrement loop 2 counter<br />

.text:00541131 add ebx, 8<br />

.text:00541134 cmp edi, 0FFFFFFFFh<br />

.text:00541137 jg short loc_541119<br />

.text:00541139 pop edi<br />

.text:0054113A pop esi<br />

.text:0054113B pop ebp<br />

.text:0054113C pop ebx<br />

.text:0054113D add esp, 40h<br />

.text:00541140 retn<br />

.text:00541140 rotate2 endp<br />

It is almost the same, except of different order of arguments of get_bit() and set_bit(). Let’s rewrite<br />

it in C-like code:<br />

void rotate2 (int v)<br />

{<br />

bool tmp[8][8]; // internal array<br />

int i, j;<br />

};<br />

<strong>for</strong> (i=0; i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!