IStream objects are scanned by using the kaveScanStream function. Except for the parameters common for all scanning functions, the kaveScanStream function requires a pointer to the IStream object to scan.
The example below demonstrates usage of the kaveScanStream function.
Example: // The kaveScanStream function usage char szEICAR[] = "X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTI-VIRUS-TEST-FILE!$H+H*"; IStream *pstm = 0; HRESULT hr; hr = CreateStreamOnHGlobal ( 0, TRUE, &pstm ); hr = pstm->Write ( szEICAR, strlen(szEICAR), 0 ); unsigned long dwScanningMode = KAV_O_M_PACKED | KAV_O_M_ARCHIVED | KAV_O_M_MAILPLAIN | KAV_O_M_HEURISTIC_LEVEL_SHALLOW; KAV_RESULT result; hr = kaveScanStream ( pstm, 4, nScanningMode, KAV_SKIP, INFINITE, ctx, &dwTaskId, &result); pstm->Release(); |
The following parameter values of the kaveScanFile function are specified in the example:
pstm—pointer to the IStream object to scan.4—scanning priority.dwScanningMode—scanning mode which is set to KAV_O_M_PACKED | KAV_O_M_ARCHIVED | KAV_O_M_MAILPLAIN | KAV_O_M_HEURISTIC_LEVEL_SHALLOW. This means that compressed executable files, archives, e-mail messages and e-mail databases scanning is on, as well as using heuristic code analyzer.KAV_CLEAN_SKIP—cleaning mode. This particular value means that if the specified memory block is infected, the application will try to disinfect it. If disinfection fails, the scan task is skipped.INFINITE—scan timeout. In this example, scanning of the specified memory block will take as much time as necessary.ctx—user context that can be used by callback functions.dwTaskID— scan ID that can be used either to cancel this scan task or by a callback function. The KAV SDK will automatically fill this out parameter with the non-zero value.&result—pointer to the scanning result. In this example it is NULL, so the scanning is asynchronous.