GETSYSTEMADDRESSFORMDL

I have the following #defines for GETSYSTEMADDRESSFORMDL, which I am afraid
might be out of date for 2003 Server even for a legacy driver. Are these
the correct ones? It is typically called like:

GETSYSTEMADDRESSFORMDL(Irp->MdlAddress,mybuffer);

Thanks.

//—

#define GETSYSTEMADDRESSFORMDL(pMdl,pAddress) \
{ \
CSHORT OldFlags; \
OldFlags = (CSHORT)(pMdl->MdlFlags & MDL_MAPPING_CAN_FAIL); \
pMdl->MdlFlags |= MDL_MAPPING_CAN_FAIL; \
pAddress = MmGetSystemAddressForMdl( pMdl ) ; \
if (!OldFlags) pMdl->MdlFlags &= ~(MDL_MAPPING_CAN_FAIL); \
}

#define MmGetSystemAddressForMdl(MDL) \
(((MDL)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | \
MDL_SOURCE_IS_NONPAGED_POOL)) ? \
((MDL)->MappedSystemVa) : \
(MmMapLockedPages((MDL),KernelMode)))

// —

Use OS-provided MmGetSystemAddressForMdlSafe instead.


Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

“Neil Weicher” wrote in message news:xxxxx@ntfsd…
> I have the following #defines for GETSYSTEMADDRESSFORMDL, which I am afraid
> might be out of date for 2003 Server even for a legacy driver. Are these
> the correct ones? It is typically called like:
>
> GETSYSTEMADDRESSFORMDL(Irp->MdlAddress,mybuffer);
>
> Thanks.
>
> //—
>
> #define GETSYSTEMADDRESSFORMDL(pMdl,pAddress) <br>> { <br>> CSHORT OldFlags; <br>> OldFlags = (CSHORT)(pMdl->MdlFlags & MDL_MAPPING_CAN_FAIL); <br>> pMdl->MdlFlags |= MDL_MAPPING_CAN_FAIL; <br>> pAddress = MmGetSystemAddressForMdl( pMdl ) ; <br>> if (!OldFlags) pMdl->MdlFlags &= ~(MDL_MAPPING_CAN_FAIL); <br>> }
>
> #define MmGetSystemAddressForMdl(MDL) <br>> (((MDL)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | <br>> MDL_SOURCE_IS_NONPAGED_POOL)) ? <br>> ((MDL)->MappedSystemVa) : <br>> (MmMapLockedPages((MDL),KernelMode)))
>
> // —
>
>