Swapping Mdl

Hi All
I want to swap the MDL buffer into my filter driver. Below is the way i am doing.
My this code is working fine for .txt files. But for .Doc it’s sometimes working sometimes not. Am i missing something. Please suggest.

originalMdl = Irp->MdlAddress;

stagingBuffer = ExAllocatePool
(
NonPagedPoolCacheAligned,
currentSp->Parameters.Write.Le?ngth
);

if (stagingBuffer != NULL)
stagingMdl = IoAllocateMdl
(
stagingBuffer,
currentSp->Parameters.Write.Le?ngth,
FALSE,
FALSE,
Irp
);

// If there were problems getting memory, just pass the request along.
if (stagingBuffer == NULL || stagingMdl == NULL)
{
if (stagingBuffer != NULL)
ExFreePool(stagingBuffer);

Irp->MdlAddress = originalMdl;

*nextSp = *currentSp;

ntStatus = IoCallDriver(filterExtension->?TargetDevice, Irp);
return (ntStatus);
}

// Required for mapping non-pagged pool memory to an MDL.
MmBuildMdlForNonPagedPool(stag?ingMdl);

// Swap the MDL in the IRP with the one we created.
Irp->MdlAddress = stagingMdl;

// Copy current stack to next stack.
*nextSp = *currentSp;

// Switch the MDL back in the completion routine
IoSetCompletionRoutine
(
Irp,
WriteCompletion,
originalMdl,
TRUE,
TRUE,
TRUE
);

// Call driver below us.
ntStatus = IoCallDriver(TargetDevice, Irp);

return (ntStatus);

Completion code:

// Initialize pointers to the MDLs.
stagingMdl = Irp->MdlAddress;
originalMdl = OriginalMdl;

// Initialize pointers to the I/O buffers
stagingBuffer = MmGetSystemAddressForMdl(stagi?ngMdl);
originalBuffer = MmGetSystemAddressForMdl(origi?nalMdl);

// Restore the original IRP.
Irp->MdlAddress = originalMdl;

IoFreeMdl(stagingMdl);
ExFreePool(stagingBuffer);

Raghwendra

*********************************************************
Disclaimer:
The contents of this E-mail (including the contents of the enclosure(s) or attachment(s) if any) are privileged and confidential material of MBT and should not be disclosed to, used by or copied in any manner by anyone other than the intended addressee(s). In case you are not the desired addressee, you should delete this message and/or re-direct it to the sender. The views expressed in this E-mail message (including the enclosure(s) or attachment(s) if any) are those of the individual sender, except where the sender expressly, and with authority, states them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be free of any virus. However, it is the responsibility of the recipient to ensure that it is virus free and MBT is not responsible for any loss or damage arising in any way from its use

********************************************************

First I see this:

> // Copy current stack to next stack.
> *nextSp = *currentSp;

This is not safe and can cause enexpected results. You need to use the macro CopyCurrentIrpStackXxx() to copy the IRP stack properly. Doing a raw copy has some side effects because of the flags. You can simply copy the macro from the 2K+ DDKs into any legacy NT 4.0 code.

Here too:

> Irp->MdlAddress = originalMdl;
> *nextSp = *currentSp;

Another interesting thing I noticed… This looks a lot like some code that I may have written a long time ago; down to the variable names, casing and sequencing :slight_smile:

Jamey

----- Original Message -----
From: Raghwendra
To: Windows File Systems Devs Interest List
Sent: Tuesday, July 05, 2005 12:03 AM
Subject: [ntfsd] Swapping Mdl

Hi All
I want to swap the MDL buffer into my filter driver. Below is the way i am doing.
My this code is working fine for .txt files. But for .Doc it’s sometimes working sometimes not. Am i missing something. Please suggest.

originalMdl = Irp->MdlAddress;

stagingBuffer = ExAllocatePool
(
NonPagedPoolCacheAligned,
currentSp->Parameters.Write.Le?ngth
);

if (stagingBuffer != NULL)
stagingMdl = IoAllocateMdl
(
stagingBuffer,
currentSp->Parameters.Write.Le?ngth,
FALSE,
FALSE,
Irp
);

// If there were problems getting memory, just pass the request along.
if (stagingBuffer == NULL || stagingMdl == NULL)
{
if (stagingBuffer != NULL)
ExFreePool(stagingBuffer);

Irp->MdlAddress = originalMdl;

*nextSp = *currentSp;

ntStatus = IoCallDriver(filterExtension->?TargetDevice, Irp);
return (ntStatus);
}

// Required for mapping non-pagged pool memory to an MDL.
MmBuildMdlForNonPagedPool(stag?ingMdl);

// Swap the MDL in the IRP with the one we created.
Irp->MdlAddress = stagingMdl;

// Copy current stack to next stack.
*nextSp = *currentSp;

// Switch the MDL back in the completion routine
IoSetCompletionRoutine
(
Irp,
WriteCompletion,
originalMdl,
TRUE,
TRUE,
TRUE
);

// Call driver below us.
ntStatus = IoCallDriver(TargetDevice, Irp);

return (ntStatus);

Completion code:

// Initialize pointers to the MDLs.
stagingMdl = Irp->MdlAddress;
originalMdl = OriginalMdl;

// Initialize pointers to the I/O buffers
stagingBuffer = MmGetSystemAddressForMdl(stagi?ngMdl);
originalBuffer = MmGetSystemAddressForMdl(origi?nalMdl);

// Restore the original IRP.
Irp->MdlAddress = originalMdl;

IoFreeMdl(stagingMdl);
ExFreePool(stagingBuffer);

Raghwendra


Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com *********************************************************
Disclaimer:
The contents of this E-mail (including the contents of the enclosure(s) or attachment(s) if any) are privileged and confidential material of MBT and should not be disclosed to, used by or copied in any manner by anyone other than the intended addressee(s). In case you are not the desired addressee, you should delete this message and/or re-direct it to the sender. The views expressed in this E-mail message (including the enclosure(s) or attachment(s) if any) are those of the individual sender, except where the sender expressly, and with authority, states them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be free of any virus. However, it is the responsibility of the recipient to ensure that it is virus free and MBT is not responsible for any loss or damage arising in any way from its use

********************************************************

HI Jamey
Thankx for reply. Yes it is your code :–)) … in my filter driver i am not using the same line of code but the machenism is similar to this …Actually i am using Framework of DriverStudio where i am using totaly different code lines. As you have mentioned about *nextSp = *currentSp; so in my case this call is happening throo frame work , which is very much using CopyCurrentIrpStackXxx() calls internally.

Appart from similar logic to your code i am also locking Newly created MDl using MmProbAndLockPages and unlocking into completion routine before reassigning the orignal MDL. This works fine for .txt file or application like Notepad, EditPlus. But for .Doc file it’s not working properly. any sugession for the same.

Regards
Raghwendra

----- Original Message -----
From: Jamey Kirby
To: Windows File Systems Devs Interest List
Sent: Tuesday, July 05, 2005 12:49 PM
Subject: Re: [ntfsd] Swapping Mdl

First I see this:

> // Copy current stack to next stack.
>> *nextSp = *currentSp;

This is not safe and can cause enexpected results. You need to use the macro CopyCurrentIrpStackXxx() to copy the IRP stack properly. Doing a raw copy has some side effects because of the flags. You can simply copy the macro from the 2K+ DDKs into any legacy NT 4.0 code.

Here too:

> Irp->MdlAddress = originalMdl;
>> *nextSp = *currentSp;

Another interesting thing I noticed… This looks a lot like some code that I may have written a long time ago; down to the variable names, casing and sequencing :slight_smile:

Jamey

----- Original Message -----
From: Raghwendra
To: Windows File Systems Devs Interest List
Sent: Tuesday, July 05, 2005 12:03 AM
Subject: [ntfsd] Swapping Mdl

Hi All
I want to swap the MDL buffer into my filter driver. Below is the way i am doing.
My this code is working fine for .txt files. But for .Doc it’s sometimes working sometimes not. Am i missing something. Please suggest.

originalMdl = Irp->MdlAddress;

stagingBuffer = ExAllocatePool
(
NonPagedPoolCacheAligned,
currentSp->Parameters.Write.Le?ngth
);

if (stagingBuffer != NULL)
stagingMdl = IoAllocateMdl
(
stagingBuffer,
currentSp->Parameters.Write.Le?ngth,
FALSE,
FALSE,
Irp
);

// If there were problems getting memory, just pass the request along.
if (stagingBuffer == NULL || stagingMdl == NULL)
{
if (stagingBuffer != NULL)
ExFreePool(stagingBuffer);

Irp->MdlAddress = originalMdl;

*nextSp = *currentSp;

ntStatus = IoCallDriver(filterExtension->?TargetDevice, Irp);
return (ntStatus);
}

// Required for mapping non-pagged pool memory to an MDL.
MmBuildMdlForNonPagedPool(stag?ingMdl);

// Swap the MDL in the IRP with the one we created.
Irp->MdlAddress = stagingMdl;

// Copy current stack to next stack.
*nextSp = *currentSp;

// Switch the MDL back in the completion routine
IoSetCompletionRoutine
(
Irp,
WriteCompletion,
originalMdl,
TRUE,
TRUE,
TRUE
);

// Call driver below us.
ntStatus = IoCallDriver(TargetDevice, Irp);

return (ntStatus);

Completion code:

// Initialize pointers to the MDLs.
stagingMdl = Irp->MdlAddress;
originalMdl = OriginalMdl;

// Initialize pointers to the I/O buffers
stagingBuffer = MmGetSystemAddressForMdl(stagi?ngMdl);
originalBuffer = MmGetSystemAddressForMdl(origi?nalMdl);

// Restore the original IRP.
Irp->MdlAddress = originalMdl;

IoFreeMdl(stagingMdl);
ExFreePool(stagingBuffer);

Raghwendra


Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com *********************************************************
Disclaimer:
The contents of this E-mail (including the contents of the enclosure(s) or attachment(s) if any) are privileged and confidential material of MBT and should not be disclosed to, used by or copied in any manner by anyone other than the intended addressee(s). In case you are not the desired addressee, you should delete this message and/or re-direct it to the sender. The views expressed in this E-mail message (including the enclosure(s) or attachment(s) if any) are those of the individual sender, except where the sender expressly, and with authority, states them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be free of any virus. However, it is the responsibility of the recipient to ensure that it is virus free and MBT is not responsible for any loss or damage arising in any way from its use

********************************************************


Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17

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

