- started implementing ntdll.NtDeviceIoControlFile and made kernel32.DeviceIoControl call it
- changed cdrom ioctl function's prototype to stick to ntdll.NtDeviceIoControlFile signature
A+ -- Eric Pouech
diff -u -N -r -x '*~' -x '.#*' -x CVS dlls/ntdll30/cdrom.c dlls/ntdll/cdrom.c --- dlls/ntdll30/cdrom.c 2003-06-14 09:21:27.000000000 +0200 +++ dlls/ntdll/cdrom.c 2003-06-14 09:20:39.000000000 +0200 @@ -615,12 +615,14 @@ #ifdef ENOMEDIUM case ENOMEDIUM: #endif - return STATUS_NO_MEDIA_IN_DEVICE; + return STATUS_NO_MEDIA_IN_DEVICE; case EPERM: - return STATUS_ACCESS_DENIED; + return STATUS_ACCESS_DENIED; case EINVAL: - return STATUS_INVALID_PARAMETER; + return STATUS_INVALID_PARAMETER; /* case EBADF: Bad file descriptor */ + case EOPNOTSUPP: + return STATUS_NOT_SUPPORTED; } FIXME("Unmapped error code %d: %s\n", errno, strerror(errno)); return STATUS_IO_DEVICE_ERROR; @@ -1684,20 +1686,23 @@ * * */ -NTSTATUS CDROM_DeviceIoControl(DWORD clientID, HANDLE hDevice, DWORD dwIoControlCode, +NTSTATUS CDROM_DeviceIoControl(DWORD clientID, HANDLE hDevice, + HANDLE hEvent, PIO_APC_ROUTINE UserApcRoutine, + PVOID UserApcContext, + PIO_STATUS_BLOCK piosb, + ULONG dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, - LPVOID lpOutBuffer, DWORD nOutBufferSize, - LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped) + LPVOID lpOutBuffer, DWORD nOutBufferSize) { DWORD sz; NTSTATUS status = STATUS_SUCCESS; int dev; - TRACE("%lx[%c] %s %lx %ld %lx %ld %lx %lx\n", + TRACE("%lx[%c] %s %lx %ld %lx %ld %p\n", (DWORD)hDevice, 'A' + LOWORD(clientID), iocodex(dwIoControlCode), (DWORD)lpInBuffer, nInBufferSize, - (DWORD)lpOutBuffer, nOutBufferSize, (DWORD)lpBytesReturned, (DWORD)lpOverlapped); + (DWORD)lpOutBuffer, nOutBufferSize, piosb); - if (lpBytesReturned) *lpBytesReturned = 0; + piosb->Information = 0; if ((status = CDROM_Open(hDevice, clientID, &dev))) goto error; @@ -1889,13 +1894,10 @@ break; } error: - if (lpOverlapped) - { - lpOverlapped->Internal = status; - lpOverlapped->InternalHigh = sz; - NtSetEvent(lpOverlapped->hEvent, NULL); - } - if (lpBytesReturned) *lpBytesReturned = sz; + piosb->u.Status = status; + piosb->Information = sz; + if (hEvent) NtSetEvent(hEvent, NULL); + CDROM_Close(clientID); return status; } diff -u -N -r -x '*~' -x '.#*' -x CVS dlls/ntdll30/file.c dlls/ntdll/file.c --- dlls/ntdll30/file.c 2003-06-21 14:34:32.000000000 +0200 +++ dlls/ntdll/file.c 2003-06-21 16:37:18.000000000 +0200 @@ -392,6 +392,7 @@ hFile,hEvent,apc,apc_user,io_status,buffer,length,offset,key); io_status->Information = 0; + io_status->u.Status = FILE_GetUnixHandleType( hFile, GENERIC_READ, &type, &flags, &unix_handle ); if (io_status->u.Status) return io_status->u.Status; @@ -644,22 +645,51 @@ * NtDeviceIoControlFile [NTDLL.@] * ZwDeviceIoControlFile [NTDLL.@] */ -NTSTATUS WINAPI NtDeviceIoControlFile( - IN HANDLE DeviceHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL, - IN PVOID UserApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG IoControlCode, - IN PVOID InputBuffer, - IN ULONG InputBufferSize, - OUT PVOID OutputBuffer, - IN ULONG OutputBufferSize) -{ - FIXME("(%p,%p,%p,%p,%p,0x%08lx,%p,0x%08lx,%p,0x%08lx): empty stub\n", - DeviceHandle, Event, UserApcRoutine, UserApcContext, - IoStatusBlock, IoControlCode, InputBuffer, InputBufferSize, OutputBuffer, OutputBufferSize); - return 0; +NTSTATUS WINAPI NtDeviceIoControlFile(HANDLE DeviceHandle, HANDLE hEvent, + PIO_APC_ROUTINE UserApcRoutine, + PVOID UserApcContext, + PIO_STATUS_BLOCK IoStatusBlock, + ULONG IoControlCode, + PVOID InputBuffer, + ULONG InputBufferSize, + PVOID OutputBuffer, + ULONG OutputBufferSize) +{ + DWORD clientID = 0; + char str[3]; + + TRACE("(%p,%p,%p,%p,%p,0x%08lx,%p,0x%08lx,%p,0x%08lx)\n", + DeviceHandle, hEvent, UserApcRoutine, UserApcContext, + IoStatusBlock, IoControlCode, + InputBuffer, InputBufferSize, OutputBuffer, OutputBufferSize); + + /* FIXME: clientID hack should disappear */ + SERVER_START_REQ( get_device_id ) + { + req->handle = DeviceHandle; + if (!wine_server_call( req )) clientID = reply->id; + } + SERVER_END_REQ; + + if (!clientID) return STATUS_INVALID_PARAMETER; + strcpy(str, "A:"); + str[0] += LOBYTE(clientID); + + /* FIXME: should use the NTDLL equivalent */ + if (GetDriveTypeA(str) == DRIVE_CDROM) + { + return CDROM_DeviceIoControl(clientID, DeviceHandle, hEvent, + UserApcRoutine, UserApcContext, + IoStatusBlock, IoControlCode, + InputBuffer, InputBufferSize, + OutputBuffer, OutputBufferSize); + } + + FIXME("Unimplemented dwIoControlCode=%08lx\n", IoControlCode); + IoStatusBlock->u.Status = STATUS_NOT_IMPLEMENTED; + IoStatusBlock->Information = 0; + if (hEvent) NtSetEvent(hEvent, NULL); + return STATUS_NOT_IMPLEMENTED; } /****************************************************************************** diff -u -N -r -x '*~' -x '.#*' -x CVS dlls/ntdll30/ntdll_misc.h dlls/ntdll/ntdll_misc.h --- dlls/ntdll30/ntdll_misc.h 2003-06-21 14:30:39.000000000 +0200 +++ dlls/ntdll/ntdll_misc.h 2003-06-21 16:21:23.000000000 +0200 @@ -49,4 +49,15 @@ { return NtCurrentTeb()->Peb->ProcessParameters; } + +/* Device IO */ +/* ntdll/cdrom.c.c */ +extern NTSTATUS CDROM_DeviceIoControl(DWORD clientID, HANDLE hDevice, + HANDLE hEvent, PIO_APC_ROUTINE UserApcRoutine, + PVOID UserApcContext, + PIO_STATUS_BLOCK piosb, + ULONG IoControlCode, + LPVOID lpInBuffer, DWORD nInBufferSize, + LPVOID lpOutBuffer, DWORD nOutBufferSize); + #endif diff -u -N -r -x '*~' -x '.#*' -x CVS include30/file.h include/file.h --- include30/file.h 2003-06-14 09:22:25.000000000 +0200 +++ include/file.h 2003-06-14 09:20:47.000000000 +0200 @@ -118,10 +118,4 @@ /* win32/device.c */ extern HANDLE DEVICE_Open( LPCWSTR filename, DWORD access, LPSECURITY_ATTRIBUTES sa ); -/* ntdll/cdrom.c.c */ -extern NTSTATUS CDROM_DeviceIoControl(DWORD clientID, HANDLE hDevice, DWORD dwIoControlCode, - LPVOID lpInBuffer, DWORD nInBufferSize, - LPVOID lpOutBuffer, DWORD nOutBufferSize, - LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped); - #endif /* __WINE_FILE_H */ diff -u -N -r -x '*~' -x '.#*' -x CVS win3230/device.c win32/device.c --- win3230/device.c 2003-06-21 14:31:04.000000000 +0200 +++ win32/device.c 2003-06-21 16:36:06.000000000 +0200 @@ -433,63 +433,33 @@ } } else - { - char str[3]; + { + NTSTATUS status; - strcpy(str, "A:"); - str[0] += LOBYTE(clientID); - if (GetDriveTypeA(str) == DRIVE_CDROM) - { - NTSTATUS status; - status = CDROM_DeviceIoControl(clientID, hDevice, dwIoControlCode, lpvInBuffer, cbInBuffer, - lpvOutBuffer, cbOutBuffer, lpcbBytesReturned, - lpOverlapped); - if (status) SetLastError(RtlNtStatusToDosError(status)); - return !status; - } - else switch( dwIoControlCode ) - { - case FSCTL_DELETE_REPARSE_POINT: - case FSCTL_DISMOUNT_VOLUME: - case FSCTL_GET_COMPRESSION: - case FSCTL_GET_REPARSE_POINT: - case FSCTL_LOCK_VOLUME: - case FSCTL_QUERY_ALLOCATED_RANGES: - case FSCTL_SET_COMPRESSION: - case FSCTL_SET_REPARSE_POINT: - case FSCTL_SET_SPARSE: - case FSCTL_SET_ZERO_DATA: - case FSCTL_UNLOCK_VOLUME: - case IOCTL_DISK_CHECK_VERIFY: - case IOCTL_DISK_EJECT_MEDIA: - case IOCTL_DISK_FORMAT_TRACKS: - case IOCTL_DISK_GET_DRIVE_GEOMETRY: - case IOCTL_DISK_GET_DRIVE_LAYOUT: - case IOCTL_DISK_GET_MEDIA_TYPES: - case IOCTL_DISK_GET_PARTITION_INFO: - case IOCTL_DISK_LOAD_MEDIA: - case IOCTL_DISK_MEDIA_REMOVAL: - case IOCTL_DISK_PERFORMANCE: - case IOCTL_DISK_REASSIGN_BLOCKS: - case IOCTL_DISK_SET_DRIVE_LAYOUT: - case IOCTL_DISK_SET_PARTITION_INFO: - case IOCTL_DISK_VERIFY: - case IOCTL_SERIAL_LSRMST_INSERT: - case IOCTL_STORAGE_CHECK_VERIFY: - case IOCTL_STORAGE_EJECT_MEDIA: - case IOCTL_STORAGE_GET_MEDIA_TYPES: - case IOCTL_STORAGE_LOAD_MEDIA: - case IOCTL_STORAGE_MEDIA_REMOVAL: - FIXME( "unimplemented dwIoControlCode=%08lx\n", dwIoControlCode); - SetLastError( ERROR_CALL_NOT_IMPLEMENTED ); - return FALSE; - break; - default: - FIXME( "ignored dwIoControlCode=%08lx\n",dwIoControlCode); - SetLastError( ERROR_CALL_NOT_IMPLEMENTED ); - return FALSE; - break; - } + if (lpOverlapped) + { + status = NtDeviceIoControlFile(hDevice, lpOverlapped->hEvent, + NULL, NULL, + (PIO_STATUS_BLOCK)lpOverlapped, + dwIoControlCode, + lpvInBuffer, cbInBuffer, + lpvOutBuffer, cbOutBuffer); + if (status) SetLastError(RtlNtStatusToDosError(status)); + if (lpcbBytesReturned) *lpcbBytesReturned = lpOverlapped->InternalHigh; + return !status; + } + else + { + IO_STATUS_BLOCK iosb; + + status = NtDeviceIoControlFile(hDevice, NULL, NULL, NULL, &iosb, + dwIoControlCode, + lpvInBuffer, cbInBuffer, + lpvOutBuffer, cbOutBuffer); + if (status) SetLastError(RtlNtStatusToDosError(status)); + if (lpcbBytesReturned) *lpcbBytesReturned = iosb.Information; + return !status; + } } return FALSE; }