On Mon, Jun 18, 2018 at 05:09:32AM -0600, Alex Henrie wrote:
Signed-off-by: Alex Henrie alexhenrie24@gmail.com
dlls/ntdll/nt.c | 172 ++++++++++++++++++++++++++++++++++++++++ dlls/ntdll/tests/info.c | 11 ++- 2 files changed, 181 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c index dc0ce04f42..40e36c0ffd 100644 --- a/dlls/ntdll/nt.c +++ b/dlls/ntdll/nt.c @@ -1850,6 +1879,127 @@ static NTSTATUS create_logical_proc_info(SYSTEM_LOGICAL_PROCESSOR_INFORMATION ** } #endif
+static inline void copy_smbios_string(char **buffer, char *s, size_t len) +{
- if (!len) return;
- strcpy(*buffer, s);
- *buffer += len + 1;
+}
+#ifdef linux
+#define FWSS 128 /* firmware string size */
+static void get_smbios_string(const char *path, char *s, size_t *len) +{
- FILE *file = fopen(path, "r");
- if (!file)
- {
*len = 0;
return;
- }
- *len = fread(s, 1, FWSS - 1, file);
That's pretty ugly. This function really shouldn't assume the size of the buffer is has to play with.
- fclose(file);
- if (*len >= 1 && s[*len - 1] == '\n')
- {
s[*len - 1] = 0;
(*len)--;
- }
- else
- {
s[*len] = 0;
- }
+}
+static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti,
ULONG available_len, ULONG *required_len)
+{
- switch (sfti->ProviderSignature)
- {
- case RSMB:
{
char bios_vendor[FWSS], bios_version[FWSS], bios_date[FWSS];
size_t bios_vendor_len, bios_version_len, bios_date_len;
char *buffer = (char*)sfti->TableBuffer;
BYTE string_count;
struct smbios_prologue *prologue;
struct smbios_bios *bios;
get_smbios_string("/sys/class/dmi/id/bios_vendor", bios_vendor, &bios_vendor_len);
get_smbios_string("/sys/class/dmi/id/bios_version", bios_version, &bios_version_len);
get_smbios_string("/sys/class/dmi/id/bios_date", bios_date, &bios_date_len);