*********************************************************
Disclaimer:
The contents of this E-mail (including the contents of the enclosure(s) or attachment(s) if any) are privileged and confidential material of MBT and should not be disclosed to, used by or copied in any manner by anyone other than the intended addressee(s). In case you are not the desired addressee, you should delete this message and/or re-direct it to the sender. The views expressed in this E-mail message (including the enclosure(s) or attachment(s) if any) are those of the individual sender, except where the sender expressly, and with authority, states them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be free of any virus. However, it is the responsibility of the recipient to ensure that it is virus free and MBT is not responsible for any loss or damage arising in any way from its use

********************************************************

You don’t adjust Irp->UserBuffer; this will cause problems whenever the file is fragmented, regardless of the type of the file. See deviosup.c in the FAT source code example (look for the use of Irp->UserBuffer.

Since you don’t mention what “not working” means it is a guess as to *how* it does not work in your environment.

Since you pass the IRP in the IoAllocateIrp call, it has already been added to the MDL chain. The way the code is now written this will work, but it is the kind of thing that will break in the future when someone changes the code around.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Raghwendra
Sent: Tuesday, July 05, 2005 3:03 AM
To: ntfsd redirect
Subject: [ntfsd] Swapping Mdl

Hi All
??? I want to swap the MDL buffer into my filter driver. Below is the way i am doing.
My this code is working fine for .txt files. But for .Doc it’s sometimes working sometimes not.?Am?i missing something. Please suggest.
?
originalMdl = Irp->MdlAddress;
? ? stagingBuffer = ExAllocatePool
? ? (
? ? ? ? NonPagedPoolCacheAligned,
? ? ? ? currentSp->Parameters.Write.Length
? ? );
? ? if (stagingBuffer != NULL)
? ? ? ? stagingMdl = IoAllocateMdl
? ? ? ? (
? ? ? ? ? ? stagingBuffer,
? ? ? ? ? ? currentSp->Parameters.Write.Length,
? ? ? ? ? ? FALSE,
? ? ? ? ? ? FALSE,
? ? ? ? ? ? Irp
? ? ? ? );
? ? // If there were problems getting memory, just pass the request along.
? ? if (stagingBuffer == NULL || stagingMdl == NULL)
? ? {
? ? ? ? if (stagingBuffer != NULL)
? ? ? ? ? ? ExFreePool(stagingBuffer);
? ? ? ? Irp->MdlAddress = originalMdl;
? ? ? ? *nextSp = *currentSp;
? ? ? ? ntStatus = IoCallDriver(filterExtension->TargetDevice, Irp);
? ? ? ? return (ntStatus);
? ? }
? ? // Required for mapping non-pagged pool memory to an MDL.
? ? MmBuildMdlForNonPagedPool(stagingMdl);
? ? // Swap the MDL in the IRP with the one we created.
? ? Irp->MdlAddress = stagingMdl;
? ? // Copy current stack to next stack.
? ? *nextSp = *currentSp;
? ? // Switch the MDL back in the completion routine
? ? IoSetCompletionRoutine
? ? (
? ? ? ? Irp,
? ? ? ? WriteCompletion,
? ? ? ? originalMdl,
? ? ? ? TRUE,
? ? ? ? TRUE,
? ? ? ? TRUE
? ? );
? ? // Call driver below us.
? ? ntStatus = IoCallDriver(TargetDevice, Irp);
? ? return (ntStatus);
Completion code:
? ? // Initialize pointers to the MDLs.
? ? stagingMdl = Irp->MdlAddress;
? ? originalMdl = OriginalMdl;
? ? // Initialize pointers to the I/O buffers
? ? stagingBuffer = MmGetSystemAddressForMdl(stagingMdl);
? ? originalBuffer = MmGetSystemAddressForMdl(originalMdl);
? ? // Restore the original IRP.
? ? Irp->MdlAddress = originalMdl;
? ? IoFreeMdl(stagingMdl);
? ? ExFreePool(stagingBuffer);
Raghwendra


Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17

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

Hi Tony
For the moment i am not playing with UserBuffer as i need to change
only MDL data. When i say not working with .Doc files means, as i assign new
MDL to IRP at IRP_MJ_WRITE, winword.exe got hang for a while and later a
page fault error occurs. Whereas for other txt editor like NotePad, Wordpad
it working smoothly. One point more some times for Winword even it work’s
fine. So actually i am unable to understand this inconsistant behavior of
system.

Since WinWord before saving any file, many times interact with cache using
fastIO calls… so i hope i am not disturbing cache by creating new MDL and
assigning it to IRP and putting back the oriznal MDL at completion routine .

Raghwendra

----- Original Message -----
From: “Tony Mason”
To: “Windows File Systems Devs Interest List”
Sent: Tuesday, July 05, 2005 5:21 PM
Subject: RE: [ntfsd] Swapping Mdl

> You don’t adjust Irp->UserBuffer; this will cause problems whenever the
file is fragmented, regardless of the type of the file. See deviosup.c in
the FAT source code example (look for the use of Irp->UserBuffer.
>
> Since you don’t mention what “not working” means it is a guess as to how
it does not work in your environment.
>
> Since you pass the IRP in the IoAllocateIrp call, it has already been
added to the MDL chain. The way the code is now written this will work, but
it is the kind of thing that will break in the future when someone changes
the code around.
>
> Regards,
>
> Tony
>
> Tony Mason
> Consulting Partner
> OSR Open Systems Resources, Inc.
> http://www.osr.com
>
>
> ________________________________________
> From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]
On Behalf Of Raghwendra
> Sent: Tuesday, July 05, 2005 3:03 AM
> To: ntfsd redirect
> Subject: [ntfsd] Swapping Mdl
>
> Hi All
> I want to swap the MDL buffer into my filter driver. Below is the way i am
doing.
> My this code is working fine for .txt files. But for .Doc it’s sometimes
working sometimes not. Am i missing something. Please suggest.
>
> originalMdl = Irp->MdlAddress;
> stagingBuffer = ExAllocatePool
> (
> NonPagedPoolCacheAligned,
> currentSp->Parameters.Write.Length
> );
> if (stagingBuffer != NULL)
> stagingMdl = IoAllocateMdl
> (
> stagingBuffer,
> currentSp->Parameters.Write.Length,
> FALSE,
> FALSE,
> Irp
> );
> // If there were problems getting memory, just pass the request along.
> if (stagingBuffer == NULL || stagingMdl == NULL)
> {
> if (stagingBuffer != NULL)
> ExFreePool(stagingBuffer);
> Irp->MdlAddress = originalMdl;
> nextSp = currentSp;
> ntStatus = IoCallDriver(filterExtension->TargetDevice, Irp);
> return (ntStatus);
> }
> // Required for mapping non-pagged pool memory to an MDL.
> MmBuildMdlForNonPagedPool(stagingMdl);
> // Swap the MDL in the IRP with the one we created.
> Irp->MdlAddress = stagingMdl;
> // Copy current stack to next stack.
> nextSp = currentSp;
> // Switch the MDL back in the completion routine
> IoSetCompletionRoutine
> (
> Irp,
> WriteCompletion,
> originalMdl,
> TRUE,
> TRUE,
> TRUE
> );
> // Call driver below us.
> ntStatus = IoCallDriver(TargetDevice, Irp);
> return (ntStatus);
> Completion code:
> // Initialize pointers to the MDLs.
> stagingMdl = Irp->MdlAddress;
> originalMdl = OriginalMdl;
> // Initialize pointers to the I/O buffers
> stagingBuffer = MmGetSystemAddressForMdl(stagingMdl);
> originalBuffer = MmGetSystemAddressForMdl(originalMdl);
> // Restore the original IRP.
> Irp->MdlAddress = originalMdl;
> IoFreeMdl(stagingMdl);
> ExFreePool(stagingBuffer);
> Raghwendra
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
> —
> Questions? First check the IFS FAQ at https://www.osronline.com/article.cf
m?id=17
>
> You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>


Disclaimer:
The contents of this E-mail (including the contents of the enclosure(s) or attachment(s) if any) are privileged and confidential material of MBT and should not be disclosed to, used by or copied in any manner by anyone other than the intended addressee(s). In case you are not the desired addressee, you should delete this message and/or re-direct it to the sender. The views expressed in this E-mail message (including the enclosure(s) or attachment(s) if any) are those of the individual sender, except where the sender expressly, and with authority, states them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be free of any virus. However, it is the responsibility of the recipient to ensure that it is virus free and MBT is not responsible for any loss or damage arising in any way from its use

***

I think you misunderstand - I wasn’t talking about the *data contents*
of the user buffer, merely the numeric value that the file system uses
when computing the correct offset when constructing partial MDLs for
fragmented files.

If you don’t update UserBuffer then the underlying file system cannot
properly handle any fragmented files. In general, this can manifest as
I/O operations that never complete or random crashes because the DMA is
done to non-existent pages or it corrupts pages that are already in
memory.

In the IFS Kit see deviosup.c in FastFat (look for IoBuildPartialMdl)
and you can see how it uses Irp->UserBuffer, although it does not use
the data contents of Irp->UserBuffer. If Irp->UserBuffer is not
updated so Irp->UserBuffer == MmGetMdlVirtualAddress(Irp->MdlAddress)
the computation it does to find the correct pages won’t work properly.

My experience is that most DMA controllers do not properly handle DMA to
invalid physical memory addresses, despite the PCI spec requirement that
they do so. That’s generally what leads to the hang situation. The
data corruption occurs when a read is done into a real physical page,
but NOT the one that should be used.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Raghwendra
Sent: Tuesday, July 05, 2005 9:25 AM
To: ntfsd redirect
Subject: Re: [ntfsd] Swapping Mdl

Hi Tony
For the moment i am not playing with UserBuffer as i need to
change
only MDL data. When i say not working with .Doc files means, as i assign
new
MDL to IRP at IRP_MJ_WRITE, winword.exe got hang for a while and later a
page fault error occurs. Whereas for other txt editor like NotePad,
Wordpad
it working smoothly. One point more some times for Winword even it
work’s
fine. So actually i am unable to understand this inconsistant behavior
of
system.

Since WinWord before saving any file, many times interact with cache
using
fastIO calls… so i hope i am not disturbing cache by creating new MDL
and
assigning it to IRP and putting back the oriznal MDL at completion
routine .

Raghwendra

----- Original Message -----
From: “Tony Mason”
To: “Windows File Systems Devs Interest List”
Sent: Tuesday, July 05, 2005 5:21 PM
Subject: RE: [ntfsd] Swapping Mdl

> You don’t adjust Irp->UserBuffer; this will cause problems whenever
the
file is fragmented, regardless of the type of the file. See deviosup.c
in
the FAT source code example (look for the use of Irp->UserBuffer.
>
> Since you don’t mention what “not working” means it is a guess as to
how
it does not work in your environment.
>
> Since you pass the IRP in the IoAllocateIrp call, it has already been
added to the MDL chain. The way the code is now written this will work,
but
it is the kind of thing that will break in the future when someone
changes
the code around.
>
> Regards,
>
> Tony
>
> Tony Mason
> Consulting Partner
> OSR Open Systems Resources, Inc.
> http://www.osr.com
>
>
> ________________________________________
> From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]
On Behalf Of Raghwendra
> Sent: Tuesday, July 05, 2005 3:03 AM
> To: ntfsd redirect
> Subject: [ntfsd] Swapping Mdl
>
> Hi All
> I want to swap the MDL buffer into my filter driver. Below is the way
i am
doing.
> My this code is working fine for .txt files. But for .Doc it’s
sometimes
working sometimes not. Am i missing something. Please suggest.
>
> originalMdl = Irp->MdlAddress;
> stagingBuffer = ExAllocatePool
> (
> NonPagedPoolCacheAligned,
> currentSp->Parameters.Write.Length
> );
> if (stagingBuffer != NULL)
> stagingMdl = IoAllocateMdl
> (
> stagingBuffer,
> currentSp->Parameters.Write.Length,
> FALSE,
> FALSE,
> Irp
> );
> // If there were problems getting memory, just pass the request along.
> if (stagingBuffer == NULL || stagingMdl == NULL)
> {
> if (stagingBuffer != NULL)
> ExFreePool(stagingBuffer);
> Irp->MdlAddress = originalMdl;
> nextSp = currentSp;
> ntStatus = IoCallDriver(filterExtension->TargetDevice, Irp);
> return (ntStatus);
> }
> // Required for mapping non-pagged pool memory to an MDL.
> MmBuildMdlForNonPagedPool(stagingMdl);
> // Swap the MDL in the IRP with the one we created.
> Irp->MdlAddress = stagingMdl;
> // Copy current stack to next stack.
> nextSp = currentSp;
> // Switch the MDL back in the completion routine
> IoSetCompletionRoutine
> (
> Irp,
> WriteCompletion,
> originalMdl,
> TRUE,
> TRUE,
> TRUE
> );
> // Call driver below us.
> ntStatus = IoCallDriver(TargetDevice, Irp);
> return (ntStatus);
> Completion code:
> // Initialize pointers to the MDLs.
> stagingMdl = Irp->MdlAddress;
> originalMdl = OriginalMdl;
> // Initialize pointers to the I/O buffers
> stagingBuffer = MmGetSystemAddressForMdl(stagingMdl);
> originalBuffer = MmGetSystemAddressForMdl(originalMdl);
> // Restore the original IRP.
> Irp->MdlAddress = originalMdl;
> IoFreeMdl(stagingMdl);
> ExFreePool(stagingBuffer);
> Raghwendra
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: unknown lmsubst tag
argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cf
m?id=17
>
> You are currently subscribed to ntfsd as: unknown lmsubst tag
argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>


Disclaimer:
The contents of this E-mail (including the contents of the enclosure(s)
or attachment(s) if any) are privileged and confidential material of MBT
and should not be disclosed to, used by or copied in any manner by
anyone other than the intended addressee(s). In case you are not the
desired addressee, you should delete this message and/or re-direct it to
the sender. The views expressed in this E-mail message (including the
enclosure(s) or attachment(s) if any) are those of the individual
sender, except where the sender expressly, and with authority, states
them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be
free of any virus. However, it is the responsibility of the recipient
to ensure that it is virus free and MBT is not responsible for any loss
or damage arising in any way from its use

***


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Hi Tony,
Thanks for the help. But we don’t have IFS Kit.
What I understand from your explanation is as follows please correct me.

Stage 1:-
// Required for mapping non-pagged pool memory to an MDL.
MmBuildMdlForNonPagedPool(pNewMdl);
Stage 2:-
// Swap the MDL in the IRP with the one we created.
I.m_Irp->MdlAddress = pNewMdl;
Then What you have Suggested ->
I.UserBuffer == MmGetMdlVirtualAddress(I.MdlAddress)

is this the right way you want to say?..

Regards,
Utkarsh S. Dabhade

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Tony Mason
Sent: Tuesday, July 05, 2005 7:37 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Swapping Mdl

I think you misunderstand - I wasn’t talking about the *data contents*
of the user buffer, merely the numeric value that the file system uses
when computing the correct offset when constructing partial MDLs for
fragmented files.

If you don’t update UserBuffer then the underlying file system cannot
properly handle any fragmented files. In general, this can manifest as
I/O operations that never complete or random crashes because the DMA is
done to non-existent pages or it corrupts pages that are already in
memory.

In the IFS Kit see deviosup.c in FastFat (look for IoBuildPartialMdl)
and you can see how it uses Irp->UserBuffer, although it does not use
the data contents of Irp->UserBuffer. If Irp->UserBuffer is not
updated so Irp->UserBuffer == MmGetMdlVirtualAddress(Irp->MdlAddress)
the computation it does to find the correct pages won’t work properly.

My experience is that most DMA controllers do not properly handle DMA to
invalid physical memory addresses, despite the PCI spec requirement that
they do so. That’s generally what leads to the hang situation. The
data corruption occurs when a read is done into a real physical page,
but NOT the one that should be used.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Raghwendra
Sent: Tuesday, July 05, 2005 9:25 AM
To: ntfsd redirect
Subject: Re: [ntfsd] Swapping Mdl

Hi Tony
For the moment i am not playing with UserBuffer as i need to
change
only MDL data. When i say not working with .Doc files means, as i assign
new
MDL to IRP at IRP_MJ_WRITE, winword.exe got hang for a while and later a
page fault error occurs. Whereas for other txt editor like NotePad,
Wordpad
it working smoothly. One point more some times for Winword even it
work’s
fine. So actually i am unable to understand this inconsistant behavior
of
system.

Since WinWord before saving any file, many times interact with cache
using
fastIO calls… so i hope i am not disturbing cache by creating new MDL
and
assigning it to IRP and putting back the oriznal MDL at completion
routine .

Raghwendra

----- Original Message -----
From: “Tony Mason”
To: “Windows File Systems Devs Interest List”
Sent: Tuesday, July 05, 2005 5:21 PM
Subject: RE: [ntfsd] Swapping Mdl

> You don’t adjust Irp->UserBuffer; this will cause problems whenever
the
file is fragmented, regardless of the type of the file. See deviosup.c
in
the FAT source code example (look for the use of Irp->UserBuffer.
>
> Since you don’t mention what “not working” means it is a guess as to
how
it does not work in your environment.
>
> Since you pass the IRP in the IoAllocateIrp call, it has already been
added to the MDL chain. The way the code is now written this will work,
but
it is the kind of thing that will break in the future when someone
changes
the code around.
>
> Regards,
>
> Tony
>
> Tony Mason
> Consulting Partner
> OSR Open Systems Resources, Inc.
> http://www.osr.com
>
>
> ________________________________________
> From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]
On Behalf Of Raghwendra
> Sent: Tuesday, July 05, 2005 3:03 AM
> To: ntfsd redirect
> Subject: [ntfsd] Swapping Mdl
>
> Hi All
> I want to swap the MDL buffer into my filter driver. Below is the way
i am
doing.
> My this code is working fine for .txt files. But for .Doc it’s
sometimes
working sometimes not. Am i missing something. Please suggest.
>
> originalMdl = Irp->MdlAddress;
> stagingBuffer = ExAllocatePool
> (
> NonPagedPoolCacheAligned,
> currentSp->Parameters.Write.Length
> );
> if (stagingBuffer != NULL)
> stagingMdl = IoAllocateMdl
> (
> stagingBuffer,
> currentSp->Parameters.Write.Length,
> FALSE,
> FALSE,
> Irp
> );
> // If there were problems getting memory, just pass the request along.
> if (stagingBuffer == NULL || stagingMdl == NULL)
> {
> if (stagingBuffer != NULL)
> ExFreePool(stagingBuffer);
> Irp->MdlAddress = originalMdl;
> nextSp = currentSp;
> ntStatus = IoCallDriver(filterExtension->TargetDevice, Irp);
> return (ntStatus);
> }
> // Required for mapping non-pagged pool memory to an MDL.
> MmBuildMdlForNonPagedPool(stagingMdl);
> // Swap the MDL in the IRP with the one we created.
> Irp->MdlAddress = stagingMdl;
> // Copy current stack to next stack.
> nextSp = currentSp;
> // Switch the MDL back in the completion routine
> IoSetCompletionRoutine
> (
> Irp,
> WriteCompletion,
> originalMdl,
> TRUE,
> TRUE,
> TRUE
> );
> // Call driver below us.
> ntStatus = IoCallDriver(TargetDevice, Irp);
> return (ntStatus);
> Completion code:
> // Initialize pointers to the MDLs.
> stagingMdl = Irp->MdlAddress;
> originalMdl = OriginalMdl;
> // Initialize pointers to the I/O buffers
> stagingBuffer = MmGetSystemAddressForMdl(stagingMdl);
> originalBuffer = MmGetSystemAddressForMdl(originalMdl);
> // Restore the original IRP.
> Irp->MdlAddress = originalMdl;
> IoFreeMdl(stagingMdl);
> ExFreePool(stagingBuffer);
> Raghwendra
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: unknown lmsubst tag
argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cf
m?id=17
>
> You are currently subscribed to ntfsd as: unknown lmsubst tag
argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>


Disclaimer:
The contents of this E-mail (including the contents of the enclosure(s)
or attachment(s) if any) are privileged and confidential material of MBT
and should not be disclosed to, used by or copied in any manner by
anyone other than the intended addressee(s). In case you are not the
desired addressee, you should delete this message and/or re-direct it to
the sender. The views expressed in this E-mail message (including the
enclosure(s) or attachment(s) if any) are those of the individual
sender, except where the sender expressly, and with authority, states
them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be
free of any virus. However, it is the responsibility of the recipient
to ensure that it is virus free and MBT is not responsible for any loss
or damage arising in any way from its use




Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

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


Disclaimer:
The contents of this E-mail (including the contents of the enclosure(s) or attachment(s) if any) are privileged and confidential material of MBT and should not be disclosed to, used by or copied in any manner by anyone other than the intended addressee(s). In case you are not the desired addressee, you should delete this message and/or re-direct it to the sender. The views expressed in this E-mail message (including the enclosure(s) or attachment(s) if any) are those of the individual sender, except where the sender expressly, and with authority, states them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be free of any virus. However, it is the responsibility of the recipient to ensure that it is virus free and MBT is not responsible for any loss or damage arising in any way from its use

**

Hi Utkarsh,

I would strongly recommend that you obtain the IFS Kit - it will likely
be the most useful US$109 that you ever spend in the file systems
development arena.

Your understanding is correct. When you restore the original MDL, I
would also suggest restoring the UserBuffer (although in many cases it
won’t be used, I generally recommend leaving the system in a consistent
state, in order to encourage interoperability with other filters, for
example).

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Utkarsh DABHADE
Sent: Wednesday, July 06, 2005 2:17 AM
To: ntfsd redirect
Subject: RE: [ntfsd] Swapping Mdl

Hi Tony,
Thanks for the help. But we don’t have IFS Kit.
What I understand from your explanation is as follows please correct me.

Stage 1:-
// Required for mapping non-pagged pool memory to an MDL.
MmBuildMdlForNonPagedPool(pNewMdl);
Stage 2:-
// Swap the MDL in the IRP with the one we created.
I.m_Irp->MdlAddress = pNewMdl;
Then What you have Suggested ->
I.UserBuffer == MmGetMdlVirtualAddress(I.MdlAddress)

is this the right way you want to say?..

Regards,
Utkarsh S. Dabhade

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Tony Mason
Sent: Tuesday, July 05, 2005 7:37 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Swapping Mdl

I think you misunderstand - I wasn’t talking about the *data contents*
of the user buffer, merely the numeric value that the file system uses
when computing the correct offset when constructing partial MDLs for
fragmented files.

If you don’t update UserBuffer then the underlying file system cannot
properly handle any fragmented files. In general, this can manifest as
I/O operations that never complete or random crashes because the DMA is
done to non-existent pages or it corrupts pages that are already in
memory.

In the IFS Kit see deviosup.c in FastFat (look for IoBuildPartialMdl)
and you can see how it uses Irp->UserBuffer, although it does not use
the data contents of Irp->UserBuffer. If Irp->UserBuffer is not
updated so Irp->UserBuffer == MmGetMdlVirtualAddress(Irp->MdlAddress)
the computation it does to find the correct pages won’t work properly.

My experience is that most DMA controllers do not properly handle DMA to
invalid physical memory addresses, despite the PCI spec requirement that
they do so. That’s generally what leads to the hang situation. The
data corruption occurs when a read is done into a real physical page,
but NOT the one that should be used.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Raghwendra
Sent: Tuesday, July 05, 2005 9:25 AM
To: ntfsd redirect
Subject: Re: [ntfsd] Swapping Mdl

Hi Tony
For the moment i am not playing with UserBuffer as i need to
change
only MDL data. When i say not working with .Doc files means, as i assign
new
MDL to IRP at IRP_MJ_WRITE, winword.exe got hang for a while and later a
page fault error occurs. Whereas for other txt editor like NotePad,
Wordpad
it working smoothly. One point more some times for Winword even it
work’s
fine. So actually i am unable to understand this inconsistant behavior
of
system.

Since WinWord before saving any file, many times interact with cache
using
fastIO calls… so i hope i am not disturbing cache by creating new MDL
and
assigning it to IRP and putting back the oriznal MDL at completion
routine .

Raghwendra

----- Original Message -----
From: “Tony Mason”
To: “Windows File Systems Devs Interest List”
Sent: Tuesday, July 05, 2005 5:21 PM
Subject: RE: [ntfsd] Swapping Mdl

> You don’t adjust Irp->UserBuffer; this will cause problems whenever
the
file is fragmented, regardless of the type of the file. See deviosup.c
in
the FAT source code example (look for the use of Irp->UserBuffer.
>
> Since you don’t mention what “not working” means it is a guess as to
how
it does not work in your environment.
>
> Since you pass the IRP in the IoAllocateIrp call, it has already been
added to the MDL chain. The way the code is now written this will work,
but
it is the kind of thing that will break in the future when someone
changes
the code around.
>
> Regards,
>
> Tony
>
> Tony Mason
> Consulting Partner
> OSR Open Systems Resources, Inc.
> http://www.osr.com
>
>
> ________________________________________
> From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]
On Behalf Of Raghwendra
> Sent: Tuesday, July 05, 2005 3:03 AM
> To: ntfsd redirect
> Subject: [ntfsd] Swapping Mdl
>
> Hi All
> I want to swap the MDL buffer into my filter driver. Below is the way
i am
doing.
> My this code is working fine for .txt files. But for .Doc it’s
sometimes
working sometimes not. Am i missing something. Please suggest.
>
> originalMdl = Irp->MdlAddress;
> stagingBuffer = ExAllocatePool
> (
> NonPagedPoolCacheAligned,
> currentSp->Parameters.Write.Length
> );
> if (stagingBuffer != NULL)
> stagingMdl = IoAllocateMdl
> (
> stagingBuffer,
> currentSp->Parameters.Write.Length,
> FALSE,
> FALSE,
> Irp
> );
> // If there were problems getting memory, just pass the request along.
> if (stagingBuffer == NULL || stagingMdl == NULL)
> {
> if (stagingBuffer != NULL)
> ExFreePool(stagingBuffer);
> Irp->MdlAddress = originalMdl;
> nextSp = currentSp;
> ntStatus = IoCallDriver(filterExtension->TargetDevice, Irp);
> return (ntStatus);
> }
> // Required for mapping non-pagged pool memory to an MDL.
> MmBuildMdlForNonPagedPool(stagingMdl);
> // Swap the MDL in the IRP with the one we created.
> Irp->MdlAddress = stagingMdl;
> // Copy current stack to next stack.
> nextSp = currentSp;
> // Switch the MDL back in the completion routine
> IoSetCompletionRoutine
> (
> Irp,
> WriteCompletion,
> originalMdl,
> TRUE,
> TRUE,
> TRUE
> );
> // Call driver below us.
> ntStatus = IoCallDriver(TargetDevice, Irp);
> return (ntStatus);
> Completion code:
> // Initialize pointers to the MDLs.
> stagingMdl = Irp->MdlAddress;
> originalMdl = OriginalMdl;
> // Initialize pointers to the I/O buffers
> stagingBuffer = MmGetSystemAddressForMdl(stagingMdl);
> originalBuffer = MmGetSystemAddressForMdl(originalMdl);
> // Restore the original IRP.
> Irp->MdlAddress = originalMdl;
> IoFreeMdl(stagingMdl);
> ExFreePool(stagingBuffer);
> Raghwendra
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: unknown lmsubst tag
argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cf
m?id=17
>
> You are currently subscribed to ntfsd as: unknown lmsubst tag
argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>


Disclaimer:
The contents of this E-mail (including the contents of the enclosure(s)
or attachment(s) if any) are privileged and confidential material of MBT
and should not be disclosed to, used by or copied in any manner by
anyone other than the intended addressee(s). In case you are not the
desired addressee, you should delete this message and/or re-direct it to
the sender. The views expressed in this E-mail message (including the
enclosure(s) or attachment(s) if any) are those of the individual
sender, except where the sender expressly, and with authority, states
them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be
free of any virus. However, it is the responsibility of the recipient
to ensure that it is virus free and MBT is not responsible for any loss
or damage arising in any way from its use




Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

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


Disclaimer:
The contents of this E-mail (including the contents of the enclosure(s)
or attachment(s) if any) are privileged and confidential material of MBT
and should not be disclosed to, used by or copied in any manner by
anyone other than the intended addressee(s). In case you are not the
desired addressee, you should delete this message and/or re-direct it to
the sender. The views expressed in this E-mail message (including the
enclosure(s) or attachment(s) if any) are those of the individual
sender, except where the sender expressly, and with authority, states
them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be
free of any virus. However, it is the responsibility of the recipient
to ensure that it is virus free and MBT is not responsible for any loss
or damage arising in any way from its use

**


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

If you don’t have the IFS Kit why even post in this newsgroup? You must
have the tools that are required. Many of the memory manager and cache
manager calls are only documented in that kit. With Longhorn it will be
included with the WDK, but it will still require some money as the current
DDK can be ordered for about $15 dollars. If you have a lot of money, it
will also come with the $11,000 MSDN subscription, but very few will need
that subscription where the renewal is $3500 per year.

“Utkarsh DABHADE” wrote in message
news:xxxxx@ntfsd…
>
> Hi Tony,
> Thanks for the help. But we don’t have IFS Kit.
> What I understand from your explanation is as follows please correct me.
>
> Stage 1:-
> // Required for mapping non-pagged pool memory to an MDL.
> MmBuildMdlForNonPagedPool(pNewMdl);
> Stage 2:-
> // Swap the MDL in the IRP with the one we created.
> I.m_Irp->MdlAddress = pNewMdl;
> Then What you have Suggested ->
> I.UserBuffer == MmGetMdlVirtualAddress(I.MdlAddress)
>
> is this the right way you want to say?..
>
>
> Regards,
> Utkarsh S. Dabhade
>
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]On Behalf Of Tony Mason
> Sent: Tuesday, July 05, 2005 7:37 PM
> To: Windows File Systems Devs Interest List
> Subject: RE: [ntfsd] Swapping Mdl
>
>
> I think you misunderstand - I wasn’t talking about the data contents
> of the user buffer, merely the numeric value that the file system uses
> when computing the correct offset when constructing partial MDLs for
> fragmented files.
>
> If you don’t update UserBuffer then the underlying file system cannot
> properly handle any fragmented files. In general, this can manifest as
> I/O operations that never complete or random crashes because the DMA is
> done to non-existent pages or it corrupts pages that are already in
> memory.
>
> In the IFS Kit see deviosup.c in FastFat (look for IoBuildPartialMdl)
> and you can see how it uses Irp->UserBuffer, although it does not use
> the data contents of Irp->UserBuffer. If Irp->UserBuffer is not
> updated so Irp->UserBuffer == MmGetMdlVirtualAddress(Irp->MdlAddress)
> the computation it does to find the correct pages won’t work properly.
>
> My experience is that most DMA controllers do not properly handle DMA to
> invalid physical memory addresses, despite the PCI spec requirement that
> they do so. That’s generally what leads to the hang situation. The
> data corruption occurs when a read is done into a real physical page,
> but NOT the one that should be used.
>
> Regards,
>
> Tony
>
> Tony Mason
> Consulting Partner
> OSR Open Systems Resources, Inc.
> http://www.osr.com
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Raghwendra
> Sent: Tuesday, July 05, 2005 9:25 AM
> To: ntfsd redirect
> Subject: Re: [ntfsd] Swapping Mdl
>
>
> Hi Tony
> For the moment i am not playing with UserBuffer as i need to
> change
> only MDL data. When i say not working with .Doc files means, as i assign
> new
> MDL to IRP at IRP_MJ_WRITE, winword.exe got hang for a while and later a
> page fault error occurs. Whereas for other txt editor like NotePad,
> Wordpad
> it working smoothly. One point more some times for Winword even it
> work’s
> fine. So actually i am unable to understand this inconsistant behavior
> of
> system.
>
> Since WinWord before saving any file, many times interact with cache
> using
> fastIO calls… so i hope i am not disturbing cache by creating new MDL
> and
> assigning it to IRP and putting back the oriznal MDL at completion
> routine .
>
> Raghwendra
>
> ----- Original Message -----
> From: “Tony Mason”
> To: “Windows File Systems Devs Interest List”
> Sent: Tuesday, July 05, 2005 5:21 PM
> Subject: RE: [ntfsd] Swapping Mdl
>
>
>> You don’t adjust Irp->UserBuffer; this will cause problems whenever
> the
> file is fragmented, regardless of the type of the file. See deviosup.c
> in
> the FAT source code example (look for the use of Irp->UserBuffer.
>>
>> Since you don’t mention what “not working” means it is a guess as to
> how
> it does not work in your environment.
>>
>> Since you pass the IRP in the IoAllocateIrp call, it has already been
> added to the MDL chain. The way the code is now written this will work,
> but
> it is the kind of thing that will break in the future when someone
> changes
> the code around.
>>
>> Regards,
>>
>> Tony
>>
>> Tony Mason
>> Consulting Partner
>> OSR Open Systems Resources, Inc.
>> http://www.osr.com
>>
>>
>> ________________________________________
>> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]
> On Behalf Of Raghwendra
>> Sent: Tuesday, July 05, 2005 3:03 AM
>> To: ntfsd redirect
>> Subject: [ntfsd] Swapping Mdl
>>
>> Hi All
>> I want to swap the MDL buffer into my filter driver. Below is the way
> i am
> doing.
>> My this code is working fine for .txt files. But for .Doc it’s
> sometimes
> working sometimes not. Am i missing something. Please suggest.
>>
>> originalMdl = Irp->MdlAddress;
>> stagingBuffer = ExAllocatePool
>> (
>> NonPagedPoolCacheAligned,
>> currentSp->Parameters.Write.Length
>> );
>> if (stagingBuffer != NULL)
>> stagingMdl = IoAllocateMdl
>> (
>> stagingBuffer,
>> currentSp->Parameters.Write.Length,
>> FALSE,
>> FALSE,
>> Irp
>> );
>> // If there were problems getting memory, just pass the request along.
>> if (stagingBuffer == NULL || stagingMdl == NULL)
>> {
>> if (stagingBuffer != NULL)
>> ExFreePool(stagingBuffer);
>> Irp->MdlAddress = originalMdl;
>> *nextSp = *currentSp;
>> ntStatus = IoCallDriver(filterExtension->TargetDevice, Irp);
>> return (ntStatus);
>> }
>> // Required for mapping non-pagged pool memory to an MDL.
>> MmBuildMdlForNonPagedPool(stagingMdl);
>> // Swap the MDL in the IRP with the one we created.
>> Irp->MdlAddress = stagingMdl;
>> // Copy current stack to next stack.
>> *nextSp = *currentSp;
>> // Switch the MDL back in the completion routine
>> IoSetCompletionRoutine
>> (
>> Irp,
>> WriteCompletion,
>> originalMdl,
>> TRUE,
>> TRUE,
>> TRUE
>> );
>> // Call driver below us.
>> ntStatus = IoCallDriver(TargetDevice, Irp);
>> return (ntStatus);
>> Completion code:
>> // Initialize pointers to the MDLs.
>> stagingMdl = Irp->MdlAddress;
>> originalMdl = OriginalMdl;
>> // Initialize pointers to the I/O buffers
>> stagingBuffer = MmGetSystemAddressForMdl(stagingMdl);
>> originalBuffer = MmGetSystemAddressForMdl(originalMdl);
>> // Restore the original IRP.
>> Irp->MdlAddress = originalMdl;
>> IoFreeMdl(stagingMdl);
>> ExFreePool(stagingBuffer);
>> Raghwendra
>>
>> —
>> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>>
>> You are currently subscribed to ntfsd as: unknown lmsubst tag
> argument: ‘’
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>>
>> —
>> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cf
> m?id=17
>>
>> You are currently subscribed to ntfsd as: unknown lmsubst tag
> argument: ‘’
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>>
>
>
> *
> Disclaimer:
> The contents of this E-mail (including the contents of the enclosure(s)
> or attachment(s) if any) are privileged and confidential material of MBT
> and should not be disclosed to, used by or copied in any manner by
> anyone other than the intended addressee(s). In case you are not the
> desired addressee, you should delete this message and/or re-direct it to
> the sender. The views expressed in this E-mail message (including the
> enclosure(s) or attachment(s) if any) are those of the individual
> sender, except where the sender expressly, and with authority, states
> them to be the views of MBT.
>
> This e-mail message including attachment/(s), if any, is believed to be
> free of any virus. However, it is the responsibility of the recipient
> to ensure that it is virus free and MBT is not responsible for any loss
> or damage arising in any way from its use
>
>

