Skip to content

Commit 75ea749

Browse files
committed
Fix Windows and C++ support
1 parent 5442015 commit 75ea749

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed

smbios.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020

2121
#define VALID_VERSION(x) (((x) >= SMBIOS_2_0 && (x) <= SMBIOS_2_8) || (x) == SMBIOS_3_0)
2222

23-
#ifdef __cplusplus
24-
namespace smbios {
25-
#endif
26-
2723
static SMBIOS_CONSTEXPR size_t SMBIOS_HEADER_SIZE = 32;
2824
static SMBIOS_CONSTEXPR size_t SMBIOS_ENTRY_HEADER_SIZE = 4;
2925

@@ -768,6 +764,3 @@ int smbios_get_version(struct ParserContext *context, int *selected, int *origin
768764
return SMBERR_OK;
769765
}
770766

771-
#ifdef __cplusplus
772-
} // namespace smbios
773-
#endif

smbios_decode.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,20 @@
2424

2525
#include <Windows.h>
2626

27-
static bool getDMI( std::vector<uint8_t> &buffer )
27+
static bool get_dmi_data( uint8_t **buffer, size_t *size )
2828
{
2929
const BYTE byteSignature[] = { 'B', 'M', 'S', 'R' };
3030
const DWORD signature = *((DWORD*)byteSignature);
3131

3232
// get the size of SMBIOS table
33-
DWORD size = GetSystemFirmwareTable(signature, 0, NULL, 0);
34-
if (size == 0) return false;
35-
buffer.resize(size, 0);
36-
// retrieve the SMBIOS table
37-
38-
if (size != GetSystemFirmwareTable(Signature, 0, buffer.data(), size))
39-
{
40-
buffer.clear();
33+
*size = GetSystemFirmwareTable(signature, 0, NULL, 0);
34+
if (*size == 0)
4135
return false;
42-
}
43-
44-
return true;
36+
*buffer = (uint8_t*) malloc(*size);
37+
if (*buffer == NULL)
38+
return false;
39+
// retrieve the SMBIOS table
40+
return (*size == GetSystemFirmwareTable(signature, 0, *buffer, *size))
4541
}
4642

4743
#else

0 commit comments

Comments
 (0)