From: Jiajin Cui cuijiajin@uniontech.com
Previously the Flush method was a no-op that always returned S_OK Now it properly calls FlushFileBuffers on the underlying file handle This ensures that all buffered data is written to disk Added error handling to return STG_E_WRITEFAULT on flush failures This fixes potential data loss issues when using file-based lock bytes
Log: Fixed file flushing to prevent data loss in file operations
Signed-off-by: Jiajin Cui cuijiajin@uniontech.com --- dlls/ole32/filelockbytes.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/dlls/ole32/filelockbytes.c b/dlls/ole32/filelockbytes.c index d806916f1d5..05de0a77f4b 100644 --- a/dlls/ole32/filelockbytes.c +++ b/dlls/ole32/filelockbytes.c @@ -279,6 +279,19 @@ static HRESULT WINAPI FileLockBytesImpl_WriteAt(
static HRESULT WINAPI FileLockBytesImpl_Flush(ILockBytes* iface) { + FileLockBytesImpl *This = impl_from_ILockBytes(iface); + + TRACE("(%p)\n", iface); + + /* verify a sane environment */ + if (!This) return E_FAIL; + + if (This->flProtect != PAGE_READWRITE) + return STG_E_ACCESSDENIED; + + if (!FlushFileBuffers(This->hfile)) + return STG_E_WRITEFAULT; + return S_OK; }