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!
You’re setting the value of
edxbefore the call toSetFilePointerand using it after the call. However, Windows API functions use thestdcallcalling convention which is not guaranteed to preserve theedxregister, so the value in it is destroyed, and the call to WriteFile fails.