From: Grigory Vasilyev h0tc0d3@gmail.com
--- dlls/kernel32/process.c | 12 ++++++- dlls/kernel32/tests/Makefile.in | 1 + dlls/kernel32/tests/firmware.c | 55 +++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 dlls/kernel32/tests/firmware.c
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index 2a4ddc68f02..88a0ce2bc33 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -763,10 +763,20 @@ BOOL WINAPI SetFirmwareEnvironmentVariableW(const WCHAR *name, const WCHAR *guid */ BOOL WINAPI GetFirmwareType(FIRMWARE_TYPE *type) { + SYSTEM_BOOT_ENVIRONMENT_INFORMATION boot_info = {0}; + if (!type) + { + SetLastError(ERROR_INVALID_PARAMETER); return FALSE; + } + + if(!set_ntstatus(NtQuerySystemInformation(SystemBootEnvironmentInformation, + &boot_info, sizeof(boot_info), NULL))) + return FALSE; + + *type = boot_info.FirmwareType;
- *type = FirmwareTypeUnknown; return TRUE; }
diff --git a/dlls/kernel32/tests/Makefile.in b/dlls/kernel32/tests/Makefile.in index e9516603ce9..17d08b7cdf6 100644 --- a/dlls/kernel32/tests/Makefile.in +++ b/dlls/kernel32/tests/Makefile.in @@ -16,6 +16,7 @@ SOURCES = \ environ.c \ fiber.c \ file.c \ + firmware.c \ format_msg.c \ generated.c \ heap.c \ diff --git a/dlls/kernel32/tests/firmware.c b/dlls/kernel32/tests/firmware.c new file mode 100644 index 00000000000..5552d70e7e1 --- /dev/null +++ b/dlls/kernel32/tests/firmware.c @@ -0,0 +1,55 @@ +/* Unit test suite for *Information* Registry API functions + * + * Copyright 2024 Grigory Vasilyev + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + * + */ + +#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "wine/test.h" +#include "windef.h" +#include "winbase.h" +#include "winerror.h" +#include "winuser.h" +#include "winternl.h" + +static void test_get_firmware_type(void) +{ + FIRMWARE_TYPE ft; + BOOL status; + + status = GetFirmwareType(&ft); + if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) + { + skip("GetFirmwareType not implemented.\n"); + return; + } + + ok(status == TRUE, "Expected TRUE.\n"); + + ok(ft == FirmwareTypeBios || ft == FirmwareTypeUefi, + "Expected FirmwareTypeBios or FirmwareTypeUefi, got %08x\n", ft); + + status = GetFirmwareType(NULL); + ok(status == FALSE && GetLastError() == ERROR_INVALID_PARAMETER, + "Expected FALSE and GetLastError() == ERROR_INVALID_PARAMETER\n"); +} + +START_TEST(firmware) +{ + test_get_firmware_type(); +}