From a9f20984cd0ea327bfd5f509e6afc6c4a5b2ff1d Mon Sep 17 00:00:00 2001 From: Stanislav Motylkov Date: Sun, 15 Apr 2018 01:56:32 +0300 Subject: [PATCH] [I8042PRT] Dump SMBIOS tables into registry for usermode access Reference: https://social.msdn.microsoft.com/Forums/en-US/0bb0840e-85f4-4cdb-9710-7581f7348f2f/how-to-get-motherboard-serial-number-without-using-wmi-in-c CORE-12105 CORE-14867 --- drivers/input/i8042prt/hwhacks.c | 70 ++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/drivers/input/i8042prt/hwhacks.c b/drivers/input/i8042prt/hwhacks.c index c7915e16fd4..885f0a25a54 100644 --- a/drivers/input/i8042prt/hwhacks.c +++ b/drivers/input/i8042prt/hwhacks.c @@ -226,6 +226,70 @@ i8042ParseSMBiosTables( } } +static +VOID +i8042StoreSMBiosTables( + _In_reads_bytes_(TableSize) PVOID SMBiosTables, + _In_ ULONG TableSize) +{ + static UNICODE_STRING mssmbiosKeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services\\mssmbios"); + static UNICODE_STRING DataName = RTL_CONSTANT_STRING(L"Data"); + static UNICODE_STRING ValueName = RTL_CONSTANT_STRING(L"SMBiosData"); + OBJECT_ATTRIBUTES ObjectAttributes; + HANDLE KeyHandle = NULL, SubKeyHandle = NULL; + NTSTATUS Status; + + /* Create registry key */ + InitializeObjectAttributes(&ObjectAttributes, + &mssmbiosKeyName, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + NULL, + NULL); + Status = ZwCreateKey(&KeyHandle, + KEY_WRITE, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_VOLATILE, + NULL); + + if (!NT_SUCCESS(Status)) + { + return; + } + + /* Create sub key */ + InitializeObjectAttributes(&ObjectAttributes, + &DataName, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + KeyHandle, + NULL); + Status = ZwCreateKey(&SubKeyHandle, + KEY_WRITE, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_VOLATILE, + NULL); + + if (!NT_SUCCESS(Status)) + { + ZwClose(KeyHandle); + return; + } + + /* Write value */ + ZwSetValueKey(SubKeyHandle, + &ValueName, + 0, + REG_BINARY, + SMBiosTables, + TableSize); + + ZwClose(SubKeyHandle); + ZwClose(KeyHandle); +} + VOID NTAPI i8042InitializeHwHacks( @@ -271,6 +335,12 @@ i8042InitializeHwHacks( return; } + /* FIXME: This function should be removed once the mssmbios driver is implemented */ + /* Store SMBios data in registry */ + i8042StoreSMBiosTables(AllData + 1, + AllData->FixedInstanceSize); + DPRINT1("SMBiosTables HACK, see CORE-14867\n"); + /* Parse the table */ i8042ParseSMBiosTables(AllData + 1, AllData->WnodeHeader.BufferSize);