in azure-protected-vm-secrets/System.cpp [53:113]
unsigned int GetSystemSmBios(unsigned char **outUuid)
{
#ifndef PLATFORM_UNIX
DWORD smbiosSize = 0;
UINT actualSize = GetSystemFirmwareTable('RSMB', 0, NULL, smbiosSize);
if (actualSize == 0)
{
return 0;
}
PUCHAR smbiosBuffer = (PUCHAR)malloc(actualSize);
if (smbiosBuffer == NULL)
{
return 0;
}
smbiosSize = GetSystemFirmwareTable('RSMB', 0, smbiosBuffer, actualSize);
RawSMBIOSData* smbiosData = (RawSMBIOSData*)smbiosBuffer;
ULONG i = 0;
SmBiosStructure* smBiosStructure = NULL;
bool properTermination = false;
do
{
properTermination = false;
// Check that the buffer contains at least one whole structure header
if (i + sizeof(SmBiosStructure) < smbiosData->Size)
{
if (smbiosData->SMBIOSTableData[i] == 1)
{
// Found structure that matches type
smBiosStructure = (SmBiosStructure*)&smbiosData->SMBIOSTableData[i];
}
// Jump to the end of the structure header
i += smbiosData->SMBIOSTableData[i + 1];
// Look for a double-null (\0\0), which indicates the end of the structure
while (i + 1 < smbiosData->Size)
{
if ((smbiosData->SMBIOSTableData[i] == 0) && (smbiosData->SMBIOSTableData[i + 1] == 0))
{
properTermination = true;
i += 2;
break;
}
++i;
}
}
} while (properTermination && !smBiosStructure);
*outUuid = ((SystemInfo*)smBiosStructure)->UUID;
return 16;
#else
#endif
}