阅读:2012回复:11
如何捕获写文件操作的内容?
小弟想写一个能捕获文件变化的程序,想到用file system filter driver 来把所有的write操作抓下来。我研究了filemon的例子,里面只捕获操作类型、offset和length的信息,具体写了什么内容却不知道怎么获得,那位高手给指点一下。不胜感激!
[编辑 - 8/13/04 by markqiu] |
|
最新喜欢:![]() |
沙发#
发布于:2004-08-13 19:08
IRP_MJ_WRITE
|
|
板凳#
发布于:2004-08-13 22:11
是呀,可以捕获IRP_MJ_WRITE,但是如何获得该irp具体写了什么内容呢?
请高手指教! |
|
地板#
发布于:2004-08-13 23:58
IRP_MJ_WRITE中的CacheWrite,数据一般存于SystemBuffer中,也可存于UserBuffer等当中,具体由相关标志确定,
|
|
|
地下室#
发布于:2004-08-14 09:49
能不能说得再详细一点?systembuffer或者userbuffer在什么地方?是在irp_stack_location里吗?
能不能提供一个例子代码? 拜托了! :D |
|
5楼#
发布于:2004-08-14 15:59
能不能说得再详细一点?systembuffer或者userbuffer在什么地方?是在irp_stack_location里吗? CurrentAddress = MmGetSystemAddressForMdlSafe(irp->MdlAddress, NormalPagePriority); buf=ExAllocatePool(NonPagedPool,io_stack->Parameters.Write.Length); RtlCopyMemory(buf,CurrentAddress,io_stack->Parameters.Write.Length); 就在buf中 |
|
6楼#
发布于:2004-08-14 21:28
谢了,我试试 :D
|
|
7楼#
发布于:2004-08-19 08:47
怎么给分哪?新来的,不会 :P
|
|
8楼#
发布于:2004-08-20 18:08
我试过了,这种方法不行啊,我用下面这段代码:
case IRP_MJ_WRITE: if( FilterDef.logwrites ) { if(currentIrpStack->Parameters.Write.Length<=4096){ PCHAR buf=ExAllocatePool(NonPagedPool,currentIrpStack->Parameters.Write.Length+1); if(buf){ RtlCopyMemory(buf,MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority), currentIrpStack->Parameters.Write.Length); buf[currentIrpStack->Parameters.Write.Length]=0; hookCompletion = LogRecord( TRUE, &seqNum, &dateTime, NULL, "%s\tIRP_MJ_WRITE%c\t%s\tOffset: %d Length: %d Content: %s", name, (Irp->Flags & IRP_PAGING_IO) || (Irp->Flags & IRP_SYNCHRONOUS_PAGING_IO) ? '*' : ' ', fullPathName, currentIrpStack->Parameters.Write.ByteOffset.LowPart, currentIrpStack->Parameters.Write.Length ,buf); ExFreePool( buf ); } }else{ hookCompletion = LogRecord( TRUE, &seqNum, &dateTime, NULL, "%s\tIRP_MJ_WRITE%c\t%s\tOffset: %d Length: %d", name, (Irp->Flags & IRP_PAGING_IO) || (Irp->Flags & IRP_SYNCHRONOUS_PAGING_IO) ? '*' : ' ', fullPathName, currentIrpStack->Parameters.Write.ByteOffset.LowPart, currentIrpStack->Parameters.Write.Length); } } break; 在filemon4.34中,运行就蓝屏,各位大侠,快救救我呀!!! [编辑 - 8/20/04 by markqiu] |
|
9楼#
发布于:2004-08-21 14:58
up
|
|
10楼#
发布于:2004-08-30 19:43
还是先仔细看看filemon的例子和有关文件驱动方面的东东再回来提问吧:)
|
|
|
11楼#
发布于:2004-08-31 11:19
谢谢指教
|
|