News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Using MASM32 Standard input and output function

Started by MBeckford05, April 08, 2008, 09:34:01 AM

Previous topic - Next topic

MBeckford05

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

BogdanOntanu

#1
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.
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro