There is something wrong with your specific implementation - the general technique does work properly. Unfortunately, nobody on the list is likely to be able to debug your specific implementation from a general description of how you have implemented it.
You could post your source code to the list for comments or you could use the debugger to figure out the flow of control.
An area in a file may be read or written multiple times. If you are saying that you receive the *same* IRP twice then it suggests you are calling your own driver or you have some other component on the system that is changing the normal operation.
I’ve seen more and more people recently doing development on systems with 3rd party filters installed (e.g., anti-virus). I strongly discourage this because it makes getting your own driver working substantially more difficult. If your IT department mandates this, disconnect the machine from your network or take other steps so that you won’t violate this policy - but do your initial development on a clean system with nothing but Windows components and your driver. Once you have that working then you can start working with other 3rd party products.
I don’t know if this is an issue for your specific environment, of course.
Regards,
Tony
Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com
Looking forward to seeing you at the next OSR File Systems class in Los Angeles, CA October 24-27, 2005.
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Jiang
Sent: Thursday, September 15, 2005 12:22 AM
To: ntfsd redirect
Subject: RE: [ntfsd] Encrypt/Decrypt a doc file in a filter driver
Well, I rewrited my code to use a seperate buffer to do encrypt/decrypt, and
I send this encrypted buffer to the lower driver
when writing, and restore the IRP UserBuffer and MdlAddress with the
original ones in completion routine.I only deal with
IRP_PAGING_IO | IRP_NOCACHE | IRP_SYNCHRONOUS_PAGING_IO. I checked other
parts of my driver and there are no
other IRP buffer moification operations.
But the same problem still occurs. The first write IRP was received twice. I
mean the first and the second wite IRP my driver
received have the same buffer address. So my encrpted doc file get
corrupted. BTW, I test my driver on WindowsXP with Office2003
installed.
Again I need your help. Thanks in advance.
Jiang
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Jiang
Sent: Wednesday, September 14, 2005 4:03 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Encrypt/Decrypt a doc file in a filter driver
Tony,
You are right. The problem should be caused by the memory mapped files. As
you suggested , I did read through the achives when I wrote this driver.
But I didn’t know where MDL buffer came from. That is the problem. I will
review and rewrite my code. Thanks again for your help! Also thanks to
others that pointed out my problem.
Jiang
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tony Mason
Sent: Wednesday, September 14, 2005 1:26 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Encrypt/Decrypt a doc file in a filter driver
Your assumption is that these two applications are not sharing memory but in
fact that isn’t true - memory mapped files (of which the cache manager is
one example) share the same pieces of memory. Thus, encryption cannot
safely be done “in place” because you are encrypting a version that is
visible to application programs.
This is the most common access pattern - but even if we were just talking
about one application with two threads, the application might not be written
to assume the data contents of that buffer change just because the I/O is
being written. So, even in a single application case this isn’t safe.
Encryption needs to be done into a different buffer.
Welcome to the “how hard could it be to write an encryption filter?” club.
It may not make you feel better, but you are merely the latest in a string
of people asking these same questions for the past 10+ years here in
NTFSD… I strongly suggest you look back through the archives.
Regards,
Tony
Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com
Looking forward to seeing you at the next OSR File Systems class in Los
Angeles, CA October 24-27, 2005.
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]
On Behalf Of Jiang
Sent: Tuesday, September 13, 2005 11:52 PM
To: ntfsd redirect
Subject: RE: [ntfsd] Encrypt/Decrypt a doc file in a filter driver
hi lu0,
Thanks for your reply.
I don’t allocate memory by myself. I just make use of the buffers IRPs pass
to my driver.Of course A and B will use different IRPs. So I think there
wouldn’t be any potential confliction problem.
I also didn’t miss write requests but got an extra write_irp which confused
me.
Jiang
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of lu0
Sent: Wednesday, September 14, 2005 12:03 PM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] Encrypt/Decrypt a doc file in a filter driver
Jiang,
First of all, the mode you are using have potential problem.
Suppose 2 applications are sharing a piece of memory. A use the memory to
write file. B is accessing memory contents simultaneously. The B may get
corrupted data during A is writting data.
And, you centainly missed some of write requests, according to your desc.
best regards,
lu0
TTC Senior engineer
http://ttcone.com
Inside Programming
http://lu0.126.com
----- Original Message -----
From: “Jiang”
To: “Windows File Systems Devs Interest List”
Sent: Tuesday, September 13, 2005 7:35 PM
Subject: [ntfsd] Encrypt/Decrypt a doc file in a filter driver
>
> hi all,
>
> I am new to this forum and need your help. I am developing a filter
> driver to encrypt/decrypt all files under a specified folder. I
> encrypt the data while
>
> receiving none-cache write irp and decrypt the data in both read and
> write irps’ completion routine. It works well except for word
> documents. When I open and save a doc file, the driver writes a dummy
> 4k bytes in the first 4k bytes of the doc file, and the rest part of
> the file is same as the original file (encrypted data). I really don’t
> know why and need your advice. Any comment
>
> will be appreciated. Thanks.
>
>
> Jiang
>
>
> Do You Yahoo!?
> ?Ż???G???䣭?й???һ???ʼ?ɧ?ų???
> http://cn.mail.yahoo.com/?id=77071
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: lulinsha@163.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: xxxxx@yahoo.com.cn To
unsubscribe send a blank email to xxxxx@lists.osr.com
NOD32 1.1216 (20050913) Information
This message was checked by NOD32 antivirus system.
http://canon-sol.jp/product/nd
Do You Yahoo!?
?Ż???G???䣭?й???һ???ʼ?ɧ?ų???
http://cn.mail.yahoo.com/?idw071
—
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.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
NOD32 1.1216 (20050913) Information
This message was checked by NOD32 antivirus system.
http://canon-sol.jp/product/nd
Do You Yahoo!?
?Ż???G???䣭?й???һ???ʼ?ɧ?ų???
http://cn.mail.yahoo.com/?idw071
—
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
Do You Yahoo!?
?Ż???G???䣭?й???һ???ʼ?ɧ?ų???
http://cn.mail.yahoo.com/?idw071
—
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