lazybios 3.0.0
Lightweight SMBIOS/DMI parsing library
Loading...
Searching...
No Matches
lazybios_internal.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: LGPL-2.1-or-later
3 *
4 * This file is part of lazybios.
5 *
6 * lazybios is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 2.1 of the License, or
9 * (at your option) any later version.
10 *
11 * lazybios is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with lazybios. If not, see <https://www.gnu.org/licenses/>.
18 */
19/**
20 * @file lazybios_internal.h
21 * @brief Internal constants and parser helpers for lazybios implementation files.
22 * @author LazySeldi
23 */
24
25#ifndef LAZYBIOS_INTERNAL_H
26#define LAZYBIOS_INTERNAL_H
27
28#include "lazybios/lazybios.h"
29
30#include <stdarg.h>
31#include <stdio.h>
32#include <stdlib.h>
33#include <string.h>
34
35// Logging system for lazybios
36
37#ifndef LAZYBIOS_QUIET
38#if defined(__MINGW32__)
39__attribute__((format(gnu_printf, 2, 3)))
40#elif defined(__GNUC__)
41__attribute__((format(printf, 2, 3)))
42#endif
43static inline void lazybios_log_internal(const char* prefix, const char* fmt, ...) {
44 va_list args;
45 va_start(args, fmt);
46 fprintf(stderr, "%s", prefix);
47 vfprintf(stderr, fmt, args);
48 fprintf(stderr, "\n");
49 va_end(args);
50}
51#endif
52
53#ifdef LAZYBIOS_QUIET
54# define lb_log(...) ((void)0)
55# define lb_dbg(...) ((void)0)
56
57#elif defined(LAZYBIOS_DEBUG)
58# define lb_log(...) lazybios_log_internal("[lazybios] ", __VA_ARGS__)
59# define lb_dbg(...) lazybios_log_internal("[lazybios-dbg] ", __VA_ARGS__)
60
61#else
62# define lb_log(...) lazybios_log_internal("[lazybios] ", __VA_ARGS__)
63# define lb_dbg(...) ((void)0)
64#endif
65
66/**
67 * @brief Appends formatted text to a decoder output buffer.
68 *
69 * snprintf returns the length the output *would* have had, so accumulating its
70 * return value lets the running length run past the buffer: the next append
71 * then writes at buf + len with a wrapped-around buf_len - len. This keeps
72 * *len at the number of bytes actually written, never above buf_len - 1, so
73 * later appends and the trailing-separator trim stay inside the buffer.
74 *
75 * @param buf Output buffer, may be NULL only when buf_len is zero.
76 * @param buf_len Capacity of buf in bytes.
77 * @param len Running output length, updated in place.
78 * @param fmt printf-style format for the text to append.
79 */
80#if defined(__MINGW32__)
81__attribute__((format(gnu_printf, 4, 5)))
82#elif defined(__GNUC__)
83__attribute__((format(printf, 4, 5)))
84#endif
85static inline void lazybiosDecoderAppend(char* buf, size_t buf_len, size_t* len, const char* fmt, ...) {
86 if (!buf || buf_len == 0 || *len + 1 >= buf_len) return;
87
88 size_t remaining = buf_len - *len;
89
90 /*
91 * Nearly every decoder appends a plain literal, so checking for a
92 * conversion first lets the common case copy the bytes straight in and
93 * never enter the format-parsing machinery. strchr/strlen measured faster
94 * than a hand-rolled scan here; the strings are long enough that the
95 * vectorized libc versions win.
96 */
97 if (!strchr(fmt, '%')) {
98 size_t n = strlen(fmt);
99 if (n >= remaining) n = remaining - 1;
100 memcpy(buf + *len, fmt, n);
101 buf[*len + n] = '\0';
102 *len += n;
103 return;
104 }
105
106 va_list args;
107 va_start(args, fmt);
108 int written = vsnprintf(buf + *len, remaining, fmt, args);
109 va_end(args);
110
111 if (written < 0) return;
112 *len += ((size_t)written >= remaining) ? remaining - 1 : (size_t)written;
113}
114
115/**
116 * @brief Scratch buffer size for the file-local decoders.
117 *
118 * The longest decoding in the corpus is a Type 0 characteristics list at just
119 * over 500 bytes, so this leaves generous headroom; the decoded text is copied
120 * to an exact-sized allocation afterwards.
121 */
122#define LAZYBIOS_DECODER_BUF_SIZE 1024
123
124/**
125 * @brief Duplicates a NUL-terminated string with malloc.
126 *
127 * strdup is POSIX rather than C99, so the parsers use this when storing a
128 * decoded string that the record owns.
129 *
130 * @param src String to copy, may be NULL.
131 * @return Newly allocated copy, or NULL on failure or a NULL input.
132 */
133static inline char* lazybiosDup(const char* src) {
134 if (!src) return NULL;
135 size_t n = strlen(src) + 1;
136 char* out = malloc(n);
137 if (out) memcpy(out, src, n);
138 return out;
139}
140
141/** @brief Size of an SMBIOS structure header (type, length, handle). */
142#define SMBIOS_HEADER_SIZE 4
143
144/** @brief Absolute path to the Linux sysfs SMBIOS entry point. */
145#define LINUX_SYSFS_SMBIOS_ENTRY "/sys/firmware/dmi/tables/smbios_entry_point"
146
147/** @brief Absolute path to the Linux sysfs DMI table. */
148#define LINUX_SYSFS_DMI_TABLE "/sys/firmware/dmi/tables/DMI"
149
150/** @brief Absolute path to the physical memory device. */
151#define DEV_MEM "/dev/mem"
152
153#define SMBIOS_TYPE_BIOS 0
154#define SMBIOS_TYPE_SYSTEM 1
155#define SMBIOS_TYPE_BASEBOARD 2
156#define SMBIOS_TYPE_CHASSIS 3
157#define SMBIOS_TYPE_PROCESSOR 4
158#define SMBIOS_TYPE_MEMORY_CONTROLLER 5
159#define SMBIOS_TYPE_MEMORY_MODULE 6
160#define SMBIOS_TYPE_CACHES 7
161#define SMBIOS_TYPE_PORT_CONNECTOR 8
162#define SMBIOS_TYPE_SYSTEM_SLOTS 9
163#define SMBIOS_TYPE_ONBOARD_DEVICES 10
164#define SMBIOS_TYPE_OEM_STRINGS 11
165#define SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS 12
166#define SMBIOS_TYPE_FIRMWARE_LANGUAGE_INFORMATION 13
167#define SMBIOS_TYPE_GROUP_ASSOCIATIONS 14
168#define SMBIOS_TYPE_SYSTEM_EVENT_LOG 15
169#define SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY 16
170#define SMBIOS_TYPE_MEMORY_DEVICE 17
171#define SMBIOS_TYPE_32BIT_MEMORY_ERROR_INFORMATION 18
172#define SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS 19
173#define SMBIOS_TYPE_MEMORY_DEVICE_MAPPED_ADDRESS 20
174#define SMBIOS_TYPE_BUILT_IN_POINTING_DEVICE 21
175#define SMBIOS_TYPE_PORTABLE_BATTERY 22
176#define SMBIOS_TYPE_SYSTEM_RESET 23
177#define SMBIOS_TYPE_HARDWARE_SECURITY 24
178#define SMBIOS_TYPE_SYSTEM_POWER_CONTROLS 25
179#define SMBIOS_TYPE_VOLTAGE_PROBE 26
180#define SMBIOS_TYPE_COOLING_DEVICE 27
181#define SMBIOS_TYPE_TEMPERATURE_PROBE 28
182#define SMBIOS_TYPE_ELECTRICAL_CURRENT_PROBE 29
183#define SMBIOS_TYPE_OUT_OF_BAND_REMOTE_ACCESS 30
184#define SMBIOS_TYPE_BOOT_INTEGRITY_SERVICES_ENTRY_POINT 31
185#define SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION 32
186#define SMBIOS_TYPE_64BIT_MEMORY_ERROR_INFORMATION 33
187#define SMBIOS_TYPE_MANAGEMENT_DEVICE 34
188#define SMBIOS_TYPE_MANAGEMENT_DEVICE_COMPONENT 35
189#define SMBIOS_TYPE_MANAGEMENT_DEVICE_THRESHOLD_DATA 36
190#define SMBIOS_TYPE_MEMORY_CHANNEL 37
191#define SMBIOS_TYPE_IPMI_DEVICE_INFORMATION 38
192#define SMBIOS_TYPE_SYSTEM_POWER_SUPPLY 39
193#define SMBIOS_TYPE_ADDITIONAL_INFORMATION 40
194#define SMBIOS_TYPE_ONBOARD_DEVICES_EXTENDED_INFORMATION 41
195#define SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE 42
196#define SMBIOS_TYPE_TPM_DEVICE 43
197#define SMBIOS_TYPE_PROCESSOR_ADDITIONAL_INFORMATION 44
198#define SMBIOS_TYPE_FIRMWARE_INVENTORY_INFORMATION 45
199#define SMBIOS_TYPE_STRING_PROPERTY 46
200#define SMBIOS_TYPE_END 127
201
202// HP
203#define SMBIOS_OEM_HP_TYPE204 204
204
205
206// DELL
207#define SMBIOS_OEM_DELL_TYPE177 177
208#define SMBIOS_OEM_DELL_TYPE212 212
209#define SMBIOS_OEM_DELL_TYPE218 218
210
211
212#define SMBIOS3_ANCHOR "_SM3_"
213#define SMBIOS3_ANCHOR_OFFSET 0x00
214#define SMBIOS3_CHECKSUM_OFFSET 0x05
215#define SMBIOS3_LENGTH_OFFSET 0x06
216#define SMBIOS3_MAJOR_OFFSET 0x07
217#define SMBIOS3_MINOR_OFFSET 0x08
218#define SMBIOS3_DOCREV_OFFSET 0x09
219#define SMBIOS3_REVISION_OFFSET 0x0A
220#define SMBIOS3_RESERVED_OFFSET 0x0B
221#define SMBIOS3_TABLE_MAX_SIZE_OFFSET 0x0C
222#define SMBIOS3_TABLE_ADDRESS_OFFSET 0x10
223#define SMBIOS3_ENTRY_POINT_LENGTH 0x18
224#define SMBIOS3_ANCHOR_SIZE 5
225
226#define SMBIOS2_ANCHOR "_SM_"
227#define SMBIOS2_INTERMEDIATE_ANCHOR "_DMI_"
228#define SMBIOS2_ANCHOR_OFFSET 0x00
229#define SMBIOS2_CHECKSUM_OFFSET 0x04
230#define SMBIOS2_LENGTH_OFFSET 0x05
231#define SMBIOS2_MAJOR_OFFSET 0x06
232#define SMBIOS2_MINOR_OFFSET 0x07
233#define SMBIOS2_MAX_STRUCTURE_SIZE_OFFSET 0x08
234#define SMBIOS2_REVISION_OFFSET 0x0A
235#define SMBIOS2_FORMATTED_AREA_OFFSET 0x0B
236#define SMBIOS2_INTERMEDIATE_ANCHOR_OFFSET 0x10
237#define SMBIOS2_INTERMEDIATE_CHECKSUM_OFFSET 0x15
238#define SMBIOS2_TABLE_LENGTH_OFFSET 0x16
239#define SMBIOS2_TABLE_ADDRESS_OFFSET 0x18
240#define SMBIOS2_STRUCTURE_COUNT_OFFSET 0x1C
241#define SMBIOS2_BCD_REVISION_OFFSET 0x1E
242#define SMBIOS2_ENTRY_POINT_LENGTH 0x1F
243#define SMBIOS2_ENTRY_POINT_LENGTH_V21 0x1E
244#define SMBIOS2_ANCHOR_SIZE 4
245#define SMBIOS2_INTERMEDIATE_ANCHOR_SIZE 5
246#define SMBIOS2_FORMATTED_AREA_SIZE 5
247
248/** @brief Marks a parsed structure field as present and valid. */
249#define LAZYBIOS_MARK_PRESENT(record, field) do { \
250 (record)->field_status.field = (lazybiosFieldStatus_t)LAZYBIOS_FIELD_PRESENT; \
251} while (0)
252
253/** @brief Marks a parsed structure field as absent. */
254#define LAZYBIOS_MARK_ABSENT(record, field) do { \
255 (record)->field_status.field = (lazybiosFieldStatus_t)LAZYBIOS_FIELD_ABSENT; \
256} while (0)
257
258/** @brief Marks a parsed structure field as unreachable (structure too short for newer spec version). */
259#define LAZYBIOS_MARK_UNREACHABLE(record, field) do { \
260 (record)->field_status.field = (lazybiosFieldStatus_t)LAZYBIOS_FIELD_UNREACHABLE; \
261} while (0)
262
263/** @brief Clamps a structure length against available buffer boundaries. */
264#define LAZYBIOS_CLAMP_STRUCTURE_LENGTH(len, p, end) do { \
265 if ((size_t)((end) - (p)) < (size_t)(len)) { \
266 (len) = (uint8_t)((end) - (p)); \
267 } \
268} while (0)
269
270/**
271 * Internal, platform-neutral backend transformations.
272 *
273 * Keeping firmware byte validation separate from the operating-system calls
274 * lets the same code run under unit tests and libFuzzer on every host.
275 */
282
283/** @brief Inspects and validates an SMBIOS 2.x or 3.x entry point. */
284int lazybiosInspectEntryPoint(const uint8_t* entry_data, size_t available, lazybiosEntryInspection* inspection);
285/** @brief Copies validated raw entry-point and DMI-table buffers into a context. */
286int lazybiosLoadRawBuffers(lazybiosCTX_t* ctx, const uint8_t* entry_data, size_t entry_len, const uint8_t* dmi_data, size_t dmi_len);
287/** @brief Loads the Windows raw SMBIOS table format into a context. */
288int lazybiosLoadWindowsRawSMBIOSData(lazybiosCTX_t* ctx, const uint8_t* raw_data, size_t raw_len);
289/** @brief Finds a valid SMBIOS entry point within a memory image. */
290int lazybiosFindSMBIOSEntryPoint(const uint8_t* image, size_t image_len, size_t* entry_offset, size_t* entry_len);
291/** @brief Extracts an SMBIOS table address and length from an entry point. */
292int lazybiosGetSMBIOSTableLocation(const uint8_t* entry_data, size_t available, size_t* entry_len, uint64_t* table_address, size_t* table_len);
293/** @brief Determines the entry-point and table layout in a combined dump file. */
294int lazybiosGetSingleFileLayout(const uint8_t* entry_data, size_t available, size_t file_len, size_t* entry_len, size_t* table_offset, size_t* table_len);
295
296/**
297 * @brief Copies a string from an SMBIOS structure's string-set.
298 * @param p Start of the SMBIOS structure.
299 * @param length Length of the structure's formatted section.
300 * @param index One-based index of the requested string.
301 * @param end Address of the next structure, as returned by DMINext, which is
302 * two bytes past this structure's string-set terminator.
303 * @return Pointer to a string in the DMI table, or NULL if the string is unavailable or invalid.
304 */
305const char* DMIString(const uint8_t* p, uint8_t length, uint8_t index, const uint8_t* end);
306
307/**
308 * @brief Locates the next SMBIOS structure in a DMI table.
309 * @param p Start of the current SMBIOS structure.
310 * @param end One-past-the-end address of the DMI table buffer.
311 * @return Pointer to the next structure, or end when no complete structure remains.
312 */
313const uint8_t* DMINext(const uint8_t* p, const uint8_t* end);
314
315/**
316 * @brief Counts SMBIOS structures having a specified type identifier.
317 * @param DMIData Raw DMI table container to inspect.
318 * @param target_type SMBIOS structure type identifier to count.
319 * @return Number of matching structures in the table, -1 if index is already filled.
320 */
321size_t lazybiosCountStructsByType(const lazybiosDMI_t* DMIData, uint8_t target_type);
322/**
323 * @brief Loads an SMBIOS entry point and DMI table from separate files.
324 * @param ctx Context that receives the loaded data.
325 * @param entry_path Path to the raw SMBIOS entry point file.
326 * @param dmi_path Path to the raw DMI structure table file.
327 * @return 0 on success, or -1 on failure.
328 */
329LAZYBIOS_WARN_UNUSED int lazybiosFile(lazybiosCTX_t* ctx, const char* entry_path, const char* dmi_path);
330
331/**
332 * @brief Loads SMBIOS entry point and DMI data from one merged file.
333 * @param ctx Context that receives the loaded data.
334 * @param bin_path Path to a file containing the entry point and DMI table,
335 * either concatenated or separated by an advertised file-relative offset.
336 * @return 0 on success, or -1 on failure.
337 */
338LAZYBIOS_WARN_UNUSED int lazybiosSingleFile(lazybiosCTX_t* ctx, const char* bin_path);
339
340/**
341 * @brief Validates and identifies an SMBIOS entry point.
342 * @param ctx Context whose entry tag and tagged union are updated.
343 * @param entry_buf Buffer containing an SMBIOS 2.x or 3.x entry point.
344 * @param buf_len Length of entry_buf in bytes.
345 * @return 0 on success, or -1 if the entry point is invalid.
346 */
347int lazybiosParseEntry(lazybiosCTX_t* ctx, const uint8_t* entry_buf, size_t buf_len);
348
349
350#define READSTR(record, field, len, offset, p, end) do { \
351 if ((len) > (offset)) { \
352 (record)->field = DMIString((p), (len), (p)[(offset)], (end)); \
353 if ((record)->field != NULL) { \
354 LAZYBIOS_MARK_PRESENT((record), field); \
355 } else { \
356 LAZYBIOS_MARK_ABSENT((record), field); \
357 } \
358 } else { \
359 (record)->field = NULL; \
360 LAZYBIOS_MARK_ABSENT((record), field); \
361 } \
362} while (0)
363
364#define READU8(record, field, len, offset, p) do { \
365 if ((len) > (offset)) { \
366 (record)->field = (p)[(offset)]; \
367 LAZYBIOS_MARK_PRESENT((record), field); \
368 } else { \
369 (record)->field = 0; \
370 LAZYBIOS_MARK_ABSENT((record), field); \
371 } \
372} while (0)
373
374#define READU16(record, field, len, offset, p) do { \
375 if ((size_t)(len) >= (size_t)(offset) + sizeof(uint16_t)) { \
376 memcpy(&(record)->field, (p) + (offset), sizeof(uint16_t)); \
377 LAZYBIOS_MARK_PRESENT((record), field); \
378 } else { \
379 (record)->field = 0; \
380 LAZYBIOS_MARK_ABSENT((record), field); \
381 } \
382} while (0)
383
384#define READU32(record, field, len, offset, p) do { \
385 if ((size_t)(len) >= (size_t)(offset) + sizeof(uint32_t)) { \
386 memcpy(&(record)->field, (p) + (offset), sizeof(uint32_t)); \
387 LAZYBIOS_MARK_PRESENT((record), field); \
388 } else { \
389 (record)->field = 0; \
390 LAZYBIOS_MARK_ABSENT((record), field); \
391 } \
392} while (0)
393
394#define READU64(record, field, len, offset, p) do { \
395 if ((size_t)(len) >= (size_t)(offset) + sizeof(uint64_t)) { \
396 memcpy(&(record)->field, (p) + (offset), sizeof(uint64_t)); \
397 LAZYBIOS_MARK_PRESENT((record), field); \
398 } else { \
399 (record)->field = 0; \
400 LAZYBIOS_MARK_ABSENT((record), field); \
401 } \
402} while (0)
403
404#if defined(OS_LINUX)
405/** @brief Loads SMBIOS data through the Linux backend. */
406int lazybiosLinux(lazybiosCTX_t* ctx);
407#endif
408
409#if defined(OS_WINDOWS)
410/** @brief Loads SMBIOS data through the Windows backend. */
411int lazybiosWindows(lazybiosCTX_t* ctx);
412#endif
413
414#if defined(OS_MACOS)
415/** @brief Loads SMBIOS data through the macOS backend. */
416int lazybiosMacOS(lazybiosCTX_t* ctx);
417#endif
418
419#if defined(OS_OPENBSD)
420/** @brief Loads SMBIOS data through the OpenBSD backend. */
421int lazybiosOpenBSD(lazybiosCTX_t* ctx);
422#endif
423
424#if defined(OS_FREEBSD)
425/** @brief Loads SMBIOS data through the FreeBSD backend. */
426int lazybiosFreeBSD(lazybiosCTX_t* ctx);
427#endif
428
429#if defined(OS_NETBSD)
430/** @brief Loads SMBIOS data through the NetBSD backend. */
431int lazybiosNetBSD(lazybiosCTX_t* ctx);
432#endif
433
434#if defined(OS_SUNOS)
435/** @brief Loads SMBIOS data through the SunOS backend. */
436int lazybiosSunOS(lazybiosCTX_t* ctx);
437#endif
438
439#if defined(OS_DRAGONFLY)
440/** @brief Loads SMBIOS data through the DragonFly BSD backend. */
441int lazybiosDragonFly(lazybiosCTX_t* ctx);
442#endif
443
444#if defined(OS_HAIKU)
445/** @brief Loads SMBIOS data through the Haiku backend. */
446int lazybiosHaiku(lazybiosCTX_t* ctx);
447#endif
448
449#if defined(OS_BEOS)
450/** @brief Loads SMBIOS data through the BeOS backend. */
451int lazybiosBeOS(lazybiosCTX_t* ctx);
452#endif
453
454#if defined(OS_REACTOS)
455/** @brief Loads SMBIOS data through the ReactOS backend. */
456int lazybiosReactOS(lazybiosCTX_t* ctx);
457#endif
458
459#if defined(OS_QNX)
460/** @brief Loads SMBIOS data through the QNX Neutrino backend. */
461int lazybiosQNX(lazybiosCTX_t* ctx);
462#endif
463
464#if defined(OS_MINIX)
465/** @brief Loads SMBIOS data through the MINIX 3 backend. */
466int lazybiosMINIX(lazybiosCTX_t* ctx);
467#endif
468
469#if defined(OS_GENERIC)
470/** @brief Loads SMBIOS data through the generic legacy backend. */
471int lazybiosGeneric(lazybiosCTX_t* ctx);
472#endif
473
474#if defined(OS_HAIKU) || defined(OS_BEOS) || defined(OS_GENERIC) || \
475 defined(OS_QNX) || defined(OS_MINIX)
476/** @brief Loads an SMBIOS table from a legacy physical-memory device. */
477int lazybiosLoadLegacyPhysicalMemory(lazybiosCTX_t* ctx,
478 const char* const* device_paths, size_t device_count,
479 const char* platform_name);
480#endif
481
482#endif
char const int length
Definition cJSON.h:169
int index
Definition cJSON.h:176
int cJSON_bool fmt
Definition cJSON.h:166
char const int const cJSON_bool format
Definition cJSON.h:169
lazybiosSMBIOSVersionTag
Identifies the SMBIOS entry point layout stored in a DMI container.
Definition lazybios.h:208
Public API for lazybios. Include this and nothing else.
#define LAZYBIOS_WARN_UNUSED
Expands to nothing on compilers without a return-value check.
Definition lazybios.h:150
int lazybiosGetSMBIOSTableLocation(const uint8_t *entry_data, size_t available, size_t *entry_len, uint64_t *table_address, size_t *table_len)
Extracts an SMBIOS table address and length from an entry point.
static char * lazybiosDup(const char *src)
Duplicates a NUL-terminated string with malloc.
const uint8_t * DMINext(const uint8_t *p, const uint8_t *end)
Locates the next SMBIOS structure in a DMI table.
int lazybiosParseEntry(lazybiosCTX_t *ctx, const uint8_t *entry_buf, size_t buf_len)
Validates and identifies an SMBIOS entry point.
int lazybiosLoadRawBuffers(lazybiosCTX_t *ctx, const uint8_t *entry_data, size_t entry_len, const uint8_t *dmi_data, size_t dmi_len)
Copies validated raw entry-point and DMI-table buffers into a context.
const char * DMIString(const uint8_t *p, uint8_t length, uint8_t index, const uint8_t *end)
Copies a string from an SMBIOS structure's string-set.
static void lazybios_log_internal(const char *prefix, const char *fmt,...)
static void lazybiosDecoderAppend(char *buf, size_t buf_len, size_t *len, const char *fmt,...)
Appends formatted text to a decoder output buffer.
int lazybiosFindSMBIOSEntryPoint(const uint8_t *image, size_t image_len, size_t *entry_offset, size_t *entry_len)
Finds a valid SMBIOS entry point within a memory image.
LAZYBIOS_WARN_UNUSED int lazybiosSingleFile(lazybiosCTX_t *ctx, const char *bin_path)
Loads SMBIOS entry point and DMI data from one merged file.
int lazybiosInspectEntryPoint(const uint8_t *entry_data, size_t available, lazybiosEntryInspection *inspection)
Inspects and validates an SMBIOS 2.x or 3.x entry point.
LAZYBIOS_WARN_UNUSED int lazybiosFile(lazybiosCTX_t *ctx, const char *entry_path, const char *dmi_path)
Loads an SMBIOS entry point and DMI table from separate files.
int lazybiosGetSingleFileLayout(const uint8_t *entry_data, size_t available, size_t file_len, size_t *entry_len, size_t *table_offset, size_t *table_len)
Determines the entry-point and table layout in a combined dump file.
size_t lazybiosCountStructsByType(const lazybiosDMI_t *DMIData, uint8_t target_type)
Counts SMBIOS structures having a specified type identifier.
int lazybiosLoadWindowsRawSMBIOSData(lazybiosCTX_t *ctx, const uint8_t *raw_data, size_t raw_len)
Loads the Windows raw SMBIOS table format into a context.
Owns raw DMI table data and its parsed SMBIOS entry point.
Definition lazybios.h:218
lazybiosSMBIOSVersionTag tag