>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@osr.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> *
> Disclaimer:
> The contents of this E-mail (including the contents of the enclosure(s) or
> attachment(s) if any) are privileged and confidential material of MBT and
> should not be disclosed to, used by or copied in any manner by anyone
> other than the intended addressee(s). In case you are not the desired
> addressee, you should delete this message and/or re-direct it to the
> sender. The views expressed in this E-mail message (including the
> enclosure(s) or attachment(s) if any) are those of the individual sender,
> except where the sender expressly, and with authority, states them to be
> the views of MBT.
>
> This e-mail message including attachment/(s), if any, is believed to be
> free of any virus. However, it is the responsibility of the recipient to
> ensure that it is virus free and MBT is not responsible for any loss or
> damage arising in any way from its use
>
>

>

Hi Tony,
Thanks for Valuable Help. IFS Kit is Really only US 109$.
If So please guide me where we can by this in same price. I might have wrong
information about price.

Regards,
Utkarsh S. Dabhade

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Tony Mason
Sent: Wednesday, July 06, 2005 11:56 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Swapping Mdl

Hi Utkarsh,

I would strongly recommend that you obtain the IFS Kit - it will likely
be the most useful US$109 that you ever spend in the file systems
development arena.

Your understanding is correct. When you restore the original MDL, I
would also suggest restoring the UserBuffer (although in many cases it
won’t be used, I generally recommend leaving the system in a consistent
state, in order to encourage interoperability with other filters, for
example).

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Utkarsh DABHADE
Sent: Wednesday, July 06, 2005 2:17 AM
To: ntfsd redirect
Subject: RE: [ntfsd] Swapping Mdl

