en.wikipedia.org/wiki/Ioctl
2 corrections found
A Win32 DeviceIoControl takes as parameters: 1. an open object handle (the Win32 equivalent of a file descriptor) 2. a request code number (the "control code") 3. a buffer for input parameters 4. length of the input buffer 5. a buffer for output results 6. length of the output buffer 7. an OVERLAPPED structure, if overlapped I/O is being used.
This list omits a required DeviceIoControl parameter. The Win32 API signature has eight parameters, including `lpBytesReturned` before `lpOverlapped`.
Full reasoning
Microsoft's official Win32 documentation shows that DeviceIoControl takes eight parameters, not seven:
BOOL DeviceIoControl(
HANDLE hDevice,
DWORD dwIoControlCode,
LPVOID lpInBuffer,
DWORD nInBufferSize,
LPVOID lpOutBuffer,
DWORD nOutBufferSize,
LPDWORD lpBytesReturned,
LPOVERLAPPED lpOverlapped
);
The missing parameter is lpBytesReturned, which receives the number of bytes placed in the output buffer. Microsoft's documentation also notes that when lpOverlapped is NULL, lpBytesReturned cannot be NULL, which confirms it is part of the standard function signature rather than an optional omission from a simplified list.
1 source
- DeviceIoControl function (ioapiset.h) - Win32 apps | Microsoft Learn
Syntax: BOOL DeviceIoControl( HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped ); ... If lpOverlapped is NULL, lpBytesReturned cannot be NULL.
all drivers, which now reside in ring 0 as well, must uphold the same level of security as the kernel core.
This overstates how drivers are implemented. Not all drivers run in ring 0/kernel mode; Windows supports user-mode drivers, and microkernel systems such as MINIX 3 run drivers as user-mode processes.
Full reasoning
The statement is too absolute. Multiple operating systems explicitly support drivers outside ring 0 / kernel mode.
- Microsoft's driver documentation says Windows has two basic types of drivers: user-mode drivers and kernel-mode drivers. It even gives printer drivers as an example of drivers that execute in user mode.
- Microsoft's overview of Windows execution modes likewise states that the processor operates in user mode and kernel mode, and that some drivers can function in user mode.
- MINIX 3's architecture documentation says the micro-kernel is the only component that runs in kernel mode, while drivers are implemented as user-mode processes.
Because real systems do have user-mode drivers, the categorical claim that all drivers now reside in ring 0 is incorrect.
3 sources
- Types of Windows Drivers - Windows drivers | Microsoft Learn
There are two basic types of Microsoft Windows drivers: User-mode drivers execute in user mode ... For example, all printer drivers execute in user mode. Kernel-mode drivers execute in kernel mode...
- User Mode and Kernel Mode - Windows drivers | Microsoft Learn
A processor in a computer that runs Windows operates in two different modes: user mode and kernel mode ... Although many drivers operate in kernel mode, some can function in user mode.
- developersguide:overviewofminixarchitecture [Wiki]
This is the only component of Minix that runs in kernel mode ... Drivers ... run in user mode and thus lack the authority to directly access hardware or memory that doesn't belong to them.