Callback function prototype

The callback function, often referred to as callback handler, is used for processing scan results received from KAV Engine when performing an on-demand scanning, which is made by calling a scanning function, or on-access scanning, performed by monitoring functions. Using the callback function is the only way for obtaining scanning results while monitoring and scanning files and memory objects asynchronously. For synchronous scanning there is the second way for accessing scan results—they are returned to the variable pointed by the pResult pointer of the scanning function. Nevertheless, if the one of the callback events occurs, the callback function defined on the initialization stage is always called regardless of the scanning mode.

A scanning or monitoring function calls the callback function with the appropriate parameters which allow your application to handle the callback event.

A pointer to the callback function must be specified while initializing KAV SDK.

Syntax

typedef CALLBACK_RESULT (__cdecl *PFNCALLBACK) (

unsigned long dwEvent,

unsigned long dwParam1,

unsigned long dwParam2,

const char *pObjectName,

const char *pVirusName,

unsigned long dwObjectID,

unsigned long dwMonitorID,

void *pUserContext);

Return value

The callback function return value is used by the calling scan function or monitor. For the list of possible values, see section "Callback function return values".

Parameters

The parameters of the callback function are described in the table below.

Callback function parameters

Name

Description

dwEvent

One of the event notification codes.

If the Proactive Defense monitor is on, this parameter can also contain one of the PDM events.

For more information, see section "Proactive Defense events".

dwParam1

One of the values described in section "Return codes". Can be used as additional information about the callback event.

If the function is called with any of the PDM events, the dwParam1 parameter contains a PDM action. For more information, see section "Proactive Defense events" and "Proactive Defense actions".

If the function is called with the EVENT_FIRSTBYTES event, the dwParam1 parameter contains a pointer to the KAV_FIRSTBYTES structure that stores the bytes.

If the function is called with the EVENT_NEWSIZE event, the dwParam1 parameter contains a new size of the disinfected object.

If the function is called with the EVENT_OBJECT_BEGIN event, the dwParam1 parameter contains the size of the current object.

If the function is called with the EVENT_DETECT, EVENT_SUSPECTED, EVENT_PREDETECT, EVENT_REQUEST, or EVENT_ALLOW_ADVDIS events, the dwParam1 parameter contains type of detection. For more information, see section "Detection types and severity".

If the function is called with the EVENT_RECORD_NAME event, the dwParam1 parameter also contains the type of detection. For more information, see sections kaveGetVirusList and "Detection types and severity".

If the function is called with the EVENT_BACKUPSUCCEEDED event, the dwParam1 parameter contains the first 32 bits of the identifier of the object which is successfully placed to the backup storage.

If the function is called with the EVENT_ADVDIS_STARTED event, this parameter contains the identifier of the task that started Advanced Disinfection.

If the function is called with the EVENT_REBOOTNEEDED event and the dwParam1 parameter contains the KRT_REQUIRED value, this indicates that the Advanced Disinfection procedure has finished and the end-user's computer must be restarted.

If the function is called with the EVENT_REBOOTNEEDED event and the dwParam1 parameter contains the KRT_PROPOSED value, this indicates that the Advanced Disinfection procedure has not been started but restart of the end-user's computer is necessary to complete the deletion of the infected file. This action may be necessary if deleting the file was not possible during the scanning procedure because the file was locked by active malware or other process and it was not possible to remove the lock.

If the callback function is called with the EVENT_DELETED event and the dwParam1 parameter contains the KDLT_ON_REBOOT value, this indicates that the infected file has been marked for deletion on the next boot.

If the function is called with the EVENT_ERROR event and the dwParam1 parameter contains the KAV_E_DELETE_ON_REBOOT_FAILED return code, this indicates that preparing the infected file for deletion on the next reboot has failed and the deletion cannot be performed on the next reboot. This code is returned by Advanced Disinfection mechanism (see section Advanced Disinfection mode) when it fails to mark for deletion the infected file that is currently locked and cannot be deleted in-place. For more information about available error codes, see section "Return codes". Please contact your Technical Account Manager to help resolve issues with failures to remove infected files on restart of operating system indicated by KAV_E_DELETE_ON_REBOOT_FAILED code.