Hi Tony,
Thanks for the help. But we don’t have IFS Kit.
What I understand from your explanation is as follows please correct me.

Stage 1:-
// Required for mapping non-pagged pool memory to an MDL.
MmBuildMdlForNonPagedPool(pNewMdl);
Stage 2:-
// Swap the MDL in the IRP with the one we created.
I.m_Irp->MdlAddress = pNewMdl;
Then What you have Suggested ->
I.UserBuffer == MmGetMdlVirtualAddress(I.MdlAddress)

is this the right way you want to say?..

Regards,
Utkarsh S. Dabhade

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Tony Mason
Sent: Tuesday, July 05, 2005 7:37 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Swapping Mdl

I think you misunderstand - I wasn’t talking about the *data contents*
of the user buffer, merely the numeric value that the file system uses
when computing the correct offset when constructing partial MDLs for
fragmented files.

If you don’t update UserBuffer then the underlying file system cannot
properly handle any fragmented files. In general, this can manifest as
I/O operations that never complete or random crashes because the DMA is
done to non-existent pages or it corrupts pages that are already in
memory.

In the IFS Kit see deviosup.c in FastFat (look for IoBuildPartialMdl)
and you can see how it uses Irp->UserBuffer, although it does not use
the data contents of Irp->UserBuffer. If Irp->UserBuffer is not
updated so Irp->UserBuffer == MmGetMdlVirtualAddress(Irp->MdlAddress)
the computation it does to find the correct pages won’t work properly.

