Hi all
I have a problem with driver-driver ioctls that I’m struggling with.
I have a wdm driver for a device with a simple ioctl interface. From a dll I can get a handle to the device using CreateFileA and talk to the device using DeviceIoControl. This works fine and has done for some time.
I’d like to now operate the device from another wdm and so use the Zw… funcs…
I can get a handle to the device:
InitializeObjectAttributes(&objAttr, &ntDeviceName, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL);
Status = ZwCreateFile(&hndFile,
FILE_READ_DATA|FILE_WRITE_DATA,
&objAttr,
&ioStatusBlock,
0, // allocation is meaningless
0, // no attributes specified
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
FILE_OPEN, // must already exist
FILE_NON_DIRECTORY_FILE, // must NOT be a directory
NULL, // no EA buffer
0); // no EA buffer size…
I can call the device ioctl:
Status = ZwDeviceIoControlFile(
hndFile,
testEvent,
NULL,
NULL,
&ioStatusBlock,
(unsigned long) IOCTL_BUFFERED_WRITE_READ,
WriteBuff,
WriteSize,
ReadBuff,
ReadSize);
And I can see the ioctl land in the other driver.
However, I’m getting a BSOD:
BAD_POOL_HEADER (19)
The pool is already corrupt at the time of the current request.
This may or may not be due to the caller.
The internal pool links must be walked to figure out a possible cause of
the problem, and then special pool applied to the suspect tags or the driver
verifier to a suspect driver.
Arguments:
Arg1: 00000020, a pool block header size is corrupt.
Arg2: 89a669b0, The pool entry we were looking for within the page.
Arg3: 89a669c0, The next pool entry.
Arg4: 1a020001, (reserved)
This seems to be as result of IoCompleteRequest in the driver before returning from the ioctl:
Irp->IoStatus.Status = Status;
IoCompleteRequest (Irp, IO_NO_INCREMENT);
return Status;
I am going about this the right way?
Thanks
Sean