kaveScanFileEx

Scans a file for malware.

This function allows you to scan files on the basis of the information obtained from the HTTP protocol data. If you do not provide this information to the function, it will behave in the same way as the kaveScanFile function.

When the Cloud Protection is enabled, this function performs additional checking of object reputation via Kaspersky Security Network.

The kaveScanFileEx function allows you to supply to KAV Engine some technical data about the file to be scanned. You can gather information about the files downloaded through the gateway interface. Collecting information about the originating URL address of downloaded files, the request and response sent over HTTP protocol to request downloading of files and get them from a remote address, may facilitate further analysis of files. The kaveScanFileEx function is highly effective when scanning web scripts.

To prevent the antivirus from detecting malicious programs by using signature analysis, attackers can encrypt these programs. This technique is typically used for targeted attacks and can be as follows. An attacker creates a malicious program, implemented as a PE executable or a script, encrypts it, and then places it on a web server. When a user accesses a malicious web page, this malware is downloaded from the web server to his computer. Also, the deceived user can download the file deliberately, or the file is downloaded automatically if an attacker exploits an existing vulnerability in the browser.

Such an encrypted file cannot be effectively scanned without first decrypting it. Sometimes, an attacker can pass the information to decrypt files right in the originating URL address of the file, or the HTTP headers of the HTTP transactions used to request or get the file. KAV Engine can use this information to decrypt protected files and scan them afterwards.

On your gateway interface you may want to filter the HTTP protocol and accumulate the following technical information about every downloaded file:

For information about how HTTP request and response headers are formed in HTTP protocol, see RFC 2616.

This data, extracted from the HTTP traffic by your custom tools, can be effectively reused by KAV Engine for a rigorous inspection of files passed for scanning using the kaveScanFileEx function. For this purpose, fill a KAV_EXTRA_OBJECT_INFO_HTTP object with the data about the URL address and HTTP request/response information related to the file to scan, and initialize the pScanFileExtraInfo pointer with a reference to the KAV_EXTRA_OBJECT_INFO_HTTP object casted to *KAV_EXTRA_OBJECT_INFO_BASE. For more information about structures, see KAV_EXTRA_OBJECT_INFO_BASE and KAV_EXTRA_OBJECT_INFO_HTTP.

If you do not have extra detail for the file, or you want KAV Engine to perform a regular scanning procedure, do either of the following:

Syntax

HRESULT kaveScanFileEx (

  const char   *pScanFileName,

  const KAV_EXTRA_OBJECT_INFO_BASE *pScanFileExtraInfo

  unsigned long   dwScanPriority,

  unsigned long   dwScanningMode,

  unsigned long   dwCleaningMode,

  unsigned long   dwScanTimeout,

  void   *pUserContext,

  unsigned long   *pdwObjectID,

  KAV_RESULT   *pResult);

Parameters

The kaveScanFileEx function has the following parameters.

kaveScanFileEx function parameters

Name

Type

Description

pScanFileName

in

A pointer to the string containing an UNC name of the file to scan. The file can reside in any data storage device.

When using local Unix domain sockets, always make sure to specify full paths to files referenced by pScanFileName parameter of the kaveScanFile function. For more information about configuring local Unix domain sockets for scanning in service integration mode, see section "Kavehost service configuration file".

pScanFileExtraInfo

in

A pointer (casted to KAV_EXTRA_OBJECT_INFO_BASE*) to a KAV_EXTRA_OBJECT_INFO_HTTP object that contains additional technical data to facilitate scanning of encrypted files on the basis of the data gathered from HTTP traffic.

If you do not have such additional information, initialize this pointer to NULL. If you only have some additional information, initialize the data fields of the KAV_EXTRA_OBJECT_INFO_HTTP structure for which you do not have the information, to NULL.

dwScanPriority

in

A priority level for scanning the indicated file. The higher the value is, the higher the priority is.

Priority level is taken into consideration when selecting the objects from the scanning queue. The queue is sorted according to the objects’ priority. The files with higher priority are scanned first.

dwScanningMode

in

File scanning mode.

For more information, see section "Scanning modes".

In case the user is supposed to decide on the action with an infected object, such action is requested by calling the callback function with the appropriate parameters.

dwCleaningMode

in

An action upon detection a malware. For possible parameter values, see section "Cleaning modes".

Regardless of the cleaning mode settings, the KAV SDK reacts to the malware detection event by calling a callback function with the appropriate parameters.

dwScanTimeout

in

The maximum time in milliseconds allotted for performing a scan task. After the specified timeout expires, the scanning is stopped and the function returns with the KAV_E_TIMEOUT error code.

To set no time limit for the scanning task, use the INFINITE value or set it to zero.

pUserContext

in

Any user data that can be used by a callback function.

pdwObjectID

out

A pointer to the scan task identifier. It helps to distinguish scan tasks and their results in case of asynchronous scanning and monitoring—it is used for accessing the scanning result through a callback function.

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

When scanning files via File Monitor, unique identifiers assigned to scanned files by KAV SDK are returned directly to callback function in the dwObjectID parameter. For more details, see section "Callback function prototype".

pResult

out

A pointer to the variable describing the scan result.

If this variable does not have the NULL value, the function is called synchronously—the function does not return until the scan is completed. The scan result will be written to the pResult variable.

If this variable has the NULL value, the function is called asynchronously. In this case the scan result can be obtained only by calling a callback function with the appropriate parameters. For more details on the callback function, see section "Callback function".

Return value

If the kaveScanFileEx function succeeds, the return code is S_OK. If any malware is detected, the scan results are returned to memory address pointed by the pResult parameter, if the kaveScanFileEx has been invoked in synchronous mode, or, when the kaveScanFileEx is invoked asynchrounously, a callback function is called and the result is returned to the address specified in your custom callback function.

For other return codes, see section "Return codes".

Page top