I know this is an old topic here, but i still have some questions about it.
In IRP_MJ_READ dispatch routine,when (Irp->Flags & IRP_NOCACHE) and
Irp->MdlAddress is
not null, I set the complete routine.
In complete routine,my code is as below:
NTSTATUS
ReadCompleteRoutine(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN PVOID Context
)
{
ULONG ReadLength = Irp->IoStatus.Information;
PVOID pbuf;
PVOID pVirtual;
PMDL OriginalMDL;
DbgPrint((“Entering Read Complete Routine. the length is %d .\n”,
ReadLength));
pbuf = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
pVirtual = ExAllocatePool( NonPagedPool, ReadLength);
RtlCopyMemory(pVirtual, pbuf, ReadLength);
// Decrypt ,just add the ASCII value by one simply
DecryptData(pVirtual, ReadLength);
OriginalMDL = Irp->MdlAddress;
Irp->MdlAddress = NULL;
//build new MDL
IoAllocateMdl( pVirtual, ReadLength, FALSE, TRUE, Irp);
MmProbeAndLockPages(Irp->MdlAddress, Irp->RequestorMode, IoWriteAccess);
if( Irp->PendingReturned )
{
IoMarkIrpPending( Irp );
}
return Irp->IoStatus.Status;
}
The content in pVirtual is decrypted correctly, but what I read is still
the
original text.
How can I do it?