Search code examples
creverse-engineering

I have some problem with loop and argument when reversing


First is about the variable I got when reverse sub_804851C((int)aThepasswordise, &s1); .Basically the function compare a value with input but the problem is value of aThepasswordise is a string like HeyIAmNoob so what is the value of (int)aThepasswordise ?

Second I got a loop like this

for ( result = *(unsigned __int8 *)a1; (_BYTE)result; result = (unsigned __int8)*v2 )

I dont understand what is the last value and the jump of this loop? Thankyou so much and sorry because my English is bad


Solution

  • About the first question.

    Strings in C are char sequences ending with \0.
    aThepasswordise is probably a pointer to such sequence so casting it to int will give you the value of the pointer as an int

    In the loop, you start by taking the first byte to which a1 is pointing to. Then the result var is compared if it is 0 and at each iteration, result is changed to the first byte of v2.

    The jump will be determined by the change of where v2 is pointing and how is it changed at each iteration.