ntdll: Implement NtCancelIoFileEx and fix NtCancelIoFile.

This commit is contained in:
Mike Kaplinskiy 2009-08-09 00:11:30 -04:00 committed by Alexandre Julliard
parent b05774ee7e
commit af25949a51
5 changed files with 47 additions and 7 deletions

View File

@ -2603,6 +2603,38 @@ NTSTATUS WINAPI NtDeleteFile( POBJECT_ATTRIBUTES ObjectAttributes )
return status; return status;
} }
/******************************************************************
* NtCancelIoFileEx (NTDLL.@)
*
*
*/
NTSTATUS WINAPI NtCancelIoFileEx( HANDLE hFile, PIO_STATUS_BLOCK iosb, PIO_STATUS_BLOCK io_status )
{
LARGE_INTEGER timeout;
TRACE("%p %p %p\n", hFile, iosb, io_status );
SERVER_START_REQ( cancel_async )
{
req->handle = wine_server_obj_handle( hFile );
req->iosb = wine_server_client_ptr( iosb );
req->only_thread = FALSE;
io_status->u.Status = wine_server_call( req );
}
SERVER_END_REQ;
if (io_status->u.Status)
return io_status->u.Status;
/* Let some APC be run, so that we can run the remaining APCs on hFile
* either the cancelation of the pending one, but also the execution
* of the queued APC, but not yet run. This is needed to ensure proper
* clean-up of allocated data.
*/
timeout.u.LowPart = timeout.u.HighPart = 0;
NtDelayExecution( TRUE, &timeout );
return io_status->u.Status;
}
/****************************************************************** /******************************************************************
* NtCancelIoFile (NTDLL.@) * NtCancelIoFile (NTDLL.@)
* *
@ -2616,17 +2648,23 @@ NTSTATUS WINAPI NtCancelIoFile( HANDLE hFile, PIO_STATUS_BLOCK io_status )
SERVER_START_REQ( cancel_async ) SERVER_START_REQ( cancel_async )
{ {
req->handle = wine_server_obj_handle( hFile ); req->handle = wine_server_obj_handle( hFile );
wine_server_call( req ); req->iosb = 0;
req->only_thread = TRUE;
io_status->u.Status = wine_server_call( req );
} }
SERVER_END_REQ; SERVER_END_REQ;
if (io_status->u.Status)
return io_status->u.Status;
/* Let some APC be run, so that we can run the remaining APCs on hFile /* Let some APC be run, so that we can run the remaining APCs on hFile
* either the cancelation of the pending one, but also the execution * either the cancelation of the pending one, but also the execution
* of the queued APC, but not yet run. This is needed to ensure proper * of the queued APC, but not yet run. This is needed to ensure proper
* clean-up of allocated data. * clean-up of allocated data.
*/ */
timeout.u.LowPart = timeout.u.HighPart = 0; timeout.u.LowPart = timeout.u.HighPart = 0;
return io_status->u.Status = NtDelayExecution( TRUE, &timeout ); NtDelayExecution( TRUE, &timeout );
return io_status->u.Status;
} }
/****************************************************************************** /******************************************************************************

View File

@ -109,6 +109,7 @@
@ stub NtCallbackReturn @ stub NtCallbackReturn
# @ stub NtCancelDeviceWakeupRequest # @ stub NtCancelDeviceWakeupRequest
@ stdcall NtCancelIoFile(long ptr) @ stdcall NtCancelIoFile(long ptr)
@ stdcall NtCancelIoFileEx(long ptr ptr)
@ stdcall NtCancelTimer(long ptr) @ stdcall NtCancelTimer(long ptr)
@ stdcall NtClearEvent(long) @ stdcall NtClearEvent(long)
@ stdcall NtClose(long) @ stdcall NtClose(long)
@ -959,6 +960,7 @@
@ stub ZwCallbackReturn @ stub ZwCallbackReturn
# @ stub ZwCancelDeviceWakeupRequest # @ stub ZwCancelDeviceWakeupRequest
@ stdcall ZwCancelIoFile(long ptr) NtCancelIoFile @ stdcall ZwCancelIoFile(long ptr) NtCancelIoFile
@ stdcall ZwCancelIoFileEx(long ptr ptr) NtCancelIoFileEx
@ stdcall ZwCancelTimer(long ptr) NtCancelTimer @ stdcall ZwCancelTimer(long ptr) NtCancelTimer
@ stdcall ZwClearEvent(long) NtClearEvent @ stdcall ZwClearEvent(long) NtClearEvent
@ stdcall ZwClose(long) NtClose @ stdcall ZwClose(long) NtClose

View File

@ -295,15 +295,14 @@ static void test_ntncdf_async(void)
ok(U(iosb).Status == 0x01234567, "status set too soon\n"); ok(U(iosb).Status == 0x01234567, "status set too soon\n");
ok(iosb.Information == 0x12345678, "info set too soon\n"); ok(iosb.Information == 0x12345678, "info set too soon\n");
todo_wine {
r = pNtCancelIoFile(hdir, &iosb); r = pNtCancelIoFile(hdir, &iosb);
ok( r == STATUS_SUCCESS, "cancel failed\n"); ok( r == STATUS_SUCCESS, "cancel failed\n");
CloseHandle(hdir); CloseHandle(hdir);
ok(U(iosb).Status == STATUS_SUCCESS, "status wrong\n"); ok(U(iosb).Status == STATUS_SUCCESS, "status wrong\n");
ok(U(iosb2).Status == STATUS_CANCELLED, "status wrong\n"); todo_wine ok(U(iosb2).Status == STATUS_CANCELLED, "status wrong\n");
}
ok(iosb.Information == 0, "info wrong\n"); ok(iosb.Information == 0, "info wrong\n");
ok(iosb2.Information == 0, "info wrong\n"); ok(iosb2.Information == 0, "info wrong\n");

View File

@ -376,7 +376,7 @@ static void read_file_test(void)
ok( U(iosb).Status == STATUS_CANCELLED, "wrong status %x\n", U(iosb).Status ); ok( U(iosb).Status == STATUS_CANCELLED, "wrong status %x\n", U(iosb).Status );
ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information ); ok( iosb.Information == 0, "wrong info %lu\n", iosb.Information );
ok( is_signaled( event ), "event is signaled\n" ); ok( is_signaled( event ), "event is signaled\n" );
ok( !apc_count, "apc was called\n" ); todo_wine ok( !apc_count, "apc was called\n" );
SleepEx( 1, TRUE ); /* alertable sleep */ SleepEx( 1, TRUE ); /* alertable sleep */
ok( apc_count == 1, "apc was not called\n" ); ok( apc_count == 1, "apc was not called\n" );
CloseHandle( read ); CloseHandle( read );

View File

@ -2013,6 +2013,7 @@ NTSYSAPI NTSTATUS WINAPI NtAreMappedFilesTheSame(PVOID,PVOID);
NTSYSAPI NTSTATUS WINAPI NtAssignProcessToJobObject(HANDLE,HANDLE); NTSYSAPI NTSTATUS WINAPI NtAssignProcessToJobObject(HANDLE,HANDLE);
NTSYSAPI NTSTATUS WINAPI NtCallbackReturn(PVOID,ULONG,NTSTATUS); NTSYSAPI NTSTATUS WINAPI NtCallbackReturn(PVOID,ULONG,NTSTATUS);
NTSYSAPI NTSTATUS WINAPI NtCancelIoFile(HANDLE,PIO_STATUS_BLOCK); NTSYSAPI NTSTATUS WINAPI NtCancelIoFile(HANDLE,PIO_STATUS_BLOCK);
NTSYSAPI NTSTATUS WINAPI NtCancelIoFileEx(HANDLE,PIO_STATUS_BLOCK,PIO_STATUS_BLOCK);
NTSYSAPI NTSTATUS WINAPI NtCancelTimer(HANDLE, BOOLEAN*); NTSYSAPI NTSTATUS WINAPI NtCancelTimer(HANDLE, BOOLEAN*);
NTSYSAPI NTSTATUS WINAPI NtClearEvent(HANDLE); NTSYSAPI NTSTATUS WINAPI NtClearEvent(HANDLE);
NTSYSAPI NTSTATUS WINAPI NtClose(HANDLE); NTSYSAPI NTSTATUS WINAPI NtClose(HANDLE);