Sign in to follow this  

[asm]

This topic is 3292 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
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
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

This topic is 3292 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this