File Monitor settings like other monitor settings are defined at the monitor loading stage when you call the kaveLoadMonitor function. They can also be changed later by using the kaveSetMonitorSettings function. For more information, see kaveLoadMonitor and kaveSetMonitorSettings.
File Monitor settings can be defined in two structures—KAV_FILE_MONITOR_SETTINGS and KAV_FILE_MONITOR_SETTINGS2. These structures are the same except for the enWorkingMode member that is present in the KAV_FILE_MONITOR_SETTINGS2 structure. This member determines the file operations that will be intercepted by the File Monitor. The table below lists the possible operating modes supported by File Monitor, which are specified as values of the enWorkingMode field.
File Monitor operating modes
Value |
Description |
|---|---|
|
Attempt to open a file is intercepted. |
|
Any attempt to open a file and every attempt to close it are intercepted. |
|
Attempt to open a file for execution (ACCESS_MASK) is intercepted. For example, any calls of |
|
Smart algorithm developed to optimize scanning performance. One of features specific to this mode is that in a series of closing attempts File Monitor intercepts only the last attempt to close the file. This approach allows you to profit from both effective security level and well-balanced scanning performance. |
If the File Monitor settings are defined by means of the KAV_FILE_MONITOR_SETTINGS structure, the KAV_FM_M_ON_SMART File Monitor operating mode will be used.
Two-pass scanning objectives
To boost scanning performance, starting from KAV SDK version 8.3.x.x or later, File Monitor uses two-pass scanning scheme.
On the first scanning pass, the KLIF.sys driver used by File Monitor performs a super-fast scanning. If nothing has been triggered for the handled file object, the KLIF.sys driver switches to processing next object in the queue, strting a new tasks. When malware is detected on this initial scanning pass in a handled file object, the KAV Engine, calls your callback function and passes to the dwObejctID callback function parameter the identifier of the file object for which the KAV Engine triggered an event, returned in the dwEvent parameter. Deep scanning of the malicious file object in dwObjectID is initiated by the kernel mode File Monitor component, and the KLIF.sys driver switches to scanning the text file object releasing the file object for which it triggered an event.
The second deep scanning pass performed by the kernel mode File Monitor component for the infected file found on the first pass is started in a new thread. This thorough scanning is performed without using the KLIF.sys driver saving from operating system lock-ups that may be caused by kernel driver and thus off-loading your CPU. As a result, this two-pass scanning scheme leads to scanning performance boost thanks to significantly reduced CPU times being allocated to low-level processing performed by KAV SDK driver.
Two-pass scanning scenario
Here is the sample scenario provided for a fictitious archived test file to help you understand what could be the typical event chain raised by File Monitor when scanning EICAR-Test-File compressed by some supported archiver.
KLIF.sys driver, which raises the following event sequence for the particular dwObjectID:EVENT_ARCHIVEEVENT_PREDETECTThe driver triggers to handling another file object, if any.
KLIF.sys driver is not used on this step.dwObjectID:EVENT_ARCHIVEEVENT_PREDETECTEVENT_DETECTSuch a behavior is different to what you could find in previous versions of File Monitor (versions released before 8.3.x.x). When previously all raised events had the same dwObjectID, new two-pass scanning scheme supposes that new unique dwObjectID is used on each scanning pass. In other words, events returned on a first scanning pass will come with a dwObjectID that is different to the value of dwObjectID callback function parameter initialized with events returned by KAV Engine in a new thread on a second scanning pass.
Please keep this new behavior in mind when enabling hooks on events returned by KAV Engine in your application. The object identifier returned in dwObjectID along with EVENT_PREDETECT on a first scanning pass is different to dwObjectID returned with the EVENT_DETECT on an second scanning pass. To work around this possible issue, you may trigger some action in your application based on the file name passed by reference in the pObjectName parameter rather than use the file identifier returned in dwObjectID.
For more information about the structures storing File Monitor settings, see KAV_FILE_MONITOR_SETTINGS and KAV_FILE_MONITOR_SETTINGS2.