ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
August 2018
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
32 participants
304 discussions
Start a n
N
ew thread
03/03: [KERNEL32] Implement System Firmware functions
by Stanislav Motylkov
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d956eafda8b91384537fa…
commit d956eafda8b91384537fa4a167f2e9ebb600915f Author: Stanislav Motylkov <x86corez(a)gmail.com> AuthorDate: Sun Jul 29 23:50:15 2018 +0300 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Thu Aug 2 21:15:28 2018 +0200 [KERNEL32] Implement System Firmware functions - Implement EnumSystemFirmwareTables - Implement GetSystemFirmwareTable These functions currently using registry workaround and can be improved later. CORE-12105 --- dll/win32/kernel32/client/sysinfo.c | 282 +++++++++++++++++++++++++++++++++++- 1 file changed, 274 insertions(+), 8 deletions(-) diff --git a/dll/win32/kernel32/client/sysinfo.c b/dll/win32/kernel32/client/sysinfo.c index f57717a33d..92474d050a 100644 --- a/dll/win32/kernel32/client/sysinfo.c +++ b/dll/win32/kernel32/client/sysinfo.c @@ -7,6 +7,7 @@ * Christoph von Wittich * Thomas Weidenmueller * Gunnar Andre Dalsnes + * Stanislav Motylkov */ /* INCLUDES *******************************************************************/ @@ -74,6 +75,82 @@ GetSystemInfoInternal(IN PSYSTEM_BASIC_INFORMATION BasicInfo, } } +UINT +WINAPI +GetRawSMBiosTableFromRegistry(OUT PVOID pData) +{ + static const LPCWSTR RegistryKey = L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\mssmbios\\Data"; + static const LPCWSTR ValueNameStr = L"SMBiosData"; + + PKEY_VALUE_PARTIAL_INFORMATION KeyInfo = NULL; + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING KeyName; + UNICODE_STRING ValueName; + HANDLE KeyHandle; + ULONG KeyInfoSize; + ULONG ReturnSize = 0; + NTSTATUS Status; + + RtlInitUnicodeString(&KeyName, RegistryKey); + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + + Status = NtOpenKey(&KeyHandle, + KEY_READ, + &ObjectAttributes); + if (!NT_SUCCESS(Status)) + { + return 0; + } + + // 256 KiB is more than enough for raw SMBIOS dump + KeyInfoSize = sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 256 * 1024; + KeyInfo = RtlAllocateHeap(RtlGetProcessHeap(), 0, KeyInfoSize); + if (KeyInfo == NULL) + { + NtClose(KeyHandle); + goto cleanup; + } + + RtlInitUnicodeString(&ValueName, ValueNameStr); + + Status = NtQueryValueKey(KeyHandle, + &ValueName, + KeyValuePartialInformation, + KeyInfo, + KeyInfoSize, + &ReturnSize); + + NtClose(KeyHandle); + ReturnSize = 0; + + if (!NT_SUCCESS(Status)) + { + goto cleanup; + } + + if (KeyInfo->Type != REG_BINARY) + { + goto cleanup; + } + + ReturnSize = KeyInfo->DataLength; + if (pData) + { + RtlCopyMemory(pData, KeyInfo->Data, KeyInfo->DataLength); + } + +cleanup: + if (KeyInfo) + { + RtlFreeHeap(RtlGetProcessHeap(), 0, KeyInfo); + } + return ReturnSize; +} + /* PUBLIC FUNCTIONS ***********************************************************/ /* @@ -423,8 +500,32 @@ SetFirmwareEnvironmentVariableA(IN LPCSTR lpName, return 0; } -/* - * @unimplemented +/** + * @name EnumSystemFirmwareTables + * @implemented + * + * Obtains firmware table identifiers. + *
https://msdn.microsoft.com/en-us/library/windows/desktop/ms724259(v=vs.85).…
+ * + * @param FirmwareTableProviderSignature + * Can be either ACPI, FIRM, or RSMB. + * + * @param pFirmwareTableBuffer + * Pointer to the output buffer, can be NULL. + * + * @param BufferSize + * Size of the output buffer. + * + * @return + * Actual size of the data in case of success, 0 otherwise. + * + * @remarks + * Data would be written to buffer only if the specified size is + * larger or equal to the actual size, in the other case Last Error + * value would be set to ERROR_INSUFFICIENT_BUFFER. + * In case of incorrect provider signature, Last Error value would be + * set to ERROR_INVALID_FUNCTION. + * */ UINT WINAPI @@ -432,12 +533,104 @@ EnumSystemFirmwareTables(IN DWORD FirmwareTableProviderSignature, OUT PVOID pFirmwareTableBuffer, IN DWORD BufferSize) { - STUB; - return 0; + UINT uSize = 0; + UINT uCount = 0; + DWORD dwError = ERROR_SUCCESS; + PDWORD pBuffer = NULL; + + switch (FirmwareTableProviderSignature) + { + case 'ACPI': + { + /* FIXME: Not implemented yet */ + dwError = ERROR_CALL_NOT_IMPLEMENTED; + break; + } + case 'FIRM': + { + /* FIXME: Not implemented yet */ + dwError = ERROR_CALL_NOT_IMPLEMENTED; + break; + } + case 'RSMB': + { + if (GetRawSMBiosTableFromRegistry(NULL) > 0) + { + uCount = 1; + uSize = uCount * sizeof(DWORD); + pBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, uSize); + if (!pBuffer) + { + SetLastError(ERROR_OUTOFMEMORY); + return 0; + } + *pBuffer = 0; + } + break; + } + default: + { + dwError = ERROR_INVALID_FUNCTION; + } + } + + if (dwError == ERROR_SUCCESS) + { + if (uSize > 0 && BufferSize >= uSize) + { + /* Write to buffer */ + if (pFirmwareTableBuffer) + { + RtlMoveMemory(pFirmwareTableBuffer, pBuffer, uSize); + } + } + else if (BufferSize < uSize) + { + dwError = ERROR_INSUFFICIENT_BUFFER; + } + } + + if (pBuffer) + { + RtlFreeHeap(RtlGetProcessHeap(), 0, pBuffer); + } + SetLastError(dwError); + return uSize; } -/* - * @unimplemented +/** + * @name GetSystemFirmwareTable + * @implemented + * + * Obtains the firmware table data. + *
https://msdn.microsoft.com/en-us/library/windows/desktop/ms724379(v=vs.85).…
+ * + * @param FirmwareTableProviderSignature + * Can be either ACPI, FIRM, or RSMB. + * + * @param FirmwareTableID + * Correct table identifier. + * + * @param pFirmwareTableBuffer + * Pointer to the output buffer, can be NULL. + * + * @param BufferSize + * Size of the output buffer. + * + * @return + * Actual size of the data in case of success, 0 otherwise. + * + * @remarks + * Data would be written to buffer only if the specified size is + * larger or equal to the actual size, in the other case Last Error + * value would be set to ERROR_INSUFFICIENT_BUFFER. + * In case of incorrect provider signature, Last Error value would be + * set to ERROR_INVALID_FUNCTION. + * Also Last Error value becomes ERROR_NOT_FOUND if incorrect + * table identifier was specified along with ACPI provider, and + * ERROR_INVALID_PARAMETER along with FIRM provider. The RSMB provider + * accepts any table identifier. + * */ UINT WINAPI @@ -446,8 +639,81 @@ GetSystemFirmwareTable(IN DWORD FirmwareTableProviderSignature, OUT PVOID pFirmwareTableBuffer, IN DWORD BufferSize) { - STUB; - return 0; + /* This function currently obtains data using a hack (registry workaround) + which is located here: drivers/input/i8042prt/hwhacks.c + i8042StoreSMBiosTables is responsible for writing SMBIOS table into registry + + Should be implemented correctly using NtQuerySystemInformation + along with SystemFirmwareTableInformation class + + Reference:
https://github.com/hfiref0x/VMDE/blob/master/src/vmde/sup.c
+ */ + + UINT uSize = 0; + DWORD dwError = ERROR_SUCCESS; + PVOID pBuffer = NULL; + + switch (FirmwareTableProviderSignature) + { + case 'ACPI': + { + /* FIXME: Not implemented yet */ + dwError = ERROR_CALL_NOT_IMPLEMENTED; + break; + } + case 'FIRM': + { + /* FIXME: Not implemented yet */ + dwError = ERROR_CALL_NOT_IMPLEMENTED; + break; + } + case 'RSMB': + { + uSize = GetRawSMBiosTableFromRegistry(NULL); + if (uSize > 0) + { + pBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, uSize); + if (!pBuffer) + { + SetLastError(ERROR_OUTOFMEMORY); + return 0; + } + GetRawSMBiosTableFromRegistry(pBuffer); + } + else + { + dwError = ERROR_NOT_FOUND; + } + break; + } + default: + { + dwError = ERROR_INVALID_FUNCTION; + } + } + + if (dwError == ERROR_SUCCESS) + { + if (uSize > 0 && BufferSize >= uSize) + { + /* Write to buffer */ + if (pFirmwareTableBuffer) + { + RtlMoveMemory(pFirmwareTableBuffer, pBuffer, uSize); + } + } + else if (BufferSize < uSize) + { + dwError = ERROR_INSUFFICIENT_BUFFER; + } + } + + if (pBuffer) + { + RtlFreeHeap(RtlGetProcessHeap(), 0, pBuffer); + } + SetLastError(dwError); + return uSize; } /*
6 years, 4 months
1
0
0
0
02/03: [KERNEL32_APITEST] Add SystemFirmware tests
by Stanislav Motylkov
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8acc68dd986316b59061c…
commit 8acc68dd986316b59061cb2d3e8b8a312a7c93d6 Author: Stanislav Motylkov <x86corez(a)gmail.com> AuthorDate: Sun Jul 29 17:43:10 2018 +0300 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Thu Aug 2 21:15:28 2018 +0200 [KERNEL32_APITEST] Add SystemFirmware tests CORE-12105 --- modules/rostests/apitests/kernel32/CMakeLists.txt | 1 + .../rostests/apitests/kernel32/SystemFirmware.c | 466 +++++++++++++++++++++ modules/rostests/apitests/kernel32/testlist.c | 2 + 3 files changed, 469 insertions(+) diff --git a/modules/rostests/apitests/kernel32/CMakeLists.txt b/modules/rostests/apitests/kernel32/CMakeLists.txt index c329031929..37c5b6adc8 100644 --- a/modules/rostests/apitests/kernel32/CMakeLists.txt +++ b/modules/rostests/apitests/kernel32/CMakeLists.txt @@ -28,6 +28,7 @@ list(APPEND SOURCE SetConsoleWindowInfo.c SetCurrentDirectory.c SetUnhandledExceptionFilter.c + SystemFirmware.c TerminateProcess.c TunnelCache.c WideCharToMultiByte.c diff --git a/modules/rostests/apitests/kernel32/SystemFirmware.c b/modules/rostests/apitests/kernel32/SystemFirmware.c new file mode 100644 index 0000000000..5ba946d815 --- /dev/null +++ b/modules/rostests/apitests/kernel32/SystemFirmware.c @@ -0,0 +1,466 @@ +/* + * PROJECT: ReactOS API Tests + * LICENSE: GPL-2.0+ (
https://spdx.org/licenses/GPL-2.0+
) + * PURPOSE: Tests for System Firmware functions + * COPYRIGHT: Copyright 2018 Stanislav Motylkov + */ + +#include "precomp.h" + +static UINT (WINAPI * pEnumSystemFirmwareTables)(DWORD, PVOID, DWORD); +static UINT (WINAPI * pGetSystemFirmwareTable)(DWORD, DWORD, PVOID, DWORD); + +typedef struct ENTRY +{ + DWORD Signature; + DWORD ErrInsuff; + DWORD ErrSuccess; +} ENTRY; + +static +VOID +test_EnumBuffer( + DWORD Signature, + PVOID Buffer, + DWORD dwSize, + UINT * pTableCount, + DWORD * pFirstTableID, + DWORD ErrInsuff, + DWORD ErrSuccess +) +{ + DWORD dwError; + DWORD dwBufferSize; + DWORD dwException; + UINT uResultSize; + + dwException = Buffer && IsBadWritePtr(Buffer, dwSize) ? STATUS_ACCESS_VIOLATION : STATUS_SUCCESS; + + // Test size = 0 + if (Buffer && dwException == STATUS_SUCCESS) + { + FillMemory(Buffer, dwSize, 0xFF); + } + SetLastError(0xbeeffeed); + dwError = GetLastError(); + dwBufferSize = 0; + uResultSize = 0; + StartSeh() + uResultSize = pEnumSystemFirmwareTables(Signature, Buffer, dwBufferSize); + dwError = GetLastError(); + EndSeh(STATUS_SUCCESS); + + if (uResultSize > 0) + { + ok(dwError == ErrInsuff, + "GetLastError() returned %ld, expected %ld\n", + dwError, ErrInsuff); + } + else + { + ok(dwError == ErrSuccess, + "GetLastError() returned %ld, expected %ld\n", + dwError, ErrSuccess); + } + if (ErrSuccess == ERROR_SUCCESS) + { + ok(uResultSize % sizeof(DWORD) == 0, + "uResultSize is %u, expected %% sizeof(DWORD)\n", + uResultSize); + } + else + { + ok(uResultSize == 0, + "uResultSize is %u, expected == 0\n", + uResultSize); + } + if (Buffer && dwException == STATUS_SUCCESS) + { + ok(*(BYTE *)Buffer == 0xFF, + "Buffer should be clean at offset 0, got %x\n", + *(BYTE *)Buffer); + } + + // Test size = 2 + if (Buffer && dwException == STATUS_SUCCESS) + { + FillMemory(Buffer, dwSize, 0xFF); + } + SetLastError(0xbeeffeed); + dwError = GetLastError(); + dwBufferSize = 2; + uResultSize = 0; + StartSeh() + uResultSize = pEnumSystemFirmwareTables(Signature, Buffer, dwBufferSize); + dwError = GetLastError(); + EndSeh(STATUS_SUCCESS); + + if (uResultSize > 0) + { + ok(dwError == ErrInsuff, + "GetLastError() returned %ld, expected %ld\n", + dwError, ErrInsuff); + } + else + { + ok(dwError == ErrSuccess, + "GetLastError() returned %ld, expected %ld\n", + dwError, ErrSuccess); + } + if (ErrSuccess == ERROR_SUCCESS) + { + ok(uResultSize % sizeof(DWORD) == 0, + "uResultSize is %u, expected %% sizeof(DWORD)\n", + uResultSize); + } + else + { + ok(uResultSize == 0, + "uResultSize is %u, expected == 0\n", + uResultSize); + } + if (Buffer && dwException == STATUS_SUCCESS) + { + ok(*(WORD *)Buffer == 0xFFFF, + "Buffer should be clean at offset 0, got %x\n", + *(WORD *)Buffer); + } + + // Test full size + if (Buffer && dwException == STATUS_SUCCESS) + { + FillMemory(Buffer, dwSize, 0xFF); + } + if (uResultSize > 0) + { + SetLastError(0xbeeffeed); + dwError = GetLastError(); + dwBufferSize = uResultSize; + uResultSize = 0; + StartSeh() + uResultSize = pEnumSystemFirmwareTables(Signature, Buffer, dwBufferSize); + dwError = GetLastError(); + EndSeh(ErrSuccess == ERROR_SUCCESS ? dwException : STATUS_SUCCESS); + // Windows 7: does not throw exception here + + if (dwException == STATUS_SUCCESS || ErrSuccess == ERROR_INVALID_FUNCTION) + { + ok(dwError == ErrSuccess, + "GetLastError() returned %ld, expected %ld\n", + dwError, ErrSuccess); + if (ErrSuccess == ERROR_SUCCESS) + { + ok(uResultSize == dwBufferSize, + "uResultSize is not equal dwBufferSize, expected %ld\n", + dwBufferSize); + } + else + { + ok(uResultSize == 0, + "uResultSize is %u, expected == 0\n", + uResultSize); + } + } + else + { + // Windows 7: returns ERROR_NOACCESS here + ok(dwError == 0xbeeffeed, + "GetLastError() returned %ld, expected %u\n", + dwError, 0xbeeffeed); + // Windows 7: returns correct size here + ok(uResultSize == 0, + "uResultSize is %u, expected == 0\n", + uResultSize); + } + } + + if (pTableCount && pFirstTableID) + { + if (uResultSize > 0) + { + if (Signature == 'RSMB') + { + // Raw SMBIOS have only one table with ID 0 + ok(*(DWORD *)Buffer == 0, + "Buffer should be filled at offset 0, got %lx\n", + *(DWORD *)Buffer); + } + else + { + // In other cases ID can be different + if (ErrSuccess == ERROR_SUCCESS) + { + ok(*(DWORD *)Buffer != 0xFFFFFFFF, + "Buffer should be filled at offset 0\n"); + } + else + { + ok(*(DWORD *)Buffer == 0xFFFFFFFF, + "Buffer should be clean at offset 0\n"); + } + } + } + *pTableCount = uResultSize / sizeof(DWORD); + *pFirstTableID = *(DWORD *)Buffer; + } +} + +static +VOID +test_GetBuffer( + DWORD Signature, + DWORD TableID, + PVOID Buffer, + DWORD dwSize, + BOOL TestFakeID, + DWORD ErrInsuff, + DWORD ErrSuccess +) +{ + DWORD dwError; + DWORD dwBufferSize; + DWORD dwException; + DWORD dwErrCase; + UINT uResultSize; + + dwException = Buffer && IsBadWritePtr(Buffer, dwSize) ? STATUS_ACCESS_VIOLATION : STATUS_SUCCESS; + switch (Signature) + { + case 'ACPI': + { + dwErrCase = ERROR_NOT_FOUND; + break; + } + case 'FIRM': + { + dwErrCase = ERROR_INVALID_PARAMETER; + break; + } + default: + { + dwErrCase = ErrInsuff; + } + } + + // Test size = 0 + if (Buffer && dwException == STATUS_SUCCESS) + { + FillMemory(Buffer, dwSize, 0xFF); + } + SetLastError(0xbeeffeed); + dwError = GetLastError(); + dwBufferSize = 0; + uResultSize = 0; + StartSeh() + uResultSize = pGetSystemFirmwareTable(Signature, TableID, Buffer, dwBufferSize); + dwError = GetLastError(); + EndSeh(STATUS_SUCCESS); + + ok(dwError == (TestFakeID ? dwErrCase : ErrInsuff), + "GetLastError() returned %ld, expected %ld\n", + dwError, (TestFakeID ? dwErrCase : ErrInsuff)); + if (ErrSuccess == ERROR_SUCCESS && (!TestFakeID || dwErrCase == ErrInsuff)) + { + ok(uResultSize > 0, + "uResultSize is %u, expected > 0\n", + uResultSize); + } + else + { + ok(uResultSize == 0, + "uResultSize is %u, expected == 0\n", + uResultSize); + } + if (Buffer && dwException == STATUS_SUCCESS) + { + ok(*(BYTE *)Buffer == 0xFF, + "Buffer should be clean at offset 0, got %x\n", + *(BYTE *)Buffer); + } + + // Test size = 2 + if (Buffer && dwException == STATUS_SUCCESS) + { + FillMemory(Buffer, dwSize, 0xFF); + } + SetLastError(0xbeeffeed); + dwError = GetLastError(); + dwBufferSize = 2; + uResultSize = 0; + StartSeh() + uResultSize = pGetSystemFirmwareTable(Signature, TableID, Buffer, dwBufferSize); + dwError = GetLastError(); + EndSeh(STATUS_SUCCESS); + + ok(dwError == (TestFakeID ? dwErrCase : ErrInsuff), + "GetLastError() returned %ld, expected %ld\n", + dwError, (TestFakeID ? dwErrCase : ErrInsuff)); + if (ErrSuccess == ERROR_SUCCESS && (!TestFakeID || dwErrCase == ErrInsuff)) + { + ok(uResultSize > 0, + "uResultSize is %u, expected > 0\n", + uResultSize); + } + else + { + ok(uResultSize == 0, + "uResultSize is %u, expected == 0\n", + uResultSize); + } + if (Buffer && dwException == STATUS_SUCCESS) + { + ok(*(WORD *)Buffer == 0xFFFF, + "Buffer should be clean at offset 0, got %x\n", + *(WORD *)Buffer); + } + + // Test full size + if (Buffer && dwException == STATUS_SUCCESS) + { + FillMemory(Buffer, dwSize, 0xFF); + } + if (uResultSize == 0) + { + return; + } + SetLastError(0xbeeffeed); + dwError = GetLastError(); + dwBufferSize = uResultSize; + uResultSize = 0; + StartSeh() + uResultSize = pGetSystemFirmwareTable(Signature, TableID, Buffer, dwBufferSize); + dwError = GetLastError(); + EndSeh(ErrSuccess == ERROR_SUCCESS ? dwException : STATUS_SUCCESS); + // Windows 7: does not throw exception here + + if (dwException == STATUS_SUCCESS || ErrSuccess == ERROR_INVALID_FUNCTION) + { + ok(dwError == ErrSuccess, + "GetLastError() returned %ld, expected %ld\n", + dwError, ErrSuccess); + if (ErrSuccess == ERROR_SUCCESS) + { + ok(uResultSize == dwBufferSize, + "uResultSize is not equal dwBufferSize, expected %ld\n", + dwBufferSize); + } + else + { + ok(uResultSize == 0, + "uResultSize is %u, expected == 0\n", + uResultSize); + } + } + else + { + // Windows 7: returns ERROR_NOACCESS here + ok(dwError == 0xbeeffeed, + "GetLastError() returned %ld, expected %u\n", + dwError, 0xbeeffeed); + // Windows 7: returns correct size here + ok(uResultSize == 0, + "uResultSize is %u, expected == 0\n", + uResultSize); + } + + if (Buffer && dwException == STATUS_SUCCESS) + { + if (ErrSuccess == ERROR_SUCCESS) + { + ok(*(DWORD *)Buffer != 0xFFFFFFFF, + "Buffer should be filled at offset 0\n"); + } + else + { + ok(*(DWORD *)Buffer == 0xFFFFFFFF, + "Buffer should be clean at offset 0\n"); + } + } +} + +START_TEST(SystemFirmware) +{ + static const ENTRY Entries[] = + { + { 'ACPI', ERROR_INSUFFICIENT_BUFFER, ERROR_SUCCESS }, + { 'FIRM', ERROR_INSUFFICIENT_BUFFER, ERROR_SUCCESS }, + { 'RSMB', ERROR_INSUFFICIENT_BUFFER, ERROR_SUCCESS }, + /* This entry should be last */ + { 0xDEAD, ERROR_INVALID_FUNCTION, ERROR_INVALID_FUNCTION }, + }; + HANDLE hKernel; + CHAR Buffer[262144]; // 256 KiB should be enough + CHAR Sign[sizeof(DWORD) + 1]; + UINT TableCount[_countof(Entries)]; + DWORD FirstTableID[_countof(Entries)]; + int i; + + hKernel = GetModuleHandleW(L"kernel32.dll"); + if (!hKernel) + { + skip("kernel32.dll module not found. Can't proceed\n"); + return; + } + + pEnumSystemFirmwareTables = (void *)GetProcAddress(hKernel, "EnumSystemFirmwareTables"); + pGetSystemFirmwareTable = (void *)GetProcAddress(hKernel, "GetSystemFirmwareTable"); + + if (!pEnumSystemFirmwareTables) + { + skip("EnumSystemFirmwareTables not found. Can't proceed\n"); + return; + } + if (!pGetSystemFirmwareTable) + { + skip("GetSystemFirmwareTable not found. Can't proceed\n"); + return; + } + + // Test EnumSystemFirmwareTables + for (i = 0; i < _countof(Entries); i++) + { + // Test with NULL buffer + test_EnumBuffer(Entries[i].Signature, NULL, sizeof(Buffer), NULL, NULL, + Entries[i].ErrInsuff, Entries[i].ErrSuccess); + // Test with wrong buffer + test_EnumBuffer(Entries[i].Signature, (PVOID *)0xbeeffeed, sizeof(Buffer), NULL, NULL, + Entries[i].ErrInsuff, Entries[i].ErrSuccess); + // Test with correct buffer + test_EnumBuffer(Entries[i].Signature, &Buffer, sizeof(Buffer), &TableCount[i], &FirstTableID[i], + Entries[i].ErrInsuff, Entries[i].ErrSuccess); + } + + // Test GetSystemFirmwareTable + for (i = 0; i < _countof(Entries); i++) + { + // Test with fake ID and NULL buffer + test_GetBuffer(Entries[i].Signature, 0xbeeffeed, NULL, sizeof(Buffer), + TRUE, Entries[i].ErrInsuff, Entries[i].ErrSuccess); + // Test with fake ID and wrong buffer + test_GetBuffer(Entries[i].Signature, 0xbeeffeed, (PVOID *)0xbeeffeed, sizeof(Buffer), + TRUE, Entries[i].ErrInsuff, Entries[i].ErrSuccess); + // Test with fake ID and correct buffer + test_GetBuffer(Entries[i].Signature, 0xbeeffeed, &Buffer, sizeof(Buffer), + TRUE, Entries[i].ErrInsuff, Entries[i].ErrSuccess); + if (TableCount[i] == 0) + { + if (i < _countof(Entries) - 1) + { + ZeroMemory(&Sign, sizeof(Sign)); + *(DWORD *)&Sign = _byteswap_ulong(Entries[i].Signature); + skip("No tables for %s found. Skipping\n", + Sign); + } + continue; + } + // Test with correct ID and NULL buffer + test_GetBuffer(Entries[i].Signature, FirstTableID[i], NULL, sizeof(Buffer), + FALSE, Entries[i].ErrInsuff, Entries[i].ErrSuccess); + // Test with correct ID and wrong buffer + test_GetBuffer(Entries[i].Signature, FirstTableID[i], (PVOID *)0xbeeffeed, sizeof(Buffer), + FALSE, Entries[i].ErrInsuff, Entries[i].ErrSuccess); + // Test with correct ID and correct buffer + test_GetBuffer(Entries[i].Signature, FirstTableID[i], &Buffer, sizeof(Buffer), + FALSE, Entries[i].ErrInsuff, Entries[i].ErrSuccess); + } +} diff --git a/modules/rostests/apitests/kernel32/testlist.c b/modules/rostests/apitests/kernel32/testlist.c index 0bf5e424dc..6364cab804 100644 --- a/modules/rostests/apitests/kernel32/testlist.c +++ b/modules/rostests/apitests/kernel32/testlist.c @@ -27,6 +27,7 @@ extern void func_PrivMoveFileIdentityW(void); extern void func_SetConsoleWindowInfo(void); extern void func_SetCurrentDirectory(void); extern void func_SetUnhandledExceptionFilter(void); +extern void func_SystemFirmware(void); extern void func_TerminateProcess(void); extern void func_TunnelCache(void); extern void func_WideCharToMultiByte(void); @@ -57,6 +58,7 @@ const struct test winetest_testlist[] = { "SetConsoleWindowInfo", func_SetConsoleWindowInfo }, { "SetCurrentDirectory", func_SetCurrentDirectory }, { "SetUnhandledExceptionFilter", func_SetUnhandledExceptionFilter }, + { "SystemFirmware", func_SystemFirmware }, { "TerminateProcess", func_TerminateProcess }, { "TunnelCache", func_TunnelCache }, { "WideCharToMultiByte", func_WideCharToMultiByte },
6 years, 4 months
1
0
0
0
01/03: [I8042PRT] Dump SMBIOS tables into registry for usermode access
by Stanislav Motylkov
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a9f20984cd0ea327bfd5f…
commit a9f20984cd0ea327bfd5f509e6afc6c4a5b2ff1d Author: Stanislav Motylkov <x86corez(a)gmail.com> AuthorDate: Sun Apr 15 01:56:32 2018 +0300 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Thu Aug 2 21:15:28 2018 +0200 [I8042PRT] Dump SMBIOS tables into registry for usermode access Reference:
https://social.msdn.microsoft.com/Forums/en-US/0bb0840e-85f4-4cdb-9710-7581…
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 c7915e16fd..885f0a25a5 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);
6 years, 4 months
1
0
0
0
01/01: [USRMGR] Disable the Extra tab. It serves no purpose. (#700)
by Jared Smudde
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4ceea7491912a03a89f4b…
commit 4ceea7491912a03a89f4b8c70aa8cf145ddf104c Author: Jared Smudde <computerwhiz02(a)hotmail.com> AuthorDate: Wed Aug 1 15:15:27 2018 -0500 Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org> CommitDate: Wed Aug 1 22:15:27 2018 +0200 [USRMGR] Disable the Extra tab. It serves no purpose. (#700) --- dll/cpl/usrmgr/usrmgr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dll/cpl/usrmgr/usrmgr.c b/dll/cpl/usrmgr/usrmgr.c index 81b57df38c..dd3bbbb470 100644 --- a/dll/cpl/usrmgr/usrmgr.c +++ b/dll/cpl/usrmgr/usrmgr.c @@ -43,7 +43,7 @@ InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc) static LONG APIENTRY UsrmgrApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam) { - PROPSHEETPAGE psp[3]; + PROPSHEETPAGE psp[2]; PROPSHEETHEADER psh; TCHAR Caption[1024]; @@ -66,7 +66,7 @@ UsrmgrApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam) InitPropSheetPage(&psp[0], IDD_USERS, UsersPageProc); InitPropSheetPage(&psp[1], IDD_GROUPS, GroupsPageProc); - InitPropSheetPage(&psp[2], IDD_EXTRA, ExtraPageProc); + /* InitPropSheetPage(&psp[2], IDD_EXTRA, ExtraPageProc); */ return (LONG)(PropertySheet(&psh) != -1); }
6 years, 4 months
1
0
0
0
← Newer
1
...
28
29
30
31
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Results per page:
10
25
50
100
200