From my understanding if the share mode is set to 0, I will not be able to open the file again.
By default I've set it to 3, but even setting it to 2 ( FILE_SHARE_WRITE
) outputs the same error.
So that makes me think that the parameters are correct.
The data:
FileName:
db 'testWriteFile.txt',0
The code:
//create file
push 0 // hTemplateFile null
push 80 //dwFlagsAndAttributes 'FILE_ATTRIBUTE_NORMAL'
push 4 // dwCreationDisposition OPEN_ALWAYS
push 0 // lpSecurityAttributes null
push 3 // dwShareMode FILE_SHARE_READ | FILE_SHARE_WRITE -> allow other programs to read and write
push C // dwDesiredAccess GENERIC_WRITE
push FileName //lpFileName
call CreateFileA
call GetLastError
What could be the cause?
Edit: CreateFIleA reference https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea