NASM x86-64: Why's my PC unable to run executable under Win64?

110 Views Asked by At

I created a small project under Win64 without any _printf from standard C library (on pure WinAPI). Code of the program below:

; ------------------------------------------------------------------------------ EXTERNS

extern GetStdHandle
extern WriteConsoleW

; ------------------------------------------------------------------------------ MACROSES

%define NULL 0
%define STD_OUTPUT_HANDLE -11

; ------------------------------------------------------------------------------ PROGRAM DATA

section .bss noexecute
        hStdOut     resq 1
        chWritten   resd 1

section .data noexecute

        ; wchar string!
        msg dw __utf16__('Ї=Ї=Ї=Ї=Ї=Ї=Ї=Ї=Ї=Ї=Ї=Ї=Ї=Ї=Ї=Ї=Ї=Ї=Ї=Ї=Ї=Ї=Ї=Ї'), 10, 0
        msg.sizeof equ ($-msg)

section .rodata noexecute

; ------------------------------------------------------------------------------ PROGRAM CODE

section .text
        global __main

        ; prologue
__main: push      rbp
        mov       rbp, rsp

        ; Get hStdOut to print in console
        mov       rcx, STD_OUTPUT_HANDLE
        call      GetStdHandle
        mov qword [hStdOut], rax

        mov       rcx, rax
        mov       rdx, msg
        mov       r8,  msg.sizeof
        mov       r9,  chWritten
        push      NULL
        call      WriteConsoleW
        
        ; epilogue
        pop       rbp
exit0:  xor       rax, rax
        ret

command:

nasm -fwin64 D:\Desktop\Roberto\asm_docs\files\myprog.asm -o myprog.exe

The error is a blue window that says:

Unable to run executable on your PC. To find a version for your computer, contact to developer of the application

No warnings during the preprocessing, compilation and linking. Tried to run with -fwin32 replacing all r- registers on e- but still no effect... What should i do? Thanks in advance!

0

There are 0 best solutions below