ReadFile/WriteFile: Require overlapped I/O on overlapped handles (#99)

This commit is contained in:
2025-10-23 23:07:56 -07:00
committed by GitHub
parent 5597da607a
commit 1500a4f815
2 changed files with 37 additions and 0 deletions

View File

@@ -718,6 +718,15 @@ BOOL WIN_FUNC WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWr
return FALSE;
}
if (lpNumberOfBytesWritten && (!file->overlapped || lpOverlapped == nullptr)) {
*lpNumberOfBytesWritten = 0;
}
if (file->overlapped && lpOverlapped == nullptr) {
wibo::lastError = ERROR_INVALID_PARAMETER;
return FALSE;
}
std::optional<off_t> offset;
bool updateFilePointer = true;
if (lpOverlapped != nullptr) {
@@ -808,6 +817,11 @@ BOOL WIN_FUNC ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead
*lpNumberOfBytesRead = 0;
}
if (file->overlapped && lpOverlapped == nullptr) {
wibo::lastError = ERROR_INVALID_PARAMETER;
return FALSE;
}
std::optional<off_t> offset;
bool updateFilePointer = true;
if (lpOverlapped != nullptr) {