FASM: Write File
by admin on Feb.20, 2011, under Programming
The example code below will create and write text into a new file. In order to use WriteFile in flat assembler you either have to include ‘WIN32AX.INC’ or handle the imports from kernel32.dll manually. I’ve used the shorter version and included win32ax.in. This sample code should work on all operating systems using the Win32 API:
format pe console 4.0 include 'WIN32AX.INC' .data buf db 'TEST' bufsize = $ - buf byteswritten dd ? .code main: invoke CreateFile, 'test.txt', GENERIC_WRITE, 0, 0, 4, FILE_ATTRIBUTE_NORMAL, 0 invoke WriteFile, eax, buf, bufsize, byteswritten, 0 invoke ExitProcess, 0 .end main
If the file already exists, it won’t get deleted, but it will be simply overwritten.
March 21st, 2011 on 05:54
hey there did you spend money for this wordpress theme you are utilizing or did you to get it at no cost somewhere and in that case might you please let me know exactly where cheers
March 22nd, 2011 on 12:49
I need to make the extra effort for that work you earn on paper within these text. I’m hoping the identical finest focus on your behalf sometime soon also. I loved your look I may check out your feed please keep posting!
October 16th, 2011 on 12:44
F*ckin’ amazing issues here. I’m very happy to peer your post. Thanks a lot and i’m looking ahead to contact you. Will you please drop me a e-mail?
February 25th, 2012 on 00:10
Good blog with some intriguing information. I will be back.