Friday, January 24, 2020

assembly basics: strcmp ; test eax, eax

push eax (1st string to compare)
push ecx (2nd string to compare)
call strcmp (do the compare using C library ... if same EAX = 0, if different EAX = 1)
test eax, eax (same as 'and eax, eax' ... so if EAX = 0 ZF = 1 ... if EAX = 1 ZF = 0)
jz loc_40124C (so jump if zero jumps if ZF = 1 ... which is when EAX = 0)

------

In simpler terms
- compare the 2 strings
- if same
  - EAX gets set to 0
  - ZF gets set to 1
  - JZ will jump because ZF = 1
- if different
  - EAX gets set to 1
  - ZF gets set to 0
  - JZ will NOT jump because ZF = 0

------

In simplest terms 
  if you see " strcmp ; test ; jz "
    JZ green if the 2 strings are the same (0)
    JZ red if the 2 strings are different (non 0)

  if you see " strcmp ; test ; jnz "
    JNZ green if the 2 strings are different (non 0)
    JNZ red if the 2 strings are the same (0)

  if you see " strlen; test ; jz "
    JZ green if empty string (0)
    JZ red if non-empty string (non 0)

  if you see " strlen ; test ; jnz "
    JNZ green if non-empty string (non 0)
    JNZ red if empty string (0)

  if you see " call; test ; jz "
    JZ green if function call successful (0)
    JZ red if function call failed (non 0)

  if you see " call ; test ; jnz "
    JNZ green if function call failed (non 0)
    JNZ red if function call successful (0)

  if you see " cmp ; test ; jz "
    JZ green if the 2 numbers are the same (0)
    JZ red if the 2 numbers are different (non 0)

  if you see " cmp ; test ; jnz "
    JNZ green if the 2 numbers are different (non 0)
    JNZ red if the 2 numbers are the same (0)


Jump arrows
Green: if condition is satisfied (JZ=0, JNZ=non-0)
Red: if the condition is not satisfied (JZ=non-0, JNZ=0)


1 comment:

  1. I want to thank Dr Emu a very powerful spell caster who help me to bring my husband back to me, few month ago i have a serious problem with my husband, to the extend that he left the house, and he started dating another woman and he stayed with the woman, i tried all i can to bring him back, but all my effort was useless until the day my friend came to my house and i told her every thing that had happened between me and my husband, then she told me of a powerful spell caster who help her when she was in the same problem I then contact Dr Emu and told him every thing and he told me not to worry my self again that my husband will come back to me after he has cast a spell on him, i thought it was a joke, after he had finish casting the spell, he told me that he had just finish casting the spell, to my greatest surprise within 48 hours, my husband really came back begging me to forgive him, if you need his help you can contact him with via email: Emutemple@gmail.com or add him up on his whatsapp +2347012841542 is willing to help any body that need his help. 

    ReplyDelete