flat assembler
Message board for the users of flat assembler.
Index
> Windows > Having trouble about WriteFile. |
Author |
|
MHajduk 13 Sep 2010, 20:11
This works for me:
Code: format pe console 4.0 include 'WIN32AX.INC' .data buf db 65,65,65 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 |
|||
13 Sep 2010, 20:11 |
|
Overflowz 13 Sep 2010, 20:23
Oh, Thank you mate! I understand now. TY!
|
|||
13 Sep 2010, 20:23 |
|
Picnic 13 Sep 2010, 20:53
Here a poor AppendToFile() procedure, just to decorate topic
Code: proc AppendToFile uses ecx ebx edx, lpFileName, lpBuffer local nBytes:DWORD mov [nBytes], INVALID_HANDLE_VALUE invoke CreateFile, [lpFileName], GENERIC_WRITE, 0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0 cmp eax, INVALID_HANDLE_VALUE jz .finish mov ebx, eax invoke SetFilePointer, eax, 0, 0, FILE_END cmp eax, INVALID_HANDLE_VALUE jz .finish invoke lstrlen, [lpBuffer] invoke WriteFile, ebx, [lpBuffer], eax, addr nBytes, 0 invoke CloseHandle, ebx .finish: mov eax, [nBytes] ret endp |
|||
13 Sep 2010, 20:53 |
|
b1528932 13 Sep 2010, 21:13
either numberofbyteswritten or overlapped argument must be valid. They both point to 0 address, wich i guess windows tread as something special.
|
|||
13 Sep 2010, 21:13 |
|
Overflowz 13 Sep 2010, 21:46
Nope, just did like MHajduk wrote and everything seems work fine!
|
|||
13 Sep 2010, 21:46 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.