K
K
Konstantin Malyarov2016-05-01 20:33:29
assembler
Konstantin Malyarov, 2016-05-01 20:33:29

What parameters should be passed to ReadConsole?

format PE console 5.0

include 'win32ax.inc'

entry start

section '.data' data readable writeable
        caption db 'First Win32 program',0
        Message db 'Hello World!',0

section '.code' code readable executable
start:
        stdcall [ReadConsole],GENERIC_READ,Message,13,0,0
        stdcall [ExitProcess],0


section '.relocs' fixups readable writeable

section '.idata' import data readable writeable
        library kernel,'KERNEL32.DLL'
        import kernel,\
        ReadConsole,'ReadConsoleA',\
        ExitProcess,'ExitProcess'

BOOL ReadConsole(

HANDLE hConsoleInput , // дескриптор буфера ввода консоли
LPVOID lpBuffer,              // буфер данных
DWORD nNumberOfCharsToRead,   // число символов для чтения
LPDWORD lpNumberOfCharsRead , // число прочитанных символов
LPVOID lpReserved             // зарезервировано

);

Everything seems to be correct ... But it seems not.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2016-05-01
@jcmvbkbc

stdcall[ReadConsole],GENERIC_READ,Message,13,0,0

The first parameter is to pass the console file descriptor. GENERIC_READ is not a file descriptor, it is the required access to the file so that ReadConsole can read from it. The required handle can be obtained by calling GetStdHandle(STD_INPUT_HANDLE) .
And I'm not sure if lpNumberOfCharsRead can be NULL.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question