Quick introduction to reverse engineering for beginners
Quick introduction to reverse engineering for beginners
Quick introduction to reverse engineering for beginners
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
add ebx, edx<br />
lea esi, [esi+0]<br />
loc_8048558: ; CODE XREF: f(int,int *,int *,int *)+CC<br />
mov edx, [edi]<br />
add eax, 1<br />
add edi, 4<br />
add edx, [esi]<br />
add esi, 4<br />
mov [ebx], edx<br />
add ebx, 4<br />
cmp ecx, eax<br />
jg short loc_8048558<br />
add esp, 0Ch<br />
xor eax, eax<br />
pop ebx<br />
pop esi<br />
pop edi<br />
pop ebp<br />
retn<br />
; ---------------------------------------------------------------------------<br />
loc_8048578: ; CODE XREF: f(int,int *,int *,int *)+52<br />
cmp eax, esi<br />
jnb loc_80484C1<br />
jmp loc_80484F8<br />
_Z1fiPiS_S_ endp<br />
Almost the same, however, not as meticulously as Intel C++ doing it.<br />
1.19.2 SIMD strlen() implementation<br />
It should be noted that SIMD-instructions may be inserted in<strong>to</strong> C/C++ code via special macros 73 . As of<br />
MSVC, some of them are located in intrin.h file.<br />
It is possible <strong>to</strong> implement strlen() function 74 using SIMD-instructions, working 2-2.5 times faster than<br />
usual implementation. This function will load 16 characters in<strong>to</strong> XMM-register and check each against zero.<br />
size_t strlen_sse2(const char *str)<br />
{<br />
register size_t len = 0;<br />
const char *s=str;<br />
bool str_is_aligned=(((unsigned int)str)&0xFFFFFFF0) == (unsigned int)str;<br />
if (str_is_aligned==false)<br />
return strlen (str);<br />
__m128i xmm0 = _mm_setzero_si128();<br />
__m128i xmm1;<br />
int mask = 0;<br />
<strong>for</strong> (;;)<br />
{<br />
xmm1 = _mm_load_si128((__m128i *)s);<br />
73 MSDN: MMX, SSE, and SSE2 Intrinsics<br />
74 strlen() — standard C library function <strong>for</strong> calculating string length<br />
99