Reading SMBIOS data from UMDF driver

Hi all,

I’m trying to read the SMBIOS data from ADXL345 driver using GetSystemFirmwareTable() API. I’m able to get the DMIRevision, MajorVersion and MinorVersion and Length values but the control directly executes the exit: section of the code without reading the SMBIOS values. The code snippet within the for() loop is not getting executed.

Can you please help with this?

NTSTATUS ADXL345AccDevice::OnPrepareHardware(
In WDFDEVICE Device,
In WDFCMRESLIST ResourcesRaw,
In WDFCMRESLIST ResourcesTranslated)

{
TraceError(“%!FUNC! Enter\n”);

DWORD error = ERROR_SUCCESS;
DWORD smBiosDataSize = 0;
RawSMBIOSData* smBiosData = NULL; // Defined in this link
DWORD bytesWritten = 0;

// Query size of SMBIOS data.
smBiosDataSize = GetSystemFirmwareTable('RSMB', 0, NULL, 0);

// Allocate memory for SMBIOS data
smBiosData = (RawSMBIOSData*)HeapAlloc(GetProcessHeap(), 0, smBiosDataSize);
if (!smBiosData) {
    error = ERROR_OUTOFMEMORY;
    goto exit;
}

// Retrieve the SMBIOS table
bytesWritten = GetSystemFirmwareTable('RSMB', 0, smBiosData, smBiosDataSize);

if (bytesWritten != smBiosDataSize) {
    error = ERROR_INVALID_DATA;
    goto exit;
}
TraceError("GetSystemFirmwareTable %x\n", bytesWritten);
    
// Print data

TraceError(“DmiRevision %x, SMBIOSMajorVersion %x, SMBIOSMinorVersion %x, Length %x \n “, smBiosData->DmiRevision, smBiosData->SMBIOSMajorVersion, smBiosData->SMBIOSMinorVersion, smBiosData->Length);
for (int i = 0; i <= smBiosData->Length; i++)
{
TraceError(”%c\t”, i, smBiosData->SMBIOSTableData[i]);
if (i % 16 == 0)
{
TraceError(“\n”);
}
}
// Process the SMBIOS data and free the memory under an exit label
exit:
TraceError(“Heap free”);
HeapFree(GetProcessHeap(), 0, smBiosData);

}

Thanks,
Subashini.

but the control directly executes the exit: section of the code without reading the SMBIOS values

That would happen if smBiosData->Length were zero. Is it?