My experience is that most DMA controllers do not properly handle DMA to
invalid physical memory addresses, despite the PCI spec requirement that
they do so. That’s generally what leads to the hang situation. The
data corruption occurs when a read is done into a real physical page,
but NOT the one that should be used.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Raghwendra
Sent: Tuesday, July 05, 2005 9:25 AM
To: ntfsd redirect
Subject: Re: [ntfsd] Swapping Mdl

Hi Tony
For the moment i am not playing with UserBuffer as i need to
change
only MDL data. When i say not working with .Doc files means, as i assign
new
MDL to IRP at IRP_MJ_WRITE, winword.exe got hang for a while and later a
page fault error occurs. Whereas for other txt editor like NotePad,
Wordpad
it working smoothly. One point more some times for Winword even it
work’s
fine. So actually i am unable to understand this inconsistant behavior
of
system.

Since WinWord before saving any file, many times interact with cache
using
fastIO calls… so i hope i am not disturbing cache by creating new MDL
and
assigning it to IRP and putting back the oriznal MDL at completion
routine .

Raghwendra

----- Original Message -----
From: “Tony Mason”
To: “Windows File Systems Devs Interest List”
Sent: Tuesday, July 05, 2005 5:21 PM
Subject: RE: [ntfsd] Swapping Mdl

