about the Completion routine!

I am writing a fs filter driver!when filter the write IRP, first I backup
the original buffer, and then encrypt the IRP’s buffer, then sent the
backup buffer to the Completion Routine by the Context, and last Call the
lower driver! And in the Write IRP’s completion routine I pick up the
backup buffer and free it. and the problem appears, System said I call the
bad pool.
Why?

Thanks a lot!

Jonathan.

Could be you’re trying to free paged pool in a completion routine, which
can run at dispatch level (and thus cannot allocate, free, or access
paged pool).

Jonathan wrote:

I am writing a fs filter driver!when filter the write IRP, first I backup
the original buffer, and then encrypt the IRP’s buffer, then sent the
backup buffer to the Completion Routine by the Context, and last Call the
lower driver! And in the Write IRP’s completion routine I pick up the
backup buffer and free it. and the problem appears, System said I call the
bad pool.
Why?

Thanks a lot!

Jonathan.


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

  • Nick Ryan (MVP for DDK)

are u doing this in paging or non paging io?

if u are doing this in paging io, encrypting the original buffer in the irp
will screw up the cache.

but from the way u’ve described, u are not doing anything with the backup
buffer. it seems u use it to backup the original buffer, then free it in the
completion. what is it for?

if u want to perform encryption, u should be doing it in paging write.
allocate a new buffer, encrypt the original buffer into this new buffer,
replace the original buffer in the irp with this new buffer. send the irp to
the lower driver. on completion, replace back the original buffer and free
the new buffer.

Ampsi

----- Original Message -----
From: “Jonathan”
To: “File Systems Developers”
Sent: Monday, July 21, 2003 10:40
Subject: [ntfsd] about the Completion routine!

I am writing a fs filter driver!when filter the write IRP, first I backup
the original buffer, and then encrypt the IRP’s buffer, then sent the
backup buffer to the Completion Routine by the Context, and last Call the
lower driver! And in the Write IRP’s completion routine I pick up the
backup buffer and free it. and the problem appears, System said I call the
bad pool.
Why?

Thanks a lot!

Jonathan.


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

Yes, I want to perform encryption, and I only dell with the NoCache write!
my way is to backup the original buffer(IRP buffer) and encrypt the
original buffer in dispatch routine, then in the completion routine copy
the backup buffer to the IRP buffer!

and the buffer I have freeed is the NonPaged buffer, so not have the IRQL
problem!

are u doing this in paging or non paging io?

if u are doing this in paging io, encrypting the original buffer in the irp
will screw up the cache.

but from the way u’ve described, u are not doing anything with the backup
buffer. it seems u use it to backup the original buffer, then free it in the
completion. what is it for?

if u want to perform encryption, u should be doing it in paging write.
allocate a new buffer, encrypt the original buffer into this new buffer,
replace the original buffer in the irp with this new buffer. send the irp to
the lower driver. on completion, replace back the original buffer and free
the new buffer.

Ampsi

----- Original Message -----
From: “Jonathan”
> To: “File Systems Developers”
> Sent: Monday, July 21, 2003 10:40
> Subject: [ntfsd] about the Completion routine!
>
>
> I am writing a fs filter driver!when filter the write IRP, first I backup
> the original buffer, and then encrypt the IRP’s buffer, then sent the
> backup buffer to the Completion Routine by the Context, and last Call the
> lower driver! And in the Write IRP’s completion routine I pick up the
> backup buffer and free it. and the problem appears, System said I call the
> bad pool.
> Why?
>
> Thanks a lot!
>
> Jonathan.
>
> —
> You are currently subscribed to ntfsd as: xxxxx@pmail.ntu.edu.sg
> To unsubscribe send a blank email to xxxxx@lists.osr.com

when I handle a .doc at NTFS,sometimes I face the same question.
So,I select this way,it can work:
when Paging Write,I encrypt original buffer,Call FileSystem,and I Decrypt
Original buffer at completion routine.

just try it.It can work for me.

No…No…No…

Don’t know how many times this has been discussed on the mailing list, but
for those that missed it, here goes.

In the dispatch handler for the write you should:-

  1. Allocate a replacement buffer from nonpaged pool
  2. Copy the data to encrypt to this new buffer
  3. Encrypt the copy of the data
  4. Call IoAllocateMdl with your buffer as first parameter
  5. Call MmBuildMdlForNonPagedPool on your allocated MDL
  6. Store the original MdlAddress address in your completion context data
  7. Store the original UserBuffer address in your completion context data
  8. Call MmGetMdlVirtualAddress with the address of your mdl and use this to
    update UserBuffer address
  9. Setup your completion routine with the completion context data
  10. Call to the lower driver

Then in your completion:-

  1. Free the mdl you allocated
  2. Put back the original MdlAddress and UserBuffer fields of the IRP
  3. Free the buffer you allocated in your dispatch routine

I think that just about covers it, if not I am sure that someone will set me
straight pretty quickly!!

Regards

Ben Curley
Software Engineer
Data Encryption Systems Ltd.

Tel: +44 (0)1823 352357 (Main)
Tel: +44 (0)1823 358320 (Direct Dial)

Web: http://www.deslock.com

-----Original Message-----
From: ecore [mailto:xxxxx@hotmail.com]
Sent: 27 July 2003 03:55
To: File Systems Developers
Subject: [ntfsd] Re: about the Completion routine!

when I handle a .doc at NTFS,sometimes I face the same question. So,I select
this way,it can work: when Paging Write,I encrypt original buffer,Call
FileSystem,and I Decrypt Original buffer at completion routine.

just try it.It can work for me.


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