Guest User

Hello World WriteConsoleA

a guest
Aug 10th, 2016
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. global _start
  2. extern ExitProcess, GetStdHandle, WriteConsoleA
  3.  
  4. section .data
  5. msg db "Hello World!", 10
  6. len equ $ - msg
  7.  
  8. section .bss
  9. dummy  resd 1
  10.  
  11. section .text
  12. _start:
  13.     push    -11          ; STD_OUTPUT_HANDLE: -11 - standard output, -10: standard input,  -12: standard error
  14.     call    GetStdHandle ; GetStdHandle - Retrieves a handle to the specified standard device
  15.  
  16.     push    0             ; lpReserved: reserved - must be NULL
  17.     push    dummy         ; A pointer to a variable that receives the number of characters actually written.
  18.     push    len           ; the length of the message
  19.     push    msg           ; the message to write
  20.     push    eax           ; handle to the console screen buffer
  21.     call    WriteConsoleA
  22.  
  23.     push    0
  24.     call    ExitProcess
  25.  
  26. ; nasm -f win32 hello_world.asm -o hello_world.obj
  27. ; GoLink.exe /console /entry _start hello_world.obj kernel32.dll
Advertisement
Add Comment
Please, Sign In to add comment