The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: MBeckford05 on April 08, 2008, 09:34:01 AM

Title: Using MASM32 Standard input and output function
Post by: MBeckford05 on April 08, 2008, 09:34:01 AM
Hi Everyone,

I noticed looking at the masm32 help section the explanation forstandard input and output is rather vague.  For example are there more references for these two functions. I have looked at Google search.

Thank you

MBeckford05
Title: Re: Using MASM32 Standard input and output function
Post by: BogdanOntanu on April 08, 2008, 10:31:16 AM
In the "good" legacy of UNIX like systems Windows standard input and output are just "files". Hence you can write to standard output by using file write operations on a special file handle obtained by GetStdHandle API.

Something like this:


...
STD_OUTPUT EQU -11
...

.data
std_out_handle dd 0
bytes_wr dd 0
msg_text db "My message for stdout",0
msg_len  equ $-msg_text

.code
invoke GetStdHandle,STD_OUTPUT
mov [out_handle],eax

invoke WriteFile,[out_handle],offset msg_txt, msg_len, offset bytes_wr, 0

invoke ExitProcess,0
ret



Study GetStdHandle,WriteFile, and ReadFile API.

Alternatively Windows also has console only API like WriteConsole and related functions.