阅读:3858回复:5
关于WINWORD透明加密中IRP_MJ_WRITE和IRP_MJ_READ的FLAG设置
代码如下:(注意已经注释掉了IRP_DEFER_IO_COMPLETION)
else if (pIrpSp->MajorFunction==IRP_MJ_READ&&(Irp->Flags & (IRP_PAGING_IO|IRP_SYNCHRONOUS_PAGING_IO|IRP_NOCACHE/*|IRP_READ_OPERATION|IRP_DEFER_IO_COMPLETION*/))) { //cfFileCacheClear(pFileObject); TEFS_ReadPre(Irp,pIrpSp); //2010-12-18 return SF_IRP_GO_ON; //return SF_IRP_PASS; } else if (pIrpSp->MajorFunction==IRP_MJ_WRITE&&(Irp->Flags & (IRP_PAGING_IO|IRP_SYNCHRONOUS_PAGING_IO|IRP_NOCACHE/*|IRP_WRITE_OPERATION|IRP_DEFER_IO_COMPLETION*/))) { if (TEFS_WritePre(Irp,pIrpSp,Context)) { //2010-12-18 return SF_IRP_GO_ON; //return SF_IRP_PASS; } else { KdPrint(("TEFS_WritePre Failed!")); IoCompleteRequest(Irp, IO_NO_INCREMENT); return SF_IRP_COMPLETED; } } VOID TEFS_ReadPre(IN PIRP irp, IN PIO_STACK_LOCATION irpsp) { PLARGE_INTEGER offset; PFILE_OBJECT pFileObject=(PFILE_OBJECT)irpsp->FileObject; PFCB fcb = (PFCB)irpsp->FileObject->FsContext; offset = &irpsp->Parameters.Read.ByteOffset; if(offset->LowPart == FILE_USE_FILE_POINTER_POSITION && offset->HighPart == -1) { pFileObject->CurrentByteOffset.QuadPart+=HEAD_SIZE; return; } offset->QuadPart += HEAD_SIZE; } BOOLEAN TEFS_WritePre(PIRP irp,PIO_STACK_LOCATION irpsp, PVOID *context) { PLARGE_INTEGER offset; ULONG length = irpsp->Parameters.Write.Length; PFILE_OBJECT pFileObject=(PFILE_OBJECT)irpsp->FileObject; offset = &irpsp->Parameters.Write.ByteOffset; if(offset->LowPart == FILE_USE_FILE_POINTER_POSITION && offset->HighPart == -1) { pFileObject->CurrentByteOffset.QuadPart+=HEAD_SIZE; return TRUE; } else if (offset->LowPart == FILE_WRITE_TO_END_OF_FILE&&offset->HighPart == -1 ) { return TRUE; } else { offset->QuadPart += HEAD_SIZE; return TRUE; } return FALSE; } 其中IRP_MJ_READ是可以正常偏移的,但IRP_MJ_WRITE是不能偏移的好像根本没有进到这个函数中,是不是延迟读写的问题,我在捕获的时候可以捕获到IRP_WRITE_OPERATION|IRP_DEFER_IO_COMPLETION,但一设置这个的话,IRP_MJ_READ会自己多偏移出4K(HEAD_SIZE),请大侠们帮帮忙! |
|
沙发#
发布于:2010-12-20 22:34
楼主 你的帖子怎么不完整 还有代码有注释的地方吗
|
|
板凳#
发布于:2010-12-20 22:49
回 1楼(wxj120bw) 的帖子
有啊,else if (pIrpSp->MajorFunction==IRP_MJ_READ&&(Irp->Flags & (IRP_PAGING_IO|IRP_SYNCHRONOUS_PAGING_IO|IRP_NOCACHE/*|IRP_READ_OPERATION|IRP_DEFER_IO_COMPLETION*/))) else if (pIrpSp->MajorFunction==IRP_MJ_WRITE&&(Irp->Flags & (IRP_PAGING_IO|IRP_SYNCHRONOUS_PAGING_IO|IRP_NOCACHE/*|IRP_WRITE_OPERATION|IRP_DEFER_IO_COMPLETION*/))) 后面那两个标志被我注释了 |
|
地板#
发布于:2011-02-16 23:04
楼主,你的问题解决了吗?能说说解决方法吗?
|
|
地下室#
发布于:2011-05-13 15:37
学习了
|
|
5楼#
发布于:2011-12-30 16:56
问题解决没
|
|