In 71aba33f, GetSystemFirmwareTable was moved from kernel32 to kernelbase. In the process, its error handling was refactored to use NtQuerySystemInformation, and it began to return zero whenever NtQuerySystemInformation failed. This prevents software from being able to make 'preflight' calls to determine how large their buffer should be.
This patch simply restores the old behavior.
Signed-off-by: John Chadwick john@jchw.io --- This supersedes patch 174124.
dlls/kernel32/tests/version.c | 1 - dlls/kernelbase/memory.c | 11 ++++------- 2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/dlls/kernel32/tests/version.c b/dlls/kernel32/tests/version.c index db42fc5a29..1bb3e20978 100644 --- a/dlls/kernel32/tests/version.c +++ b/dlls/kernel32/tests/version.c @@ -738,7 +738,6 @@ static void test_GetSystemFirmwareTable(void)
expected_len -= min_sfti_len; len = pGetSystemFirmwareTable(RSMB, 0, NULL, 0); -todo_wine ok(len == expected_len, "Expected length %u, got %u\n", expected_len, len);
smbios_table = HeapAlloc(GetProcessHeap(), 0, expected_len); diff --git a/dlls/kernelbase/memory.c b/dlls/kernelbase/memory.c index 6be399bc97..c93d490e74 100644 --- a/dlls/kernelbase/memory.c +++ b/dlls/kernelbase/memory.c @@ -1161,13 +1161,10 @@ UINT WINAPI GetSystemFirmwareTable( DWORD provider, DWORD id, void *buffer, DWOR info->Action = SystemFirmwareTable_Get; info->TableID = id;
- if (set_ntstatus( NtQuerySystemInformation( SystemFirmwareTableInformation, - info, buffer_size, &buffer_size ))) - { - buffer_size -= offsetof( SYSTEM_FIRMWARE_TABLE_INFORMATION, TableBuffer ); - if (buffer_size <= size) memcpy( buffer, info->TableBuffer, buffer_size ); - } - else buffer_size = 0; + set_ntstatus( NtQuerySystemInformation( SystemFirmwareTableInformation, + info, buffer_size, &buffer_size )); + buffer_size -= offsetof( SYSTEM_FIRMWARE_TABLE_INFORMATION, TableBuffer ); + if (buffer_size <= size) memcpy( buffer, info->TableBuffer, buffer_size );
HeapFree( GetProcessHeap(), 0, info ); return buffer_size;