Commit 583bb3fd authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

- started implementing ntdll.NtDeviceIoControlFile and made

kernel32.DeviceIoControl call it - changed cdrom ioctl function's prototype to stick to ntdll.NtDeviceIoControlFile signature
parent d9df6460
...@@ -615,12 +615,14 @@ static NTSTATUS CDROM_GetStatusCode(int io) ...@@ -615,12 +615,14 @@ static NTSTATUS CDROM_GetStatusCode(int io)
#ifdef ENOMEDIUM #ifdef ENOMEDIUM
case ENOMEDIUM: case ENOMEDIUM:
#endif #endif
return STATUS_NO_MEDIA_IN_DEVICE; return STATUS_NO_MEDIA_IN_DEVICE;
case EPERM: case EPERM:
return STATUS_ACCESS_DENIED; return STATUS_ACCESS_DENIED;
case EINVAL: case EINVAL:
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
/* case EBADF: Bad file descriptor */ /* case EBADF: Bad file descriptor */
case EOPNOTSUPP:
return STATUS_NOT_SUPPORTED;
} }
FIXME("Unmapped error code %d: %s\n", errno, strerror(errno)); FIXME("Unmapped error code %d: %s\n", errno, strerror(errno));
return STATUS_IO_DEVICE_ERROR; return STATUS_IO_DEVICE_ERROR;
...@@ -1684,20 +1686,23 @@ static NTSTATUS CDROM_GetAddress(int dev, SCSI_ADDRESS* address) ...@@ -1684,20 +1686,23 @@ static NTSTATUS CDROM_GetAddress(int dev, SCSI_ADDRESS* address)
* *
* *
*/ */
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 lpInBuffer, DWORD nInBufferSize,
LPVOID lpOutBuffer, DWORD nOutBufferSize, LPVOID lpOutBuffer, DWORD nOutBufferSize)
LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped)
{ {
DWORD sz; DWORD sz;
NTSTATUS status = STATUS_SUCCESS; NTSTATUS status = STATUS_SUCCESS;
int dev; 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)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; if ((status = CDROM_Open(hDevice, clientID, &dev))) goto error;
...@@ -1889,13 +1894,10 @@ NTSTATUS CDROM_DeviceIoControl(DWORD clientID, HANDLE hDevice, DWORD dwIoControl ...@@ -1889,13 +1894,10 @@ NTSTATUS CDROM_DeviceIoControl(DWORD clientID, HANDLE hDevice, DWORD dwIoControl
break; break;
} }
error: error:
if (lpOverlapped) piosb->u.Status = status;
{ piosb->Information = sz;
lpOverlapped->Internal = status; if (hEvent) NtSetEvent(hEvent, NULL);
lpOverlapped->InternalHigh = sz;
NtSetEvent(lpOverlapped->hEvent, NULL);
}
if (lpBytesReturned) *lpBytesReturned = sz;
CDROM_Close(clientID); CDROM_Close(clientID);
return status; return status;
} }
...@@ -285,22 +285,51 @@ NTSTATUS WINAPI NtWriteFile ( ...@@ -285,22 +285,51 @@ NTSTATUS WINAPI NtWriteFile (
* NtDeviceIoControlFile [NTDLL.@] * NtDeviceIoControlFile [NTDLL.@]
* ZwDeviceIoControlFile [NTDLL.@] * ZwDeviceIoControlFile [NTDLL.@]
*/ */
NTSTATUS WINAPI NtDeviceIoControlFile( NTSTATUS WINAPI NtDeviceIoControlFile(HANDLE DeviceHandle, HANDLE hEvent,
IN HANDLE DeviceHandle, PIO_APC_ROUTINE UserApcRoutine,
IN HANDLE Event OPTIONAL, PVOID UserApcContext,
IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL, PIO_STATUS_BLOCK IoStatusBlock,
IN PVOID UserApcContext OPTIONAL, ULONG IoControlCode,
OUT PIO_STATUS_BLOCK IoStatusBlock, PVOID InputBuffer,
IN ULONG IoControlCode, ULONG InputBufferSize,
IN PVOID InputBuffer, PVOID OutputBuffer,
IN ULONG InputBufferSize, ULONG OutputBufferSize)
OUT PVOID OutputBuffer,
IN ULONG OutputBufferSize)
{ {
FIXME("(%p,%p,%p,%p,%p,0x%08lx,%p,0x%08lx,%p,0x%08lx): empty stub\n", DWORD clientID = 0;
DeviceHandle, Event, UserApcRoutine, UserApcContext, char str[3];
IoStatusBlock, IoControlCode, InputBuffer, InputBufferSize, OutputBuffer, OutputBufferSize);
return 0; 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;
} }
/****************************************************************************** /******************************************************************************
......
...@@ -49,4 +49,15 @@ static inline RTL_USER_PROCESS_PARAMETERS* ntdll_get_process_pmts(void) ...@@ -49,4 +49,15 @@ static inline RTL_USER_PROCESS_PARAMETERS* ntdll_get_process_pmts(void)
{ {
return NtCurrentTeb()->Peb->ProcessParameters; 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 #endif
...@@ -118,10 +118,4 @@ extern int PROFILE_GetWineIniBool( LPCWSTR section, LPCWSTR key_name, int def ); ...@@ -118,10 +118,4 @@ extern int PROFILE_GetWineIniBool( LPCWSTR section, LPCWSTR key_name, int def );
/* win32/device.c */ /* win32/device.c */
extern HANDLE DEVICE_Open( LPCWSTR filename, DWORD access, LPSECURITY_ATTRIBUTES sa ); 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 */ #endif /* __WINE_FILE_H */
...@@ -433,63 +433,33 @@ BOOL WINAPI DeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, ...@@ -433,63 +433,33 @@ BOOL WINAPI DeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode,
} }
} }
else else
{ {
char str[3]; NTSTATUS status;
strcpy(str, "A:"); if (lpOverlapped)
str[0] += LOBYTE(clientID); {
if (GetDriveTypeA(str) == DRIVE_CDROM) status = NtDeviceIoControlFile(hDevice, lpOverlapped->hEvent,
{ NULL, NULL,
NTSTATUS status; (PIO_STATUS_BLOCK)lpOverlapped,
status = CDROM_DeviceIoControl(clientID, hDevice, dwIoControlCode, lpvInBuffer, cbInBuffer, dwIoControlCode,
lpvOutBuffer, cbOutBuffer, lpcbBytesReturned, lpvInBuffer, cbInBuffer,
lpOverlapped); lpvOutBuffer, cbOutBuffer);
if (status) SetLastError(RtlNtStatusToDosError(status)); if (status) SetLastError(RtlNtStatusToDosError(status));
return !status; if (lpcbBytesReturned) *lpcbBytesReturned = lpOverlapped->InternalHigh;
} return !status;
else switch( dwIoControlCode ) }
{ else
case FSCTL_DELETE_REPARSE_POINT: {
case FSCTL_DISMOUNT_VOLUME: IO_STATUS_BLOCK iosb;
case FSCTL_GET_COMPRESSION:
case FSCTL_GET_REPARSE_POINT: status = NtDeviceIoControlFile(hDevice, NULL, NULL, NULL, &iosb,
case FSCTL_LOCK_VOLUME: dwIoControlCode,
case FSCTL_QUERY_ALLOCATED_RANGES: lpvInBuffer, cbInBuffer,
case FSCTL_SET_COMPRESSION: lpvOutBuffer, cbOutBuffer);
case FSCTL_SET_REPARSE_POINT: if (status) SetLastError(RtlNtStatusToDosError(status));
case FSCTL_SET_SPARSE: if (lpcbBytesReturned) *lpcbBytesReturned = iosb.Information;
case FSCTL_SET_ZERO_DATA: return !status;
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;
}
} }
return FALSE; return FALSE;
} }
......
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