smbios-parser
smbios-parser copied to clipboard
Windows support broken
Hello. I just discovered this project.
But trying to build for _WIN32 is broken at the moment. Seems it has never worked.
Several issues:
- Use of
std::vectorw/o an#include <vector> Signatureshould besignature.getDMI()should be calledget_dmi_data()- etc.
So with this patch it works for MSVC and clang-cl:
--- a/smbios_decode.c 2024-12-13 01:43:15
+++ b/smbios_decode.c 2025-09-13 07:25:05
@@ -24,22 +24,24 @@
#include <Windows.h>
-static bool getDMI( std::vector<uint8_t> &buffer )
+static bool get_dmi_data( uint8_t **buffer, size_t *size )
{
const BYTE byteSignature[] = { 'B', 'M', 'S', 'R' };
const DWORD signature = *((DWORD*)byteSignature);
// get the size of SMBIOS table
- DWORD size = GetSystemFirmwareTable(signature, 0, NULL, 0);
- if (size == 0) return false;
- buffer.resize(size, 0);
+ *size = GetSystemFirmwareTable(signature, 0, NULL, 0);
+ if (*size == 0)
+ return false;
+
+ *buffer = (uint8_t*) malloc(*size);
+ if (*buffer == NULL)
+ return false;
+
// retrieve the SMBIOS table
- if (size != GetSystemFirmwareTable(Signature, 0, buffer.data(), size))
- {
- buffer.clear();
+ if (*size != GetSystemFirmwareTable(signature, 0, *buffer, *size))
return false;
- }
return true;
}
Wait, there are more issues. If you were serious about compiling smbios.c as C++, there are these errors:
smbios.c(131,12): error: call to 'smbios_get_string' is ambiguous
131 | return smbios_get_string(&context->entry, index);
| ^~~~~~~~~~~~~~~~~
smbios.h(493,27): note: candidate function
493 | SMBIOS_EXPORT const char *smbios_get_string( const struct Entry *entry, int index );
| ^
smbios.c(115,13): note: candidate function
115 | const char *smbios_get_string( const struct Entry *entry, int index )
| ^
smbios.c(753,9): error: call to 'smbios_reset' is ambiguous
753 | smbios_reset(context);
| ^~~~~~~~~~~~
smbios.h(461,19): note: candidate function
461 | SMBIOS_EXPORT int smbios_reset(struct ParserContext * context);
| ^
smbios.c(134,5): note: candidate function
134 | int smbios_reset( struct ParserContext *context )
| ^
2 errors generated.
Thanks for reporting this! I refactored the code a while back and overlooked those parts. I no longer have any Windows machines, so I forgot to update the code to load SMBIOS info in Windows environments. As for the C++ issue, it was caused by an outdated namespace definition, which has already been removed from the header file.