News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

masm console app

Started by sofy abbas, February 10, 2016, 05:45:29 PM

Previous topic - Next topic

sofy abbas

hi every body  :biggrin: ,i,m new masm32 trainer  :greenclp: and I'd like to make console application to read from text file in cmd window
best regards , any help well be appreciated  :t  :greensml:

jj2007

See this post on how to use qEditor with console applications.

Then, give us more detail on what you want to achieve. Reading from, or to a text file?

dedndave

a lot depends on size - if you read a small file into memory, a buffer can be created in the .DATA? section
if a larger buffer is needed, you need to find an appropriate memory allocation method (there are several)

otherwise, reading a file involves
1) open the file with the CreateFile function (also used for existing files)
2) read the file contents into a buffer with the ReadFile function
3) close the file handle with CloseHandle

oddly, displaying text into the console can also be done as though it were a file
however, the handles are pre-assigned
1) use GetStdHandle to get the handle
2) use WriteFile to display text
3) no need to close a console handle

there are many technicalities involved in writing to the console
and, there are other ways to do it besides using WriteFile
the masm32 package has functions and macros to make life easier

sofy abbas

dedndave
if u please - and have a time - code u write me the code cause I am new   :bgrin:
?

jj2007

Believe me, dedndave's code is too complicated for you 8)

I strongly recommend this video.

dedndave

install the masm32 package and browse through the masm32\examples folder   :t

Vortex

Hi sofy abbas,

You can try the read_disk_file function from masm32.lib You can check the manual \masm32\help\masmlib.chm