ReactOS 0.4.15-dev-6068-g8061a6f
dmilib.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS DMI/SMBIOS Library
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dmilib.c
5 * PURPOSE: SMBIOS table parsing functions
6 * PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org)
7 * REFERENCES: http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.0.0.pdf
8 */
9
10#include "precomp.h"
11
12static
16 _In_ ULONG FieldOffset)
17{
20
21 StringIndex = ((PUCHAR)Header)[FieldOffset];
22 if (StringIndex == 0)
23 {
24 return NULL;
25 }
26
27 String = (PCHAR)Header + Header->Length;
28
29 while (--StringIndex != 0)
30 {
31 while (*String != 0)
32 String++;
33
34 String++;
35 }
36
37 return String;
38}
39
40VOID
42 _In_reads_bytes_(TableSize) PVOID SMBiosTables,
45{
46 PMSSmBios_RawSMBiosTables BiosTablesHeader = SMBiosTables;
48 ULONG Remaining;
49 PCHAR Data;
50
51 Header = (PDMI_HEADER)(&BiosTablesHeader->SMBiosData);
52 Remaining = BiosTablesHeader->Size;
53
54 while (Remaining >= sizeof(*Header))
55 {
56 if (Header->Type == DMI_ENTRY_END_OF_TABLE)
57 break;
58
59 switch (Header->Type)
60 {
61 case DMI_ENTRY_BIOS:
62 if (Remaining < DMI_BIOS_SIZE)
63 return;
67 break;
68
70 if (Remaining < DMI_SYS_SIZE)
71 return;
78 break;
79
81 if (Remaining < DMI_BOARD_SIZE)
82 return;
88 break;
89
93 // DMI_ENTRY_IPMI_DEV?
94 // DMI_ENTRY_ONBOARD_DEV_EXT?
95 break;
96 }
97
98 Remaining -= Header->Length;
99 Data = (PCHAR)Header + Header->Length;
100
101 /* Now loop until we find 2 zeroes */
102 while ((Remaining >= 2) && ((Data[0] != 0) || (Data[1] != 0)))
103 {
104 Data++;
105 Remaining--;
106 }
107
108 if (Remaining < 2)
109 break;
110
111 /* Go to the next header */
112 Remaining -= 2;
113 Header = (PDMI_HEADER)((PUCHAR)Data + 2);
114 }
115}
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
Definition: Header.h:9
#define NULL
Definition: types.h:112
static const WCHAR Strings[]
Definition: reg.c:35
@ DMI_BOARD_ASSET_TAG
Definition: dmi.h:99
@ DMI_SYS_SIZE
Definition: dmi.h:92
@ DMI_BOARD_VERSION
Definition: dmi.h:97
@ DMI_BIOS_VERSION
Definition: dmi.h:81
@ DMI_BIOS_DATE
Definition: dmi.h:82
@ DMI_BOARD_NAME
Definition: dmi.h:96
@ DMI_BOARD_SERIAL
Definition: dmi.h:98
@ DMI_SYS_VENDOR
Definition: dmi.h:86
@ DMI_SYS_VERSION
Definition: dmi.h:88
@ DMI_BIOS_SIZE
Definition: dmi.h:83
@ DMI_SYS_SKU
Definition: dmi.h:90
@ DMI_BOARD_SIZE
Definition: dmi.h:100
@ DMI_SYS_PRODUCT
Definition: dmi.h:87
@ DMI_BOARD_VENDOR
Definition: dmi.h:95
@ DMI_SYS_FAMILY
Definition: dmi.h:91
@ DMI_SYS_SERIAL
Definition: dmi.h:89
@ DMI_BIOS_VENDOR
Definition: dmi.h:80
@ DMI_ENTRY_END_OF_TABLE
Definition: dmi.h:74
@ DMI_ENTRY_OEMSTRINGS
Definition: dmi.h:42
@ DMI_ENTRY_ONBOARD_DEVICE
Definition: dmi.h:41
@ DMI_ENTRY_BIOS
Definition: dmi.h:31
@ DMI_ENTRY_BASEBOARD
Definition: dmi.h:33
@ DMI_ENTRY_SYSTEM
Definition: dmi.h:32
@ DMI_ENTRY_CHASSIS
Definition: dmi.h:34
struct _DMI_HEADER * PDMI_HEADER
static PCHAR GetDmiString(_In_ PDMI_HEADER Header, _In_ ULONG FieldOffset)
Definition: dmilib.c:14
VOID ParseSMBiosTables(_In_reads_bytes_(TableSize) PVOID SMBiosTables, _In_ ULONG TableSize, _Inout_updates_(ID_STRINGS_MAX) PCHAR *Strings)
Definition: dmilib.c:41
@ BIOS_VERSION
Definition: dmilib.h:16
@ BOARD_VENDOR
Definition: dmilib.h:24
@ SYS_VERSION
Definition: dmilib.h:20
@ SYS_PRODUCT
Definition: dmilib.h:19
@ ID_STRINGS_MAX
Definition: dmilib.h:30
@ BOARD_ASSET_TAG
Definition: dmilib.h:28
@ BIOS_DATE
Definition: dmilib.h:17
@ SYS_VENDOR
Definition: dmilib.h:18
@ BIOS_VENDOR
Definition: dmilib.h:15
@ BOARD_NAME
Definition: dmilib.h:25
@ BOARD_VERSION
Definition: dmilib.h:26
@ BOARD_SERIAL
Definition: dmilib.h:27
@ SYS_SERIAL
Definition: dmilib.h:21
@ SYS_FAMILY
Definition: dmilib.h:23
@ SYS_SKU
Definition: dmilib.h:22
#define PCHAR
Definition: match.c:90
#define _In_reads_bytes_(size)
Definition: ms_sal.h:321
#define _Inout_updates_(size)
Definition: ms_sal.h:387
#define _In_
Definition: ms_sal.h:308
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR StringIndex
Definition: wdfusb.h:1080
_Must_inspect_result_ typedef _Out_ PULONG TableSize
Definition: iotypes.h:4327