MichaelPetch

hello world assembly winapi 64-bit

Sep 5th, 2020 (edited)
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. extrn MessageBoxA: PROC
  2. extrn ExitProcess: PROC
  3.  
  4. .data
  5. titles db 'Win64', 0
  6. msg db 'Hello World!', 0
  7.  
  8. .code
  9. msgbox_ready:
  10. sub rsp, 28h ; 32 byte for 4 arguments, 8 byte for 'call' it self
  11. mov rcx, 0 ; hWnd = HWND_DESKTOP
  12. lea rdx, msg ; LPCSTR lpText
  13. lea r8, titles ; LPCSTR lpCaption
  14. mov r9d, 0 ; uType = MB_OK
  15. call MessageBoxA
  16. mov ecx, eax
  17. add rsp, 28h
  18. ret ; Return from function
  19.  
  20. main proc
  21. push rbp ; Push 8 bytes to align stack to 16 byte boundary before calling a function
  22. call msgbox_ready
  23. ; call ExitProcess ; Using ExitProcess instead of the pop rbp and ret is an option
  24. pop rbp ; Restore RBP and rebalance stack before returning
  25. ret ; Return to C startup code and exit program
  26. main endp
  27. End
Add Comment
Please, Sign In to add comment