mardi 4 août 2020

Go back after jump

I have this code, I need check RCX register three times. I made a few lines of code (24-34 lines). In the first time (first jz), I move to true: label, but after I can't go back and check it the second time (28-30 lines). My program just finish everytime after the first jz. How can I go back and check it three time?

default REL
extern GetStdHandle
extern WriteFile
extern ExitProcess


section .data
    true_msg db 'Yes', 0

    true_msg_len equ $-true_msg

section .text
    global _main

_main:
    and rsp, -10h
    sub rsp, 020h

    mov rcx, -0Bh
    call GetStdHandle

    ;jmp true

    mov rcx, 2
    cmp rcx, 2
    jz true

    mov rcx, 0
    cmp rcx, 0
    jz true
    
    mov rcx, 1
    cmp rcx, 0
    jz true

;----------------
    add rsp, 28h                            ; Restore Stack Pointer
;----------------
    mov rcx, 0                              ; RCX - first argument.
    call ExitProcess
;----------------
    xor rax, rax
    ret

true:
    mov rcx, rax
    mov rdx, true_msg
    mov r8, true_msg_len
    xor r9, r9
    push r9
    sub rsp, 20h
    call WriteFile

I want to get something like:

if(...){
   ...
}

if(...){
   ...
}

if(...){
   ...
}

I need every condition to be checked.

Aucun commentaire:

Enregistrer un commentaire