One of the Use Cases for the Virtual Disk Library is to scan a VMDK for virus signatures. Using our sample program framework, the function in
Example: Function to Scan VMDK for Viruses implements the
-virus command-line option, using hypothetical library routine
SecureVirusScan(), supplied by an antivirus software vendor. The library routine scans a buffer against the vendor’s latest pattern library, returning TRUE if it identifies a virus.
This function calls VixDiskLib_GetInfo() to determine the number of sectors allocated in the virtual disk. The number of sectors is available in the
VixDiskLibDiskInfo structure, but normally not in the metadata. With
SPARSE type layout, data can occur in any sector, so this function reads all sectors, whether filled or not.
VixDiskLib_Read() continues without error when it encounters an empty sector full of zeroes.