correct way to use mdl for file system filter

what is the correct procedure to swap the buffer described by the mdl at
irp->mdladdress on paging writes with my driver’s?
i tried to replace irp->mdladdress->mappedsystemva with my own buffer and
set irp->mdlflags to 7. on completion, i did the opposite. this works for
the floppy but not for the harddisk, which seems to be unaffected by the
swap.

Ho Mun Chuen
@@ “Not everything that counts can be counted;
<” )~ and not everything that can be counted counts"
//\ … Albert Einstein

> i tried to replace irp->mdladdress->mappedsystemva with my own buffer and

set irp->mdlflags to 7. on completion, i did the opposite. this works for

This seems to be the thing which will ruin MM. Inpage MDLs are allocated in
a very special way.
Allocate your own nonpaged buffer, build a MDL on it and pass it down.
In the completion routine - copy the data to the original MDL and free your
MDL and your buffer.

Max

This is mostly correct but I must add this:

You must save the Irp->MdlAddress and Irp->UserBuffer.
Then change those values to your MdlAddress and
AllocatedBuffer.
In a completition routine you have to restore original values
and free the Mdl and Buffer.

File systems (I found that in FASTFAT and NTFS) have bug
in them: in some occasions in the NonCached path
the Mdl is replaced for the lower level driver incorrectly -
by using the Irp->UserBuffer instead of MmGetMdlVirtualAddress().

Paul

PS: I have found this BUG last week after a very long debug session.

-----P?vodn? zpr?va-----
Od: Maxim S. Shatskih [SMTP:xxxxx@storagecraft.com]
Odesl?no: 26. ?ervna 2000 13:56
Komu: File Systems Developers
P?edm?t: [ntfsd] Re: correct way to use mdl for file system filter

> i tried to replace irp->mdladdress->mappedsystemva with my own buffer
and
> set irp->mdlflags to 7. on completion, i did the opposite. this works
for

This seems to be the thing which will ruin MM. Inpage MDLs are allocated
in
a very special way.
Allocate your own nonpaged buffer, build a MDL on it and pass it down.
In the completion routine - copy the data to the original MDL and free
your
MDL and your buffer.

Max


You are currently subscribed to ntfsd as: xxxxx@sodatsw.cz
To unsubscribe send a blank email to $subst(‘Email.Unsub’)