Hi,
I am trying to develop a Encryption Filter Driver for WinXp (a old
discussed
problem in this group I guess). At Present all I am trying is to
encrypt any
file in a given Drive. When I am writing to a specific file the first 5
bytes get corrupted – evrything after that is fine ? What am I doing
wrong.
As my aim at present is to encrypt anything within a drive I am not modifying my IRP_MJ_CREATE ( I am using the FileSpy example) …
Code Below:-
Thanx,
Prithvi
BufferSize = irpSp->Parameters.Write.Length;
SeekPos = (int) irpSp->Parameters.Write.ByteOffset.QuadPart;
if (Irp->MdlAddress){
UserBuffer = (PUCHAR)
MmGetSystemAddressForMdlSafe(Irp->MdlAddress,HighPagePriority);
}
else{
UserBuffer = ((PUCHAR) Irp->UserBuffer);
}
SystemVirtual = (PUCHAR) ExAllocatePool(NonPagedPool, BufferSize);
if (SystemVirtual !=NULL && UserBuffer !=NULL){
RtlCopyBytes(SystemVirtual,UserBuffer,BufferSize);
for(i=0;i
}
//Irp->MdlAddress = NULL;
pMdl=IoAllocateMdl(SystemVirtual,BufferSize,FALSE,FALSE,NULL);
MmBuildMdlForNonPagedPool( pMdl);
Irp->MdlAddress = pMdl;
Irp->UserBuffer = MmGetMdlVirtualAddress( pMdl);
MmProbeAndLockPages(Irp->MdlAddress,KernelMode,IoReadAccess);
UserVirtual=MmMapLockedPages(Irp->MdlAddress,UserMode);
//IoSetCompletionRoutine(Irp,sfWriteCompletion,EncData,TRUE,TRUE,TRUE);
/// ENCWRITEDATA *EncWrite = (ENCWRITEDATA *) Context;
MmUnmapLockedPages(UserVirtual, Irp->MdlAddress);
MmUnlockPages(Irp->MdlAddress);
IoFreeMdl(Irp->MdlAddress);
Irp->MdlAddress = OrgMDL;
Irp->Flags |= IRP_NOCACHE;
ExFreePool(SystemVirtual);
if(Irp->PendingReturned)
IoMarkIrpPending(Irp);
---------------------------------
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs