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.

}<br />

};<br />

xmm1 = _mm_cmpeq_epi8(xmm1, xmm0);<br />

if ((mask = _mm_movemask_epi8(xmm1)) != 0)<br />

{<br />

unsigned long pos;<br />

_BitScanForward(&pos, mask);<br />

len += (size_t)pos;<br />

break;<br />

}<br />

s += sizeof(__m128i);<br />

len += sizeof(__m128i);<br />

return len;<br />

(the example is based on source code from there).<br />

Let’s compile in MSVC 2010 with /Ox option:<br />

_pos$75552 = -4 ; size = 4<br />

_str$ = 8 ; size = 4<br />

?strlen_sse2@@YAIPBD@Z PROC ; strlen_sse2<br />

push ebp<br />

mov ebp, esp<br />

and esp, -16 ; fffffff0H<br />

mov eax, DWORD PTR _str$[ebp]<br />

sub esp, 12 ; 0000000cH<br />

push esi<br />

mov esi, eax<br />

and esi, -16 ; fffffff0H<br />

xor edx, edx<br />

mov ecx, eax<br />

cmp esi, eax<br />

je SHORT $LN4@strlen_sse<br />

lea edx, DWORD PTR [eax+1]<br />

npad 3<br />

$LL11@strlen_sse:<br />

mov cl, BYTE PTR [eax]<br />

inc eax<br />

test cl, cl<br />

jne SHORT $LL11@strlen_sse<br />

sub eax, edx<br />

pop esi<br />

mov esp, ebp<br />

pop ebp<br />

ret 0<br />

$LN4@strlen_sse:<br />

movdqa xmm1, XMMWORD PTR [eax]<br />

pxor xmm0, xmm0<br />

pcmpeqb xmm1, xmm0<br />

pmovmskb eax, xmm1<br />

test eax, eax<br />

jne SHORT $LN9@strlen_sse<br />

$LL3@strlen_sse:<br />

100

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

Saved successfully!

Ooh no, something went wrong!