Jump to content
  • Advertisement
Sign in to follow this  
monp

[asm]

This topic is 3632 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to write a simple program to create a text file and put text into it, but I do not know how to get it to make a new line. This is the Part here.

  mov [hsFile], eax
  invoke WriteFile, [hsFile], "Textfile", 8, BytesWritten, 0
  invoke WriteFile, [hsFile], "This is an example", 16, BytesWritten, 0 



It keeps it as all one line.

Share this post


Link to post
Share on other sites
Advertisement
mov [hsFile], eax
invoke WriteFile, [hsFile], "Textfile", 8, BytesWritten, 0
invoke WriteFile, [hsFile], "This is an example", 16, BytesWritten, 0


try this instead

 
TxtFileString db "Textfile", 0, 0Dh, 0Ah
ExampleString db "This is an example", 0, 0Dh, 0Ah

mov [hsFile], eax
invoke WriteFile, [hsFile], addr TxtFileString, 8, BytesWritten, 0
invoke WriteFile, [hsFile], addr ExampleString, 16, BytesWritten, 0


I hope it works for you

Share this post


Link to post
Share on other sites
What does this do?

invoke lstrcat, Drive, 'Test.exe'
invoke CopyFile, szPath, Drive, 07


Share this post


Link to post
Share on other sites
Quote:
Original post by monp
What does this do?
*** Source Snippet Removed ***


It seems to be concatinating(putting together) the strings "Test.exe" and string Drive

The second function copies the file referenced by Drive string to the szPath location, 7 is probably the size of the Drive file

Share this post


Link to post
Share on other sites
I am trying to get the exe two create to text files and it is clashing them together leaving alot of the information and Keeping it all in one line. Here is the code.


invoke lstrcat, FirstFile, 'test.txt'
invoke CreateFile, FirstFile, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0
mov [hsFile], eax
invoke WriteFile, [hsFile], addr fLine, 9, BytesWritten, 0
invoke WriteFile, [hsFile], addr sLine, 38, BytesWritten, 0
invoke WriteFile, [hsFile], addr tLine, 14, BytesWritten, 0
invoke CloseHandle, [hsFile]

invoke lstrcpy, Filename, Drive
invoke lstrcat, Filename, 'test2.txt'
invoke CreateFile, Filename, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0
mov [fsFile], eax
invoke WriteFile, [fsFile], addr Fline, 9, BytesWritten, 0
invoke WriteFile, [fsFile], addr Sline, 22, BytesWritten, 0
invoke WriteFile, [fsFile], addr Tline, 15, BytesWritten, 0
invoke CloseHandle, [fsFile]


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!