Answer the question
In order to leave comments, you need to log in
What does this piece of code do?
format PE console 4.0
include 'win32ax.inc'
ENABLE_PROCESSED_OUTPUT = 00000001h
invoke AllocConsole
invoke GetStdHandle, STD_INPUT_HANDLE
push eax
push eax
invoke GetStdHandle, STD_OUTPUT_HANDLE
push eax
invoke SetConsoleMode, eax, ENABLE_PROCESSED_OUTPUT
pop eax
invoke WriteConsole, eax, hello, msgsz, NULL, NULL
invoke FlushConsoleInputBuffer
pop eax
invoke ReadConsole, eax, buf, bufsz, cnt, NULL
invoke FreeConsole
invoke ExitProcess,0
cnt dd ?
buf db 10 dup(?)
bufsz = $ - buf
hello db 'Hello World!',0
msgsz = $ - hello
data import
library kernel32,'KERNEL32.DLL'
import kernel32,\
ExitProcess,'ExitProcess',\
SetConsoleCP,'SetConsoleCP',\
SetConsoleOutputCP,'SetConsoleOutputCP',\
GetStdHandle,'GetStdHandle',\
SetConsoleMode,'SetConsoleMode',\
ReadConsole,'ReadFile',\
WriteConsole,'WriteConsoleA',\
FreeConsole,'FreeConsole',\
FlushConsoleInputBuffer,'FlushConsoleInputBuffer',\
AllocConsole,'AllocConsole'
end data
invoke GetStdHandle, STD_INPUT_HANDLE
push eax
push eax
invoke GetStdHandle, STD_OUTPUT_HANDLE
push eax
invoke SetConsoleMode, eax, ENABLE_PROCESSED_OUTPUT
pop eax
invoke WriteConsole, eax, hello, msgsz, NULL, NULL
invoke FlushConsoleInputBuffer
pop eax
invoke ReadConsole, eax, buf, bufsz, cnt, NULL
Answer the question
In order to leave comments, you need to log in
1. GetStdHandle Retrieves a handle to the device's standard input, standard output, or standard error.
2. SetConsoleMode sets the input mode of the console input buffer or the output mode of the console screen buffer.
3. WriteConsole prints Hello, World!
4. FlushConsoleInputBuffer disables the console input buffer.
5. ReadConsole reads a character from the console.
What the functions return is what we push, that is:
invoke AllocConsole
invoke GetStdHandle, STD_INPUT_HANDLE
push eax ;InputHandle
push eax ;InputHandle
invoke GetStdHandle, STD_OUTPUT_HANDLE
push eax ; OutputHandle
invoke SetConsoleMode, eax, ENABLE_PROCESSED_OUTPUT ; OutputHandle
pop eax
invoke WriteConsole, eax, hello, msgsz, NULL, NULL ; OutputHandle
invoke FlushConsoleInputBuffer ; функция сама забирает 1 аргумент, InputHandle
pop eax
invoke ReadConsole, eax, buf, bufsz, cnt, NULL ; InputHandle
invoke FreeConsole
invoke ExitProcess,0
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question