News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Is possible to read from the Console?

Started by x64Core, June 11, 2012, 04:17:13 AM

Previous topic - Next topic

x64Core

Hello guys, just I want to if is possile to read from the console?
took several hours searching, and I find nothing  :shock: it's impossible?
My last hope is the forum where I know the wisest people in programming  :biggrin:

qWord

WinAPI: ReadFile,ReadConsole
CRT: scanf,...
MASM32: input$()-macro,StdIn,...
...
MREAL macros - when you need floating point arithmetic while assembling!

x64Core



x64Core

Quote from: Vortex on June 11, 2012, 06:20:47 AM
Hi RHL,

Here is a Simple console piping example

thanks Vortex, yeah, in really I wanted read, but data are already written on the console, not from the start of a function :P thanks guys

jj2007

Here is the old HangMan example, demonstrating how to use Locate(x,y) in console mode. Another simple example:

include \masm32\MasmBasic\MasmBasic.inc   ; download
   Init
   .Repeat
      Let esi=Input$("What's your name? ", "RHL")
      .Break .if word ptr [esi]!="HR"
      Print "I asked for your name, not your nick!", CrLf$
   .Until 0
   Inkey "Hi ", esi, ", how are you?"
   Exit
end start

KeepingRealBusy

Quote from: RHL on June 11, 2012, 07:45:41 AM
Quote from: Vortex on June 11, 2012, 06:20:47 AM
Hi RHL,

Here is a Simple console piping example

thanks Vortex, yeah, in really I wanted read, but data are already written on the console, not from the start of a function :P thanks guys

RHL,

You can read the console output buffer, but only for your console screen, not an arbitrary console screen. See the API for GetConsoleScreenBufferInfo.

Dave.

jj2007

It basically boils down to
invoke GetStdHandle, STD_INPUT_HANDLE
...
invoke SetConsoleMode, eax, ENABLE_LINE_INPUT or ENABLE_ECHO_INPUT or ENABLE_PROCESSED_INPUT
...
invoke ReadFile, hInput, pBuffer, bLen, ADDR bRead, NULL