Reverse Engineering for Beginners

(avery) #1

CHAPTER 43. INLINE FUNCTIONS CHAPTER 43. INLINE FUNCTIONS


push OFFSET $SG3458
push OFFSET $SG3459
call DWORD PTR __imp___wassert
add esp, 12
pop esi

ret 0
?is_bool@@YA_NPAD@Z ENDP ; is_bool


43.1.2 strlen()


Listing 43.6: strlen() example

int strlen_test(char *s1)
{
return strlen(s1);
};


Listing 43.7: Optimizing MSVC 2010

_s1$ = 8 ; size = 4
_strlen_test PROC
mov eax, DWORD PTR _s1$[esp-4]
lea edx, DWORD PTR [eax+1]
$LL3@strlen_tes:
mov cl, BYTE PTR [eax]
inc eax
test cl, cl
jne SHORT $LL3@strlen_tes
sub eax, edx
ret 0
_strlen_test ENDP


43.1.3 strcpy()


Listing 43.8: strcpy() example

void strcpy_test(char s1, char outbuf)
{
strcpy(outbuf, s1);
};


Listing 43.9: Optimizing MSVC 2010

_s1$ = 8 ; size = 4
_outbuf$ = 12 ; size = 4
_strcpy_test PROC
mov eax, DWORD PTR _s1$[esp-4]
mov edx, DWORD PTR _outbuf$[esp-4]
sub edx, eax
npad 6 ; align next label
$LL3@strcpy_tes:
mov cl, BYTE PTR [eax]
mov BYTE PTR [edx+eax], cl
inc eax
test cl, cl
jne SHORT $LL3@strcpy_tes
ret 0
_strcpy_test ENDP


43.1.4 memset().


Example#1

Free download pdf