If your callback handler is called with the EVENT_DISINFECTED while Advanced Disinfection is in progress, the dwParam1 parameter indicates the action performed with the scanned file:

  • If the dwParam1 parameter is set to integer 1, which translates to literal code KDIS_ON_REBOOT, the scanned file is queued for disinfection on the next restart of operating system.
  • If the dwParam1 parameter is set to integer 0, which translates to literal code KDIS_NORMAL, the scanned file is disinfected.

    If the function is called with the EVENT_TCP_CONNINFO event code, this parameter contains the originating application process identifier.

    If the function is called with one of the Proactive Defense Monitor events, this parameter contains the PDM action available for the particular PDM event; this refers to the the following events:

  • EVENT_PDM_HEURISTIC
  • EVENT_PDM_SURE
  • EVENT_PDM_BLOCKING

    For more information, see section "Proactive Defense events".

    If the function is called with EVENT_OBJECT_HASH event notification code, this parameter contains:

  • For a 32-bit pointer

    The whole 4 bytes of the pointer to the KAV_OBJECT_HASH structure.

  • For a 64-bit pointer

    The low-order 4 bytes of the pointer to the KAV_OBJECT_HASH.

dwParam2

One of the values described in section "Return codes". Can be used as additional information on the callback event.

If the function is called with the EVENT_DETECT, EVENT_SUSPECTED, EVENT_PREDETECT, EVENT_REQUEST, or EVENT_ALLOW_ADVDIS events, the dwParam2 parameter contains the danger level. For more information, see section "Detection types and severity".

If the function is called with the EVENT_RECORD_NAME event, the dwParam2 parameter also contains the type of detection. For more information, see sections kaveGetVirusList and "Detection types and severity".

If the function is called with the EVENT_BACKUPSUCCEEDED event, the dwParam2 parameter contains the last 32 bits of the identifier of the object which is successfully placed to the backup storage.

If the function is called with the EVENT_ADVDIS_STARTED event, this parameter contains the identifier of the task that started the Advanced Disinfection.

If the function is called with the EVENT_TCP_CONNINFO (see section "Event notification codes") event, this parameter contains the thread ID for the process that initiated the outgoing TCP connection.

If the function is called with EVENT_OBJECT_HASH event notification code, this parameter contains:

  • For a 32-bit pointer

    Zero (0) value.

  • For a 64-bit pointer

    The high-order 4 bytes of the pointer to the KAV_OBJECT_HASH.

pObjectName

A pointer to the object being scanned at the moment the callback event has occurred.

When the scanned file is an embedded file, such as a file located within a scanned archive, the pObjectName points to the variable storing the path relative to the scanned archive.

When invoked with the EVENT_ALLOW_ADVDIS event, this parameter points to the path of the object that should be handled with Advanced Disinfection.

When the function is called with the EVENT_BACKUP, EVENT_BACKUPSUCCEEDED or EVENT_BACKUPFAILED events, this parameter contains the original name of the object that can be placed or is already placed or cannot be placed into the backup storage.

If the function is called with the EVENT_TCP_CONNINFO (see section "Event notification codes") event, this parameter points to the variable containing destination remote IP address and port number for the outgoing connection in the following format: XXX.XXX.XXX.XXX:port

If the function is called with one of the Proactive Defense Monitor events, this parameter contains the name of the detected malware; this refers to the following events:

  • EVENT_PDM_HEURISTIC
  • EVENT_PDM_SURE
  • EVENT_PDM_BLOCKING

    For more information, see section "Proactive Defense events".

    See "Severity level types" table in section "Detection types and severity" section for more information about supported malware severity level types.

pVirusName

If a malware is detected, a pointer to the detected object name. This object can be some type of malware like virus or worm detected by signatures, potentially dangerous software or just an archiver, EXE packer or a cryptor.

If the function is called with the EVENT_ARCHIVE or EVENT_PACKED events, this parameter contains the archiver or packer name.

If the function is called with the EVENT_RECORD_NAME event, this parameter contains the name of detectable object. For more information, see kaveGetVirusList.

When the function is called with the EVENT_BACKUP, EVENT_BACKUPSUCCEEDED or EVENT_BACKUPFAILED events, this parameter contains the name of a malware found in the scanned file that can be placed or is already placed, or cannot be placed into the backup storage.

dwObjectID

A scan task identifier.

The scan task ID can be used for canceling this particular scanning task. For more information, see kaveCancelScan.

When scanning a file via File Monitor, this parameter contains a unique file identifier allowing you to associate the raised event in dwEvent parameter with the scanned file. Compared to scanning files via a scanning function, where the task ID is generated by scanning function itself and contained at the address pointed by the pdwObjectID pointer, the dwObjectID parameter is the only way to match events to scanned files when scanning files with File Monitor. The file ID returned in dwObjectID is generated internally by KAV SDK. You can track the raised events back to files associated with particular events.

If the function is called with one of the Proactive Defense Monitor events, this parameter contains the process identifier (PID) of the process intercepted by PDM; this refers to the following events:

dwMonitorID

An identifier of the monitor or scanning function that has been scanning the object at the moment the callback event has occurred.

This can be one of the monitor type values described in section "Monitor types", or "0" that corresponds to the scanning function.

pUserContext

A pointer to any user data to hand over additional information.

Page top