I’m using DeviceIoControl
to send IOCTL commands to my IddCx-based (virtual) video adapter driver. If I install the driver and create a single instance of the virtual display adapter…:
DEVCON.EXE INSTALL my-virtual-display-driver.inf MyVirtualDisplayModel
When I run my IOCTL test program (As Administrator), I get Access Denied when I call CreateFileW
to get a handle to the adapter…:
// Open the virtual display device
hDevice = ::CreateFileW(
devicePath.c_str(), // Name of the device to be opened
GENERIC_WRITE | GENERIC_READ, // Requested access to the device
FILE_SHARE_READ | FILE_SHARE_WRITE, // Requested sharing mode of the device
nullptr, // Default security attributes
OPEN_EXISTING, // Disposition
0, // Device attributes and flags
nullptr); // No template file to copy file attributes from
…but completely by accident, I discovered that if I manually create another instance of my virtual display adapter (in Device Manager via Action > Add legacy hardware), the CreateFileW
call succeeds.
Can anyone shed light on this? Is the OS somehow holding an exclusive handle to the first instance?