1

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

mike bayko
  • 375
  • 5
  • 20
  • Open `CONIN$` using CreateFile(). – Harry Johnston Jul 25 '17 at 04:31
  • 3
    `AllocConsole` initializes standard input, standard output, and standard error handles for the new console. The standard input handle is a handle to the console's input buffer, and the standard output and standard error handles are handles to the console's screen buffer. **To retrieve these handles, use the `GetStdHandle` function.** – RbMm Jul 25 '17 at 07:11

1 Answers1

6

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.

Martin Rosenau
  • 17,897
  • 3
  • 19
  • 38