Virtual Disk API Programming Guide - Documentation - VMware
Virtual Disk API Programming Guide - Documentation - VMware
Virtual Disk API Programming Guide - Documentation - VMware
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
6Vi<br />
Practical <strong>Programming</strong> Tasks 6<br />
This chapter presents some practical programming challenges not covered in the sample program, including:<br />
“Scan VMDK for Virus Signatures” on page 49<br />
“Creating <strong>Virtual</strong> <strong>Disk</strong>s” on page 50<br />
“Working with <strong>Virtual</strong> <strong>Disk</strong> Data” on page 51<br />
“Managing Child <strong>Disk</strong>s” on page 52<br />
“RDM <strong>Disk</strong>s and <strong>Virtual</strong> BIOS” on page 53<br />
“Interfacing With <strong>VMware</strong> vSphere” on page 54<br />
Scan VMDK for Virus Signatures<br />
One of the tasks listed in “Use Cases for the <strong>Virtual</strong> <strong>Disk</strong> Library” on page 12 is to scan a VMDK for virus<br />
signatures. Using the framework of our sample program, a function can implement the -virus command‐line<br />
option. The function in Example 6‐1 relies on a pre‐existing library routine called SecureVirusScan(), which<br />
typically is supplied by a vendor of antivirus software. As it does for email messages, the library routine scans<br />
a buffer of any size against the vendor’s latest pattern library, and returns TRUE if it identifies a virus.<br />
Example 6-1. Function to Scan VMDK for Viruses<br />
extern int SecureVirusScan(const uint8 *buf, size_t n);<br />
/*<br />
* DoVirusScan - Scan the content of a virtual disk for virus signatures.<br />
*/<br />
static void DoVirusScan(void)<br />
{<br />
Vix<strong>Disk</strong> disk(appGlobals.connection, appGlobals.diskPath, appGlobals.openFlags);<br />
Vix<strong>Disk</strong>Lib<strong>Disk</strong>Info info;<br />
uint8 buf[VIXDISKLIB_SECTOR_SIZE];<br />
Vix<strong>Disk</strong>LibSectorType sector;<br />
}<br />
VixError vixError = Vix<strong>Disk</strong>Lib_GetInfo(disk.Handle(), &info);<br />
CHECK_AND_THROW(vixError);<br />
cout