Re: TDI Client and MDL [LONG]

> Hello,

I’m writting a TDI client driver and have problems using MDL.
Below you can see my source code… First I create a transport address,
then a connection end-point and then I associates them. And I try to
create a MDL for the TdiBuildQueryInformation function but whenever the
IoCallDriver function is called (in my own QueryInformation function) I
get a BSOD with PFN_LIST_CORRUPT.
What is wrong in my code ? Should I use MmMapLockedPages() ?? Or do I
create the transport address and connection end-point incorrectly ??

That’s because I/O manager does MmUnlockPages when it frees MDL. To avoid
this BSOD you can lock pages in MDL (pages from NonPagedPool!) But I don’t
recomend it due to stability (and sanity) reasons. The better way is to set
Irp->MdlAddress to NULL in completion routine i.e.:

if (Irp->MdlAddress != NULL) {
IoFreeMdl(Irp->MdlAddress);
Irp->MdlAddress = NULL;
}

Hope it helps. (And thanks to Dan Partelly for this trick)

Vlad