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
Что мы проталкиваем в стек, и что оттуда тянем?