Tracing which process that has opened a particular file

后端 未结 4 581
忘了有多久
忘了有多久 2020-12-17 06:36

From kernel mode in Windows I\'m able to intercept and monitor virtually all actions performed on a particular disk. When a file is opened for any purpose I get an event.

4条回答
  •  醉酒成梦
    2020-12-17 07:05

    Sysinternals Filemon (free) does this, and better yet they describe how they did it:

    For the Windows 9x driver, the heart of FileMon is in the virtual device driver, Filevxd.vxd. It is dynamically loaded, and in its initialization it installs a file system filter via the VxD service, IFSMGR_InstallFileSystemApiHook, to insert itself onto the call chain of all file system requests. On Windows NT the heart of FileMon is a file system driver that creates and attaches filter device objects to target file system device objects so that FileMon will see all IRPs and FastIO requests directed at drives. When FileMon sees an open, create or close call, it updates an internal hash table that serves as the mapping between internal file handles and file path names. Whenever it sees calls that are handle based, it looks up the handle in the hash table to obtain the full name for display. If a handle-based access references a file opened before FileMon started, FileMon will fail to find the mapping in its hash table and will simply present the handle's value instead.

    -Adam

提交回复
热议问题