Search code examples
winapiassemblyx86masmconsole-input

Getting console input with win32 api in x86 assembly


In my assembly program I called AllocConsole from the kernel32 library, however I do not know how to get input from the allocated console. Is there any function that the winapi contains that will get input from the allocated console in the current program?

CALL AllocConsole

All of the functions such as ReadConsole require an input buffer, and I do not know how to get the input buffer for my allocated console, let alone whether the function even does what I need.

To summarize, is there a function in the winapi that can get input from the allocated console in a program?

Thanks


Solution

  • All of the functions such as ReadConsole require an input buffer, and I do not know how to get the input buffer

    The functions you have to call are the same in C and in assembly language. So your problem is not assembly language specific.

    You can get the standard input and standard output handles using the GetStdHandle function.

    To get the input handle you must pass the constant STD_INPUT_HANDLE (-10 = 0xFFFFFFF6 in the case of a 32-bit program) as argument to the function.