mirror of
https://github.com/decompals/wibo.git
synced 2025-12-13 07:06:18 +00:00
Split kernel32 into separate files (part 3)
This commit is contained in:
49
dll/kernel32/ioapiset.cpp
Normal file
49
dll/kernel32/ioapiset.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#include "ioapiset.h"
|
||||
|
||||
#include "errors.h"
|
||||
#include "synchapi.h"
|
||||
|
||||
namespace kernel32 {
|
||||
|
||||
BOOL WIN_FUNC GetOverlappedResult(HANDLE hFile, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred,
|
||||
BOOL bWait) {
|
||||
DEBUG_LOG("GetOverlappedResult(%p, %p, %p, %d)\n", hFile, lpOverlapped, lpNumberOfBytesTransferred, bWait);
|
||||
(void)hFile;
|
||||
if (!lpOverlapped) {
|
||||
wibo::lastError = ERROR_INVALID_PARAMETER;
|
||||
return FALSE;
|
||||
}
|
||||
if (bWait && lpOverlapped->Internal == STATUS_PENDING) {
|
||||
if (lpOverlapped->hEvent) {
|
||||
WaitForSingleObject(lpOverlapped->hEvent, 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
const auto status = static_cast<NTSTATUS>(lpOverlapped->Internal);
|
||||
if (status == STATUS_PENDING) {
|
||||
wibo::lastError = ERROR_IO_INCOMPLETE;
|
||||
if (lpNumberOfBytesTransferred) {
|
||||
*lpNumberOfBytesTransferred = static_cast<DWORD>(lpOverlapped->InternalHigh);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (lpNumberOfBytesTransferred) {
|
||||
*lpNumberOfBytesTransferred = static_cast<DWORD>(lpOverlapped->InternalHigh);
|
||||
}
|
||||
|
||||
if (status == STATUS_SUCCESS) {
|
||||
wibo::lastError = ERROR_SUCCESS;
|
||||
return TRUE;
|
||||
}
|
||||
if (status == STATUS_END_OF_FILE || status == ERROR_HANDLE_EOF) {
|
||||
wibo::lastError = ERROR_HANDLE_EOF;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
wibo::lastError = status;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
} // namespace kernel32
|
||||
|
||||
Reference in New Issue
Block a user