Advertisement
krot

Console Hello World

Jul 8th, 2018
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.                                                            format PE64 Console 5.0
  2. entry Start
  3.  
  4. include 'win64a.inc'
  5.  
  6. section '.text' code readable executable
  7.  
  8. Start:
  9.   invoke SetConsoleTitleA, conTitle
  10.   test eax, eax
  11.   jz Exit
  12.  
  13.   invoke GetStdHandle, [STD_OUTP_HNDL]
  14.   mov [hStdOut], eax
  15.  
  16.   invoke GetStdHandle, [STD_INP_HNDL]
  17.   mov [hStdIn], eax
  18.  
  19.   invoke WriteConsoleA, [hStdOut], mes, mesLen, chrsWritten, 0
  20.  
  21.   invoke ReadConsoleA, [hStdIn], readBuf, 1, chrsRead, 0
  22.  
  23. Exit:
  24.   invoke  ExitProcess, 0
  25.  
  26. section '.data' data readable writeable
  27.  
  28.   conTitle    db 'Console', 0
  29.   mes         db 'Hello World!', 0dh, 0ah, 0
  30.   mesLen      = $-mes
  31.  
  32.   hStdIn      dd 0
  33.   hStdOut     dd 0
  34.   chrsRead    dd 0
  35.   chrsWritten dd 0
  36.  
  37.   STD_INP_HNDL  dd -10
  38.   STD_OUTP_HNDL dd -11
  39.  
  40. section '.bss' readable writeable
  41.  
  42.   readBuf  db ?
  43.  
  44. section '.idata' import data readable
  45.  
  46.   library kernel,'KERNEL32.DLL'
  47.  
  48.   import kernel,\
  49.     SetConsoleTitleA, 'SetConsoleTitleA',\
  50.     GetStdHandle, 'GetStdHandle',\
  51.     WriteConsoleA, 'WriteConsoleA',\
  52.     ReadConsoleA, 'ReadConsoleA',\
  53.     ExitProcess, 'ExitProcess'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement