kaveInitialize

Initializes KAV Engine: checks license validity, sets path to the anti-virus database, sets scanner host type, indicates the anti-virus database part not to load, sets the number of scanning threads, and so on. When checking the license validity, the SDK engine will first look for the application ID file (appinfo.kli) and the license keys in the folder with the application executable file, then in the folder with the kave8.dll library.

If the QSCAN cleanup functionality is turned on and the QSCAN component is missing from the set of files comprising the anti-virus database, KAV SDK returns the KAV_E_MOD_NOT_FOUND error on the initialization stage. For more information about turning on the QSCAN cleanup funcitonality, see section "Turning on QSCAN Cleanup".

Using this function is not recommended. Use the kaveInitializeEx function instead. For more information, please appeal to your Technical Account Manager.

This function is declared in kave8_dll_loader.h and implemented in kave8_dll_loader.cpp.

The kaveInitialize function must be called before any other KAV SDK functions, except for the kaveLoad function.

The application must call the kaveUninitialize function after it finishes working with the SDK interface.

When initializing KAV SDK on a Windows platform, the installation of the klbg boot guard driver is validated and, if necessary, the driver registration within the operating system gets automatically updated. Re-registering is performed by updating the system registry. After the updated anti-virus database is retrieved, KAV SDK compares the key value within the system registry with the data within the database. If the current registry value does not match the driver dump value within the database, KAV SDK overwrites the registry key with the new value as contained in the anti-virus database.

The driver update is performed only if you have an already installed copy of the klbg driver. The driver can be installed using the udinstaller32(64) utility (see section "Drivers"). If the driver has not been installed using this utility prior to updating the anti-virus database, the update is not performed even if the newer version of this driver has been retrieved by KAV SDK with the updated database.

Scanner host types and options

The KAV scanner can be run as a separate process or from inside the application. The dwScannerHostType parameter defines the scanner host type; it is specified during SDK initialization. For detailed information about KAV SDK initializing flags, which can be specified in the dwScannerHostType parameter, refer to section "Initialization flags".

Syntax

HRESULT kaveInitialize (

const char *pTempFolder,

const char *pDatabasesPath,

unsigned long dwScannerHostType,

unsigned long dwOutprocScannersCount,

unsigned long dwScanningThreadsCount,

unsigned long dwQueueLength,

PFNCALLBACK pfnUserCallback);

Parameters

The kaveInitialize function has the following parameters.

kaveInitialize function parameters

Name

Type

Description

pTempFolder

in

A pointer to a string containing the path to a folder where, if necessary, temporary files will be created. The folder is used, for example, for unpacking archives while scanning.

Make sure that permissions assigned to the specified temporary folder grant the execution rights to the user account used to run the process that integrates KAV SDK components.

If this parameter is NULL, temporary files will be created in the folder specified in the %TEMP% environmental variable.

This setting can be changed later by using the kaveSetTempFolder function.

pDatabasesPath

in

A pointer to a string that contains the path to the anti-virus database.

If this parameter is NULL, the anti-virus database will be loaded from the default %SDK_folder%/bases folder.

dwScannerHostType

in

One of the host scanner types that can be combined with one or two anti-virus database loading options.

For possible values, see table "Scanner host types" in section "Initialization flags".

dwOutprocScannersCount

in

Windows platforms

  • When the KAV scanner runs as a separate process (that is, dwScannerHostType is set to KAV_SHT_OUTPROC), this parameter defines the number of such processes. There will be dwOutprocScannersCount scanning processes and the process of your application project.

    If this parameter is set to 0, the default value 1 will be used instead.

  • When KAV SDK is used in in-process or service mode (that is, dwScannerHostType is set to KAV_SHT_INPROC or KAV_SHT_SERVICE), the dwOutprocScannersCount parameter is ignored.

Unix-like platforms

  • When the KAV scanner runs as a separate process, the dwOutprocScannersCount parameter defines the number of such scanner processes.

    To configure KAV scanner as a separate process, set dwScannerHostType to one of the following values: KAV_SHT_OUTPROC (each scanner works in its own process) or KAV_SHT_SERVICE (each scanner works as a service hosted by kavehost process).

    If this parameter is set to 0, the default value 1 will be used instead.

  • When the scanner is placed in the current process (dwScannerHostType is set to KAV_SHT_INPROC), this parameter is ignored.

Both platforms

The maximum permissible number of scanning processes is 256. If this number is greater than 256, the E_INVALIDARG value is returned.

Note that in out-of-process mode (dwScannerHostType is set to KAV_SHT_OUTPROC) every scanner process uses its own copy of malware definition database. Thus initializing with a large number of scanner processes consumes considerable time and memory resources.

dwScanningThreadsCount

in

The maximum number of simultaneously running scanning threads.

If this parameter is set to 0, the default value 2 will be used instead.

The scanning threads are distributed among scanning processes, number of which is specified by the dwOutprocScannerCount parameter. For example, if dwOutprocScannersCount is 4, and there are eight scanner threads, there will be two scanner threads in each scanning process.

If dwOutprocScannersCount is 4 and you set two scanner threads, there will be four scanner processes and four scanner threads (each scanner process handles one scanner thread).

The maximum permissible number of scanning threads is 256. If this number is greater than 256, the E_INVALIDARG value is returned.

dwQueueLength

in

The maximum length of the scanning task queue. The queue is used in asynchronous scanning. All the scanning processes take the scanning tasks from a single queue.

If you set the dwQueueLength value to 0, the default value 1024 will be used instead.

To organize an infinite queue, set dwQueueLength to INFINITE or 0xFFFFFFFF.

The length can be changed later by calling the kaveSetQueueLen function.

pfnUserCallback

in

A pointer to the callback function. This function is called if one of the callback events occurs, for example, malware is detected, or an error occurs, or inquiry on disinfection is needed, or the user must be notified about scan completion, and so on.

Return value

The table below contains possible values that the kaveInitialize function can return.

kaveInitialize function return codes

Return code

Description

S_OK

The function succeeds and the anti-virus database is valid.

KAV_E_INVALID_BASES

The function succeeds, but the anti-virus database is corrupted and cannot be used.

E_INVALIDARG

dwScanningThreadsCount is greater than 256.

Note that in Windows initializing with large number of scanner processes consumes considerable time and memory resources. On minimal hardware and software configuration initializing with 32 scanner processes can fail.

Do not remove the default web page template files from the /bin/loc/common directory. Missing template files cause KAV SDK initialization process to fail with KAV_E_MOD_NOT_FOUND error.

Page top