What does the function shown in Figure 2-15 do?
Here is the function's disassembly:
![]() |
| Figure 2-15. Practical Reverse Engineering. © 2014 by Bruce Dang |
The ARM processor is in Thumb state. This is essentially the same functionality as Figure 2-14, except the count variable is gone.
int32_t comparison(char *str1, char *str2)
{
/* LDR R5, =byteArray */
static BYTE byteArray[] = {0, 1, ..., 0xff};
while(1)
{
/* CMP R4, #0 */
if (*str1 == '\0')
break;
/* LDRB R3, [R1] */
/* LDRB R4, [R3,R6] */
/* LDRB R3, [R5,R6] */
/* CMP R3, R4 */
if (byteArray[*str1] != byteArray[*str2])
break;
++str1; /* ADDS R0, #1 */
++str2; /* ADDS R1, #1 */
}
/* LDRB R2, [R3,R5] */
/* LDRB R3, [R3,R5] */
/* SUBS R0, R3, R2 */
return byteArray[*str1] - byteArray[*str2];
}

No comments :
Post a Comment