VC + + changes VMware BIOS, uuid_location, ethernet0_address and so on. Major issues such as the following
(1) Randomly generates 16 binary numbers.
(2) Change the VMX corresponding item. According to the rules generally only change the last three items;
/************************************************************************/
/*
Abstract: Generates a hexadecimal random number string. such as "0C 8B 9A" or "0c:8b:9a"
Return value: Returns the generated random number string. Formats such as "0C 8B 9A" or "0c:8b:9a"
Author:abolee
Date: April 6, 2014
*/
/************************************************************************/
void Random (char *szrand,bool ismacaddr)
{
Srand ((unsigned) time (NULL));
if (!ISMACADDR)
sprintf (Szrand, "%02x%02x%02x", Rand () & 0xFF, Rand () & 0xFF, Rand () & 0xFF);
Else
sprintf (Szrand, "%02x:%02x:%02x", Rand () & 0xFF, Rand () & 0xFF, Rand () & 0xFF);
SZRAND[8] = ' "';
}
/************************************************************************/
/*
Summary: Change the virtual machine *. VMX file Uuid.bios?? Uuid.location?? Ethernet0.address
Three-item values after general modification according to the calibration rules
Author:abolee
Date: April 6, 2014
*/
/************************************************************************/
const char *uuid_bios = "Uuid.bios = \" ";
const char *uuid_location = "uuid.location = \" ";
const char *ethernet0_address = "ethernet0.address = \" ";
int modifyvmbiosandaddress (wchar_t *szvmwarepath)
{
Char buffer[8 * 1024];
CFile file;
File. Open (Szvmwarepath,cfile::modereadwrite);
int fileSize = file. Read (Buffer, 8 * 1024);
Char *p = strstr (Buffer, Uuid_bios);
if (p = = NULL) return-1;
p + = 52;
Random (P,false);
Char *p2 = strstr (Buffer, uuid_location);
P2 + = 56;
memcpy (P2, p2, 8);
Char *p3 = strstr (Buffer, ethernet0_address);
if (P3 = = NULL) return-1;
P3 + = 30;
Random (p3,true);
File. Seektobegin ();
File. Write (buffer,filesize);
File. Close ();
return 0;
}
VC + + changes VMware BIOS, uuid_location, ethernet0_address, etc.