Adventure in Windows Assembly

So, I decided to see what I would need to do to create a Windows program in assembly. Started with a basic Hello World example that I found on the internet, and then had to debug it to get it to compile and link correctly in MASM. Had to change title to win_title, for one of the ‘variables’, as title seems to be a reserved word. Went ahead and changed msg to win_msg to have a matching naming convention for both values.

;---ASM Hello World Win64 MessageBox

extrn MessageBoxA: PROC
extrn ExitProcess: PROC

.data
win_title db 'Hello', 0
win_msg db 'Hello World!', 0

.code
main proc
  sub rsp, 28h  
  mov rcx, 0       ; hWnd = HWND_DESKTOP
  lea r8, win_title    ; LPCSTR lpCaption
  lea rdx, win_msg     ; LPCSTR lpText
  mov r9d, 0       ; uType = MB_OK
  call MessageBoxA
  add rsp, 28h  
  mov ecx, eax     ; uExitCode = MessageBox(...)
  call ExitProcess
main endp

EndCode language: Intel x86 Assembly (x86asm)

Leave a Comment

7 + eighteen =