╮(╯▽╰)╭ 最近 这个minifilter搞的头大的很...
小弟有些疑问 希望各位给点思路 或是 建议..
在过滤文件重命名 :
捕获IRP_MJ_SET_INFORMATION
判读 :Data->Iopb->Parameters->SetFileInformation->FileInformationClass == FileRenameInformation
然后获取 重命名前文件名 但是我接下来要怎么获得 该过的文件名呢..
还有对于 文件修改
我的思路是:捕获到文件有过写操作 记录下 在关闭时判断记录
就得出是否进行修改
这思路可以不 而这个记录 是否与fileobject 有关呢?
哎总之 迷糊啊
如果各位有更好的 方案思路 请发表下 谢谢
如果可以加下 QQ 那就更感谢了
(请大家踊跃发表意见 人人有分 分我可以再开贴送...)
再 次感谢 谢谢!!!!
22 个解决方案
#1
不懂,友情帮顶.
#2
来学习一下
#3
然后获取 重命名前文件名 但是我接下来要怎么获得 该过的文件名呢..
设置完成函数,如果是minifilter,在postsetinfomation做
捕获到文件有过写操作 记录下 在 关闭时判断记录
这个关闭很难说,就是说很难知道文件已经关闭了
设置完成函数,如果是minifilter,在postsetinfomation做
捕获到文件有过写操作 记录下 在 关闭时判断记录
这个关闭很难说,就是说很难知道文件已经关闭了
#4
O(∩_∩)O~ 谢谢你哦 兄弟 每次都麻烦你..
对于文件关闭我想 判断 irp_mj_close
来进行判断 记录
恩 但是 这个记录我是在全局中??呢 做个指针数组?? 还是怎样来处理这个记录集
前面那个 我也是在postsetinfomation 这里做的..
有个疑问 我看了下 file_object 结构的定义 对于结构中的flag成员还是很迷糊
如果可以的能给点中文资料 或解惑么 谢谢...O(∩_∩)O
#5
就是说很难知道文件已经关闭了,你了解下win的内存缓冲
打个比方说,你写文件,然后保存,如果这时候突然断电,你可能发现你保存的东西没有写入文件,
或者说有时候你检测不到readfile的请求,都是内存缓冲在作怪,不知道这个名字描述的准确不准确,
反正用irp_mj_close一定不对,
中文资料没有,既然想搞这行,就得多学e文了,不懂硬着头皮也得看,
刚才那个内存缓存不知道有没有这个名字,想仔细了解就得看看fat或者ntfs的实现,微软貌似不开源的,也没准备开源的(我没看过,只了解一点)
打个比方说,你写文件,然后保存,如果这时候突然断电,你可能发现你保存的东西没有写入文件,
或者说有时候你检测不到readfile的请求,都是内存缓冲在作怪,不知道这个名字描述的准确不准确,
反正用irp_mj_close一定不对,
中文资料没有,既然想搞这行,就得多学e文了,不懂硬着头皮也得看,
刚才那个内存缓存不知道有没有这个名字,想仔细了解就得看看fat或者ntfs的实现,微软貌似不开源的,也没准备开源的(我没看过,只了解一点)
#6
哎 是啊 头痛..
我现在正在测 正常情况都得不到 ..
研究 研究 %>_<%.....
我现在正在测 正常情况都得不到 ..
研究 研究 %>_<%.....
#7
Windows Driver Kit
FILE_OBJECT
The FILE_OBJECT structure is used by the system to represent a file object. To user-mode protected subsystems, a file object represents an open instance of a file, device, directory, or volume. To device and intermediate drivers, a file object usually represents a device object. To drivers in the file system stack, a file object usually represents a directory or file.
A file object is partially opaque. Certain types of drivers, such as file system drivers and network transport drivers, use some of the fields of file objects.
typedef struct _FILE_OBJECT {
CSHORT Type;
CSHORT Size;
PDEVICE_OBJECT DeviceObject;
PVPB Vpb;
PVOID FsContext;
PVOID FsContext2;
PSECTION_OBJECT_POINTERS SectionObjectPointer;
PVOID PrivateCacheMap;
NTSTATUS FinalStatus;
struct _FILE_OBJECT *RelatedFileObject;
BOOLEAN LockOperation;
BOOLEAN DeletePending;
BOOLEAN ReadAccess;
BOOLEAN WriteAccess;
BOOLEAN DeleteAccess;
BOOLEAN SharedRead;
BOOLEAN SharedWrite;
BOOLEAN SharedDelete;
ULONG Flags;
UNICODE_STRING FileName;
LARGE_INTEGER CurrentByteOffset;
ULONG Waiters;
ULONG Busy;
PVOID LastLock;
KEVENT Lock;
KEVENT Event;
PIO_COMPLETION_CONTEXT CompletionContext;
KSPIN_LOCK IrpListLock;
LIST_ENTRY IrpList;
PVOID FileObjectExtension;
} FILE_OBJECT, *PFILE_OBJECT;
Members
Type
A read-only member used by the system to indicate that the object is a file object. If the object is a file object, the value of this member is 5.
Size
A read-only member that specifies the size, in bytes, of the file object. This size does not include the file object extension, if one is present.
DeviceObject
A pointer to the device object on which the file is opened.
Vpb
A pointer to the volume parameter block associated with the file object.
Note that if the Vpb member is non-NULL, the file resides on a mounted volume.
FsContext
A pointer to whatever optional state a driver maintains about the file object; otherwise, NULL. For file system drivers, this member must point to a FSRTL_ADVANCED_FCB_HEADER header structure that is contained within a file-system-specific structure; otherwise system instability can result. Usually, this header structure is embedded in a file control block (FCB). However, on some file systems that support multiple data streams, such as NTFS, this header structure is a stream control block (SCB).
Note In a WDM device stack, only the functional device object (FDO) can use the two context pointers. File system drivers share this member across multiple opens to the same data stream.
FsContext2
A pointer to whatever additional state a driver maintains about the file object; otherwise, NULL.
Note This member is opaque for drivers in the file system stack because the underlying file system utilizes this member.
SectionObjectPointer
A pointer to the file object's read-only section object. This member is set only by file systems and used for Cache Manager interaction.
PrivateCacheMap
An opaque member, set only by file systems, that points to handle-specific information and that is used for Cache Manager interaction.
FinalStatus
A read-only member that is used, in certain synchronous cases, to indicate the final status of the file object's I/O request.
RelatedFileObject
A pointer to a FILE_OBJECT structure used to indicate that the current file object has been opened relative to an already open file object. The file object pointed to by this member is usually a directory (meaning the current file has been opened relative to this directory). However, a file can be reopened relative to itself, and alternate data streams for a file can be opened relative to an already open primary data stream for that same file. The RelatedFileObject member is only valid during the processing of the IRP_MJ_CREATE requests.
LockOperation
A read-only member. If FALSE, a lock operation (NtLockFile) has never been performed on the file object. If TRUE, at least one lock operation has been performed on the file object. Once set to TRUE, this member always remains TRUE (for example, releasing file locks on the file object does not reset this member to FALSE).
DeletePending
A read-only member. If TRUE, a delete operation for the file associated with the file object exists. If FALSE, there currently is no pending delete operation for the file object.
ReadAccess
A read-only member. If TRUE, the file associated with the file object has been opened for read access. If FALSE, the file has been opened without read access. This information is used when checking and/or setting the share access of the file.
WriteAccess
A read-only member. If TRUE, the file associated with the file object has been opened for write access. If FALSE, the file has been opened without write access. This information is used when checking and/or setting the share access of the file.
DeleteAccess
A read-only member. If TRUE, the file associated with the file object has been opened for delete access. If FALSE, the file has been opened without delete access. This information is used when checking and/or setting the share access of the file.
SharedRead
A read-only member. If TRUE, the file associated with the file object has been opened for read sharing access. If FALSE, the file has been opened without read sharing access. This information is used when checking and/or setting the share access of the file.
SharedWrite
A read-only member. If TRUE, the file associated with the file object has been opened for write sharing access. If FALSE, the file has been opened without write sharing access. This information is used when checking and/or setting the share access of the file.
SharedDelete
A read-only member. If TRUE, the file associated with the file object has been opened for delete sharing access. If FALSE, the file has been opened without delete sharing access. This information is used when checking and/or setting the share access of the file.
Flags
A read-only member used by the system to hold one or more (a bitwise inclusive OR combination) of the following private flag values. Flag Meaning
FO_FILE_OPEN Deprecated.
FO_SYNCHRONOUS_IO The file object is opened for synchronous I/O.
FO_ALERTABLE_IO Any wait in the I/O manager, as a result of a request made to this file object, is alertable.
FO_NO_INTERMEDIATE_BUFFERING The file associated with the file object cannot be cached or buffered in a driver's internal buffers.
FO_WRITE_THROUGH System services, file system drivers, and drivers that write data to the file must transfer the data into the file before any requested write operation is considered complete.
FO_SEQUENTIAL_ONLY The file associated with the file object was opened for sequential I/O operations only.
FO_CACHE_SUPPORTED The file associated with the file object is cacheable.
FO_NAMED_PIPE The file object represents a named pipe.
FO_STREAM_FILE The file object represents a file stream.
FO_MAILSLOT The file object represents a mailslot.
FO_GENERATE_AUDIT_ON_CLOSE Deprecated.
FO_QUEUE_IRP_TO_THREAD IRPs will not be queued to this file object.
FO_DIRECT_DEVICE_OPEN The device targeted by this file object was opened directly.
FO_FILE_MODIFIED The file associated with the file object has been modified.
FO_FILE_SIZE_CHANGED The file associated with the file object has changed in size.
FO_CLEANUP_COMPLETE The file system has completed its cleanup for this file object.
FO_TEMPORARY_FILE The file associated with the file object is a temporary file.
FO_DELETE_ON_CLOSE The file associated with the file object will be deleted by the file system upon close.
FO_OPENED_CASE_SENSITIVE The file name case of the file associated with the file object is respected.
FO_HANDLE_CREATED A file handle was created for file object.
FO_FILE_FAST_IO_READ A fast I/O read was performed on this file object.
FO_RANDOM_ACCESS The file associated with the file object was opened for random access.
FO_FILE_OPEN_CANCELLED The create request for this file object was cancelled before completing.
FO_VOLUME_OPEN The file object represents a volume open request.
FO_REMOTE_ORIGIN The create request for the file associated with the file object originated on a remote machine.
FO_SKIP_COMPLETION_PORT For a file object associated with a port, determines if the system should skip queuing to the completion port when the IRP is completed synchronously with a non-error status return value.
FO_SKIP_SET_EVENT Skip setting the event for the file object upon IRP completion.
FO_SKIP_SET_FAST_IO Skip setting an event supplied to a system service when the fast I/O path is successful.
FILE_OBJECT
The FILE_OBJECT structure is used by the system to represent a file object. To user-mode protected subsystems, a file object represents an open instance of a file, device, directory, or volume. To device and intermediate drivers, a file object usually represents a device object. To drivers in the file system stack, a file object usually represents a directory or file.
A file object is partially opaque. Certain types of drivers, such as file system drivers and network transport drivers, use some of the fields of file objects.
typedef struct _FILE_OBJECT {
CSHORT Type;
CSHORT Size;
PDEVICE_OBJECT DeviceObject;
PVPB Vpb;
PVOID FsContext;
PVOID FsContext2;
PSECTION_OBJECT_POINTERS SectionObjectPointer;
PVOID PrivateCacheMap;
NTSTATUS FinalStatus;
struct _FILE_OBJECT *RelatedFileObject;
BOOLEAN LockOperation;
BOOLEAN DeletePending;
BOOLEAN ReadAccess;
BOOLEAN WriteAccess;
BOOLEAN DeleteAccess;
BOOLEAN SharedRead;
BOOLEAN SharedWrite;
BOOLEAN SharedDelete;
ULONG Flags;
UNICODE_STRING FileName;
LARGE_INTEGER CurrentByteOffset;
ULONG Waiters;
ULONG Busy;
PVOID LastLock;
KEVENT Lock;
KEVENT Event;
PIO_COMPLETION_CONTEXT CompletionContext;
KSPIN_LOCK IrpListLock;
LIST_ENTRY IrpList;
PVOID FileObjectExtension;
} FILE_OBJECT, *PFILE_OBJECT;
Members
Type
A read-only member used by the system to indicate that the object is a file object. If the object is a file object, the value of this member is 5.
Size
A read-only member that specifies the size, in bytes, of the file object. This size does not include the file object extension, if one is present.
DeviceObject
A pointer to the device object on which the file is opened.
Vpb
A pointer to the volume parameter block associated with the file object.
Note that if the Vpb member is non-NULL, the file resides on a mounted volume.
FsContext
A pointer to whatever optional state a driver maintains about the file object; otherwise, NULL. For file system drivers, this member must point to a FSRTL_ADVANCED_FCB_HEADER header structure that is contained within a file-system-specific structure; otherwise system instability can result. Usually, this header structure is embedded in a file control block (FCB). However, on some file systems that support multiple data streams, such as NTFS, this header structure is a stream control block (SCB).
Note In a WDM device stack, only the functional device object (FDO) can use the two context pointers. File system drivers share this member across multiple opens to the same data stream.
FsContext2
A pointer to whatever additional state a driver maintains about the file object; otherwise, NULL.
Note This member is opaque for drivers in the file system stack because the underlying file system utilizes this member.
SectionObjectPointer
A pointer to the file object's read-only section object. This member is set only by file systems and used for Cache Manager interaction.
PrivateCacheMap
An opaque member, set only by file systems, that points to handle-specific information and that is used for Cache Manager interaction.
FinalStatus
A read-only member that is used, in certain synchronous cases, to indicate the final status of the file object's I/O request.
RelatedFileObject
A pointer to a FILE_OBJECT structure used to indicate that the current file object has been opened relative to an already open file object. The file object pointed to by this member is usually a directory (meaning the current file has been opened relative to this directory). However, a file can be reopened relative to itself, and alternate data streams for a file can be opened relative to an already open primary data stream for that same file. The RelatedFileObject member is only valid during the processing of the IRP_MJ_CREATE requests.
LockOperation
A read-only member. If FALSE, a lock operation (NtLockFile) has never been performed on the file object. If TRUE, at least one lock operation has been performed on the file object. Once set to TRUE, this member always remains TRUE (for example, releasing file locks on the file object does not reset this member to FALSE).
DeletePending
A read-only member. If TRUE, a delete operation for the file associated with the file object exists. If FALSE, there currently is no pending delete operation for the file object.
ReadAccess
A read-only member. If TRUE, the file associated with the file object has been opened for read access. If FALSE, the file has been opened without read access. This information is used when checking and/or setting the share access of the file.
WriteAccess
A read-only member. If TRUE, the file associated with the file object has been opened for write access. If FALSE, the file has been opened without write access. This information is used when checking and/or setting the share access of the file.
DeleteAccess
A read-only member. If TRUE, the file associated with the file object has been opened for delete access. If FALSE, the file has been opened without delete access. This information is used when checking and/or setting the share access of the file.
SharedRead
A read-only member. If TRUE, the file associated with the file object has been opened for read sharing access. If FALSE, the file has been opened without read sharing access. This information is used when checking and/or setting the share access of the file.
SharedWrite
A read-only member. If TRUE, the file associated with the file object has been opened for write sharing access. If FALSE, the file has been opened without write sharing access. This information is used when checking and/or setting the share access of the file.
SharedDelete
A read-only member. If TRUE, the file associated with the file object has been opened for delete sharing access. If FALSE, the file has been opened without delete sharing access. This information is used when checking and/or setting the share access of the file.
Flags
A read-only member used by the system to hold one or more (a bitwise inclusive OR combination) of the following private flag values. Flag Meaning
FO_FILE_OPEN Deprecated.
FO_SYNCHRONOUS_IO The file object is opened for synchronous I/O.
FO_ALERTABLE_IO Any wait in the I/O manager, as a result of a request made to this file object, is alertable.
FO_NO_INTERMEDIATE_BUFFERING The file associated with the file object cannot be cached or buffered in a driver's internal buffers.
FO_WRITE_THROUGH System services, file system drivers, and drivers that write data to the file must transfer the data into the file before any requested write operation is considered complete.
FO_SEQUENTIAL_ONLY The file associated with the file object was opened for sequential I/O operations only.
FO_CACHE_SUPPORTED The file associated with the file object is cacheable.
FO_NAMED_PIPE The file object represents a named pipe.
FO_STREAM_FILE The file object represents a file stream.
FO_MAILSLOT The file object represents a mailslot.
FO_GENERATE_AUDIT_ON_CLOSE Deprecated.
FO_QUEUE_IRP_TO_THREAD IRPs will not be queued to this file object.
FO_DIRECT_DEVICE_OPEN The device targeted by this file object was opened directly.
FO_FILE_MODIFIED The file associated with the file object has been modified.
FO_FILE_SIZE_CHANGED The file associated with the file object has changed in size.
FO_CLEANUP_COMPLETE The file system has completed its cleanup for this file object.
FO_TEMPORARY_FILE The file associated with the file object is a temporary file.
FO_DELETE_ON_CLOSE The file associated with the file object will be deleted by the file system upon close.
FO_OPENED_CASE_SENSITIVE The file name case of the file associated with the file object is respected.
FO_HANDLE_CREATED A file handle was created for file object.
FO_FILE_FAST_IO_READ A fast I/O read was performed on this file object.
FO_RANDOM_ACCESS The file associated with the file object was opened for random access.
FO_FILE_OPEN_CANCELLED The create request for this file object was cancelled before completing.
FO_VOLUME_OPEN The file object represents a volume open request.
FO_REMOTE_ORIGIN The create request for the file associated with the file object originated on a remote machine.
FO_SKIP_COMPLETION_PORT For a file object associated with a port, determines if the system should skip queuing to the completion port when the IRP is completed synchronously with a non-error status return value.
FO_SKIP_SET_EVENT Skip setting the event for the file object upon IRP completion.
FO_SKIP_SET_FAST_IO Skip setting an event supplied to a system service when the fast I/O path is successful.
#8
FileName
A pointer to a read-only Unicode string that holds the name of the file opened on the volume. If the volume is being opened, the Length member of the UNICODE_STRING structure pointed to by FileName will be zero. Note that this file name is valid only during the processing of an IRP_MJ_CREATE request.
CurrentByteOffset
A read-only member that specifies the file offset, in bytes, associated with the file object.
Waiters
A read-only member used by the system to count the number of outstanding waiters on a file object opened for synchronous access.
Busy
A read-only member used by the system to indicate whether a file object opened for synchronous access is currently busy.
LastLock
An opaque pointer to the last lock applied to the file object.
Lock
An opaque member used by the system to hold a file object event lock. The event lock is used to control synchronous access to the file object. Applicable only to file objects that are opened for synchronous access.
Event
An opaque member used by the system to hold an event object for the file object. The event object is used to signal the completion of an I/O request on the file object if no user event was supplied or a synchronous API was called.
CompletionContext
An opaque pointer to completion port information (port pointer and key) associated with the file object, if any.
IrpListLock
An opaque pointer to a KSPIN_LOCK structure that serves as the spin lock used to synchronize access to the file object's IRP list.
IrpList
An opaque pointer to the head of the IRP list associated with the file object.
FileObjectExtension
An opaque pointer to the file object’s file object extension (FOBX) structure. The FOBX structure contains various opaque contexts used internally as well as the per-file object contexts available through FsRtlXxx routines.
Comments
Drivers can use the FsContext and FsContext2 members to maintain driver-determined state about an open file object. A driver cannot use these members unless the file object is accessible in the driver's I/O stack location of an IRP.
All remaining members in a file object are either opaque or read-only:
Opaque members within a file object should be considered inaccessible. Drivers with dependencies on object field locations or access to opaque members might not remain portable and interoperable with other drivers over time.
Drivers can use read-only members to acquire relevant information but must not modify read-only members and, if a pointer, the object that the member points to.
During the processing of an IRP_MJ_CREATE request, a file system driver calls the IoSetShareAccess routine (if the client is the first to open the file) or the IoCheckShareAccess routine (for subsequent clients that want to share the file). IoSetShareAccess and IoCheckShareAccess update the ReadAccess, WriteAccess, and DeleteAccess members to indicate the access rights that are granted to the client if the client has exclusive access to the file. Additionally, IoCheckShareAccess updates the SharedRead, SharedWrite, and SharedDelete members to indicate the access rights that are simultaneously granted to two or more clients that share the file. If the driver for a device other than a file system has to monitor the access rights of clients, this driver typically stores access rights information in context buffers that are pointed to by the FsContext and FsContext2 members.
Note The type of object (for example, a file, directory, or volume) that a given file object represents cannot be determined by only examining the contents of the file object structure. For information about how to determine the type of object that a file object represents, see ZwQueryInformationFile.
Requirements
Headers: Defined in Wdm.h. Include Wdm.h, Ntddk.h, Ntifs.h, or Fltkernel.h.
See Also
DEVICE_OBJECT, FOBX, FSRTL_ADVANCED_FCB_HEADER, IoGetDeviceObjectPointer, IoCheckShareAccess, IoSetShareAccess, IRP_MJ_CREATE, ObDereferenceObject, ZwQueryInformationFile
? 2009 Microsoft Corporation
Send feedback on this topic
Windows Driver Kit / experimental CHM version
Built on December 10, 2009
硬着头皮看吧,
A pointer to a read-only Unicode string that holds the name of the file opened on the volume. If the volume is being opened, the Length member of the UNICODE_STRING structure pointed to by FileName will be zero. Note that this file name is valid only during the processing of an IRP_MJ_CREATE request.
CurrentByteOffset
A read-only member that specifies the file offset, in bytes, associated with the file object.
Waiters
A read-only member used by the system to count the number of outstanding waiters on a file object opened for synchronous access.
Busy
A read-only member used by the system to indicate whether a file object opened for synchronous access is currently busy.
LastLock
An opaque pointer to the last lock applied to the file object.
Lock
An opaque member used by the system to hold a file object event lock. The event lock is used to control synchronous access to the file object. Applicable only to file objects that are opened for synchronous access.
Event
An opaque member used by the system to hold an event object for the file object. The event object is used to signal the completion of an I/O request on the file object if no user event was supplied or a synchronous API was called.
CompletionContext
An opaque pointer to completion port information (port pointer and key) associated with the file object, if any.
IrpListLock
An opaque pointer to a KSPIN_LOCK structure that serves as the spin lock used to synchronize access to the file object's IRP list.
IrpList
An opaque pointer to the head of the IRP list associated with the file object.
FileObjectExtension
An opaque pointer to the file object’s file object extension (FOBX) structure. The FOBX structure contains various opaque contexts used internally as well as the per-file object contexts available through FsRtlXxx routines.
Comments
Drivers can use the FsContext and FsContext2 members to maintain driver-determined state about an open file object. A driver cannot use these members unless the file object is accessible in the driver's I/O stack location of an IRP.
All remaining members in a file object are either opaque or read-only:
Opaque members within a file object should be considered inaccessible. Drivers with dependencies on object field locations or access to opaque members might not remain portable and interoperable with other drivers over time.
Drivers can use read-only members to acquire relevant information but must not modify read-only members and, if a pointer, the object that the member points to.
During the processing of an IRP_MJ_CREATE request, a file system driver calls the IoSetShareAccess routine (if the client is the first to open the file) or the IoCheckShareAccess routine (for subsequent clients that want to share the file). IoSetShareAccess and IoCheckShareAccess update the ReadAccess, WriteAccess, and DeleteAccess members to indicate the access rights that are granted to the client if the client has exclusive access to the file. Additionally, IoCheckShareAccess updates the SharedRead, SharedWrite, and SharedDelete members to indicate the access rights that are simultaneously granted to two or more clients that share the file. If the driver for a device other than a file system has to monitor the access rights of clients, this driver typically stores access rights information in context buffers that are pointed to by the FsContext and FsContext2 members.
Note The type of object (for example, a file, directory, or volume) that a given file object represents cannot be determined by only examining the contents of the file object structure. For information about how to determine the type of object that a file object represents, see ZwQueryInformationFile.
Requirements
Headers: Defined in Wdm.h. Include Wdm.h, Ntddk.h, Ntifs.h, or Fltkernel.h.
See Also
DEVICE_OBJECT, FOBX, FSRTL_ADVANCED_FCB_HEADER, IoGetDeviceObjectPointer, IoCheckShareAccess, IoSetShareAccess, IRP_MJ_CREATE, ObDereferenceObject, ZwQueryInformationFile
? 2009 Microsoft Corporation
Send feedback on this topic
Windows Driver Kit / experimental CHM version
Built on December 10, 2009
硬着头皮看吧,
#9
有些重要的结构,微软还有隐藏数据(BT)
因此还需要用dbg多调试,不同的操作系统可能还有变化,因此还需要多测试
烦躁的时候,要多耐心些,
很少有人愿意帮你,至少我的感觉如此
因此还需要用dbg多调试,不同的操作系统可能还有变化,因此还需要多测试
烦躁的时候,要多耐心些,
很少有人愿意帮你,至少我的感觉如此
#10
wdk有fastfat.sys的源代码,文件缓存应该由它来管理,我没看过
WriteFile时会发IRP_MJ_WRITE,你可以记录一下这个
WriteFile时会发IRP_MJ_WRITE,你可以记录一下这个
#11
我调的就头大 要不也不能 求救大家给点意见了
你给的那个文档我看了
看的我头痛
E语 我恨恨...
#12
恩 看看 学习下..
现在最想解决的是 抓不到相应文件关闭啊...
晕晕的...
#13
抓文件关闭干什么
#14
就是抓到文件后
在记录查找 来判断是否 重命名或是修改...
O(∩_∩)O~ 这只是想法 也许很白
在记录查找 来判断是否 重命名或是修改...
O(∩_∩)O~ 这只是想法 也许很白
#15
你截获setinformation不是已经记录了吗
#16
但是我要抓取 修改后的文件名啊....
文件修改也是
都在文件关闭后 进行确认 ...
文件修改也是
都在文件关闭后 进行确认 ...
#17
wrk的NtSetInformationFile中重命名的部分
(PFILE_RENAME_INFORMATION)(irp->AssociatedIrp.SystemBuffer)->FileName就是改后的文件名
PVOID systemBuffer;
systemBuffer =
irp->AssociatedIrp.SystemBuffer = ExAllocatePoolWithQuota( NonPagedPool,
Length );
RtlCopyMemory( irp->AssociatedIrp.SystemBuffer,
FileInformation,
Length );
.........................
else if (FileInformationClass == FileRenameInformation ||
FileInformationClass == FileLinkInformation ||
FileInformationClass == FileMoveClusterInformation) {
//
// Note that following code depends on the fact that the rename
// information, link information and copy-on-write information
// structures look exactly the same.
//
PFILE_RENAME_INFORMATION renameBuffer = irp->AssociatedIrp.SystemBuffer;
//
// The information being set is a variable-length structure with
// embedded size information. Walk the structure to ensure that
// it is valid so the driver does not walk off the end and incur
// an access violation in kernel mode.
//
if (renameBuffer->FileNameLength <= 0 || (renameBuffer->FileNameLength & (sizeof(WCHAR) -1))) {
status = STATUS_INVALID_PARAMETER;
irp->IoStatus.Status = status;
} else if ((ULONG) (Length - FIELD_OFFSET( FILE_RENAME_INFORMATION, FileName[0] )) < renameBuffer->FileNameLength) {
status = STATUS_INVALID_PARAMETER;
irp->IoStatus.Status = status;
} else {
//
// Copy the value of the replace BOOLEAN (or the ClusterCount field)
// from the caller's buffer to the I/O stack location parameter
// field where it is expected by file systems.
//
if (FileInformationClass == FileMoveClusterInformation) {
irpSp->Parameters.SetFile.ClusterCount =
((FILE_MOVE_CLUSTER_INFORMATION *) renameBuffer)->ClusterCount;
} else {
irpSp->Parameters.SetFile.ReplaceIfExists = renameBuffer->ReplaceIfExists;
}
//
// Check to see whether or not a fully qualified pathname was
// supplied. If so, then more processing is required.
//
if (renameBuffer->FileName[0] == (WCHAR) OBJ_NAME_PATH_SEPARATOR ||
renameBuffer->RootDirectory) {
//
// A fully qualified file name was specified as the target of
// the rename operation. Attempt to open the target file and
// ensure that the replacement policy for the file is consistent
// with the caller's request, and ensure that the file is on the
// same volume.
//
status = IopOpenLinkOrRenameTarget( &targetHandle,
irp,
renameBuffer,
fileObject );
if (!NT_SUCCESS( status )) {
irp->IoStatus.Status = status;
} else {
//
// The fully qualified file name specifies a file on the
// same volume and if it exists, then the caller specified
// that it should be replaced.
//
status = IoCallDriver( deviceObject, irp );
}
} else {
//
// This is a simple rename operation, so call the driver and
// let it perform the rename operation within the same directory
// as the source file.
//
status = IoCallDriver( deviceObject, irp );
}
}
(PFILE_RENAME_INFORMATION)(irp->AssociatedIrp.SystemBuffer)->FileName就是改后的文件名
#18
msdn上面就有
http://msdn.microsoft.com/en-us/library/ff549366(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ff549366(VS.85).aspx
#19
哦 我看看 试试 我用的是minifilter 框架(框架不想动了 因为还有好多别的需要)..
试试看
嘿嘿 大侠 那个那个 那修改思路 ?
我那个算是pass le '
试试看
嘿嘿 大侠 那个那个 那修改思路 ?
我那个算是pass le '
#20
你这里的是
Data->Iopb->Parameters->SetFileInformation->InfoBuffer
把它typecast成PFILE_RENAME_INFORMATION
Data->Iopb->Parameters->SetFileInformation->InfoBuffer
把它typecast成PFILE_RENAME_INFORMATION
#21
楼上列宁已经回答了 他自带的BUFFER中就是重命名的名字
因为SETINFORMATION有很多种 所以需要把BUFFER改成PFILE_RENAME_INFORMATION
这个可以自己查查MSDN 迟早要学会的 在一日学会早一日收益啊
#22
还有对于 文件修改
我的思路是:捕获到文件有过写操作 记录下 在关闭时判断记录
就得出是否进行修改
这思路可以不 而这个记录 是否与fileobject 有关呢?
哎总之 迷糊啊
在写操作的完成函数 也就是MINIFILTER的 POSTWRITE中
判断IRP中IOSTATUS的结构中的STATUS 为成功 INFORMATION不为零
一个表示写操作状态 一个表示操作的字节数
MINIFILTER中 注意过滤分页写操作 这样缓存什么的就不会困扰你了
至于怎么设置SKIPCACHE 或者 skippagingio 查资料 网络上也有翻译的中文mINIFILTER文档
所谓的什么突然断电 检测不到READFILE都是对缓存和分页操作不大熟悉而已
操作是否写入文件是完全可以准确判定的 不然微软就不用写操作系统了 没人敢买连写到硬盘上都不确定的系统
我的思路是:捕获到文件有过写操作 记录下 在关闭时判断记录
就得出是否进行修改
这思路可以不 而这个记录 是否与fileobject 有关呢?
哎总之 迷糊啊
在写操作的完成函数 也就是MINIFILTER的 POSTWRITE中
判断IRP中IOSTATUS的结构中的STATUS 为成功 INFORMATION不为零
一个表示写操作状态 一个表示操作的字节数
MINIFILTER中 注意过滤分页写操作 这样缓存什么的就不会困扰你了
至于怎么设置SKIPCACHE 或者 skippagingio 查资料 网络上也有翻译的中文mINIFILTER文档
所谓的什么突然断电 检测不到READFILE都是对缓存和分页操作不大熟悉而已
操作是否写入文件是完全可以准确判定的 不然微软就不用写操作系统了 没人敢买连写到硬盘上都不确定的系统
#1
不懂,友情帮顶.
#2
来学习一下
#3
然后获取 重命名前文件名 但是我接下来要怎么获得 该过的文件名呢..
设置完成函数,如果是minifilter,在postsetinfomation做
捕获到文件有过写操作 记录下 在 关闭时判断记录
这个关闭很难说,就是说很难知道文件已经关闭了
设置完成函数,如果是minifilter,在postsetinfomation做
捕获到文件有过写操作 记录下 在 关闭时判断记录
这个关闭很难说,就是说很难知道文件已经关闭了
#4
O(∩_∩)O~ 谢谢你哦 兄弟 每次都麻烦你..
对于文件关闭我想 判断 irp_mj_close
来进行判断 记录
恩 但是 这个记录我是在全局中??呢 做个指针数组?? 还是怎样来处理这个记录集
前面那个 我也是在postsetinfomation 这里做的..
有个疑问 我看了下 file_object 结构的定义 对于结构中的flag成员还是很迷糊
如果可以的能给点中文资料 或解惑么 谢谢...O(∩_∩)O
#5
就是说很难知道文件已经关闭了,你了解下win的内存缓冲
打个比方说,你写文件,然后保存,如果这时候突然断电,你可能发现你保存的东西没有写入文件,
或者说有时候你检测不到readfile的请求,都是内存缓冲在作怪,不知道这个名字描述的准确不准确,
反正用irp_mj_close一定不对,
中文资料没有,既然想搞这行,就得多学e文了,不懂硬着头皮也得看,
刚才那个内存缓存不知道有没有这个名字,想仔细了解就得看看fat或者ntfs的实现,微软貌似不开源的,也没准备开源的(我没看过,只了解一点)
打个比方说,你写文件,然后保存,如果这时候突然断电,你可能发现你保存的东西没有写入文件,
或者说有时候你检测不到readfile的请求,都是内存缓冲在作怪,不知道这个名字描述的准确不准确,
反正用irp_mj_close一定不对,
中文资料没有,既然想搞这行,就得多学e文了,不懂硬着头皮也得看,
刚才那个内存缓存不知道有没有这个名字,想仔细了解就得看看fat或者ntfs的实现,微软貌似不开源的,也没准备开源的(我没看过,只了解一点)
#6
哎 是啊 头痛..
我现在正在测 正常情况都得不到 ..
研究 研究 %>_<%.....
我现在正在测 正常情况都得不到 ..
研究 研究 %>_<%.....
#7
Windows Driver Kit
FILE_OBJECT
The FILE_OBJECT structure is used by the system to represent a file object. To user-mode protected subsystems, a file object represents an open instance of a file, device, directory, or volume. To device and intermediate drivers, a file object usually represents a device object. To drivers in the file system stack, a file object usually represents a directory or file.
A file object is partially opaque. Certain types of drivers, such as file system drivers and network transport drivers, use some of the fields of file objects.
typedef struct _FILE_OBJECT {
CSHORT Type;
CSHORT Size;
PDEVICE_OBJECT DeviceObject;
PVPB Vpb;
PVOID FsContext;
PVOID FsContext2;
PSECTION_OBJECT_POINTERS SectionObjectPointer;
PVOID PrivateCacheMap;
NTSTATUS FinalStatus;
struct _FILE_OBJECT *RelatedFileObject;
BOOLEAN LockOperation;
BOOLEAN DeletePending;
BOOLEAN ReadAccess;
BOOLEAN WriteAccess;
BOOLEAN DeleteAccess;
BOOLEAN SharedRead;
BOOLEAN SharedWrite;
BOOLEAN SharedDelete;
ULONG Flags;
UNICODE_STRING FileName;
LARGE_INTEGER CurrentByteOffset;
ULONG Waiters;
ULONG Busy;
PVOID LastLock;
KEVENT Lock;
KEVENT Event;
PIO_COMPLETION_CONTEXT CompletionContext;
KSPIN_LOCK IrpListLock;
LIST_ENTRY IrpList;
PVOID FileObjectExtension;
} FILE_OBJECT, *PFILE_OBJECT;
Members
Type
A read-only member used by the system to indicate that the object is a file object. If the object is a file object, the value of this member is 5.
Size
A read-only member that specifies the size, in bytes, of the file object. This size does not include the file object extension, if one is present.
DeviceObject
A pointer to the device object on which the file is opened.
Vpb
A pointer to the volume parameter block associated with the file object.
Note that if the Vpb member is non-NULL, the file resides on a mounted volume.
FsContext
A pointer to whatever optional state a driver maintains about the file object; otherwise, NULL. For file system drivers, this member must point to a FSRTL_ADVANCED_FCB_HEADER header structure that is contained within a file-system-specific structure; otherwise system instability can result. Usually, this header structure is embedded in a file control block (FCB). However, on some file systems that support multiple data streams, such as NTFS, this header structure is a stream control block (SCB).
Note In a WDM device stack, only the functional device object (FDO) can use the two context pointers. File system drivers share this member across multiple opens to the same data stream.
FsContext2
A pointer to whatever additional state a driver maintains about the file object; otherwise, NULL.
Note This member is opaque for drivers in the file system stack because the underlying file system utilizes this member.
SectionObjectPointer
A pointer to the file object's read-only section object. This member is set only by file systems and used for Cache Manager interaction.
PrivateCacheMap
An opaque member, set only by file systems, that points to handle-specific information and that is used for Cache Manager interaction.
FinalStatus
A read-only member that is used, in certain synchronous cases, to indicate the final status of the file object's I/O request.
RelatedFileObject
A pointer to a FILE_OBJECT structure used to indicate that the current file object has been opened relative to an already open file object. The file object pointed to by this member is usually a directory (meaning the current file has been opened relative to this directory). However, a file can be reopened relative to itself, and alternate data streams for a file can be opened relative to an already open primary data stream for that same file. The RelatedFileObject member is only valid during the processing of the IRP_MJ_CREATE requests.
LockOperation
A read-only member. If FALSE, a lock operation (NtLockFile) has never been performed on the file object. If TRUE, at least one lock operation has been performed on the file object. Once set to TRUE, this member always remains TRUE (for example, releasing file locks on the file object does not reset this member to FALSE).
DeletePending
A read-only member. If TRUE, a delete operation for the file associated with the file object exists. If FALSE, there currently is no pending delete operation for the file object.
ReadAccess
A read-only member. If TRUE, the file associated with the file object has been opened for read access. If FALSE, the file has been opened without read access. This information is used when checking and/or setting the share access of the file.
WriteAccess
A read-only member. If TRUE, the file associated with the file object has been opened for write access. If FALSE, the file has been opened without write access. This information is used when checking and/or setting the share access of the file.
DeleteAccess
A read-only member. If TRUE, the file associated with the file object has been opened for delete access. If FALSE, the file has been opened without delete access. This information is used when checking and/or setting the share access of the file.
SharedRead
A read-only member. If TRUE, the file associated with the file object has been opened for read sharing access. If FALSE, the file has been opened without read sharing access. This information is used when checking and/or setting the share access of the file.
SharedWrite
A read-only member. If TRUE, the file associated with the file object has been opened for write sharing access. If FALSE, the file has been opened without write sharing access. This information is used when checking and/or setting the share access of the file.
SharedDelete
A read-only member. If TRUE, the file associated with the file object has been opened for delete sharing access. If FALSE, the file has been opened without delete sharing access. This information is used when checking and/or setting the share access of the file.
Flags
A read-only member used by the system to hold one or more (a bitwise inclusive OR combination) of the following private flag values. Flag Meaning
FO_FILE_OPEN Deprecated.
FO_SYNCHRONOUS_IO The file object is opened for synchronous I/O.
FO_ALERTABLE_IO Any wait in the I/O manager, as a result of a request made to this file object, is alertable.
FO_NO_INTERMEDIATE_BUFFERING The file associated with the file object cannot be cached or buffered in a driver's internal buffers.
FO_WRITE_THROUGH System services, file system drivers, and drivers that write data to the file must transfer the data into the file before any requested write operation is considered complete.
FO_SEQUENTIAL_ONLY The file associated with the file object was opened for sequential I/O operations only.
FO_CACHE_SUPPORTED The file associated with the file object is cacheable.
FO_NAMED_PIPE The file object represents a named pipe.
FO_STREAM_FILE The file object represents a file stream.
FO_MAILSLOT The file object represents a mailslot.
FO_GENERATE_AUDIT_ON_CLOSE Deprecated.
FO_QUEUE_IRP_TO_THREAD IRPs will not be queued to this file object.
FO_DIRECT_DEVICE_OPEN The device targeted by this file object was opened directly.
FO_FILE_MODIFIED The file associated with the file object has been modified.
FO_FILE_SIZE_CHANGED The file associated with the file object has changed in size.
FO_CLEANUP_COMPLETE The file system has completed its cleanup for this file object.
FO_TEMPORARY_FILE The file associated with the file object is a temporary file.
FO_DELETE_ON_CLOSE The file associated with the file object will be deleted by the file system upon close.
FO_OPENED_CASE_SENSITIVE The file name case of the file associated with the file object is respected.
FO_HANDLE_CREATED A file handle was created for file object.
FO_FILE_FAST_IO_READ A fast I/O read was performed on this file object.
FO_RANDOM_ACCESS The file associated with the file object was opened for random access.
FO_FILE_OPEN_CANCELLED The create request for this file object was cancelled before completing.
FO_VOLUME_OPEN The file object represents a volume open request.
FO_REMOTE_ORIGIN The create request for the file associated with the file object originated on a remote machine.
FO_SKIP_COMPLETION_PORT For a file object associated with a port, determines if the system should skip queuing to the completion port when the IRP is completed synchronously with a non-error status return value.
FO_SKIP_SET_EVENT Skip setting the event for the file object upon IRP completion.
FO_SKIP_SET_FAST_IO Skip setting an event supplied to a system service when the fast I/O path is successful.
FILE_OBJECT
The FILE_OBJECT structure is used by the system to represent a file object. To user-mode protected subsystems, a file object represents an open instance of a file, device, directory, or volume. To device and intermediate drivers, a file object usually represents a device object. To drivers in the file system stack, a file object usually represents a directory or file.
A file object is partially opaque. Certain types of drivers, such as file system drivers and network transport drivers, use some of the fields of file objects.
typedef struct _FILE_OBJECT {
CSHORT Type;
CSHORT Size;
PDEVICE_OBJECT DeviceObject;
PVPB Vpb;
PVOID FsContext;
PVOID FsContext2;
PSECTION_OBJECT_POINTERS SectionObjectPointer;
PVOID PrivateCacheMap;
NTSTATUS FinalStatus;
struct _FILE_OBJECT *RelatedFileObject;
BOOLEAN LockOperation;
BOOLEAN DeletePending;
BOOLEAN ReadAccess;
BOOLEAN WriteAccess;
BOOLEAN DeleteAccess;
BOOLEAN SharedRead;
BOOLEAN SharedWrite;
BOOLEAN SharedDelete;
ULONG Flags;
UNICODE_STRING FileName;
LARGE_INTEGER CurrentByteOffset;
ULONG Waiters;
ULONG Busy;
PVOID LastLock;
KEVENT Lock;
KEVENT Event;
PIO_COMPLETION_CONTEXT CompletionContext;
KSPIN_LOCK IrpListLock;
LIST_ENTRY IrpList;
PVOID FileObjectExtension;
} FILE_OBJECT, *PFILE_OBJECT;
Members
Type
A read-only member used by the system to indicate that the object is a file object. If the object is a file object, the value of this member is 5.
Size
A read-only member that specifies the size, in bytes, of the file object. This size does not include the file object extension, if one is present.
DeviceObject
A pointer to the device object on which the file is opened.
Vpb
A pointer to the volume parameter block associated with the file object.
Note that if the Vpb member is non-NULL, the file resides on a mounted volume.
FsContext
A pointer to whatever optional state a driver maintains about the file object; otherwise, NULL. For file system drivers, this member must point to a FSRTL_ADVANCED_FCB_HEADER header structure that is contained within a file-system-specific structure; otherwise system instability can result. Usually, this header structure is embedded in a file control block (FCB). However, on some file systems that support multiple data streams, such as NTFS, this header structure is a stream control block (SCB).
Note In a WDM device stack, only the functional device object (FDO) can use the two context pointers. File system drivers share this member across multiple opens to the same data stream.
FsContext2
A pointer to whatever additional state a driver maintains about the file object; otherwise, NULL.
Note This member is opaque for drivers in the file system stack because the underlying file system utilizes this member.
SectionObjectPointer
A pointer to the file object's read-only section object. This member is set only by file systems and used for Cache Manager interaction.
PrivateCacheMap
An opaque member, set only by file systems, that points to handle-specific information and that is used for Cache Manager interaction.
FinalStatus
A read-only member that is used, in certain synchronous cases, to indicate the final status of the file object's I/O request.
RelatedFileObject
A pointer to a FILE_OBJECT structure used to indicate that the current file object has been opened relative to an already open file object. The file object pointed to by this member is usually a directory (meaning the current file has been opened relative to this directory). However, a file can be reopened relative to itself, and alternate data streams for a file can be opened relative to an already open primary data stream for that same file. The RelatedFileObject member is only valid during the processing of the IRP_MJ_CREATE requests.
LockOperation
A read-only member. If FALSE, a lock operation (NtLockFile) has never been performed on the file object. If TRUE, at least one lock operation has been performed on the file object. Once set to TRUE, this member always remains TRUE (for example, releasing file locks on the file object does not reset this member to FALSE).
DeletePending
A read-only member. If TRUE, a delete operation for the file associated with the file object exists. If FALSE, there currently is no pending delete operation for the file object.
ReadAccess
A read-only member. If TRUE, the file associated with the file object has been opened for read access. If FALSE, the file has been opened without read access. This information is used when checking and/or setting the share access of the file.
WriteAccess
A read-only member. If TRUE, the file associated with the file object has been opened for write access. If FALSE, the file has been opened without write access. This information is used when checking and/or setting the share access of the file.
DeleteAccess
A read-only member. If TRUE, the file associated with the file object has been opened for delete access. If FALSE, the file has been opened without delete access. This information is used when checking and/or setting the share access of the file.
SharedRead
A read-only member. If TRUE, the file associated with the file object has been opened for read sharing access. If FALSE, the file has been opened without read sharing access. This information is used when checking and/or setting the share access of the file.
SharedWrite
A read-only member. If TRUE, the file associated with the file object has been opened for write sharing access. If FALSE, the file has been opened without write sharing access. This information is used when checking and/or setting the share access of the file.
SharedDelete
A read-only member. If TRUE, the file associated with the file object has been opened for delete sharing access. If FALSE, the file has been opened without delete sharing access. This information is used when checking and/or setting the share access of the file.
Flags
A read-only member used by the system to hold one or more (a bitwise inclusive OR combination) of the following private flag values. Flag Meaning
FO_FILE_OPEN Deprecated.
FO_SYNCHRONOUS_IO The file object is opened for synchronous I/O.
FO_ALERTABLE_IO Any wait in the I/O manager, as a result of a request made to this file object, is alertable.
FO_NO_INTERMEDIATE_BUFFERING The file associated with the file object cannot be cached or buffered in a driver's internal buffers.
FO_WRITE_THROUGH System services, file system drivers, and drivers that write data to the file must transfer the data into the file before any requested write operation is considered complete.
FO_SEQUENTIAL_ONLY The file associated with the file object was opened for sequential I/O operations only.
FO_CACHE_SUPPORTED The file associated with the file object is cacheable.
FO_NAMED_PIPE The file object represents a named pipe.
FO_STREAM_FILE The file object represents a file stream.
FO_MAILSLOT The file object represents a mailslot.
FO_GENERATE_AUDIT_ON_CLOSE Deprecated.
FO_QUEUE_IRP_TO_THREAD IRPs will not be queued to this file object.
FO_DIRECT_DEVICE_OPEN The device targeted by this file object was opened directly.
FO_FILE_MODIFIED The file associated with the file object has been modified.
FO_FILE_SIZE_CHANGED The file associated with the file object has changed in size.
FO_CLEANUP_COMPLETE The file system has completed its cleanup for this file object.
FO_TEMPORARY_FILE The file associated with the file object is a temporary file.
FO_DELETE_ON_CLOSE The file associated with the file object will be deleted by the file system upon close.
FO_OPENED_CASE_SENSITIVE The file name case of the file associated with the file object is respected.
FO_HANDLE_CREATED A file handle was created for file object.
FO_FILE_FAST_IO_READ A fast I/O read was performed on this file object.
FO_RANDOM_ACCESS The file associated with the file object was opened for random access.
FO_FILE_OPEN_CANCELLED The create request for this file object was cancelled before completing.
FO_VOLUME_OPEN The file object represents a volume open request.
FO_REMOTE_ORIGIN The create request for the file associated with the file object originated on a remote machine.
FO_SKIP_COMPLETION_PORT For a file object associated with a port, determines if the system should skip queuing to the completion port when the IRP is completed synchronously with a non-error status return value.
FO_SKIP_SET_EVENT Skip setting the event for the file object upon IRP completion.
FO_SKIP_SET_FAST_IO Skip setting an event supplied to a system service when the fast I/O path is successful.
#8
FileName
A pointer to a read-only Unicode string that holds the name of the file opened on the volume. If the volume is being opened, the Length member of the UNICODE_STRING structure pointed to by FileName will be zero. Note that this file name is valid only during the processing of an IRP_MJ_CREATE request.
CurrentByteOffset
A read-only member that specifies the file offset, in bytes, associated with the file object.
Waiters
A read-only member used by the system to count the number of outstanding waiters on a file object opened for synchronous access.
Busy
A read-only member used by the system to indicate whether a file object opened for synchronous access is currently busy.
LastLock
An opaque pointer to the last lock applied to the file object.
Lock
An opaque member used by the system to hold a file object event lock. The event lock is used to control synchronous access to the file object. Applicable only to file objects that are opened for synchronous access.
Event
An opaque member used by the system to hold an event object for the file object. The event object is used to signal the completion of an I/O request on the file object if no user event was supplied or a synchronous API was called.
CompletionContext
An opaque pointer to completion port information (port pointer and key) associated with the file object, if any.
IrpListLock
An opaque pointer to a KSPIN_LOCK structure that serves as the spin lock used to synchronize access to the file object's IRP list.
IrpList
An opaque pointer to the head of the IRP list associated with the file object.
FileObjectExtension
An opaque pointer to the file object’s file object extension (FOBX) structure. The FOBX structure contains various opaque contexts used internally as well as the per-file object contexts available through FsRtlXxx routines.
Comments
Drivers can use the FsContext and FsContext2 members to maintain driver-determined state about an open file object. A driver cannot use these members unless the file object is accessible in the driver's I/O stack location of an IRP.
All remaining members in a file object are either opaque or read-only:
Opaque members within a file object should be considered inaccessible. Drivers with dependencies on object field locations or access to opaque members might not remain portable and interoperable with other drivers over time.
Drivers can use read-only members to acquire relevant information but must not modify read-only members and, if a pointer, the object that the member points to.
During the processing of an IRP_MJ_CREATE request, a file system driver calls the IoSetShareAccess routine (if the client is the first to open the file) or the IoCheckShareAccess routine (for subsequent clients that want to share the file). IoSetShareAccess and IoCheckShareAccess update the ReadAccess, WriteAccess, and DeleteAccess members to indicate the access rights that are granted to the client if the client has exclusive access to the file. Additionally, IoCheckShareAccess updates the SharedRead, SharedWrite, and SharedDelete members to indicate the access rights that are simultaneously granted to two or more clients that share the file. If the driver for a device other than a file system has to monitor the access rights of clients, this driver typically stores access rights information in context buffers that are pointed to by the FsContext and FsContext2 members.
Note The type of object (for example, a file, directory, or volume) that a given file object represents cannot be determined by only examining the contents of the file object structure. For information about how to determine the type of object that a file object represents, see ZwQueryInformationFile.
Requirements
Headers: Defined in Wdm.h. Include Wdm.h, Ntddk.h, Ntifs.h, or Fltkernel.h.
See Also
DEVICE_OBJECT, FOBX, FSRTL_ADVANCED_FCB_HEADER, IoGetDeviceObjectPointer, IoCheckShareAccess, IoSetShareAccess, IRP_MJ_CREATE, ObDereferenceObject, ZwQueryInformationFile
? 2009 Microsoft Corporation
Send feedback on this topic
Windows Driver Kit / experimental CHM version
Built on December 10, 2009
硬着头皮看吧,
A pointer to a read-only Unicode string that holds the name of the file opened on the volume. If the volume is being opened, the Length member of the UNICODE_STRING structure pointed to by FileName will be zero. Note that this file name is valid only during the processing of an IRP_MJ_CREATE request.
CurrentByteOffset
A read-only member that specifies the file offset, in bytes, associated with the file object.
Waiters
A read-only member used by the system to count the number of outstanding waiters on a file object opened for synchronous access.
Busy
A read-only member used by the system to indicate whether a file object opened for synchronous access is currently busy.
LastLock
An opaque pointer to the last lock applied to the file object.
Lock
An opaque member used by the system to hold a file object event lock. The event lock is used to control synchronous access to the file object. Applicable only to file objects that are opened for synchronous access.
Event
An opaque member used by the system to hold an event object for the file object. The event object is used to signal the completion of an I/O request on the file object if no user event was supplied or a synchronous API was called.
CompletionContext
An opaque pointer to completion port information (port pointer and key) associated with the file object, if any.
IrpListLock
An opaque pointer to a KSPIN_LOCK structure that serves as the spin lock used to synchronize access to the file object's IRP list.
IrpList
An opaque pointer to the head of the IRP list associated with the file object.
FileObjectExtension
An opaque pointer to the file object’s file object extension (FOBX) structure. The FOBX structure contains various opaque contexts used internally as well as the per-file object contexts available through FsRtlXxx routines.
Comments
Drivers can use the FsContext and FsContext2 members to maintain driver-determined state about an open file object. A driver cannot use these members unless the file object is accessible in the driver's I/O stack location of an IRP.
All remaining members in a file object are either opaque or read-only:
Opaque members within a file object should be considered inaccessible. Drivers with dependencies on object field locations or access to opaque members might not remain portable and interoperable with other drivers over time.
Drivers can use read-only members to acquire relevant information but must not modify read-only members and, if a pointer, the object that the member points to.
During the processing of an IRP_MJ_CREATE request, a file system driver calls the IoSetShareAccess routine (if the client is the first to open the file) or the IoCheckShareAccess routine (for subsequent clients that want to share the file). IoSetShareAccess and IoCheckShareAccess update the ReadAccess, WriteAccess, and DeleteAccess members to indicate the access rights that are granted to the client if the client has exclusive access to the file. Additionally, IoCheckShareAccess updates the SharedRead, SharedWrite, and SharedDelete members to indicate the access rights that are simultaneously granted to two or more clients that share the file. If the driver for a device other than a file system has to monitor the access rights of clients, this driver typically stores access rights information in context buffers that are pointed to by the FsContext and FsContext2 members.
Note The type of object (for example, a file, directory, or volume) that a given file object represents cannot be determined by only examining the contents of the file object structure. For information about how to determine the type of object that a file object represents, see ZwQueryInformationFile.
Requirements
Headers: Defined in Wdm.h. Include Wdm.h, Ntddk.h, Ntifs.h, or Fltkernel.h.
See Also
DEVICE_OBJECT, FOBX, FSRTL_ADVANCED_FCB_HEADER, IoGetDeviceObjectPointer, IoCheckShareAccess, IoSetShareAccess, IRP_MJ_CREATE, ObDereferenceObject, ZwQueryInformationFile
? 2009 Microsoft Corporation
Send feedback on this topic
Windows Driver Kit / experimental CHM version
Built on December 10, 2009
硬着头皮看吧,
#9
有些重要的结构,微软还有隐藏数据(BT)
因此还需要用dbg多调试,不同的操作系统可能还有变化,因此还需要多测试
烦躁的时候,要多耐心些,
很少有人愿意帮你,至少我的感觉如此
因此还需要用dbg多调试,不同的操作系统可能还有变化,因此还需要多测试
烦躁的时候,要多耐心些,
很少有人愿意帮你,至少我的感觉如此
#10
wdk有fastfat.sys的源代码,文件缓存应该由它来管理,我没看过
WriteFile时会发IRP_MJ_WRITE,你可以记录一下这个
WriteFile时会发IRP_MJ_WRITE,你可以记录一下这个
#11
我调的就头大 要不也不能 求救大家给点意见了
你给的那个文档我看了
看的我头痛
E语 我恨恨...
#12
恩 看看 学习下..
现在最想解决的是 抓不到相应文件关闭啊...
晕晕的...
#13
抓文件关闭干什么
#14
就是抓到文件后
在记录查找 来判断是否 重命名或是修改...
O(∩_∩)O~ 这只是想法 也许很白
在记录查找 来判断是否 重命名或是修改...
O(∩_∩)O~ 这只是想法 也许很白
#15
你截获setinformation不是已经记录了吗
#16
但是我要抓取 修改后的文件名啊....
文件修改也是
都在文件关闭后 进行确认 ...
文件修改也是
都在文件关闭后 进行确认 ...
#17
wrk的NtSetInformationFile中重命名的部分
(PFILE_RENAME_INFORMATION)(irp->AssociatedIrp.SystemBuffer)->FileName就是改后的文件名
PVOID systemBuffer;
systemBuffer =
irp->AssociatedIrp.SystemBuffer = ExAllocatePoolWithQuota( NonPagedPool,
Length );
RtlCopyMemory( irp->AssociatedIrp.SystemBuffer,
FileInformation,
Length );
.........................
else if (FileInformationClass == FileRenameInformation ||
FileInformationClass == FileLinkInformation ||
FileInformationClass == FileMoveClusterInformation) {
//
// Note that following code depends on the fact that the rename
// information, link information and copy-on-write information
// structures look exactly the same.
//
PFILE_RENAME_INFORMATION renameBuffer = irp->AssociatedIrp.SystemBuffer;
//
// The information being set is a variable-length structure with
// embedded size information. Walk the structure to ensure that
// it is valid so the driver does not walk off the end and incur
// an access violation in kernel mode.
//
if (renameBuffer->FileNameLength <= 0 || (renameBuffer->FileNameLength & (sizeof(WCHAR) -1))) {
status = STATUS_INVALID_PARAMETER;
irp->IoStatus.Status = status;
} else if ((ULONG) (Length - FIELD_OFFSET( FILE_RENAME_INFORMATION, FileName[0] )) < renameBuffer->FileNameLength) {
status = STATUS_INVALID_PARAMETER;
irp->IoStatus.Status = status;
} else {
//
// Copy the value of the replace BOOLEAN (or the ClusterCount field)
// from the caller's buffer to the I/O stack location parameter
// field where it is expected by file systems.
//
if (FileInformationClass == FileMoveClusterInformation) {
irpSp->Parameters.SetFile.ClusterCount =
((FILE_MOVE_CLUSTER_INFORMATION *) renameBuffer)->ClusterCount;
} else {
irpSp->Parameters.SetFile.ReplaceIfExists = renameBuffer->ReplaceIfExists;
}
//
// Check to see whether or not a fully qualified pathname was
// supplied. If so, then more processing is required.
//
if (renameBuffer->FileName[0] == (WCHAR) OBJ_NAME_PATH_SEPARATOR ||
renameBuffer->RootDirectory) {
//
// A fully qualified file name was specified as the target of
// the rename operation. Attempt to open the target file and
// ensure that the replacement policy for the file is consistent
// with the caller's request, and ensure that the file is on the
// same volume.
//
status = IopOpenLinkOrRenameTarget( &targetHandle,
irp,
renameBuffer,
fileObject );
if (!NT_SUCCESS( status )) {
irp->IoStatus.Status = status;
} else {
//
// The fully qualified file name specifies a file on the
// same volume and if it exists, then the caller specified
// that it should be replaced.
//
status = IoCallDriver( deviceObject, irp );
}
} else {
//
// This is a simple rename operation, so call the driver and
// let it perform the rename operation within the same directory
// as the source file.
//
status = IoCallDriver( deviceObject, irp );
}
}
(PFILE_RENAME_INFORMATION)(irp->AssociatedIrp.SystemBuffer)->FileName就是改后的文件名
#18
msdn上面就有
http://msdn.microsoft.com/en-us/library/ff549366(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ff549366(VS.85).aspx
#19
哦 我看看 试试 我用的是minifilter 框架(框架不想动了 因为还有好多别的需要)..
试试看
嘿嘿 大侠 那个那个 那修改思路 ?
我那个算是pass le '
试试看
嘿嘿 大侠 那个那个 那修改思路 ?
我那个算是pass le '
#20
你这里的是
Data->Iopb->Parameters->SetFileInformation->InfoBuffer
把它typecast成PFILE_RENAME_INFORMATION
Data->Iopb->Parameters->SetFileInformation->InfoBuffer
把它typecast成PFILE_RENAME_INFORMATION
#21
楼上列宁已经回答了 他自带的BUFFER中就是重命名的名字
因为SETINFORMATION有很多种 所以需要把BUFFER改成PFILE_RENAME_INFORMATION
这个可以自己查查MSDN 迟早要学会的 在一日学会早一日收益啊
#22
还有对于 文件修改
我的思路是:捕获到文件有过写操作 记录下 在关闭时判断记录
就得出是否进行修改
这思路可以不 而这个记录 是否与fileobject 有关呢?
哎总之 迷糊啊
在写操作的完成函数 也就是MINIFILTER的 POSTWRITE中
判断IRP中IOSTATUS的结构中的STATUS 为成功 INFORMATION不为零
一个表示写操作状态 一个表示操作的字节数
MINIFILTER中 注意过滤分页写操作 这样缓存什么的就不会困扰你了
至于怎么设置SKIPCACHE 或者 skippagingio 查资料 网络上也有翻译的中文mINIFILTER文档
所谓的什么突然断电 检测不到READFILE都是对缓存和分页操作不大熟悉而已
操作是否写入文件是完全可以准确判定的 不然微软就不用写操作系统了 没人敢买连写到硬盘上都不确定的系统
我的思路是:捕获到文件有过写操作 记录下 在关闭时判断记录
就得出是否进行修改
这思路可以不 而这个记录 是否与fileobject 有关呢?
哎总之 迷糊啊
在写操作的完成函数 也就是MINIFILTER的 POSTWRITE中
判断IRP中IOSTATUS的结构中的STATUS 为成功 INFORMATION不为零
一个表示写操作状态 一个表示操作的字节数
MINIFILTER中 注意过滤分页写操作 这样缓存什么的就不会困扰你了
至于怎么设置SKIPCACHE 或者 skippagingio 查资料 网络上也有翻译的中文mINIFILTER文档
所谓的什么突然断电 检测不到READFILE都是对缓存和分页操作不大熟悉而已
操作是否写入文件是完全可以准确判定的 不然微软就不用写操作系统了 没人敢买连写到硬盘上都不确定的系统