> You don’t adjust Irp->UserBuffer; this will cause problems whenever
the
file is fragmented, regardless of the type of the file. See deviosup.c
in
the FAT source code example (look for the use of Irp->UserBuffer.
>
> Since you don’t mention what “not working” means it is a guess as to
how
it does not work in your environment.
>
> Since you pass the IRP in the IoAllocateIrp call, it has already been
added to the MDL chain. The way the code is now written this will work,
but
it is the kind of thing that will break in the future when someone
changes
the code around.
>
> Regards,
>
> Tony
>
> Tony Mason
> Consulting Partner
> OSR Open Systems Resources, Inc.
> http://www.osr.com
>
>
> ________________________________________
> From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]
On Behalf Of Raghwendra
> Sent: Tuesday, July 05, 2005 3:03 AM
> To: ntfsd redirect
> Subject: [ntfsd] Swapping Mdl
>
> Hi All
> I want to swap the MDL buffer into my filter driver. Below is the way
i am
doing.
> My this code is working fine for .txt files. But for .Doc it’s
sometimes
working sometimes not. Am i missing something. Please suggest.
>
> originalMdl = Irp->MdlAddress;
> stagingBuffer = ExAllocatePool
> (
> NonPagedPoolCacheAligned,
> currentSp->Parameters.Write.Length
> );
> if (stagingBuffer != NULL)
> stagingMdl = IoAllocateMdl
> (
> stagingBuffer,
> currentSp->Parameters.Write.Length,
> FALSE,
> FALSE,
> Irp
> );
> // If there were problems getting memory, just pass the request along.
> if (stagingBuffer == NULL || stagingMdl == NULL)
> {
> if (stagingBuffer != NULL)
> ExFreePool(stagingBuffer);
> Irp->MdlAddress = originalMdl;
> nextSp = currentSp;
> ntStatus = IoCallDriver(filterExtension->TargetDevice, Irp);
> return (ntStatus);
> }
> // Required for mapping non-pagged pool memory to an MDL.
> MmBuildMdlForNonPagedPool(stagingMdl);
> // Swap the MDL in the IRP with the one we created.
> Irp->MdlAddress = stagingMdl;
> // Copy current stack to next stack.
> nextSp = currentSp;
> // Switch the MDL back in the completion routine
> IoSetCompletionRoutine
> (
> Irp,
> WriteCompletion,
> originalMdl,
> TRUE,
> TRUE,
> TRUE
> );
> // Call driver below us.
> ntStatus = IoCallDriver(TargetDevice, Irp);
> return (ntStatus);
> Completion code:
> // Initialize pointers to the MDLs.
> stagingMdl = Irp->MdlAddress;
> originalMdl = OriginalMdl;
> // Initialize pointers to the I/O buffers
> stagingBuffer = MmGetSystemAddressForMdl(stagingMdl);
> originalBuffer = MmGetSystemAddressForMdl(originalMdl);
> // Restore the original IRP.
> Irp->MdlAddress = originalMdl;
> IoFreeMdl(stagingMdl);
> ExFreePool(stagingBuffer);
> Raghwendra
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: unknown lmsubst tag
argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cf
m?id=17
>
> You are currently subscribed to ntfsd as: unknown lmsubst tag
argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>


Disclaimer:
The contents of this E-mail (including the contents of the enclosure(s)
or attachment(s) if any) are privileged and confidential material of MBT
and should not be disclosed to, used by or copied in any manner by
anyone other than the intended addressee(s). In case you are not the
desired addressee, you should delete this message and/or re-direct it to
the sender. The views expressed in this E-mail message (including the
enclosure(s) or attachment(s) if any) are those of the individual
sender, except where the sender expressly, and with authority, states
them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be
free of any virus. However, it is the responsibility of the recipient
to ensure that it is virus free and MBT is not responsible for any loss
or damage arising in any way from its use




Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

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


Disclaimer:
The contents of this E-mail (including the contents of the enclosure(s)
or attachment(s) if any) are privileged and confidential material of MBT
and should not be disclosed to, used by or copied in any manner by
anyone other than the intended addressee(s). In case you are not the
desired addressee, you should delete this message and/or re-direct it to
the sender. The views expressed in this E-mail message (including the
enclosure(s) or attachment(s) if any) are those of the individual
sender, except where the sender expressly, and with authority, states
them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be
free of any virus. However, it is the responsibility of the recipient
to ensure that it is virus free and MBT is not responsible for any loss
or damage arising in any way from its use




Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

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


Disclaimer:
The contents of this E-mail (including the contents of the enclosure(s) or attachment(s) if any) are privileged and confidential material of MBT and should not be disclosed to, used by or copied in any manner by anyone other than the intended addressee(s). In case you are not the desired addressee, you should delete this message and/or re-direct it to the sender. The views expressed in this E-mail message (including the enclosure(s) or attachment(s) if any) are those of the individual sender, except where the sender expressly, and with authority, states them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be free of any virus. However, it is the responsibility of the recipient to ensure that it is virus free and MBT is not responsible for any loss or damage arising in any way from its use

*

Utkarsh,

Search is your friend!

http://www.microsoft.com/whdc/devtools/ifskit/ServerIFSKitOrderinfo.mspx

Regards

Ben Curley

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Utkarsh DABHADE
Sent: 06 July 2005 08:58
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Swapping Mdl

Hi Tony,
Thanks for Valuable Help. IFS Kit is Really only US 109$.
If So please guide me where we can by this in same price. I might have
wrong information about price.

Regards,
Utkarsh S. Dabhade

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Tony Mason
Sent: Wednesday, July 06, 2005 11:56 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Swapping Mdl

Hi Utkarsh,

I would strongly recommend that you obtain the IFS Kit - it will likely
be the most useful US$109 that you ever spend in the file systems
development arena.

Your understanding is correct. When you restore the original MDL, I
would also suggest restoring the UserBuffer (although in many cases it
won’t be used, I generally recommend leaving the system in a consistent
state, in order to encourage interoperability with other filters, for
example).

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Utkarsh DABHADE
Sent: Wednesday, July 06, 2005 2:17 AM
To: ntfsd redirect
Subject: RE: [ntfsd] Swapping Mdl

Hi Tony,
Thanks for the help. But we don’t have IFS Kit.
What I understand from your explanation is as follows please correct me.

Stage 1:-
// Required for mapping non-pagged pool memory to an MDL.
MmBuildMdlForNonPagedPool(pNewMdl);
Stage 2:-
// Swap the MDL in the IRP with the one we created.
I.m_Irp->MdlAddress = pNewMdl;
Then What you have Suggested ->
I.UserBuffer == MmGetMdlVirtualAddress(I.MdlAddress)

is this the right way you want to say?..

Regards,
Utkarsh S. Dabhade

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Tony Mason
Sent: Tuesday, July 05, 2005 7:37 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Swapping Mdl

I think you misunderstand - I wasn’t talking about the *data contents*
of the user buffer, merely the numeric value that the file system uses
when computing the correct offset when constructing partial MDLs for
fragmented files.

If you don’t update UserBuffer then the underlying file system cannot
properly handle any fragmented files. In general, this can manifest as
I/O operations that never complete or random crashes because the DMA is
done to non-existent pages or it corrupts pages that are already in
memory.

In the IFS Kit see deviosup.c in FastFat (look for IoBuildPartialMdl)
and you can see how it uses Irp->UserBuffer, although it does not use
the data contents of Irp->UserBuffer. If Irp->UserBuffer is not
updated so Irp->UserBuffer == MmGetMdlVirtualAddress(Irp->MdlAddress)
the computation it does to find the correct pages won’t work properly.

My experience is that most DMA controllers do not properly handle DMA to
invalid physical memory addresses, despite the PCI spec requirement that
they do so. That’s generally what leads to the hang situation. The
data corruption occurs when a read is done into a real physical page,
but NOT the one that should be used.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Raghwendra
Sent: Tuesday, July 05, 2005 9:25 AM
To: ntfsd redirect
Subject: Re: [ntfsd] Swapping Mdl

Hi Tony
For the moment i am not playing with UserBuffer as i need to
change only MDL data. When i say not working with .Doc files means, as i
assign new MDL to IRP at IRP_MJ_WRITE, winword.exe got hang for a while
and later a page fault error occurs. Whereas for other txt editor like
NotePad, Wordpad it working smoothly. One point more some times for
Winword even it work’s fine. So actually i am unable to understand this
inconsistant behavior of system.

Since WinWord before saving any file, many times interact with cache
using fastIO calls… so i hope i am not disturbing cache by creating
new MDL and assigning it to IRP and putting back the oriznal MDL at
completion routine .

Raghwendra

----- Original Message -----
From: “Tony Mason”
To: “Windows File Systems Devs Interest List”
Sent: Tuesday, July 05, 2005 5:21 PM
Subject: RE: [ntfsd] Swapping Mdl

> You don’t adjust Irp->UserBuffer; this will cause problems whenever
the
file is fragmented, regardless of the type of the file. See deviosup.c
in the FAT source code example (look for the use of Irp->UserBuffer.
>
> Since you don’t mention what “not working” means it is a guess as to
how
it does not work in your environment.
>
> Since you pass the IRP in the IoAllocateIrp call, it has already been
added to the MDL chain. The way the code is now written this will work,
but it is the kind of thing that will break in the future when someone
changes the code around.
>
> Regards,
>
> Tony
>
> Tony Mason
> Consulting Partner
> OSR Open Systems Resources, Inc.
> http://www.osr.com
>
>
> ________________________________________
> From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]
On Behalf Of Raghwendra
> Sent: Tuesday, July 05, 2005 3:03 AM
> To: ntfsd redirect
> Subject: [ntfsd] Swapping Mdl
>
> Hi All
> I want to swap the MDL buffer into my filter driver. Below is the way
i am
doing.
> My this code is working fine for .txt files. But for .Doc it’s
sometimes
working sometimes not. Am i missing something. Please suggest.
>
> originalMdl = Irp->MdlAddress;
> stagingBuffer = ExAllocatePool
> (
> NonPagedPoolCacheAligned,
> currentSp->Parameters.Write.Length
> );
> if (stagingBuffer != NULL)
> stagingMdl = IoAllocateMdl
> (
> stagingBuffer,
> currentSp->Parameters.Write.Length,
> FALSE,
> FALSE,
> Irp
> );
> // If there were problems getting memory, just pass the request along.
> if (stagingBuffer == NULL || stagingMdl == NULL) { if (stagingBuffer
> != NULL) ExFreePool(stagingBuffer);
> Irp->MdlAddress = originalMdl;
> nextSp = currentSp;
> ntStatus = IoCallDriver(filterExtension->TargetDevice, Irp); return
> (ntStatus); } // Required for mapping non-pagged pool memory to an
> MDL.
> MmBuildMdlForNonPagedPool(stagingMdl);
> // Swap the MDL in the IRP with the one we created.
> Irp->MdlAddress = stagingMdl;
> // Copy current stack to next stack.
> nextSp = currentSp;
> // Switch the MDL back in the completion routine
> IoSetCompletionRoutine ( Irp, WriteCompletion, originalMdl, TRUE,
> TRUE, TRUE ); // Call driver below us.
> ntStatus = IoCallDriver(TargetDevice, Irp); return (ntStatus);
> Completion code:
> // Initialize pointers to the MDLs.
> stagingMdl = Irp->MdlAddress;
> originalMdl = OriginalMdl;
> // Initialize pointers to the I/O buffers stagingBuffer =
> MmGetSystemAddressForMdl(stagingMdl);
> originalBuffer = MmGetSystemAddressForMdl(originalMdl);
> // Restore the original IRP.
> Irp->MdlAddress = originalMdl;
> IoFreeMdl(stagingMdl);
> ExFreePool(stagingBuffer);
> Raghwendra
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: unknown lmsubst tag
argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cf
m?id=17
>
> You are currently subscribed to ntfsd as: unknown lmsubst tag
argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>


Disclaimer:
The contents of this E-mail (including the contents of the enclosure(s)
or attachment(s) if any) are privileged and confidential material of MBT
and should not be disclosed to, used by or copied in any manner by
anyone other than the intended addressee(s). In case you are not the
desired addressee, you should delete this message and/or re-direct it to
the sender. The views expressed in this E-mail message (including the
enclosure(s) or attachment(s) if any) are those of the individual
sender, except where the sender expressly, and with authority, states
them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be
free of any virus. However, it is the responsibility of the recipient
to ensure that it is virus free and MBT is not responsible for any loss
or damage arising in any way from its use




Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com To unsubscribe
send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

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


Disclaimer:
The contents of this E-mail (including the contents of the enclosure(s)
or attachment(s) if any) are privileged and confidential material of MBT
and should not be disclosed to, used by or copied in any manner by
anyone other than the intended addressee(s). In case you are not the
desired addressee, you should delete this message and/or re-direct it to
the sender. The views expressed in this E-mail message (including the
enclosure(s) or attachment(s) if any) are those of the individual
sender, except where the sender expressly, and with authority, states
them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be
free of any virus. However, it is the responsibility of the recipient
to ensure that it is virus free and MBT is not responsible for any loss
or damage arising in any way from its use




Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com To unsubscribe
send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

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


Disclaimer:
The contents of this E-mail (including the contents of the enclosure(s)
or attachment(s) if any) are privileged and confidential material of MBT
and should not be disclosed to, used by or copied in any manner by
anyone other than the intended addressee(s). In case you are not the
desired addressee, you should delete this message and/or re-direct it to
the sender. The views expressed in this E-mail message (including the
enclosure(s) or attachment(s) if any) are those of the individual
sender, except where the sender expressly, and with authority, states
them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be
free of any virus. However, it is the responsibility of the recipient
to ensure that it is virus free and MBT is not responsible for any loss
or damage arising in any way from its use

*


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@des.co.uk To unsubscribe
send a blank email to xxxxx@lists.osr.com

Hi Tony
Thanx very much for your suggesstion. It’s working very fine for us
now.

Raghwendra
----- Original Message -----
From: “Tony Mason”
To: “Windows File Systems Devs Interest List”
Sent: Wednesday, July 06, 2005 11:55 AM
Subject: RE: [ntfsd] Swapping Mdl

> Hi Utkarsh,
>
> I would strongly recommend that you obtain the IFS Kit - it will likely
> be the most useful US$109 that you ever spend in the file systems
> development arena.
>
> Your understanding is correct. When you restore the original MDL, I
> would also suggest restoring the UserBuffer (although in many cases it
> won’t be used, I generally recommend leaving the system in a consistent
> state, in order to encourage interoperability with other filters, for
> example).
>
> Regards,
>
> Tony
>
> Tony Mason
> Consulting Partner
> OSR Open Systems Resources, Inc.
> http://www.osr.com
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Utkarsh DABHADE
> Sent: Wednesday, July 06, 2005 2:17 AM
> To: ntfsd redirect
> Subject: RE: [ntfsd] Swapping Mdl
>
>
> Hi Tony,
> Thanks for the help. But we don’t have IFS Kit.
> What I understand from your explanation is as follows please correct me.
>
> Stage 1:-
> // Required for mapping non-pagged pool memory to an MDL.
> MmBuildMdlForNonPagedPool(pNewMdl);
> Stage 2:-
> // Swap the MDL in the IRP with the one we created.
> I.m_Irp->MdlAddress = pNewMdl;
> Then What you have Suggested ->
> I.UserBuffer == MmGetMdlVirtualAddress(I.MdlAddress)
>
> is this the right way you want to say?..
>
>
> Regards,
> Utkarsh S. Dabhade
>
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]On Behalf Of Tony Mason
> Sent: Tuesday, July 05, 2005 7:37 PM
> To: Windows File Systems Devs Interest List
> Subject: RE: [ntfsd] Swapping Mdl
>
>
> I think you misunderstand - I wasn’t talking about the data contents
> of the user buffer, merely the numeric value that the file system uses
> when computing the correct offset when constructing partial MDLs for
> fragmented files.
>
> If you don’t update UserBuffer then the underlying file system cannot
> properly handle any fragmented files. In general, this can manifest as
> I/O operations that never complete or random crashes because the DMA is
> done to non-existent pages or it corrupts pages that are already in
> memory.
>
> In the IFS Kit see deviosup.c in FastFat (look for IoBuildPartialMdl)
> and you can see how it uses Irp->UserBuffer, although it does not use
> the data contents of Irp->UserBuffer. If Irp->UserBuffer is not
> updated so Irp->UserBuffer == MmGetMdlVirtualAddress(Irp->MdlAddress)
> the computation it does to find the correct pages won’t work properly.
>
> My experience is that most DMA controllers do not properly handle DMA to
> invalid physical memory addresses, despite the PCI spec requirement that
> they do so. That’s generally what leads to the hang situation. The
> data corruption occurs when a read is done into a real physical page,
> but NOT the one that should be used.
>
> Regards,
>
> Tony
>
> Tony Mason
> Consulting Partner
> OSR Open Systems Resources, Inc.
> http://www.osr.com
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Raghwendra
> Sent: Tuesday, July 05, 2005 9:25 AM
> To: ntfsd redirect
> Subject: Re: [ntfsd] Swapping Mdl
>
>
> Hi Tony
> For the moment i am not playing with UserBuffer as i need to
> change
> only MDL data. When i say not working with .Doc files means, as i assign
> new
> MDL to IRP at IRP_MJ_WRITE, winword.exe got hang for a while and later a
> page fault error occurs. Whereas for other txt editor like NotePad,
> Wordpad
> it working smoothly. One point more some times for Winword even it
> work’s
> fine. So actually i am unable to understand this inconsistant behavior
> of
> system.
>
> Since WinWord before saving any file, many times interact with cache
> using
> fastIO calls… so i hope i am not disturbing cache by creating new MDL
> and
> assigning it to IRP and putting back the oriznal MDL at completion
> routine .
>
> Raghwendra
>
> ----- Original Message -----
> From: “Tony Mason”
> To: “Windows File Systems Devs Interest List”
> Sent: Tuesday, July 05, 2005 5:21 PM
> Subject: RE: [ntfsd] Swapping Mdl
>
>
> > You don’t adjust Irp->UserBuffer; this will cause problems whenever
> the
> file is fragmented, regardless of the type of the file. See deviosup.c
> in
> the FAT source code example (look for the use of Irp->UserBuffer.
> >
> > Since you don’t mention what “not working” means it is a guess as to
> how
> it does not work in your environment.
> >
> > Since you pass the IRP in the IoAllocateIrp call, it has already been
> added to the MDL chain. The way the code is now written this will work,
> but
> it is the kind of thing that will break in the future when someone
> changes
> the code around.
> >
> > Regards,
> >
> > Tony
> >
> > Tony Mason
> > Consulting Partner
> > OSR Open Systems Resources, Inc.
> > http://www.osr.com
> >
> >
> > ________________________________________
> > From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]
> On Behalf Of Raghwendra
> > Sent: Tuesday, July 05, 2005 3:03 AM
> > To: ntfsd redirect
> > Subject: [ntfsd] Swapping Mdl
> >
> > Hi All
> > I want to swap the MDL buffer into my filter driver. Below is the way
> i am
> doing.
> > My this code is working fine for .txt files. But for .Doc it’s
> sometimes
> working sometimes not. Am i missing something. Please suggest.
> >
> > originalMdl = Irp->MdlAddress;
> > stagingBuffer = ExAllocatePool
> > (
> > NonPagedPoolCacheAligned,
> > currentSp->Parameters.Write.Length
> > );
> > if (stagingBuffer != NULL)
> > stagingMdl = IoAllocateMdl
> > (
> > stagingBuffer,
> > currentSp->Parameters.Write.Length,
> > FALSE,
> > FALSE,
> > Irp
> > );
> > // If there were problems getting memory, just pass the request along.
> > if (stagingBuffer == NULL || stagingMdl == NULL)
> > {
> > if (stagingBuffer != NULL)
> > ExFreePool(stagingBuffer);
> > Irp->MdlAddress = originalMdl;
> > nextSp = currentSp;
> > ntStatus = IoCallDriver(filterExtension->TargetDevice, Irp);
> > return (ntStatus);
> > }
> > // Required for mapping non-pagged pool memory to an MDL.
> > MmBuildMdlForNonPagedPool(stagingMdl);
> > // Swap the MDL in the IRP with the one we created.
> > Irp->MdlAddress = stagingMdl;
> > // Copy current stack to next stack.
> > nextSp = currentSp;
> > // Switch the MDL back in the completion routine
> > IoSetCompletionRoutine
> > (
> > Irp,
> > WriteCompletion,
> > originalMdl,
> > TRUE,
> > TRUE,
> > TRUE
> > );
> > // Call driver below us.
> > ntStatus = IoCallDriver(TargetDevice, Irp);
> > return (ntStatus);
> > Completion code:
> > // Initialize pointers to the MDLs.
> > stagingMdl = Irp->MdlAddress;
> > originalMdl = OriginalMdl;
> > // Initialize pointers to the I/O buffers
> > stagingBuffer = MmGetSystemAddressForMdl(stagingMdl);
> > originalBuffer = MmGetSystemAddressForMdl(originalMdl);
> > // Restore the original IRP.
> > Irp->MdlAddress = originalMdl;
> > IoFreeMdl(stagingMdl);
> > ExFreePool(stagingBuffer);
> > Raghwendra
> >
> > —
> > Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
> >
> > You are currently subscribed to ntfsd as: unknown lmsubst tag
> argument: ‘’
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
> > —
> > Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cf
> m?id=17
> >
> > You are currently subscribed to ntfsd as: unknown lmsubst tag
> argument: ‘’
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
>
>
>
> Disclaimer:
> The contents of this E-mail (including the contents of the enclosure(s)
> or attachment(s) if any) are privileged and confidential material of MBT
> and should not be disclosed to, used by or copied in any manner by
> anyone other than the intended addressee(s). In case you are not the
> desired addressee, you should delete this message and/or re-direct it to
> the sender. The views expressed in this E-mail message (including the
> enclosure(s) or attachment(s) if any) are those of the individual
> sender, except where the sender expressly, and with authority, states
> them to be the views of MBT.
>
> This e-mail message including attachment/(s), if any, is believed to be
> free of any virus. However, it is the responsibility of the recipient
> to ensure that it is virus free and MBT is not responsible for any loss
> or damage arising in any way from its use
>
>

>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@osr.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: unknown lmsubst tag argument:
> ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
> Disclaimer:
> The contents of this E-mail (including the contents of the enclosure(s)
> or attachment(s) if any) are privileged and confidential material of MBT
> and should not be disclosed to, used by or copied in any manner by
> anyone other than the intended addressee(s). In case you are not the
> desired addressee, you should delete this message and/or re-direct it to
> the sender. The views expressed in this E-mail message (including the
> enclosure(s) or attachment(s) if any) are those of the individual
> sender, except where the sender expressly, and with authority, states
> them to be the views of MBT.
>
> This e-mail message including attachment/(s), if any, is believed to be
> free of any virus. However, it is the responsibility of the recipient
> to ensure that it is virus free and MBT is not responsible for any loss
> or damage arising in any way from its use
>
>

>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@osr.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>


Disclaimer:
The contents of this E-mail (including the contents of the enclosure(s) or attachment(s) if any) are privileged and confidential material of MBT and should not be disclosed to, used by or copied in any manner by anyone other than the intended addressee(s). In case you are not the desired addressee, you should delete this message and/or re-direct it to the sender. The views expressed in this E-mail message (including the enclosure(s) or attachment(s) if any) are those of the individual sender, except where the sender expressly, and with authority, states them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be free of any virus. However, it is the responsibility of the recipient to ensure that it is virus free and MBT is not responsible for any loss or damage arising in any way from its use

*****

Hey Great Man Tony,
The correction you have suggested for Swapping buffer and user buffer.
Implemented and working fine !! for Office Kind of Application.
Many Many Thanks…

One More thing Long back you have asked why you write your header in Start
of File
Why Not at the End…
Dude I Have Done that and it’s Working for Me…Thanks again.

Regards,
Utkarsh S. Dabhade

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Tony Mason
Sent: Wednesday, July 06, 2005 11:56 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Swapping Mdl

Hi Utkarsh,

I would strongly recommend that you obtain the IFS Kit - it will likely
be the most useful US$109 that you ever spend in the file systems
development arena.

Your understanding is correct. When you restore the original MDL, I
would also suggest restoring the UserBuffer (although in many cases it
won’t be used, I generally recommend leaving the system in a consistent
state, in order to encourage interoperability with other filters, for
example).

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Utkarsh DABHADE
Sent: Wednesday, July 06, 2005 2:17 AM
To: ntfsd redirect
Subject: RE: [ntfsd] Swapping Mdl

Hi Tony,
Thanks for the help. But we don’t have IFS Kit.
What I understand from your explanation is as follows please correct me.

Stage 1:-
// Required for mapping non-pagged pool memory to an MDL.
MmBuildMdlForNonPagedPool(pNewMdl);
Stage 2:-
// Swap the MDL in the IRP with the one we created.
I.m_Irp->MdlAddress = pNewMdl;
Then What you have Suggested ->
I.UserBuffer == MmGetMdlVirtualAddress(I.MdlAddress)

is this the right way you want to say?..

Regards,
Utkarsh S. Dabhade

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Tony Mason
Sent: Tuesday, July 05, 2005 7:37 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Swapping Mdl

I think you misunderstand - I wasn’t talking about the *data contents*
of the user buffer, merely the numeric value that the file system uses
when computing the correct offset when constructing partial MDLs for
fragmented files.

If you don’t update UserBuffer then the underlying file system cannot
properly handle any fragmented files. In general, this can manifest as
I/O operations that never complete or random crashes because the DMA is
done to non-existent pages or it corrupts pages that are already in
memory.

In the IFS Kit see deviosup.c in FastFat (look for IoBuildPartialMdl)
and you can see how it uses Irp->UserBuffer, although it does not use
the data contents of Irp->UserBuffer. If Irp->UserBuffer is not
updated so Irp->UserBuffer == MmGetMdlVirtualAddress(Irp->MdlAddress)
the computation it does to find the correct pages won’t work properly.

My experience is that most DMA controllers do not properly handle DMA to
invalid physical memory addresses, despite the PCI spec requirement that
they do so. That’s generally what leads to the hang situation. The
data corruption occurs when a read is done into a real physical page,
but NOT the one that should be used.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Raghwendra
Sent: Tuesday, July 05, 2005 9:25 AM
To: ntfsd redirect
Subject: Re: [ntfsd] Swapping Mdl

Hi Tony
For the moment i am not playing with UserBuffer as i need to
change
only MDL data. When i say not working with .Doc files means, as i assign
new
MDL to IRP at IRP_MJ_WRITE, winword.exe got hang for a while and later a
page fault error occurs. Whereas for other txt editor like NotePad,
Wordpad
it working smoothly. One point more some times for Winword even it
work’s
fine. So actually i am unable to understand this inconsistant behavior
of
system.

Since WinWord before saving any file, many times interact with cache
using
fastIO calls… so i hope i am not disturbing cache by creating new MDL
and
assigning it to IRP and putting back the oriznal MDL at completion
routine .

Raghwendra

----- Original Message -----
From: “Tony Mason”
To: “Windows File Systems Devs Interest List”
Sent: Tuesday, July 05, 2005 5:21 PM
Subject: RE: [ntfsd] Swapping Mdl

> You don’t adjust Irp->UserBuffer; this will cause problems whenever
the
file is fragmented, regardless of the type of the file. See deviosup.c
in
the FAT source code example (look for the use of Irp->UserBuffer.
>
> Since you don’t mention what “not working” means it is a guess as to
how
it does not work in your environment.
>
> Since you pass the IRP in the IoAllocateIrp call, it has already been
added to the MDL chain. The way the code is now written this will work,
but
it is the kind of thing that will break in the future when someone
changes
the code around.
>
> Regards,
>
> Tony
>
> Tony Mason
> Consulting Partner
> OSR Open Systems Resources, Inc.
> http://www.osr.com
>
>
> ________________________________________
> From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]
On Behalf Of Raghwendra
> Sent: Tuesday, July 05, 2005 3:03 AM
> To: ntfsd redirect
> Subject: [ntfsd] Swapping Mdl
>
> Hi All
> I want to swap the MDL buffer into my filter driver. Below is the way
i am
doing.
> My this code is working fine for .txt files. But for .Doc it’s
sometimes
working sometimes not. Am i missing something. Please suggest.
>
> originalMdl = Irp->MdlAddress;
> stagingBuffer = ExAllocatePool
> (
> NonPagedPoolCacheAligned,
> currentSp->Parameters.Write.Length
> );
> if (stagingBuffer != NULL)
> stagingMdl = IoAllocateMdl
> (
> stagingBuffer,
> currentSp->Parameters.Write.Length,
> FALSE,
> FALSE,
> Irp
> );
> // If there were problems getting memory, just pass the request along.
> if (stagingBuffer == NULL || stagingMdl == NULL)
> {
> if (stagingBuffer != NULL)
> ExFreePool(stagingBuffer);
> Irp->MdlAddress = originalMdl;
> nextSp = currentSp;
> ntStatus = IoCallDriver(filterExtension->TargetDevice, Irp);
> return (ntStatus);
> }
> // Required for mapping non-pagged pool memory to an MDL.
> MmBuildMdlForNonPagedPool(stagingMdl);
> // Swap the MDL in the IRP with the one we created.
> Irp->MdlAddress = stagingMdl;
> // Copy current stack to next stack.
> nextSp = currentSp;
> // Switch the MDL back in the completion routine
> IoSetCompletionRoutine
> (
> Irp,
> WriteCompletion,
> originalMdl,
> TRUE,
> TRUE,
> TRUE
> );
> // Call driver below us.
> ntStatus = IoCallDriver(TargetDevice, Irp);
> return (ntStatus);
> Completion code:
> // Initialize pointers to the MDLs.
> stagingMdl = Irp->MdlAddress;
> originalMdl = OriginalMdl;
> // Initialize pointers to the I/O buffers
> stagingBuffer = MmGetSystemAddressForMdl(stagingMdl);
> originalBuffer = MmGetSystemAddressForMdl(originalMdl);
> // Restore the original IRP.
> Irp->MdlAddress = originalMdl;
> IoFreeMdl(stagingMdl);
> ExFreePool(stagingBuffer);
> Raghwendra
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: unknown lmsubst tag
argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cf
m?id=17
>
> You are currently subscribed to ntfsd as: unknown lmsubst tag
argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>


Disclaimer:
The contents of this E-mail (including the contents of the enclosure(s)
or attachment(s) if any) are privileged and confidential material of MBT
and should not be disclosed to, used by or copied in any manner by
anyone other than the intended addressee(s). In case you are not the
desired addressee, you should delete this message and/or re-direct it to
the sender. The views expressed in this E-mail message (including the
enclosure(s) or attachment(s) if any) are those of the individual
sender, except where the sender expressly, and with authority, states
them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be
free of any virus. However, it is the responsibility of the recipient
to ensure that it is virus free and MBT is not responsible for any loss
or damage arising in any way from its use




Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

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


Disclaimer:
The contents of this E-mail (including the contents of the enclosure(s)
or attachment(s) if any) are privileged and confidential material of MBT
and should not be disclosed to, used by or copied in any manner by
anyone other than the intended addressee(s). In case you are not the
desired addressee, you should delete this message and/or re-direct it to
the sender. The views expressed in this E-mail message (including the
enclosure(s) or attachment(s) if any) are those of the individual
sender, except where the sender expressly, and with authority, states
them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be
free of any virus. However, it is the responsibility of the recipient
to ensure that it is virus free and MBT is not responsible for any loss
or damage arising in any way from its use




Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

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


Disclaimer:
The contents of this E-mail (including the contents of the enclosure(s) or attachment(s) if any) are privileged and confidential material of MBT and should not be disclosed to, used by or copied in any manner by anyone other than the intended addressee(s). In case you are not the desired addressee, you should delete this message and/or re-direct it to the sender. The views expressed in this E-mail message (including the enclosure(s) or attachment(s) if any) are those of the individual sender, except where the sender expressly, and with authority, states them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be free of any virus. However, it is the responsibility of the recipient to ensure that it is virus free and MBT is not responsible for any loss or damage arising in any way from its use

*