Answer the question
In order to leave comments, you need to log in
Why is ReadConsole not working properly?
.386
.model flat,stdcall
option casemap:none
include ..\INCLUDE\kernel32.inc
include ..\INCLUDE\user32.inc
includelib ..\LIB\kernel32.lib
includelib ..\LIB\user32.lib
.data
state db 4 dup(7)
continue db 1
input dd ?
input_buf dd 3 dup(?)
read db ?
output dd ?
written db ?
.code
start:
invoke AllocConsole
invoke GetStdHandle, -10
mov input,eax
invoke GetStdHandle, -11
mov output,eax
main:
invoke Sleep, 2000
invoke ReadConsole, ADDR input, ADDR input_buf, 1, ADDR read, 0
invoke WriteConsoleA, output, ADDR input_buf, 3, ADDR written, 0
invoke ExitProcess,0
end start
Answer the question
In order to leave comments, you need to log in
First, don't
invoke ReadConsole, ADDR input, ADDR input_buf, 1, ADDR read, 0
invoke ReadConsole, input, ADDR input_buf, 1, ADDR read, 0
read
and written
must be of size not db
, but dd
. ReadConsole returns DWORD, not BYTE, and by itself the returned value read
clogs the previously received output
one, zeros are obtained there and therefore nothing is displayed. invoke ReadConsole, input, ADDR input_buf, 1, ADDR read, 0
ONE character is read , and outputinvoke WriteConsoleA, output, ADDR input_buf, 3, ADDR written, 0
input_buf db КОЛИЧЕСТВО_БАЙТ_ПЛАНИРУЕМОЕ_ПРОЧИТАТЬ dup(?)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question