I have 2 structures declared:
struct irp_list {
IRP *irp;
LIST_ENTRY lh;
};
and
struct dev_info {
...
LIST_ENTRY lh;
...
};
Inside DriverWrite function (IRP_MJ_WRITE) I do:
struct irp_list *il;
struct dev_info *di = (struct dev_info*)device->DeviceExtension;
if (!(il = ExAllocatePool(NonPagedPool, sizeof(*il)))) {
ret = STATUS_NO_MEMORY;
DbgPrint("[uart] UartWrite can't handle irp...\n");
goto error;
}
il->irp = irp; // store DriverWrite irp
InsertTailList(&di->lh, &il->lh); // this insert is not failing...
irp->IoStatus.Information = 0;
IoMarkIrpPending(irp);
return STATUS_PENDING;
Inside a DPC function I try access the nonpaged memory of il with:
struct dev_info* di;
di = (struct dev_info*)device->DeviceExtension;
if(!IsListEmpty(&di->lh))
{
// code never reached
}
I know that a DPC can only read nonpaged memory, but why is !IsListEmpty always returning FALSE as if the insert failed?