The File Monitor scans all files that are accessed by the user or by the system—for example, when they are opened, saved or executed.
If a malware is detected in the scanned file, the File Monitor temporary blocks access to this file. This locking remains in effect until the operating system restart because file lock is performed by a driver. Please note that the File Monitor component always uses NTFS alternate data streams when scanning files located on NTFS file system (otherwise enabled by KAV_O_M_NTFS_ADS scanning mode specified through the dwScanningMode parameter.
To leverage scanning performance in on-access scanning operations File Monitor utilizes Kaspersky whitelisting technology. This technology optimizes scanning operations in File Monitor allowing to minimize system resource usage and enhance performance of on-access scanning of files.
Please note that the File Monitor does not block attempts to start the riskware, which malware type is KDT_RISKWARE (see section "Detection types and severity"). If you want the potentially unwanted programs be blocked like malware, use the KAV_O_M_BLOCK_RISKWARE scanning option. For more details on this option, see section "Scanning modes".
The results of a scanning task processed by the File Monitor can be obtained in your application through the callback function. The name of the malware detected by the KAV Engine is returned by KAV Engine to the variable referenced by the pVirusName callback parameter when the KAV Engine calls the provided callback handler (see section "Callback function prototype") with one of the supported events (values of the dwEvent parameter).
The File Monitor supports all types of events (see section "Event notification codes") except for the following types:
EVENT_RESULTEVENT_NEWSIZEEVENT_OBJECT_BEGINEVENT_INPROGRESSEVENT_ADVDIS_STARTEDEVENT_REBOOTNEEDEDEVENT_TCP_CONNINFOEVENT_RELOAD_DATABASES_STARTEDEVENT_RELOAD_DATABASES_FINIHSEDEVENT_RECORD_NAME.
Please note that in contrast to on-demand scanning, which is performed by calling functions such as kaveScanFile, the File Monitor never calls provided callback function with the dwEvent parameter set to EVENT_RESULT. This is the reason why this event notification code is present in the list above.
Also, when working in Advanced Disinfection mode (KAV_O_M_ADVDIS flag is enabled) File Monitor will send the EVENT_ALLOW_ADVDIS event requesting the disinfection mode to be turned on. If you pass the CLBK_OK from your application back to the callback function, a new scanning task is started, and the EVENT_ADVDIS_STARTED event notification code, which confirms that the task has started, is returned from the on-demand scanning function. The File Monitor will not return the EVENT_ADVDIS_STARTED, because returning CLBK_OK cancels its task so that the new task is processed as a typical on-demand scanning (that is not monitoring) function.
For more information about the events, see section "Event notification codes". For details on the on-demand scanning, see section "Scanning functions".
When KAV SDK calls the callback function, it fills the memory address specified by the callback parameters with the result of scanning, which is received from the KAV Engine. The result is returned to the dwParam1 parameter of the callback function, and, depending on the callback event, which comes in the dwEvent parameter, additional information is returned to the dwParam2 parameter.
In other words, values that you get in dwParam1 and dwParam2 parameters of the callback are strictly determined by the event notification code you receive in the dwEvent parameter.
There is a number of event notification codes that may be of special interest regarding the File Monitor.
When callback function is invoked by KAV SDK with the dwEvent parameter set to EVENT_PREDETECT, the KAV Engine is signaling to your application that it is time to consider whether the file with detected malicious object in it should be further proceeded by the KAV Engine. If you decide not to proceed this file furthermore, you must return CLBK_CANCEL_OBJECT code from your application to the KAV SDK. Returning CLBK_OK grants KAV Engine with permission to continue with scanning of the file; it is not possible to cancel scanning afterwards and the file will be handled by KAV Engine until scanning is finished. See details about processing the EVENT_PREDETECT code in your application listed in section "Event notification codes". Full list of callback return codes, which are expected by KAV SDK as a response from your application to a specific event returned before then, is available in the "Expected return codes from callback" table in section "Expected return codes for callback function".
The EVENT_PREDETECT event is typically followed by the EVENT_DETECT event, which is raised to show that a malware has been detected in the scanned file. The dwParam1 parameter of the callback handler gets filled with one of the codes listed in the "Detection types" table, provided in section "Detection types and severity"). These codes allow your application to identify the type of malware found in the scanned file; for example KDT_TROJWARE code received from KAV SDK in the dwParam1 signals about found Trojan. At the same time, the dwParam2 parameter will contain information about severity level for the found malware. For more information, see section "Detection types and severity".
The EVENT_PREDETECT is a member of the following set of events:
EVENT_PREDETECTEVENT_DETECTEVENT_SUSPECTEDEVENT_REQUESTThese events imply that dwParam1 is filled with the types of malicious objects, detected in the handled file, and the dwParam2 is initialized to one of the values identifying severity level for the found threat.
Some events do not imply any additional information that may be returned with the event to the dwParam2. If this is the case, zero value is returned to the dwParam2 parameter. One of such event codes is EVENT_VERDICT_CURABILITY. This code signals that KAV Engine has identified the curability factor, that is whether the scanned file can be disinfected or disinfection it is not possible and the file should be deleted. When this event notification code is returned to the dwEvent parameter of the callback function, the dwParam1 field contains one of the values, listed in section "Curability verdicts".
File Monitor settings are defined either by the KAV_FILE_MONITOR_SETTINGS structure or by the KAV_FILE_MONITOR_SETTINGS2 structure. These structures contain the same settings except for the additional member of the KAV_FILE_MONITOR_SETTINGS2 structure which defines the file operations that will be intercepted by the File Monitor. For more details on the possible File Monitor operating modes, see section "File Monitor operating modes".
The other File Monitor settings include the same settings as are used by scanning functions—scanning mode, cleaning mode and scanning timeout. There is also an opportunity to specify a limit (in Mbytes) for the size of unpacked archive being scanned—files larger than the size specified will be skipped by the monitor.
Special File Monitor settings allow to exclude certain files from the File Monitor scope, or to make this monitor to scan such files anyway. Include masks define drives, extensions and locations of the files that should be scanned when accessed. Exclude masks define drives, file extensions and file locations of the files to skip. To eliminate collisions when the same value is set for both the include and exclude masks, the exclude mask takes priority over the include mask. Files matching the exclude mask will not be scanned by the File Monitor even if they match the include mask. For more information on masks, see descriptions of the pExclude and pIncludeMask members of the KAV_FILE_MONITOR_SETTINGS and KAV_FILE_MONITOR_SETTINGS2 structures.
Note that File Monitor functionality requires file monitor drivers to be installed. For more information, see section "Drivers".