For Ms Windows — Pe32 Executable -console- X86-64
nasm -f win64 hello.asm -o hello.obj x86_64-w64-mingw32-ld hello.obj -o hello.exe -lkernel32 8.1 Check basic info (using dumpbin ) dumpbin /headers myapp.exe | findstr "machine magic subsystem" Output example:
my_func PROC push rbp mov rbp, rsp sub rsp, 32 ; shadow space + locals ; ... add rsp, 32 pop rbp ret my_func ENDP 7.1 Using MSVC (Visual Studio) cl /c hello.c link hello.obj /SUBSYSTEM:CONSOLE /MACHINE:X64 7.2 Using MinGW-w64 (gcc) x86_64-w64-mingw32-gcc -m64 hello.c -o hello.exe 7.3 Using NASM + LD (raw assembly) ; hello.asm bits 64 section .data msg db 'Hello PE32+ console', 0xd, 0xa, 0 section .text global main extern GetStdHandle extern WriteFile extern ExitProcess pe32 executable -console- x86-64 for ms windows
Build:
Compile (MSVC):
| Component | Meaning | |-----------|---------| | | 64-bit Portable Executable format (extension of original PE32). Uses 64-bit fields for image base, virtual addresses, and sizes. | | console | Subsystem = Console. App runs in a terminal window (cmd/powershell). Not GUI ( /SUBSYSTEM:WINDOWS ). | | x86-64 | Target machine architecture = AMD64 (also called x64, Intel 64). Not ARM, not IA64 (Itanium). | | MS Windows | Target OS: Windows (NT family: 2000, XP, Vista, 7, 10, 11, Server). | 2. PE32+ File Structure PE32+ follows the same logical layout as PE32, but with key structural differences. nasm -f win64 hello
PE32+ executable (console) x86-64 for MS Windows | | console | Subsystem = Console
It breaks down as: