The MASM Forum

General => The Campus => Topic started by: sofy abbas on February 10, 2016, 05:45:29 PM

Title: masm console app
Post by: sofy abbas on February 10, 2016, 05:45:29 PM
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:
Title: Re: masm console app
Post by: jj2007 on February 10, 2016, 06:45:32 PM
See this post on how to use qEditor with console applications. (http://masm32.com/board/index.php?topic=5096.msg54834#msg54834)

Then, give us more detail on what you want to achieve. Reading from, or to a text file?
Title: Re: masm console app
Post by: dedndave on February 10, 2016, 10:15:22 PM
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
Title: Re: masm console app
Post by: sofy abbas on February 10, 2016, 10:50:06 PM
dedndave
if u please - and have a time - code u write me the code cause I am new   :bgrin:
?
Title: Re: masm console app
Post by: jj2007 on February 10, 2016, 11:53:23 PM
Believe me, dedndave's code is too complicated for you 8)

I strongly recommend this video (https://www.youtube.com/watch?v=EBF04jJbu_o).
Title: Re: masm console app
Post by: dedndave on February 11, 2016, 12:19:47 AM
install the masm32 package and browse through the masm32\examples folder   :t
Title: Re: masm console app
Post by: Vortex on February 11, 2016, 06:45:11 AM
Hi sofy abbas,

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