Can you tell me what are possible causes of this error code from calling this function, or at least what may be relevant to my particular case?
I've been doing a bit of rewriting of a kernel driver I wrote, and now the user side gets error code 1 (incorrect function) from DeviceIoControl. It used to work before.
The IOCTL control code on the user side and the driver side is identical, in fact, from the same source file. The driver's creation of the device calls
s2 = IoCreateDevice (pDriverObject, sizeof (DeviceExt), &internalName, FILE_DEVICE_UNKNOWN, 0, false, &pDeviceObject);
So the device is created with shared access.
On the user side, the file handle is successfully created with
HANDLE handle = CreateFile (deviceName.c_str (), GENERIC_READ + GENERIC_WRITE,
exclusive ? 0 : FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
The 'exclusive' parameter is either true or false, with the same result.
The driver's DeviceControl routine handles an unknown IOCTL code (or any incorrect parameters for the correct IOCTL code) by setting the IRP with a STATUS_INVALID_DEVICE_REQUEST, or C0000010h. So I suspect that DeviceControl is not even getting called.
I haven't found anything useful searching online.