Reputation: 65
Ive got an annoying problem, I cant append any text to the text file. Every time I open it for writing, I overwrite the data. I tried to move the file pointer to the end of the file, but no result (no writing to the file at all). Here is the code:
INVOKE CreateFile, offset filePath, GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,0
mov hFile, eax
mov edx, 10
INVOKE SetFilePointer, hFile, 0, 0, FILE_END
INVOKE WriteFile, hFile, offset buffer, edx, ADDR SizeReadWrite, NULL
INVOKE CloseHandle, hFile
Any ideas? Thank you in advance!
Upvotes: 1
Views: 1352
Reputation: 110154
You're setting the value of edx
before the call to SetFilePointer
and using it after the call. However, Windows API functions use the stdcall
calling convention which is not guaranteed to preserve the edx
register, so the value in it is destroyed, and the call to WriteFile fails.
Upvotes: 2