WriteIntoThisFile PROC USES
EBX EDI ESI,__hFile:HANDLE,__lpBuffer:LPBYTE,__dwDataSize:DWord
LOCAL
_dwNbOfBytesWritten:DWord
mov
edi,__hFile
mov esi,__lpBuffer
mov ebx,__dwDataSize
test edi,edi
; The file handle is NULL ?
jz @Error
test
esi,esi
; The file buffer is NULL ?
jz
@Error
test ebx,ebx
; Data size to write is 0 ?
jz
@Error
INVOKE WriteFile,edi,esi,__dwDataSize,ADDR
_dwNbOfBytesWritten,NULL
test eax,eax
; Function failed
jz @Exit
cmp
ebx,_dwNbOfBytesWritten ; Datas written to disk ?
je
@Exit
; Yes
@Error
: xor
eax,eax
@Exit :
test eax,eax
ret
WriteIntoThisFile ENDP
This function returns TRUE if the write
operation returns successfully.
The function return FALSE if an error occured or if the file handle is NULL or
the file buffer is NULL or the datas size to write is 0.
At the end of the function the ZERO flag is set if an error occured.
INVOKE WriteIntoThisFile,_FileHandle,ADDR
_szBuffer,SIZEOF _szBuffer
jz @Error
<Return>