Scans an IStream object 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 kaveScanStream function.
The kaveScanStreamEx function allows you to supply to KAV Engine some extra technical data about the IStream object 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 IStream objects associated with the downloaded files. The kaveScanStreamEx 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.
The IStream object associated with 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:
The web address of the downloaded file.
An HTTP request header from an HTTP protocol transaction as sent when requesting the file download.
An HTTP response header from a server message received in an HTTP protocol transaction.
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 IStream objects passed for scanning using the kaveScanStreamEx 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 IStream object to scan, and initialize the pScanStreamExtraInfo 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 associated with the IStream object you scan, or you want KAV Engine to perform a regular scanning procedure, do either of the following:
kaveScanStream function.pScanStreamExtraInfo of the kaveScanStreamEx function with NULL.The function will behave the same way as the kaveScanStream function.
Each IStream object has its own internal state. This state is changed each time a caller thread calls the kaveScanStreamEx against the specific IStream object. Invoking the kaveScanStreamEx function with the same value of pIStream from several caller threads may result in abnormal behavior. Avoid concurrent scanning of the same IStream object from different threads of your application.
When the Cloud Protection is enabled, this function performs additional checking of object reputation via Kaspersky Security Network.
Syntax
HRESULT kaveScanStreamEx (
IStream *pIStream,
const KAV_EXTRA_OBJECT_INFO_BASE *pScanStreamExtraInfo
unsigned long dwScanPriority,
unsigned long dwScanningMode,
unsigned long dwCleaningMode,
unsigned long dwScanTimeout,
void *pUserContext,
unsigned long *pdwObjectID,
KAV_RESULT *pResult);
Parameters
The kaveScanStreamEx function has the following parameters.
kaveScanStreamEx function parameters
Name |
Type |
Description |
|---|---|---|
|
in |
A pointer to an When working on a Windows platform, functionality is provided by functions declared in the On a UNIX-like platform you may use a custom IStream interface provided in the |
|
in |
A pointer (casted to If you do not have such additional information, initialize this pointer to |
|
in |
A priority level for scanning the indicated stream. 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 objects with higher priority are scanned first. |
|
in |
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. |
|
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. |
|
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 To set no time limit for the scanning task, use the |
|
in |
A pointer to any user data that can be used by a callback function. |
|
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 When scanning files via File Monitor, unique identifiers assigned to scanned files by KAV SDK are returned directly to callback function in the |
|
out |
A pointer to the variable describing the scan result. If this variable does not have the If this variable has the |
Return value
If the kaveScanStreamEx function succeeds, its return value is S_OK. For information on other return codes, see section "Return codes".