Last active
November 15, 2017 16:14
-
-
Save georgy7/e9280f998caa6e7a1a163e2eb20365e1 to your computer and use it in GitHub Desktop.
flat assembler Windows (PE) CLI HelloWorld
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
format pe CONSOLE 4.0 | |
entry start | |
include 'win32a.inc' | |
stdin = -10 | |
stdout = -11 | |
stderr = -12 | |
section '.data' data readable writeable | |
message db 'Hello, World!',10 | |
stdinHandle dd ? | |
stdoutHandle dd ? | |
section '.code' code readable executable | |
start: | |
invoke GetStdHandle,stdin | |
mov [stdinHandle],eax | |
invoke GetStdHandle, stdout | |
mov [stdoutHandle],eax | |
; Probably the same as `_setmode(_fileno(handle) _o_binary);` in C. | |
invoke SetConsoleMode,stdinHandle,0 | |
invoke SetConsoleMode,stdoutHandle,0 | |
invoke WriteConsoleA,[stdoutHandle],message,14,NULL,NULL | |
invoke ExitProcess,0 | |
section '.idata' import data readable writeable | |
library kernel32,'kernel32.dll' | |
import kernel32,\ | |
GetStdHandle,'GetStdHandle',\ | |
ExitProcess,'ExitProcess',\ | |
SetConsoleMode,'SetConsoleMode',\ | |
ReadConsoleA,'ReadConsoleA',\ | |
WriteConsoleA,'WriteConsoleA' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment