Commit 308f73c0 authored by Andrey Turkin's avatar Andrey Turkin Committed by Alexandre Julliard

kernel32: Pass completion value to ntdll layer.

parent d1a81558
......@@ -155,6 +155,7 @@ BOOL WINAPI ReadDirectoryChangesW( HANDLE handle, LPVOID buffer, DWORD len, BOOL
IO_STATUS_BLOCK *ios;
NTSTATUS status;
BOOL ret = TRUE;
LPVOID cvalue = NULL;
TRACE("%p %p %08x %d %08x %p %p %p\n", handle, buffer, len, subtree, filter,
returned, overlapped, completion );
......@@ -166,12 +167,15 @@ BOOL WINAPI ReadDirectoryChangesW( HANDLE handle, LPVOID buffer, DWORD len, BOOL
pov = &ov;
}
else
{
pov = overlapped;
if (!completion && ((ULONG_PTR)overlapped->hEvent & 1) == 0) cvalue = overlapped;
}
ios = (PIO_STATUS_BLOCK) pov;
ios->u.Status = STATUS_PENDING;
status = NtNotifyChangeDirectoryFile( handle, pov->hEvent, NULL, NULL,
status = NtNotifyChangeDirectoryFile( handle, pov->hEvent, NULL, cvalue,
ios, buffer, len, filter, subtree );
if (status == STATUS_PENDING)
{
......
......@@ -402,6 +402,7 @@ BOOL WINAPI ReadFile( HANDLE hFile, LPVOID buffer, DWORD bytesToRead,
PIO_STATUS_BLOCK io_status = &iosb;
HANDLE hEvent = 0;
NTSTATUS status;
LPVOID cvalue = NULL;
TRACE("%p %p %d %p %p\n", hFile, buffer, bytesToRead,
bytesRead, overlapped );
......@@ -419,11 +420,12 @@ BOOL WINAPI ReadFile( HANDLE hFile, LPVOID buffer, DWORD bytesToRead,
poffset = &offset;
hEvent = overlapped->hEvent;
io_status = (PIO_STATUS_BLOCK)overlapped;
if (((ULONG_PTR)hEvent & 1) == 0) cvalue = overlapped;
}
io_status->u.Status = STATUS_PENDING;
io_status->Information = 0;
status = NtReadFile(hFile, hEvent, NULL, NULL, io_status, buffer, bytesToRead, poffset, NULL);
status = NtReadFile(hFile, hEvent, NULL, cvalue, io_status, buffer, bytesToRead, poffset, NULL);
if (status == STATUS_PENDING && !overlapped)
{
......@@ -488,6 +490,7 @@ BOOL WINAPI WriteFile( HANDLE hFile, LPCVOID buffer, DWORD bytesToWrite,
NTSTATUS status;
IO_STATUS_BLOCK iosb;
PIO_STATUS_BLOCK piosb = &iosb;
LPVOID cvalue = NULL;
TRACE("%p %p %d %p %p\n", hFile, buffer, bytesToWrite, bytesWritten, overlapped );
......@@ -501,17 +504,18 @@ BOOL WINAPI WriteFile( HANDLE hFile, LPCVOID buffer, DWORD bytesToWrite,
poffset = &offset;
hEvent = overlapped->hEvent;
piosb = (PIO_STATUS_BLOCK)overlapped;
if (((ULONG_PTR)hEvent & 1) == 0) cvalue = overlapped;
}
piosb->u.Status = STATUS_PENDING;
piosb->Information = 0;
status = NtWriteFile(hFile, hEvent, NULL, NULL, piosb,
status = NtWriteFile(hFile, hEvent, NULL, cvalue, piosb,
buffer, bytesToWrite, poffset, NULL);
/* FIXME: NtWriteFile does not always cause page faults, generate them now */
if (status == STATUS_INVALID_USER_BUFFER && !IsBadReadPtr( buffer, bytesToWrite ))
{
status = NtWriteFile(hFile, hEvent, NULL, NULL, piosb,
status = NtWriteFile(hFile, hEvent, NULL, cvalue, piosb,
buffer, bytesToWrite, poffset, NULL);
if (status != STATUS_INVALID_USER_BUFFER)
FIXME("Could not access memory (%p,%d) at first, now OK. Protected by DIBSection code?\n",
......@@ -1052,9 +1056,9 @@ BOOL WINAPI LockFile( HANDLE hFile, DWORD offset_low, DWORD offset_high,
offset.u.LowPart = offset_low;
offset.u.HighPart = offset_high;
status = NtLockFile( hFile, 0, NULL, NULL,
status = NtLockFile( hFile, 0, NULL, NULL,
NULL, &offset, &count, NULL, TRUE, TRUE );
if (status != STATUS_SUCCESS) SetLastError( RtlNtStatusToDosError(status) );
return !status;
}
......@@ -1077,6 +1081,7 @@ BOOL WINAPI LockFileEx( HANDLE hFile, DWORD flags, DWORD reserved,
{
NTSTATUS status;
LARGE_INTEGER count, offset;
LPVOID cvalue = NULL;
if (reserved)
{
......@@ -1093,11 +1098,13 @@ BOOL WINAPI LockFileEx( HANDLE hFile, DWORD flags, DWORD reserved,
offset.u.LowPart = overlapped->u.s.Offset;
offset.u.HighPart = overlapped->u.s.OffsetHigh;
status = NtLockFile( hFile, overlapped->hEvent, NULL, NULL,
NULL, &offset, &count, NULL,
if (((ULONG_PTR)overlapped->hEvent & 1) == 0) cvalue = overlapped;
status = NtLockFile( hFile, overlapped->hEvent, NULL, cvalue,
NULL, &offset, &count, NULL,
flags & LOCKFILE_FAIL_IMMEDIATELY,
flags & LOCKFILE_EXCLUSIVE_LOCK );
if (status) SetLastError( RtlNtStatusToDosError(status) );
return !status;
}
......
......@@ -1328,6 +1328,7 @@ BOOL WINAPI ConnectNamedPipe(HANDLE hPipe, LPOVERLAPPED overlapped)
{
NTSTATUS status;
IO_STATUS_BLOCK status_block;
LPVOID cvalue = NULL;
TRACE("(%p,%p)\n", hPipe, overlapped);
......@@ -1335,9 +1336,10 @@ BOOL WINAPI ConnectNamedPipe(HANDLE hPipe, LPOVERLAPPED overlapped)
{
overlapped->Internal = STATUS_PENDING;
overlapped->InternalHigh = 0;
if (((ULONG_PTR)overlapped->hEvent & 1) == 0) cvalue = overlapped;
}
status = NtFsControlFile(hPipe, overlapped ? overlapped->hEvent : NULL, NULL, NULL,
status = NtFsControlFile(hPipe, overlapped ? overlapped->hEvent : NULL, NULL, cvalue,
overlapped ? (IO_STATUS_BLOCK *)overlapped : &status_block,
FSCTL_PIPE_LISTEN, NULL, 0, NULL, 0);
......
......@@ -351,16 +351,17 @@ BOOL WINAPI DeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode,
if (lpOverlapped)
{
LPVOID cvalue = ((ULONG_PTR)lpOverlapped->hEvent & 1) ? NULL : lpOverlapped;
lpOverlapped->Internal = STATUS_PENDING;
lpOverlapped->InternalHigh = 0;
if (HIWORD(dwIoControlCode) == FILE_DEVICE_FILE_SYSTEM)
status = NtFsControlFile(hDevice, lpOverlapped->hEvent,
NULL, NULL, (PIO_STATUS_BLOCK)lpOverlapped,
NULL, cvalue, (PIO_STATUS_BLOCK)lpOverlapped,
dwIoControlCode, lpvInBuffer, cbInBuffer,
lpvOutBuffer, cbOutBuffer);
else
status = NtDeviceIoControlFile(hDevice, lpOverlapped->hEvent,
NULL, NULL, (PIO_STATUS_BLOCK)lpOverlapped,
NULL, cvalue, (PIO_STATUS_BLOCK)lpOverlapped,
dwIoControlCode, lpvInBuffer, cbInBuffer,
lpvOutBuffer, cbOutBuffer);
if (lpcbBytesReturned) *lpcbBytesReturned = lpOverlapped->InternalHigh;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment