Encrypt Write

Hi again

Please can you tell me if my theory for performing encrypted writes is
correct as I am seeing some IRQL_NOT_LESS_OR_EQUAL errors.

In The IRP_MJ_WRITE

/* Get the Virtual Address of the user buffer */
LPBYTE UserBuffer = (LPBYTE)MmGetSystemAddressForMdl(Irp->MdlAddress);
/* Get the buffer Size */
DWORD BufferSize = Irp->MdlAddress->ByteCount;
/* Allocate my buffer */
LPBYTE MyBuf = (LPBYTE)ExAllocatePool(PagedPool, BufferSize);
/* Copy the data into the buffer */
RtlCopyMemory(MyBuf, UserBuffer, BufferSize);
/* Encrypt Data */
EncipherData(MyBuf, BufferSize);
/* Create a new MDL attached to this IRP */
Irp->MdlAddress = NULL;
IoAllocateMdl(MyBuf, BufferSize, FALSE, FALSE, Irp);
/* Build the MDL to describe the memory pages */
MmProbeAndLockPages(Irp->MdlAddress);
/* Setup the completion Routine so can delete Replacement MDL (MUST DO
ALWAYS) */
IoSetCompletionRoutine(Irp, SFilterWriteCompletion, EncWrite, TRUE, TRUE,
TRUE);
/* Now call the appropriate file system driver with the request. */
Status = IoCallDriver(PtrDeviceExtension->TargetDeviceObject, Irp);
return (Status);

TTFN
Paul Delivett

Hi,

LPBYTE MyBuf = (LPBYTE)ExAllocatePool(PagedPool, BufferSize);
why you are allocating memory from PagedPool?
Try NonPagedPool.

Well, I’m not sure, but allocating memory and copying it from MDL is not
necessery. Try this:
PVOID* Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
ULONG Length = IoGetCurrentStackLocation(Irp)->Parameters.Write.Length;
.
.
.
CipherBuffer(Buffer,Length)

I mean, that’s all.

Ozon

Hi

Thanks for the reply.

I allocate from Paged Pool because the I can not get the
MmBuildFromNonPagedPool to work :frowning:

I used to just encipher the buffer as you have suggested, and decipher
during the completion, however this did not work for floppy drives. Also
there was a thread in this a while back about problems with mapped files, so
I was trying to follow the advise previously given. I might go back and
ignore encrypted floppies if I can’t solve it soon.

TTFN
Paul Delivett

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of xxxxx@seznam.cz
Sent: Thursday, September 14, 2000 7:39 AM
To: File Systems Developers
Subject: [ntfsd] Re: Encrypt Write

Hi,
> LPBYTE MyBuf = (LPBYTE)ExAllocatePool(PagedPool, BufferSize);
why you are allocating memory from PagedPool?
Try NonPagedPool.

Well, I’m not sure, but allocating memory and copying it from MDL is not
necessery. Try this:
PVOID* Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
ULONG Length = IoGetCurrentStackLocation(Irp)->Parameters.Write.Length;
.
.
.
CipherBuffer(Buffer,Length)

I mean, that’s all.

Ozon


You are currently subscribed to ntfsd as: xxxxx@Carraig.co.uk
To unsubscribe send a blank email to $subst(‘Email.Unsub’)

Hi
Encyphering and decyphering buffer is very bad idea. You will never know
what aplications work with encrypted files and what aplications not.

If you allocate buffer in non paged pool, you will have problems with some
redirectors.

Best Regards
mari

-----Original Message-----
From: Paul Delivett [mailto:xxxxx@Carraig.co.uk]
Sent: Thursday, September 14, 2000 1:44 PM
To: File Systems Developers
Subject: [ntfsd] Re: Encrypt Write

Hi

Thanks for the reply.

I allocate from Paged Pool because the I can not get the
MmBuildFromNonPagedPool to work :frowning:

I used to just encipher the buffer as you have suggested, and decipher
during the completion, however this did not work for floppy drives. Also
there was a thread in this a while back about problems with mapped files, so
I was trying to follow the advise previously given. I might go back and
ignore encrypted floppies if I can’t solve it soon.

TTFN
Paul Delivett

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of xxxxx@seznam.cz
Sent: Thursday, September 14, 2000 7:39 AM
To: File Systems Developers
Subject: [ntfsd] Re: Encrypt Write

Hi,
> LPBYTE MyBuf = (LPBYTE)ExAllocatePool(PagedPool, BufferSize);
why you are allocating memory from PagedPool?
Try NonPagedPool.

Well, I’m not sure, but allocating memory and copying it from MDL is not
necessery. Try this:
PVOID* Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
ULONG Length = IoGetCurrentStackLocation(Irp)->Parameters.Write.Length;
.
.
.
CipherBuffer(Buffer,Length)

I mean, that’s all.

Ozon


You are currently subscribed to ntfsd as: xxxxx@Carraig.co.uk
To unsubscribe send a blank email to $subst(‘Email.Unsub’)


You are currently subscribed to ntfsd as: xxxxx@decros.cz
To unsubscribe send a blank email to $subst(‘Email.Unsub’)