Skip to content

Instantly share code, notes, and snippets.

@Chen-Michael
Last active August 19, 2016 14:29
Show Gist options
  • Select an option

  • Save Chen-Michael/647b1592bb4edcbad722867edc8290ef to your computer and use it in GitHub Desktop.

Select an option

Save Chen-Michael/647b1592bb4edcbad722867edc8290ef to your computer and use it in GitHub Desktop.
STD_OUTPUT_HANDLE EQU -11
NULL EQU 0
GLOBAL GobleyGook
EXTERN ExitProcess, GetLastError, GetStdHandle, WriteConsoleA, WriteConsoleOutputA, FormatMessageA
SECTION .data
msg DB "Hello World!", 13, 10, "M", 0
msg.len EQU $ - msg
STRUC lpBuffer
.Char : RESW 1
.Attributes: RESD 1
ENDSTRUC
_lpBuffer ISTRUC lpBuffer
at lpBuffer.Char, DW 'AB'
at lpBuffer.Attributes, DD 1H
IEND
STRUC dwBufferSize
.X: RESW 1
.Y: RESW 1
ENDSTRUC
_dwBufferSize ISTRUC dwBufferSize
at dwBufferSize.X, DW 10
at dwBufferSize.Y, DW 10
IEND
STRUC dwBufferCoord
.X: RESW 1
.Y: RESW 1
ENDSTRUC
_dwBufferCoord ISTRUC dwBufferCoord
at dwBufferCoord.X, DW 0
at dwBufferCoord.Y, DW 0
IEND
STRUC smallRect
.Left : RESW 1
.Top : RESW 1
.Right : RESW 1
.Bottom: RESW 1
ENDSTRUC
_smallRect ISTRUC smallRect
IEND
SECTION .bss
dummy RESD 1
err RESD 1
err2 RESD 1
SECTION .text
GobleyGook:
PUSH STD_OUTPUT_HANDLE
CALL GetStdHandle
; push NULL
; push dummy
; push msg.len
; push msg
; push eax
; call WriteConsoleA
PUSH _smallRect
PUSH _dwBufferCoord
PUSH _dwBufferSize
PUSH _lpBuffer
PUSH EAX
CALL WriteConsoleOutputA
CALL GetLastError
PUSH NULL
PUSH 99
PUSH err
PUSH NULL
PUSH EAX
PUSH NULL
PUSH 1000H
CALL FormatMessageA
PUSH STD_OUTPUT_HANDLE
CALL GetStdHandle
push NULL
push dummy
push 32
push err
push EAX
call WriteConsoleA
PUSH NULL
CALL ExitProcess
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment