File Monitor Filter Driver SDK

Download  EaseFilter File Monitor SDK Setup File
Download  EaseFilter File Monitor SDK Zip File

What is the file monitor filter driver

Nowadays the computer's security is more and more important, you want to know who and when your files were accessed. You want to track the file I/O activities for the file audit or continue data protection application. The EaseFilter File Monitor Filter Driver SDK is a file system filter driver development kit, allows you to develop the file system monitoring software easily.

Understand The File System Filter Driver

A file system filter driver intercepts requests targeted at a file system or another file system filter driver. By intercepting the request before it reaches its intended target, the filter driver can extend or replace functionality provided by the original target of the request. File system filtering services are available through the filter manager in Windows. The Filter Manager provides a framework for developing File Systems and File System Filter Drivers without having to manage all the complexities of file I/O.

filter driver

The EaseFilter File Monitor Filter Driver SDK

EaseFilter Filter Driver SDK can monitor Windows file I/O activities in real time, track the file access and changes, monitor file and folder permission changes, audit who is writing, deleting, moving or reading files, report the user name and process name, get the user name and the ip address when the Windows file server's file is accessed by network user.

file monitor

What Can You Do With File Monitor Filter Driver SDK

You can develop the software for the following purposes with the File Monitor Filter Driver SDK:

  • Continuous data protection (CDP). Create your own Continuous data protection (CDP) software to log the file update information, write information with offset and length in real time.
  • File Auditing. Audit your file content. You can intercept any file system call, analyze it content, log it.
  • Log File Access. Create Access Log, you will know who, when, what files were accessed.
  • File Journaling. Journal the file update information. This control may be based on any file parameters, such as its location, type, size, etc.

Track the file changes

With the File Monitor SDK, you can watch for changes in files and subdirectories of the specified directory. You can create a filter rule to watch files on a local computer, a network drive, or a remote computer. You can register the file change events to get the notification when the user or process changed a file.

  • Monitor file creation:  you will get the notification when a user/process created a new file.
  • Monitor file delete:  you will get the notification when a user/process deleted a file.
  • Monitor file rename: you can get the notification when user/process renamed a file.
  • Monitor file written:  you can get the notification when a user/process wrote data to a file.
  • Monitor file security changes: you can get the notification when a user/process changed a file's security.
  • Monitor file information changes: you can get the notification when a user/process changed a file's information (file size, file time, file attributes).

Track the file I/O activities in real-time

You can register the below file I/O events to get the notification when a process requested an I/O to a file. From the return events you will know who accessed the file, the I/O request information and the I/O return status.

OnPostFileCreate: fires this event after a process opened or created a file. You will know know the create option "DesiredAccess", "CreateDisposition", "CreateOptions" and "ShareAccess". You will know the create status of the operation with one of these: FILE_CREATED, FILE_OPENED, FILE_OVERWRITTEN, FILE_SUPERSEDED, FILE_EXISTS, FILE_DOES_NOT_EXIST.

OnPostFileRead: fires this event after a process read the file's data. You will know the read offset and length, read type: cache read, non cache read or paging read.

OnPostFileWrite: fires this event after a process wrote data to a file. You will know the write offset and length, write type: cache write, non cache write or paging write.

OnPostQueryFileInfofires this event after a process queried file's information. You will get the file's allocation size, file size, file time, file attributes and file internal Id.

OnPostSetFileInfofires this event after a process changed a file's information. You will know what file's information(file size, file attributes, file time) was set to a file.

OnPostMoveOrRenameFilefires this event after a process renamed a file. You will know the old file name and the new file name.

OnPostDeleteFilefires this event after a process deleted a file. You will know the deleted file name.

OnPostQueryDirectoryFilefires this event after a process browsed a directory. You will get the file list of the directory.

OnPostQueryFileSecurityfires this event after a process queried a file's security information. You will get the file's security information.

OnPostSetFileSecurityfires this event after a process changed a file's security information. You will know the file's security information set to the file.

OnPostFileHandleClosefires this event after a process closed a file's handle.

Monitor File Access for Specific Processes or Users

To monitor the file I/O, you can setup multiple file filter rules. In the file filter rule, you can setup what processes or users can monitor the file I/O, you can setup the file filter mask which you can only monitor the specific file's I/O, you can filter the file I/O with the file open options, you can register the file change events or register the specific file I/Os.

filter rule

  • Setup the file filter mask of the filter rule: you can create the file filter mask with the wildcard characters, i.e. c:\test\*.txt, the monitor driver only monitors the text files in folder c:\test.
  • Setup the exclude file filter mask: you can exclude the files from the file filter rule , i.e. *.exe, all the .exe files will be excluded from the filter rule.
  • Setup the include process name: the monitor driver will only monitor the I/Os from the included processes.
  • Setup the exclude process name: the monitor driver will exclude the I/Os from the excluded processes.
  • Setup the include user name: the monitor driver will only monitor the I/Os from the included users.
  • Setup the exclude user name: the monitor driver will exclude the I/Os from the excluded users.
  • Setup the file open filter options : you can monitor the I/Os only the files were opened with the specific option DesiredAccess, Disposition or CreateOptions when they are not 0.
  • Register the file changed events: you can get the notification when the files were changed. The file changed events will be sent only when the file handle was closed.

file change

  • Register the specific file I/O events: you can get the notification when the specific file I/O was triggered with your setting. The file I/O events were sent right after the registered I/Os were completed and the file handle was not closed yet.
    • OnPostFileCreate: Fires this event after the file create IO was returned from the file system.
    • OnPostFileRead: Fires this event after the file read IO was returned from the file system.
    • OnPostFileWrite: Fires this event after the file write IO was returned from the file system.
    • OnPostQueryFileSize: Fires this event after the query file size IO was returned from the file system.
    • OnPostQueryFileBasicInfo: Fires this event after the query file basic info IO was returned from the file system.
    • OnPostQueryFileStandardInfo: Fires this event after the query file standard info IO was returned from the file system.
    • OnPostQueryFileNetworkInfo: Fires this event after the query file network info IO was returned from the file system.
    • OnPostQueryFileId: Fires this event after the query file Id IO was returned from the file system.
    • OnPostQueryFileInfo: Fires this event after the query file info IO was returned from the file system.
    • OnPostSetFileSize: Fires this event after the set file size IO was returned from the file system.
    • OnPostSetFileBasicInfo: Fires this event after the set file basic info IO was returned from the file system.
    • OnPostSetFileStandardInfo: Fires this event after the set file standard info IO was returned from the file system.
    • OnPostSetFileNetworkInfo: Fires this event after the set file network info was returned from the file system.
    • OnPostMoveOrRenameFile: Fires this event after the file move or rename IO was returned from the file system.
    • OnPostDeleteFile: Fires this event after the file delete IO was returned from the file system.
    • OnPostSetFileInfo: Fires this event after the set file info IO was returned from the file system.
    • OnPostQueryDirectoryFile: Fires this event after the query directory file info was returned from the file system.
    • OnPostQueryFileSecurity: Fires this event after the query file security IO was returned from the file system.
    • OnPostSetFileSecurity: Fires this event after the set file security IO was returned from the file system.
    • OnPostFileHandleClose: Fires this event after the file handle close IO was returned from the file system.
    • OnPostFileClose: Fires this event after the file close IO was returned from the file system.

file monitor events

File Audit Information

In the file monitor, you can register the file changed events, or register the specific file I/O events. With the file notification event you can get the information as below:

  • User name: the user who accessed the file.
  • Process name and process Id: the process which accessed the file and initiated this I/O request.
  • ThreadId: the thread which accessed the file and initiated this I/O request.
  • I/O Event name: for the file change event, you will know if the file was created, written, renamed, deleted or file information was changed. For file I/O event, you will know the specific I/O names: file open, file create, file read, file write, query or set file information, query or set file security, file close.
  • FileObject: it is similar to file handle concept, every file open, the system I/O manager will generate a unique file object till the file handle was closed.
  • File name: the file name which was associated to this I/O request.
  • File size: the file size of the file which was accessed.
  • File attributes: the file attributes of the file which was accessed.
  • Last write time: the last write time of the file which was accessed.
  • File Create Options: you will know how the file was opened with different options.
  • File I/O data: the read/write data, or query/set file information data.
  • I/O status: the return I/O status, it shows the I/O result if it was return with success, warning or error code.

file monitor console

How To Use The EaseFilter File Monitor Filter Driver SDK

It is simple to use the EaseFilter File Monitor Filter Driver SDK. The following example creates a filter rule to watch the directory specified at run time. The component is set to watch for all file change in the directory. If a file was changed, the file name, file change type, user name, process name will be printed to the console. The component also is set to watch the file open and file read IO, the IO was triggered, the file open and file read information will be printed to the console.

  		
using System;
using EaseFilter.FilterControl;

namespace FileMonitorConsole
{
    class Program
    {
        static FilterControl filterControl = new FilterControl();

        static void Main(string[] args)
        {
            string lastError = string.Empty;
            string licenseKey = "**************************";
                
            FilterAPI.FilterType filterType = FilterAPI.FilterType.MONITOR_FILTER;
            int serviceThreads = 5;
            int connectionTimeOut = 10; //seconds

            try
            {
                if (!filterControl.StartFilter(filterType, serviceThreads, connectionTimeOut, licenseKey, ref lastError))
                {
                    Console.WriteLine("Start Filter Service failed with error:" + lastError);
                    return;
                }

                //the watch path can use wildcard to be the file path filter mask.i.e. '*.txt' only monitor text file.
                string watchPath = "c:\\test\\*";

                if (args.Length > 0)
                {
                    watchPath = args[0];
                }

                //create a file monitor filter rule, every filter rule must have the unique watch path. 
                FileFilter fileMonitorFilter = new FileFilter(watchPath);

                //Filter the file change event to monitor all file change events.
                fileMonitorFilter.FileChangeEventFilter = FilterAPI.MonitorFileEvents.NotifyAll;

                //register the file change callback events.
                fileMonitorFilter.NotifyFileWasChanged += NotifyFileChanged;

                //Filter the monitor file IO events
                fileMonitorFilter.MonitorFileIOEventFilter = (ulong)(MonitorFileIOEvents.OnFileOpen | MonitorFileIOEvents.OnFileRead);

                fileMonitorFilter.OnFileOpen += OnFileOpen;
                fileMonitorFilter.OnFileRead += OnFileRead;

                filterControl.AddFilter(fileMonitorFilter);

                if (!filterControl.SendConfigSettingsToFilter(ref lastError))
                {
                    Console.WriteLine("SendConfigSettingsToFilter failed." + lastError);
                    return;
                }

                Console.WriteLine("Start filter service succeeded.");

                // Wait for the user to quit the program.
                Console.WriteLine("Press 'q' to quit the sample.");
                while (Console.Read() != 'q') ;

                filterControl.StopFilter();

            }
            catch (Exception ex)
            {
                Console.WriteLine("Start filter service failed with error:" + ex.Message);
            }

        }

        /// Fires this event when the file was changed.
        static void NotifyFileChanged(object sender, FileChangeEventArgs e)
        {
            Console.WriteLine("NotifyFileChanged:" + e.FileName + ",eventType:" + e.eventType.ToString() 
				+ ",userName:" + e.UserName + ",processName:" + e.ProcessName);
        }

        /// Fires this event after the file was opened, the handle is not closed. 
        static void OnFileOpen(object sender, FileCreateEventArgs e)
        {
            Console.WriteLine("FileOpen:" + e.FileName + ",status:" +  e.IOStatusToString() 
				+ ",userName:" + e.UserName + ",processName:" + e.ProcessName);
        }

        /// Fires this event after the read IO was returned.
        static void OnFileRead(object sender, FileReadEventArgs e)
        {
            Console.WriteLine("FileRead:" + e.FileName + ",offset:" + e.offset + ",readLength:" 
				+ e.returnReadLength + ",userName:" + e.UserName + ",processName:" + e.ProcessName);
        }
    }
}