MDL Behavior on Win2003

Hi,

I am developing a NDIS Protocol driver that works on Win2000, XP and 2003. With respect to a particular implementation wherein user buffers are accessed in the kernel mode through MDL, I am seeing different behavior on Win2003. Can anybody pls suggest me the cause of difference? Problem is stated below:

I allocate a buffer array in user application, fill a first few buffer array element with the valid data and pass the buffer array to driver through an asynchronous operation. Driver starts processing the buffer array meanwhile user application is filling rest of the buffers.
A MDL is created from buffer pointer and buffer length of the buffer sent from the user application.
Code that is being used in the Driver to create MDL is given below:

mdl_size = MmSizeOfMdl(buffer_ptr,buffer_length);
mdl_ptr = (PMDL)ExAllocatePoolWithTag( NonPagedPool,mdl_size, ‘LDM’);
MmInitializeMdl(mdl_ptr,buffer_ptr,buffer_length);
if(mdl_ptr)
{
MmProbeAndLockPages(mdl_ptr,KernelMode,IoReadAccess);
mdl_buf = MmGetSystemAddressForMdlSafe(mdl_ptr,HighPagePriority);
//Now i store the mdl_buf & further use this to access the user space memory
svc_objp->txmt_pool->buffer_pool = mdl_buf;
}
Then this buffer pool is further used by the driver.

When this scenario is executed on the Windows 2000 & Windows XP machine, everything works fine. But Windows 2003 Server machine behave in a different fashion. Found that in the Windows 2003 Server machine only those buffers which were filled before making a call to the driver are having valid data & rest of the buffers contains some junk data.

Can u pls suggest me the reasons for the different behaviour of Windows 20003 Server and possible solutions?

Your help is very much appreciated !
Regds,
Bharti

Use IoAllocateMdl instead - simpler and more reliable.

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

----- Original Message -----
From: Bharti Batra
To: Windows System Software Devs Interest List
Sent: Monday, January 17, 2005 4:54 PM
Subject: [ntdev] MDL Behavior on Win2003

Hi,

I am developing a NDIS Protocol driver that works on Win2000, XP and 2003. With respect to a particular implementation wherein user buffers are accessed in the kernel mode through MDL, I am seeing different behavior on Win2003. Can anybody pls suggest me the cause of difference? Problem is stated below:

I allocate a buffer array in user application, fill a first few buffer array element with the valid data and pass the buffer array to driver through an asynchronous operation. Driver starts processing the buffer array meanwhile user application is filling rest of the buffers.
A MDL is created from buffer pointer and buffer length of the buffer sent from the user application.
Code that is being used in the Driver to create MDL is given below:

mdl_size = MmSizeOfMdl(buffer_ptr,buffer_length);
mdl_ptr = (PMDL)ExAllocatePoolWithTag( NonPagedPool,mdl_size, ‘LDM’);
MmInitializeMdl(mdl_ptr,buffer_ptr,buffer_length);
if(mdl_ptr)
{
MmProbeAndLockPages(mdl_ptr,KernelMode,IoReadAccess);
mdl_buf = MmGetSystemAddressForMdlSafe(mdl_ptr,HighPagePriority);
//Now i store the mdl_buf & further use this to access the user space memory
svc_objp->txmt_pool->buffer_pool = mdl_buf;
}
Then this buffer pool is further used by the driver.

When this scenario is executed on the Windows 2000 & Windows XP machine, everything works fine. But Windows 2003 Server machine behave in a different fashion. Found that in the Windows 2003 Server machine only those buffers which were filled before making a call to the driver are having valid data & rest of the buffers contains some junk data.

Can u pls suggest me the reasons for the different behaviour of Windows 20003 Server and possible solutions?

Your help is very much appreciated !
Regds,
Bharti


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Thanx a lot Maxim! I think this will work...

Regds,
Bharti
----- Original Message -----
From: Maxim S. Shatskih
To: Windows System Software Devs Interest List
Sent: Monday, January 17, 2005 8:20 PM
Subject: Re: [ntdev] MDL Behavior on Win2003

Use IoAllocateMdl instead - simpler and more reliable.

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

----- Original Message -----
From: Bharti Batra
To: Windows System Software Devs Interest List
Sent: Monday, January 17, 2005 4:54 PM
Subject: [ntdev] MDL Behavior on Win2003

Hi,

I am developing a NDIS Protocol driver that works on Win2000, XP and 2003. With respect to a particular implementation wherein user buffers are accessed in the kernel mode through MDL, I am seeing different behavior on Win2003. Can anybody pls suggest me the cause of difference? Problem is stated below:

I allocate a buffer array in user application, fill a first few buffer array element with the valid data and pass the buffer array to driver through an asynchronous operation. Driver starts processing the buffer array meanwhile user application is filling rest of the buffers.
A MDL is created from buffer pointer and buffer length of the buffer sent from the user application.
Code that is being used in the Driver to create MDL is given below:

mdl_size = MmSizeOfMdl(buffer_ptr,buffer_length);
mdl_ptr = (PMDL)ExAllocatePoolWithTag( NonPagedPool,mdl_size, 'LDM');
MmInitializeMdl(mdl_ptr,buffer_ptr,buffer_length);
if(mdl_ptr)
{
MmProbeAndLockPages(mdl_ptr,KernelMode,IoReadAccess);
mdl_buf = MmGetSystemAddressForMdlSafe(mdl_ptr,HighPagePriority);
//Now i store the mdl_buf & further use this to access the user space memory
svc_objp->txmt_pool->buffer_pool = mdl_buf;
}
Then this buffer pool is further used by the driver.

When this scenario is executed on the Windows 2000 & Windows XP machine, everything works fine. But Windows 2003 Server machine behave in a different fashion. Found that in the Windows 2003 Server machine only those buffers which were filled before making a call to the driver are having valid data & rest of the buffers contains some junk data.

Can u pls suggest me the reasons for the different behaviour of Windows 20003 Server and possible solutions?

Your help is very much appreciated !
Regds,
Bharti


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ''
To unsubscribe send a blank email to xxxxx@lists.osr.com

Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ''
To unsubscribe send a blank email to xxxxx@lists.osr.com