Skip to content

Instantly share code, notes, and snippets.

@jaburns
Created November 3, 2019 20:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaburns/8d7fce3bb0481bf87293745c00b6f9aa to your computer and use it in GitHub Desktop.
Save jaburns/8d7fce3bb0481bf87293745c00b6f9aa to your computer and use it in GitHub Desktop.
Win32 assembly hello messagebox
global _mainCRTStartup
extern _ExitProcess@4
extern _MessageBoxA@16 ; Value after @ is size of args on stack
section .text
_mainCRTStartup:
; Setup stack to give us 4 bytes to play with
; push ebp
; sub esp, 4
; MessageBoxA( NULL, str_message, "", 0 );
push 0
push str_empty
push str_message
push 0
call _MessageBoxA@16
; ExitProcess( 0 );
push 0
call _ExitProcess@4
section .data
str_message db "Hello world", 0
str_empty db 0
# https://yasm.tortall.net/Download.html
.\yasm-1.3.0-win64.exe -fwin32 .\hello.asm
&"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe" `
/OUT:hello.exe `
# Replace with whatever Windows SDK path
/LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x86" `
/MACHINE:X86 `
/SUBSYSTEM:CONSOLE `
kernel32.lib user32.lib `
hello.obj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment