ntdll: - `NtQuerySystemInformation` `SystemBootEnvironmentInformation` - `NtQuerySystemEnvironmentValueEx`
kernel32: - `GetFirmwareType` - `GetFirmwareEnvironmentVariableExA` - `GetFirmwareEnvironmentVariableExW` - `GetFirmwareEnvironmentVariableA` - `GetFirmwareEnvironmentVariableW`.
The code is needed to check SecureBoot status, security systems and for example to check the licenses of software that can use efi variables. The behavior matches the behavior of Windows 11. And the output is no different on wine and Windows 11.
Example:
```C #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <windows.h> #include <winnt.h> #include <winternl.h> #include <winbase.h> #include <securitybaseapi.h>
/* x86_64-w64-mingw32-gcc -O2 firmware.c -o firmware.exe -Wl,--subsystem,console */ #define SystemBootEnvironmentInformation 90
#define GUID_FORMAT "%08X-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX" #define GUID_ARG(guid) \ (unsigned int)(guid).Data1, (guid).Data2, (guid).Data3, (guid).Data4[0], \ (guid).Data4[1], (guid).Data4[2], (guid).Data4[3], (guid).Data4[4], \ (guid).Data4[5], (guid).Data4[6], (guid).Data4[7]
typedef struct _SYSTEM_BOOT_ENVIRONMENT_INFORMATION { GUID BootIdentifier; FIRMWARE_TYPE FirmwareType; union { ULONGLONG BootFlags; struct { ULONGLONG DbgMenuOsSelection : 1; ULONGLONG DbgHiberBoot : 1; ULONGLONG DbgSoftBoot : 1; ULONGLONG DbgMeasuredLaunch : 1; ULONGLONG DbgMeasuredLaunchCapable : 1; ULONGLONG DbgSystemHiveReplace : 1; ULONGLONG DbgMeasuredLaunchSmmProtections : 1; ULONGLONG DbgMeasuredLaunchSmmLevel : 7; }; }; } SYSTEM_BOOT_ENVIRONMENT_INFORMATION, *PSYSTEM_BOOT_ENVIRONMENT_INFORMATION;
typedef NTSTATUS(NTAPI *LPFNZwInitUnicodeString)(IN OUT PUNICODE_STRING DestinationString, IN PCWSTR SourceString);
typedef NTSTATUS(NTAPI *LPFNZwQuerySystemInformation)( IN SYSTEM_INFORMATION_CLASS SystemInformationClass, IN OUT PVOID SystemInformation, IN ULONG SystemInformationLength, OUT PULONG ReturnLength);
typedef NTSTATUS(NTAPI *LPFNZwQuerySystemEnvironmentValueEx)( IN PUNICODE_STRING VariableName, IN LPGUID VendorGuid, IN PVOID Value, IN OUT PULONG ReturnLength, OUT PULONG Attributes);
BOOL EnableTokenPrivilege(HANDLE hToken, const char *pszPrivilegesName, BOOL bEnabled) { LUID luid; TOKEN_PRIVILEGES tp;
if (!LookupPrivilegeValue(NULL, pszPrivilegesName, &luid)) { return FALSE; }
tp.PrivilegeCount = 1; tp.Privileges[0].Luid = luid; tp.Privileges[0].Attributes = bEnabled ? SE_PRIVILEGE_ENABLED : 0;
if (!AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), NULL, NULL)) { return FALSE; }
return TRUE; }
int main(int argc, char **argv) { DWORD ret; ULONG ret_size; HANDLE hToken; HANDLE hProcess; HINSTANCE hNTdll; NTSTATUS status; DWORD attributes; BOOLEAN secureboot = 0; FIRMWARE_TYPE type = FirmwareTypeUnknown; char asus_license[2048] = {0}; UNICODE_STRING asus_name; UNICODE_STRING dummy_name; UNICODE_STRING secureboot_name;
GUID asus_guid = { 0x02076249, 0xa52b, 0x420e, {0xbd, 0x53, 0xae, 0xd0, 0x44, 0x34, 0x93, 0x79}}; GUID secureboot_guid = { 0x8be4df61, 0x93ca, 0x11d2, {0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c}}; GUID dummy_guid = {0};
SYSTEM_BOOT_ENVIRONMENT_INFORMATION boot_info = {0};
LPFNZwInitUnicodeString ZwInitUnicodeString; LPFNZwQuerySystemInformation ZwQuerySystemInformation; LPFNZwQuerySystemEnvironmentValueEx ZwQuerySystemEnvironmentValueEx;
hNTdll = LoadLibraryW(L"Ntdll.dll");
if (!hNTdll) { printf("Can't load ntdll liabrary!\n"); return -1; }
ZwInitUnicodeString = (LPFNZwInitUnicodeString)GetProcAddress(hNTdll, "RtlInitUnicodeString"); if (!ZwInitUnicodeString) { printf("Can't get GetProcAddress RtlInitUnicodeString error: %d!\n", GetLastError()); return -1; }
ZwInitUnicodeString(&asus_name, L"AsusOnboardToolLicense"); ZwInitUnicodeString(&dummy_name, L"DummyName"); ZwInitUnicodeString(&secureboot_name, L"SecureBoot");
ZwQuerySystemInformation = (LPFNZwQuerySystemInformation)GetProcAddress(hNTdll, "ZwQuerySystemInformation"); if (!ZwQuerySystemInformation) { printf("Can't get GetProcAddress ZwQuerySystemInformation error: %d!\n", GetLastError()); return -1; }
ZwQuerySystemEnvironmentValueEx = (LPFNZwQuerySystemEnvironmentValueEx)GetProcAddress( hNTdll, "ZwQuerySystemEnvironmentValueEx"); if (!ZwQuerySystemEnvironmentValueEx) { printf("Can't get GetProcAddress ZwQuerySystemEnvironmentValueEx error: %d!\n", GetLastError()); return -1; }
hProcess = GetCurrentProcess(); if (!hProcess) { printf("GetCurrentProcessToken error: %d!\n", GetLastError()); return -1; }
if (!OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) { printf("OpenProcessToken error: %d!\n", GetLastError()); return -1; }
if (!EnableTokenPrivilege(hToken, SE_SYSTEM_ENVIRONMENT_NAME, TRUE)) { printf("EnableTokenPrivilege error: %d!\n", GetLastError()); return -1; }
if (GetFirmwareType(&type)) printf("GetFirmwareType: %s\n\n", type == FirmwareTypeUefi ? "UEFI" : "BIOS");
ret = GetFirmwareEnvironmentVariableA("SecureBoot", "{8be4df61-93ca-11d2-aa0d-00e098032b8c}", &secureboot, sizeof(BOOLEAN)); if (!ret) printf("GetFirmwareEnvironmentVariableA error: 0x%08lx.\n\n", GetLastError());
printf("GetFirmwareEnvironmentVariableA\nBytes: %d\nSecureBoot: %s\n\n", ret, secureboot ? "enabled" : "disabled");
ret = GetFirmwareEnvironmentVariableA("DummyName", "{00000000-0000-0000-0000-000000000000}", &secureboot, sizeof(BOOLEAN)); if (!ret) printf("GetFirmwareEnvironmentVariableA Dummy GUID error: 0x%08lx.\n\n", GetLastError());
secureboot = 0; ret = GetFirmwareEnvironmentVariableW(L"SecureBoot", L"{8be4df61-93ca-11d2-aa0d-00e098032b8c}", &secureboot, sizeof(BOOLEAN)); if (!ret) printf("GetFirmwareEnvironmentVariableW error: 0x%08lx.\n\n", GetLastError());
printf("GetFirmwareEnvironmentVariableW\nBytes: %d\nSecureBoot: %s\n\n", ret, secureboot ? "enabled" : "disabled");
attributes = 0; secureboot = 0; ret = GetFirmwareEnvironmentVariableExA("SecureBoot", "{8be4df61-93ca-11d2-aa0d-00e098032b8c}", &secureboot, sizeof(BOOLEAN), &attributes); if (!ret) printf("GetFirmwareEnvironmentVariableExA error: 0x%08lx.\n\n", GetLastError());
printf("GetFirmwareEnvironmentVariableExA\nBytes: %d\nAttributes: 0x%08x\nSecureBoot: %s\n\n", ret, attributes, secureboot ? "enabled" : "disabled");
attributes = 0; ret = GetFirmwareEnvironmentVariableExW(L"AsusOnboardToolLicense", L"{02076249-a52b-420e-bd53-aed044349379}", asus_license, sizeof(asus_license), &attributes); if (!ret) printf("GetFirmwareEnvironmentVariableExW error: 0x%08lx.\n\n", GetLastError());
printf("GetFirmwareEnvironmentVariableExW\nBytes: %d\nAttributes: 0x%08x\nAsus License: \n%s\n\n", ret, attributes, asus_license);
ret_size = sizeof(secureboot); attributes = 0; secureboot = 0; status = ZwQuerySystemEnvironmentValueEx(&secureboot_name, &secureboot_guid, &secureboot, &ret_size, &attributes);
if (!status) printf("NtQuerySystemEnvironmentValueEx error: 0x%08lx.\n\n", status);
printf("NtQuerySystemEnvironmentValueEx\nBytes: %d\nAttributes: 0x%08x\nSecureBoot: %s\n\n", ret_size, attributes, secureboot ? "enabled" : "disabled");
ret_size = sizeof(secureboot); attributes = 0; secureboot = 0; status = ZwQuerySystemEnvironmentValueEx(&dummy_name, &dummy_guid, &secureboot, &ret_size, &attributes);
printf("NtQuerySystemEnvironmentValueEx Dummy GUID error: 0x%08lx.\n\n", status);
ret_size = sizeof(asus_license); attributes = 0; for (size_t i = 0; i < ret_size; i++) { asus_license[i] = '\0'; } status = ZwQuerySystemEnvironmentValueEx(&asus_name, &asus_guid, asus_license, &ret_size, &attributes); if (status) printf("NtQuerySystemEnvironmentValueEx error: 0x%08lx.\n\n", status);
printf("NtQuerySystemEnvironmentValueEx\nBytes: %d\nAttributes: 0x%08x\nAsus License: \n%s\n\n", ret_size, attributes, asus_license);
status = ZwQuerySystemInformation( (SYSTEM_INFORMATION_CLASS)SystemBootEnvironmentInformation, &boot_info, sizeof(boot_info), &ret_size); if (status) printf("NtQuerySystemInformation error: 0x%08lx.\n\n", status);
printf("SystemBootEnvironmentInformation:\nBootIdentifier: {" GUID_FORMAT "}", GUID_ARG(boot_info.BootIdentifier)); printf("\nFirmwareType: %s\nBootFlags: 0x%llX\n\n", (boot_info.FirmwareType == FirmwareTypeUefi ? "UEFI" : "BIOS"), boot_info.BootFlags);
FreeLibrary(hNTdll);
return 0; } ```
Output: ``` GetFirmwareType: UEFI
GetFirmwareEnvironmentVariableA Bytes: 1 SecureBoot: enabled
GetFirmwareEnvironmentVariableW Bytes: 1 SecureBoot: enabled
GetFirmwareEnvironmentVariableExA Bytes: 1 Attributes: 0x00000006 SecureBoot: enabled
GetFirmwareEnvironmentVariableExW Bytes: 1570 Attributes: 0x00000006 Asus License: BASE64_BIG_LICENSE_TEXT== [LicenseID]:FED7A1 [Model]:Dummy-BaseBoard-Id [Tools]:WAsusDmiS,LogoFlashS,ASUSFwConfigS,AsusEventLogS,AsusNvLockS [Customer]:DummyLic [Expire]:2022-11-24
NtQuerySystemEnvironmentValueEx Bytes: 1 Attributes: 0x00000006 SecureBoot: enabled
NtQuerySystemEnvironmentValueEx Bytes: 1570 Attributes: 0x00000006 Asus License: BASE64_BIG_LICENSE_TEXT== [LicenseID]:FED7A1 [Model]:Dummy-BaseBoard-Id [Tools]:WAsusDmiS,LogoFlashS,ASUSFwConfigS,AsusEventLogS,AsusNvLockS [Customer]:DummyLic [Expire]:2022-11-24
SystemBootEnvironmentInformation: BootIdentifier: {8522FFCA-6A31-11EF-952A-966164983DCB} FirmwareType: UEFI BootFlags: 0x0 ```
-- v29: kernel32: Implement GetFirmwareEnvironmentVariableExA, GetFirmwareEnvironmentVariableExW, GetFirmwareEnvironmentVariableA, GetFirmwareEnvironmentVariableW.
From: Grigory Vasilyev h0tc0d3@gmail.com
--- dlls/ntdll/tests/info.c | 32 ++++++++++++++ dlls/ntdll/unix/system.c | 96 ++++++++++++++++++++++++++++++++++++++++ dlls/wow64/system.c | 3 ++ include/winternl.h | 22 +++++++++ 4 files changed, 153 insertions(+)
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c index ba19b248e43..62c17649808 100644 --- a/dlls/ntdll/tests/info.c +++ b/dlls/ntdll/tests/info.c @@ -322,6 +322,37 @@ static void test_query_basic(void) } }
+static void test_query_boot(void) +{ + NTSTATUS status; + ULONG ret_size; + SYSTEM_BOOT_ENVIRONMENT_INFORMATION bi = {0}; + + /* + * NtQuerySystemInformation - SystemBootEnvironmentInformation + */ + status = pNtQuerySystemInformation(SystemBootEnvironmentInformation, &bi, sizeof(bi), &ret_size); + if (status == STATUS_NOT_IMPLEMENTED) + { + skip("NtQuerySystemInformation - SystemBootEnvironmentInformation not implemented.\n"); + return; + } + ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS.\n"); + + ok(ret_size == sizeof(bi), "Expected ret_size == sizeof(SYSTEM_BOOT_ENVIRONMENT_INFORMATION).\n"); + + ok(bi.FirmwareType == FirmwareTypeBios || bi.FirmwareType == FirmwareTypeUefi, + "Expected FirmwareTypeBios or FirmwareTypeUefi, got %02x\n", bi.FirmwareType); + + ok(bi.BootIdentifier.Data1 != 0, "A non-zero BootIdentifier value is expected.\n"); + + status = pNtQuerySystemInformation(SystemBootEnvironmentInformation, NULL, sizeof(bi), NULL); + ok(status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION.\n"); + + status = pNtQuerySystemInformation(SystemBootEnvironmentInformation, NULL, 0, NULL); + ok(status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH.\n"); +} + static void test_query_cpu(void) { NTSTATUS status; @@ -4080,6 +4111,7 @@ START_TEST(info)
/* NtQuerySystemInformation */ test_query_basic(); + test_query_boot(); test_query_cpu(); test_query_performance(); test_query_timeofday(); diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c index b015cfff923..b280b552ec7 100644 --- a/dlls/ntdll/unix/system.c +++ b/dlls/ntdll/unix/system.c @@ -30,6 +30,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #include <errno.h> @@ -2927,6 +2928,101 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class, break; }
+ case SystemBootEnvironmentInformation: /* 90 */ + { + static SYSTEM_BOOT_ENVIRONMENT_INFORMATION boot_info = {0}; + struct stat stat_info = {0}; + ssize_t ssz; +#if defined(__linux__) || defined(__gnu_linux__) + int fd; + char buffer[32]; +#endif + len = sizeof(boot_info); + if (size == len) + { +#if defined(__linux__) || defined(__gnu_linux__) + if (boot_info.FirmwareType == FirmwareTypeUnknown) + { + if (!stat("/sys/firmware/efi", &stat_info)) + boot_info.FirmwareType = FirmwareTypeUefi; + else + boot_info.FirmwareType = FirmwareTypeBios; + } +#elif defined(__APPLE__) + /* + * Since 2006, Mac computers use Extensible Firmware Interface (EFI). + * Reference: https://support.apple.com/guide/security/uefi-firmware-security-in-an-intel-... + */ + boot_info.FirmwareType = FirmwareTypeUefi; +#else + boot_info.FirmwareType = FirmwareTypeBios; +#endif + if (boot_info.BootIdentifier.Data1 == 0) + { +#if defined(__linux__) || defined(__gnu_linux__) + if (!stat("/etc/machine-id", &stat_info) && stat_info.st_size >= 32) + { + fd = open("/etc/machine-id", O_RDONLY); + if (fd == -1) + goto try_read_hostid; + ssz = read(fd, &buffer, 32); + if (ssz < 0) + { + close(fd); + goto try_read_hostid; + } + close(fd); + if (sscanf(buffer, + "%08X%04hX%04hX%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX", + (unsigned int *)&boot_info.BootIdentifier.Data1, &boot_info.BootIdentifier.Data2, + &boot_info.BootIdentifier.Data3, &boot_info.BootIdentifier.Data4[0], + &boot_info.BootIdentifier.Data4[1], &boot_info.BootIdentifier.Data4[2], + &boot_info.BootIdentifier.Data4[3], &boot_info.BootIdentifier.Data4[4], + &boot_info.BootIdentifier.Data4[5], &boot_info.BootIdentifier.Data4[6], + &boot_info.BootIdentifier.Data4[7]) != 11) + goto try_read_hostid; + } + else + { + try_read_hostid: +#endif +#ifdef __APPLE__ + if (!stat("/Users", &stat_info) || !stat("/System", &stat_info)) +#else + if (!stat("/home", &stat_info) || !stat("/usr", &stat_info)) +#endif + { + boot_info.BootIdentifier.Data1 = gethostid() & 0xFFFFFFFF; + boot_info.BootIdentifier.Data2 = stat_info.st_dev & 0xFFFF; + boot_info.BootIdentifier.Data3 = stat_info.st_ino & 0xFFFF; + boot_info.BootIdentifier.Data4[0] = 'W' ^ (boot_info.BootIdentifier.Data1 & 0xFF); + boot_info.BootIdentifier.Data4[1] = 'I' ^ ((boot_info.BootIdentifier.Data1 >> 4) & 0xFF); + boot_info.BootIdentifier.Data4[2] = 'N' ^ ((boot_info.BootIdentifier.Data1 >> 8) & 0xFF); + boot_info.BootIdentifier.Data4[3] = 'E' ^ ((boot_info.BootIdentifier.Data1 >> 12) & 0xFF); + boot_info.BootIdentifier.Data4[4] = 'B' ^ ((boot_info.BootIdentifier.Data1 >> 16) & 0xFF); + boot_info.BootIdentifier.Data4[5] = 'O' ^ ((boot_info.BootIdentifier.Data1 >> 20) & 0xFF); + boot_info.BootIdentifier.Data4[6] = 'O' ^ ((boot_info.BootIdentifier.Data1 >> 24) & 0xFF); + boot_info.BootIdentifier.Data4[7] = 'T' ^ ((boot_info.BootIdentifier.Data1 >> 28) & 0xFF); + } +#if defined(__linux__) || defined(__gnu_linux__) + } +#endif + boot_info.BootIdentifier.Data3 &= 0x0fff; + boot_info.BootIdentifier.Data3 |= (4 << 12); + /* Set the topmost bits of Data4 (clock_seq_hi_and_reserved) as + * specified in RFC 4122, section 4.4. + */ + boot_info.BootIdentifier.Data4[0] &= 0x3f; + boot_info.BootIdentifier.Data4[0] |= 0x80; + } + if (!info) ret = STATUS_ACCESS_VIOLATION; + else memcpy(info, &boot_info, len); + } + else ret = STATUS_INFO_LENGTH_MISMATCH; + if (ret_size) *ret_size = len; + break; + } + case SystemCpuInformation: /* 1 */ if (size >= (len = sizeof(cpu_info))) memcpy(info, &cpu_info, len); else ret = STATUS_INFO_LENGTH_MISMATCH; diff --git a/dlls/wow64/system.c b/dlls/wow64/system.c index 5f3056a4179..402b53e1eda 100644 --- a/dlls/wow64/system.c +++ b/dlls/wow64/system.c @@ -356,6 +356,9 @@ NTSTATUS WINAPI wow64_NtQuerySystemInformation( UINT *args ) if (retlen) *retlen = sizeof(SYSTEM_BASIC_INFORMATION32); return status;
+ case SystemBootEnvironmentInformation: /* SYSTEM_BOOT_ENVIRONMENT_INFORMATION */ + return NtQuerySystemInformation(class, ptr, len, retlen); + case SystemProcessInformation: /* SYSTEM_PROCESS_INFORMATION */ case SystemExtendedProcessInformation: /* SYSTEM_PROCESS_INFORMATION */ { diff --git a/include/winternl.h b/include/winternl.h index 828fbc6e915..510bba09042 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -2724,6 +2724,28 @@ typedef struct _SYSTEM_BASIC_INFORMATION { #endif } SYSTEM_BASIC_INFORMATION, *PSYSTEM_BASIC_INFORMATION;
+/* System Information Class 0x90 */ +typedef struct _SYSTEM_BOOT_ENVIRONMENT_INFORMATION +{ + GUID BootIdentifier; + FIRMWARE_TYPE FirmwareType; + union + { + ULONGLONG BootFlags; + struct + { + ULONGLONG DbgMenuOsSelection : 1; + ULONGLONG DbgHiberBoot : 1; + ULONGLONG DbgSoftBoot : 1; + ULONGLONG DbgMeasuredLaunch : 1; + ULONGLONG DbgMeasuredLaunchCapable : 1; + ULONGLONG DbgSystemHiveReplace : 1; + ULONGLONG DbgMeasuredLaunchSmmProtections : 1; + ULONGLONG DbgMeasuredLaunchSmmLevel : 7; + }; + }; +} SYSTEM_BOOT_ENVIRONMENT_INFORMATION, *PSYSTEM_BOOT_ENVIRONMENT_INFORMATION; + /* System Information Class 0x01 */
typedef struct _SYSTEM_CPU_INFORMATION {
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(); +}
From: Grigory Vasilyev h0tc0d3@gmail.com
--- dlls/ntdll/tests/info.c | 52 +++++++++++++++- dlls/ntdll/unix/system.c | 124 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 174 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c index 62c17649808..b1f5fd2fe1c 100644 --- a/dlls/ntdll/tests/info.c +++ b/dlls/ntdll/tests/info.c @@ -34,6 +34,7 @@ static NTSTATUS (WINAPI * pNtQuerySystemInformation)(SYSTEM_INFORMATION_CLASS, PVOID, ULONG, PULONG); static NTSTATUS (WINAPI * pNtSetSystemInformation)(SYSTEM_INFORMATION_CLASS, PVOID, ULONG); static NTSTATUS (WINAPI * pRtlGetNativeSystemInformation)(SYSTEM_INFORMATION_CLASS, PVOID, ULONG, PULONG); +static NTSTATUS (WINAPI * pNtQuerySystemEnvironmentValueEx)(PUNICODE_STRING, LPGUID, PVOID, PULONG, PULONG); static NTSTATUS (WINAPI * pNtQuerySystemInformationEx)(SYSTEM_INFORMATION_CLASS, void*, ULONG, void*, ULONG, ULONG*); static NTSTATUS (WINAPI * pNtPowerInformation)(POWER_INFORMATION_LEVEL, PVOID, ULONG, PVOID, ULONG); static NTSTATUS (WINAPI * pNtQueryInformationThread)(HANDLE, THREADINFOCLASS, PVOID, ULONG, PULONG); @@ -91,6 +92,7 @@ static void InitFunctionPtrs(void)
NTDLL_GET_PROC(NtQuerySystemInformation); NTDLL_GET_PROC(NtQuerySystemInformationEx); + NTDLL_GET_PROC(NtQuerySystemEnvironmentValueEx); NTDLL_GET_PROC(NtSetSystemInformation); NTDLL_GET_PROC(RtlGetNativeSystemInformation); NTDLL_GET_PROC(NtPowerInformation); @@ -322,10 +324,14 @@ static void test_query_basic(void) } }
-static void test_query_boot(void) +static void test_query_boot_and_system_env(void) { NTSTATUS status; ULONG ret_size; + BOOLEAN secureboot; + DWORD attributes; + UNICODE_STRING secureboot_name; + GUID secureboot_guid = {0x8be4df61, 0x93ca, 0x11d2, {0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c}}; SYSTEM_BOOT_ENVIRONMENT_INFORMATION bi = {0};
/* @@ -351,6 +357,48 @@ static void test_query_boot(void)
status = pNtQuerySystemInformation(SystemBootEnvironmentInformation, NULL, 0, NULL); ok(status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH.\n"); + + /* + * NtQuerySystemEnvironmentValueEx + */ + RtlInitUnicodeString(&secureboot_name, L"SecureBoot"); + ret_size = sizeof(secureboot); + + status = pNtQuerySystemEnvironmentValueEx(&secureboot_name, &secureboot_guid, &secureboot, &ret_size, &attributes); + if(bi.FirmwareType != FirmwareTypeUefi) + ok(status == STATUS_NOT_IMPLEMENTED, "Expected STATUS_NOT_IMPLEMENTED on non-UEFI boots.\n"); + + if (status == STATUS_NOT_IMPLEMENTED) + { + skip("NtQuerySystemEnvironmentValueEx not implemented.\n"); + return; + } + + ok(status == STATUS_SUCCESS || status == STATUS_VARIABLE_NOT_FOUND, "Expected STATUS_SUCCESS or STATUS_VARIABLE_NOT_FOUND.\n"); + + status = pNtQuerySystemEnvironmentValueEx(NULL, NULL, &secureboot, &ret_size, &attributes); + ok(status == STATUS_INVALID_PARAMETER, "Expected STATUS_INVALID_PARAMETER.\n"); + + status = pNtQuerySystemEnvironmentValueEx(NULL, &secureboot_guid, &secureboot, &ret_size, &attributes); + ok(status == STATUS_INVALID_PARAMETER, "Expected STATUS_INVALID_PARAMETER.\n"); + + status = pNtQuerySystemEnvironmentValueEx(&secureboot_name, NULL, &secureboot, &ret_size, &attributes); + ok(status == STATUS_INVALID_PARAMETER, "Expected STATUS_INVALID_PARAMETER.\n"); + + status = pNtQuerySystemEnvironmentValueEx(&secureboot_name, &secureboot_guid, NULL, NULL, NULL); + ok(status == STATUS_INVALID_PARAMETER, "Expected STATUS_INVALID_PARAMETER.\n"); + + status = pNtQuerySystemEnvironmentValueEx(&secureboot_name, &secureboot_guid, &secureboot, NULL, NULL); + ok(status == STATUS_INVALID_PARAMETER, "Expected STATUS_INVALID_PARAMETER.\n"); + + status = pNtQuerySystemEnvironmentValueEx(&secureboot_name, &secureboot_guid, &secureboot, NULL, &attributes); + ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS.\n"); + + status = pNtQuerySystemEnvironmentValueEx(&secureboot_name, &secureboot_guid, NULL, &ret_size, NULL); + ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS.\n"); + + status = pNtQuerySystemEnvironmentValueEx(&secureboot_name, &secureboot_guid, NULL, &ret_size, &attributes); + ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS.\n"); }
static void test_query_cpu(void) @@ -4111,7 +4159,7 @@ START_TEST(info)
/* NtQuerySystemInformation */ test_query_basic(); - test_query_boot(); + test_query_boot_and_system_env(); test_query_cpu(); test_query_performance(); test_query_timeofday(); diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c index b280b552ec7..7e8794cfca5 100644 --- a/dlls/ntdll/unix/system.c +++ b/dlls/ntdll/unix/system.c @@ -3912,9 +3912,133 @@ NTSTATUS WINAPI NtQuerySystemEnvironmentValue( UNICODE_STRING *name, WCHAR *buff NTSTATUS WINAPI NtQuerySystemEnvironmentValueEx( UNICODE_STRING *name, GUID *vendor, void *buffer, ULONG *retlen, ULONG *attrib ) { +#if defined(__linux__) || defined(__gnu_linux__) + int fd, rc; + size_t bytes, pos = 0; + ssize_t ssz; + char buff[4]; + char *cname; + char filename[PATH_MAX + 1]; + NTSTATUS status; + struct stat stat_info = {0}; + static SYSTEM_BOOT_ENVIRONMENT_INFORMATION boot_info = {0}; + + if(boot_info.FirmwareType == FirmwareTypeUnknown) + { + status = NtQuerySystemInformation(SystemBootEnvironmentInformation, + &boot_info, sizeof(boot_info), NULL); + if(status != STATUS_SUCCESS) return status; + } + + if(boot_info.FirmwareType != FirmwareTypeUefi) + { + /* + * This behavior matches the behavior of Windows for non-UEFI boots, + * and older versions of Windows. + */ + return STATUS_NOT_IMPLEMENTED; + } + + if(!name || !vendor || (name && vendor && !retlen && !attrib)) + { + return STATUS_INVALID_PARAMETER; + } + + cname = (char *) malloc(wcslen(name->Buffer) * 3 + 1); + if(!cname) + return STATUS_MEMORY_NOT_ALLOCATED; + + rc = ntdll_wcstoumbs(name->Buffer, wcslen(name->Buffer) + 1, cname, wcslen(name->Buffer) * 3 + 1, TRUE); + if(rc <= 0) { + free(cname); + return STATUS_SOME_NOT_MAPPED; + } + + snprintf(filename, sizeof(filename), + "/sys/firmware/efi/efivars/%s-%08lx-%04hx-%04hx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx", + cname, (unsigned long)vendor->Data1, vendor->Data2, vendor->Data3, + vendor->Data4[0], vendor->Data4[1], vendor->Data4[2], vendor->Data4[3], + vendor->Data4[4], vendor->Data4[5], vendor->Data4[6], vendor->Data4[7]); + + fd = open(filename, O_RDONLY); + if (fd == -1) + { + free(cname); + return STATUS_VARIABLE_NOT_FOUND; + } + + rc = fstat(fd, &stat_info); + if (rc < 0 || stat_info.st_size == 0) + goto done; + + if(attrib) ssz = read(fd, attrib, 4); + else ssz = read(fd, buff, 4); // lseek not work in efifs. + if (ssz < 0) goto done; + + if(buffer && retlen) + { + if (stat_info.st_size - 4 < *retlen) + bytes = stat_info.st_size - 4; + else + bytes = *retlen; + while (pos < bytes) + { + ssz = read(fd, (char *) buffer + pos, bytes - pos); + if (ssz < 0) goto done; + pos += ssz; + } + *retlen = ssz & 0xFFFFFFFF; + } + else if(retlen) *retlen = (stat_info.st_size - 4) & 0xFFFFFFFF; + + close(fd); + return STATUS_SUCCESS; + +done: + free(cname); + if (fd >= 0) + close(fd); + return STATUS_UNSUCCESSFUL; +#elif defined(__APPLE__) + int rc; + char *cname; + GUID secureboot_guid = {0x8be4df61, 0x93ca, 0x11d2, {0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c}}; + if(!name || !vendor || (name && vendor && !retlen && !attrib)) + { + return STATUS_INVALID_PARAMETER; + } + + cname = (char *) malloc(wcslen(name->Buffer) * 3 + 1); + if(!cname) + return STATUS_MEMORY_NOT_ALLOCATED; + + rc = ntdll_wcstoumbs(name->Buffer, wcslen(name->Buffer) + 1, cname, wcslen(name->Buffer) * 3 + 1, TRUE); + if(rc <= 0) { + free(cname); + return STATUS_SOME_NOT_MAPPED; + } + /* + * Since 2006, Mac computers use Extensible Firmware Interface (EFI). + * Apple requires a developer account and mandatory code signing, + * and the entire system boot process is verified, we can return SecureBoot enabled. + * Reference: https://support.apple.com/guide/security/uefi-firmware-security-in-an-intel-... + */ + if(!memcmp(vendor, &secureboot_guid, sizeof(secureboot_guid)) && !strcmp(cname, "SecureBoot")) + { + if(attrib) *attrib = 0x06; + if(buffer && retlen && *retlen == sizeof(BOOLEAN)) *((BOOLEAN *)buffer) = 1; + else if(retlen) *retlen = sizeof(BOOLEAN) & 0xFFFFFFFF; + free(cname); + return STATUS_SUCCESS; + } + + free(cname); + return STATUS_VARIABLE_NOT_FOUND; +#else FIXME( "(%s, %s, %p, %p, %p), stub\n", debugstr_us(name), debugstr_guid(vendor), buffer, retlen, attrib ); return STATUS_NOT_IMPLEMENTED; +#endif }
From: Grigory Vasilyev h0tc0d3@gmail.com
--- dlls/kernel32/kernel32.spec | 2 + dlls/kernel32/process.c | 98 ++++++++++- dlls/kernel32/tests/firmware.c | 295 +++++++++++++++++++++++++++++++++ include/winbase.h | 4 + 4 files changed, 391 insertions(+), 8 deletions(-)
diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec index 7ed8048f5d0..5d3556a2078 100644 --- a/dlls/kernel32/kernel32.spec +++ b/dlls/kernel32/kernel32.spec @@ -695,7 +695,9 @@ @ stdcall -import GetFileType(long) @ stdcall -import GetFinalPathNameByHandleA(long ptr long long) @ stdcall -import GetFinalPathNameByHandleW(long ptr long long) +@ stdcall GetFirmwareEnvironmentVariableExA(str str ptr long ptr) @ stdcall GetFirmwareEnvironmentVariableA(str str ptr long) +@ stdcall GetFirmwareEnvironmentVariableExW(wstr wstr ptr long ptr) @ stdcall GetFirmwareEnvironmentVariableW(wstr wstr ptr long) @ stdcall GetFirmwareType(ptr) @ stdcall -import GetFullPathNameA(str long ptr ptr) diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index 88a0ce2bc33..436d6cc6920 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -719,13 +719,43 @@ WORD WINAPI GetMaximumProcessorGroupCount(void) }
/*********************************************************************** - * GetFirmwareEnvironmentVariableA (KERNEL32.@) + * GetFirmwareEnvironmentVariableExW (KERNEL32.@) */ -DWORD WINAPI GetFirmwareEnvironmentVariableA(LPCSTR name, LPCSTR guid, PVOID buffer, DWORD size) +DWORD WINAPI GetFirmwareEnvironmentVariableExW(LPCWSTR name, LPCWSTR guid, PVOID buffer, DWORD size, PDWORD attributes) { - FIXME("stub: %s %s %p %lu\n", debugstr_a(name), debugstr_a(guid), buffer, size); - SetLastError(ERROR_INVALID_FUNCTION); - return 0; + GUID vendor = {0}; + NTSTATUS status; + UNICODE_STRING uname; + UNICODE_STRING uguid; + DWORD ret_size = size; + + if(!name || !guid || !attributes) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + + RtlInitUnicodeString(&uguid, guid); + + if (!set_ntstatus(RtlGUIDFromString(&uguid, &vendor))) + return 0; + + RtlInitUnicodeString(&uname, name); + + status = NtQuerySystemEnvironmentValueEx(&uname, &vendor, buffer, + &ret_size, attributes); + if (status) + { + if(status == STATUS_VARIABLE_NOT_FOUND) + SetLastError(ERROR_ENVVAR_NOT_FOUND); + else if(status == STATUS_NOT_IMPLEMENTED) + SetLastError(ERROR_INVALID_FUNCTION); + else + SetLastError(RtlNtStatusToDosError(status)); + ret_size = 0; + } + + return ret_size; }
/*********************************************************************** @@ -733,9 +763,61 @@ DWORD WINAPI GetFirmwareEnvironmentVariableA(LPCSTR name, LPCSTR guid, PVOID buf */ DWORD WINAPI GetFirmwareEnvironmentVariableW(LPCWSTR name, LPCWSTR guid, PVOID buffer, DWORD size) { - FIXME("stub: %s %s %p %lu\n", debugstr_w(name), debugstr_w(guid), buffer, size); - SetLastError(ERROR_INVALID_FUNCTION); - return 0; + DWORD attributes; + return GetFirmwareEnvironmentVariableExW(name, guid, buffer, size, &attributes); +} + +/*********************************************************************** + * GetFirmwareEnvironmentVariableExA (KERNEL32.@) + */ +DWORD WINAPI GetFirmwareEnvironmentVariableExA(LPCSTR name, LPCSTR guid, PVOID buffer, DWORD size, PDWORD attributes) +{ + int nsize; + LPWSTR wname; + LPWSTR wguid; + DWORD ret_size; + + if(!name || !guid || !attributes) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + + nsize = MultiByteToWideChar(CP_ACP, 0, guid, -1, NULL, 0); + + if (!(wguid = HeapAlloc(GetProcessHeap(), 0, nsize * sizeof(wguid)))) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + + MultiByteToWideChar(CP_ACP, 0, guid, -1, wguid, nsize); + + nsize = MultiByteToWideChar(CP_ACP, 0, name, -1, NULL, 0); + + if (!(wname = HeapAlloc(GetProcessHeap(), 0, nsize * sizeof(wname)))) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + + MultiByteToWideChar(CP_ACP, 0, name, -1, wname, nsize); + + ret_size = GetFirmwareEnvironmentVariableExW(wname, wguid, buffer, size, attributes); + + HeapFree(GetProcessHeap(), 0, wname); + HeapFree(GetProcessHeap(), 0, wguid); + + return ret_size; +} + +/*********************************************************************** + * GetFirmwareEnvironmentVariableA (KERNEL32.@) + */ +DWORD WINAPI GetFirmwareEnvironmentVariableA(LPCSTR name, LPCSTR guid, PVOID buffer, DWORD size) +{ + DWORD attributes; + return GetFirmwareEnvironmentVariableExA(name, guid, buffer, size, &attributes); }
/*********************************************************************** diff --git a/dlls/kernel32/tests/firmware.c b/dlls/kernel32/tests/firmware.c index 5552d70e7e1..c8ac8b7491c 100644 --- a/dlls/kernel32/tests/firmware.c +++ b/dlls/kernel32/tests/firmware.c @@ -49,7 +49,302 @@ static void test_get_firmware_type(void) "Expected FALSE and GetLastError() == ERROR_INVALID_PARAMETER\n"); }
+static BOOL EnableTokenPrivilege(HANDLE hToken, const char *pszPrivilegesName, BOOL bEnabled) +{ + LUID luid; + TOKEN_PRIVILEGES tp; + + if (!LookupPrivilegeValueA(NULL, pszPrivilegesName, &luid)) + { + return FALSE; + } + + tp.PrivilegeCount = 1; + tp.Privileges[0].Luid = luid; + tp.Privileges[0].Attributes = bEnabled ? SE_PRIVILEGE_ENABLED : 0; + + if (!AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), NULL, NULL)) + { + return FALSE; + } + + return TRUE; +} + +static void test_get_firmware_environment(void) +{ + int status; + BOOLEAN secureboot; + DWORD attributes; + HANDLE hToken; + HANDLE hProcess; + BOOL privileged = FALSE; + + hProcess = GetCurrentProcess(); + if(hProcess && OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken) + && EnableTokenPrivilege(hToken, SE_SYSTEM_ENVIRONMENT_NAME, TRUE)) + privileged = TRUE; + + /* + * GetFirmwareEnvironmentVariableA + */ + status = GetFirmwareEnvironmentVariableA("SecureBoot", "{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + &secureboot, sizeof(BOOLEAN)); + + if(!privileged && !status && GetLastError() == ERROR_PRIVILEGE_NOT_HELD) + { + skip("GetFirmwareEnvironmentVariable* demand privileges SE_SYSTEM_ENVIRONMENT_NAME.\n"); + return; + } + + if (!status && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) + { + skip("GetFirmwareEnvironmentVariableA call NtQuerySystemEnvironmentValueEx" + "and NtQuerySystemEnvironmentValueEx not implemented.\n"); + goto get_firmware_environment_variable_w; + } + + if (!status && GetLastError() == ERROR_INVALID_FUNCTION) + { + skip("GetFirmwareEnvironmentVariableA call NtQuerySystemEnvironmentValueEx" + " and NtQuerySystemEnvironmentValueEx returned ERROR_INVALID_FUNCTION.\n" + "This behavior matches the behavior of Windows for non-UEFI boots and older versions of Windows.\n"); + goto get_firmware_environment_variable_w; + } + + ok(status > 0 || GetLastError() == ERROR_ENVVAR_NOT_FOUND, + "Expected status > 0 or GetLastError() == ERROR_ENVVAR_NOT_FOUND, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableA(NULL, NULL, &secureboot, sizeof(secureboot)); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableA(NULL, "{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + &secureboot, sizeof(secureboot)); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableA("SecureBoot", NULL, &secureboot, sizeof(secureboot)); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableA("SecureBoot", "{8be4df61-93ca-11d2-aa0d-00e098032b8c}", NULL, 0); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableA("SecureBoot", "{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + &secureboot, 0); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableA("SecureBoot", "{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + NULL, sizeof(secureboot)); + ok(status > 0 || GetLastError() == ERROR_ENVVAR_NOT_FOUND, + "Expected status > 0 or GetLastError() == ERROR_ENVVAR_NOT_FOUND, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableA("DummyName", "{00000000-0000-0000-0000-000000000000}", + &secureboot, sizeof(secureboot)); + ok(GetLastError() == ERROR_ENVVAR_NOT_FOUND, + "Expected ERROR_ENVVAR_NOT_FOUND, got error %ld.\n", GetLastError()); + + /* + * GetFirmwareEnvironmentVariableW + */ + get_firmware_environment_variable_w: + status = GetFirmwareEnvironmentVariableW(L"SecureBoot", L"{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + &secureboot, sizeof(BOOLEAN)); + + if (!status && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) + { + skip("GetFirmwareEnvironmentVariableW call NtQuerySystemEnvironmentValueEx" + "and NtQuerySystemEnvironmentValueEx not implemented.\n"); + goto get_firmware_environment_variable_ex_a; + } + + if (!status && GetLastError() == ERROR_INVALID_FUNCTION) + { + skip("GetFirmwareEnvironmentVariableW call NtQuerySystemEnvironmentValueEx" + " and NtQuerySystemEnvironmentValueEx returned ERROR_INVALID_FUNCTION.\n" + "This behavior matches the behavior of Windows for non-UEFI boots and older versions of Windows.\n"); + goto get_firmware_environment_variable_ex_a; + } + + ok(status > 0 || GetLastError() == ERROR_ENVVAR_NOT_FOUND, + "Expected status > 0, got error %ld\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableW(NULL, NULL, &secureboot, sizeof(secureboot)); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableW(NULL, L"{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + &secureboot, sizeof(secureboot)); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableW(L"SecureBoot", NULL, &secureboot, sizeof(secureboot)); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableW(L"SecureBoot", L"{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + NULL, 0); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableW(L"SecureBoot", L"{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + &secureboot, 0); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableW(L"SecureBoot", L"{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + NULL, sizeof(secureboot)); + ok(status > 0 || GetLastError() == ERROR_ENVVAR_NOT_FOUND, + "Expected status > 0 or GetLastError() == ERROR_ENVVAR_NOT_FOUND, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableW(L"DummyName", L"{00000000-0000-0000-0000-000000000000}", + &secureboot, sizeof(secureboot)); + ok(GetLastError() == ERROR_ENVVAR_NOT_FOUND, + "Expected ERROR_ENVVAR_NOT_FOUND, got error %ld.\n", GetLastError()); + + /* + * GetFirmwareEnvironmentVariableExA + */ + get_firmware_environment_variable_ex_a: + status = GetFirmwareEnvironmentVariableExA("SecureBoot", "{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + &secureboot, sizeof(BOOLEAN), &attributes); + + if (!status && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) + { + skip("GetFirmwareEnvironmentVariableExA call NtQuerySystemEnvironmentValueEx" + "and NtQuerySystemEnvironmentValueEx not implemented.\n"); + goto get_firmware_environment_variable_ex_w; + } + + if (!status && GetLastError() == ERROR_INVALID_FUNCTION) + { + skip("GetFirmwareEnvironmentVariableExA call NtQuerySystemEnvironmentValueEx" + " and NtQuerySystemEnvironmentValueEx returned ERROR_INVALID_FUNCTION.\n" + "This behavior matches the behavior of Windows for non-UEFI boots and older versions of Windows.\n"); + goto get_firmware_environment_variable_ex_w; + } + + ok(status > 0 || GetLastError() == ERROR_ENVVAR_NOT_FOUND, + "Expected status > 0, got error %ld\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableExA(NULL, NULL, &secureboot, sizeof(secureboot), &attributes); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableExA(NULL, "{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + &secureboot, sizeof(secureboot), &attributes); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableExA("SecureBoot", NULL, &secureboot, + sizeof(secureboot), &attributes); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableExA("SecureBoot", "{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + NULL, 0, NULL); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableExA("SecureBoot", "{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + &secureboot, 0, NULL); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableExA("SecureBoot", "{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + &secureboot, 0, &attributes); + ok(status > 0 || GetLastError() == ERROR_ENVVAR_NOT_FOUND, + "Expected status > 0 or GetLastError() == ERROR_ENVVAR_NOT_FOUND, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableExA("SecureBoot", "{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + NULL, sizeof(secureboot), NULL); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableExA("SecureBoot", "{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + NULL, sizeof(secureboot), &attributes); + ok(status > 0 || GetLastError() == ERROR_ENVVAR_NOT_FOUND, + "Expected status > 0 or GetLastError() == ERROR_ENVVAR_NOT_FOUND, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableExA("DummyName", "{00000000-0000-0000-0000-000000000000}", + &secureboot, sizeof(secureboot), &attributes); + ok(GetLastError() == ERROR_ENVVAR_NOT_FOUND, + "Expected ERROR_ENVVAR_NOT_FOUND, got error %ld.\n", GetLastError()); + + /* + * GetFirmwareEnvironmentVariableExW + */ + get_firmware_environment_variable_ex_w: + status = GetFirmwareEnvironmentVariableExW(L"SecureBoot", L"{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + &secureboot, sizeof(BOOLEAN), &attributes); + + if (!status && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) + { + skip("GetFirmwareEnvironmentVariableExW call NtQuerySystemEnvironmentValueEx" + "and NtQuerySystemEnvironmentValueEx not implemented.\n"); + return; + } + + if (!status && GetLastError() == ERROR_INVALID_FUNCTION) + { + skip("GetFirmwareEnvironmentVariableExW call NtQuerySystemEnvironmentValueEx" + " and NtQuerySystemEnvironmentValueEx returned ERROR_INVALID_FUNCTION.\n" + "This behavior matches the behavior of Windows for non-UEFI boots and older versions of Windows.\n"); + return; + } + + ok(status > 0 || GetLastError() == ERROR_ENVVAR_NOT_FOUND, + "Expected status > 0, got error %ld\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableExW(NULL, NULL, &secureboot, sizeof(secureboot), &attributes); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableExW(NULL, L"{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + &secureboot, sizeof(secureboot), &attributes); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableExW(L"SecureBoot", NULL, &secureboot, sizeof(secureboot), &attributes); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableExW(L"SecureBoot", L"{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + NULL, 0, NULL); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableExW(L"SecureBoot", L"{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + &secureboot, 0, NULL); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableExW(L"SecureBoot", L"{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + &secureboot, 0, &attributes); + ok(status > 0 || GetLastError() == ERROR_ENVVAR_NOT_FOUND, + "Expected status > 0 or GetLastError() == ERROR_ENVVAR_NOT_FOUND, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableExW(L"SecureBoot", L"{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + NULL, sizeof(secureboot), NULL); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableExW(L"SecureBoot", L"{8be4df61-93ca-11d2-aa0d-00e098032b8c}", + NULL, sizeof(secureboot), &attributes); + ok(status > 0 || GetLastError() == ERROR_ENVVAR_NOT_FOUND, + "Expected status > 0 or GetLastError() == ERROR_ENVVAR_NOT_FOUND, got error %ld.\n", GetLastError()); + + status = GetFirmwareEnvironmentVariableExW(L"DummyName", L"{00000000-0000-0000-0000-000000000000}", + &secureboot, sizeof(secureboot), &attributes); + ok(GetLastError() == ERROR_ENVVAR_NOT_FOUND, + "Expected ERROR_ENVVAR_NOT_FOUND, got error %ld.\n", GetLastError()); +} + START_TEST(firmware) { test_get_firmware_type(); + test_get_firmware_environment(); } diff --git a/include/winbase.h b/include/winbase.h index fe143cc7a61..2517417b170 100644 --- a/include/winbase.h +++ b/include/winbase.h @@ -2216,6 +2216,10 @@ WINBASEAPI DWORD WINAPI GetFileSize(HANDLE,LPDWORD); WINBASEAPI BOOL WINAPI GetFileSizeEx(HANDLE,PLARGE_INTEGER); WINBASEAPI BOOL WINAPI GetFileTime(HANDLE,LPFILETIME,LPFILETIME,LPFILETIME); WINBASEAPI DWORD WINAPI GetFileType(HANDLE); +WINBASEAPI DWORD WINAPI GetFirmwareEnvironmentVariableA(LPCSTR,LPCSTR,PVOID,DWORD); +WINBASEAPI DWORD WINAPI GetFirmwareEnvironmentVariableExA(LPCSTR,LPCSTR,PVOID,DWORD,PDWORD); +WINBASEAPI DWORD WINAPI GetFirmwareEnvironmentVariableW(LPCWSTR,LPCWSTR,PVOID,DWORD); +WINBASEAPI DWORD WINAPI GetFirmwareEnvironmentVariableExW(LPCWSTR,LPCWSTR,PVOID,DWORD,PDWORD); WINBASEAPI BOOL WINAPI GetFirmwareType(PFIRMWARE_TYPE); #define GetFreeSpace(w) (__MSABI_LONG(0x100000)) WINBASEAPI DWORD WINAPI GetFullPathNameA(LPCSTR,DWORD,LPSTR,LPSTR*);
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=148325
Your paranoid android.
=== w10pro64_zh_CN (64 bit report) ===
kernel32: console.c:5233: Test failed: test #5: CreateProcess failed: 1455 C:\Users\winetest\AppData\Local\Temp\console_cui.exe console.c:5236: Test failed: test #5: Child didn't init 258 000000000000019C console.c:5261: Test failed: test #5: Expecting child to be terminated console.c:5266: Test failed: test #5: Couldn't get exit code console.c:5268: Test failed: test #5: Unexpected exit code 0xfe, instead of 0
=== w1064_adm (64 bit report) ===
kernel32: firmware.c:115: Test failed: Expected status > 0 or GetLastError() == ERROR_ENVVAR_NOT_FOUND, got error 1314. firmware.c:132: Test failed: Expected ERROR_INVALID_PARAMETER, got error 1314. firmware.c:137: Test failed: Expected ERROR_INVALID_PARAMETER, got error 1314. firmware.c:142: Test failed: Expected status > 0 or GetLastError() == ERROR_ENVVAR_NOT_FOUND, got error 1314. firmware.c:147: Test failed: Expected ERROR_ENVVAR_NOT_FOUND, got error 1314. firmware.c:172: Test failed: Expected status > 0, got error 1314 firmware.c:190: Test failed: Expected ERROR_INVALID_PARAMETER, got error 1314. firmware.c:195: Test failed: Expected ERROR_INVALID_PARAMETER, got error 1314. firmware.c:200: Test failed: Expected status > 0 or GetLastError() == ERROR_ENVVAR_NOT_FOUND, got error 1314. firmware.c:205: Test failed: Expected ERROR_ENVVAR_NOT_FOUND, got error 1314. firmware.c:230: Test failed: Expected status > 0, got error 1314 firmware.c:249: Test failed: Expected ERROR_INVALID_PARAMETER, got error 1314. firmware.c:254: Test failed: Expected ERROR_INVALID_PARAMETER, got error 1314. firmware.c:259: Test failed: Expected status > 0 or GetLastError() == ERROR_ENVVAR_NOT_FOUND, got error 1314. firmware.c:264: Test failed: Expected ERROR_INVALID_PARAMETER, got error 1314. firmware.c:269: Test failed: Expected status > 0 or GetLastError() == ERROR_ENVVAR_NOT_FOUND, got error 1314. firmware.c:274: Test failed: Expected ERROR_ENVVAR_NOT_FOUND, got error 1314. firmware.c:299: Test failed: Expected status > 0, got error 1314 firmware.c:317: Test failed: Expected ERROR_INVALID_PARAMETER, got error 1314. firmware.c:322: Test failed: Expected ERROR_INVALID_PARAMETER, got error 1314. firmware.c:327: Test failed: Expected status > 0 or GetLastError() == ERROR_ENVVAR_NOT_FOUND, got error 1314. firmware.c:332: Test failed: Expected ERROR_INVALID_PARAMETER, got error 1314. firmware.c:337: Test failed: Expected status > 0 or GetLastError() == ERROR_ENVVAR_NOT_FOUND, got error 1314. firmware.c:342: Test failed: Expected ERROR_ENVVAR_NOT_FOUND, got error 1314.
=== w10pro64_en_AE_u8 (32 bit report) ===
kernel32: heap.c:3314: Test failed: HeapValidate failed heap.c:3323: Test failed: HeapValidate failed
=== w1064_tsign (32 bit report) ===
kernel32: process.c:2739: Test failed: expected 0 assigned processes, got 1 process.c:2739: Test failed: expected 0 process IDs, got 1
=== w864 (64 bit report) ===
kernel32: process.c:2740: Test failed: expected 0 active processes, got 1
=== w1064_2qxl (64 bit report) ===
kernel32: process.c:2739: Test failed: expected 0 assigned processes, got 1 process.c:2739: Test failed: expected 0 process IDs, got 1
=== w7u_2qxl (32 bit report) ===
ntdll: info.c:348: Test failed: Expected ret_size == sizeof(SYSTEM_BOOT_ENVIRONMENT_INFORMATION).
=== w7u_adm (32 bit report) ===
ntdll: info.c:348: Test failed: Expected ret_size == sizeof(SYSTEM_BOOT_ENVIRONMENT_INFORMATION).
=== w7u_el (32 bit report) ===
ntdll: info.c:348: Test failed: Expected ret_size == sizeof(SYSTEM_BOOT_ENVIRONMENT_INFORMATION).
=== w1064_tsign (32 bit report) ===
ntdll: info.c:369: Test failed: Expected STATUS_NOT_IMPLEMENTED on non-UEFI boots. info.c:377: Test failed: Expected STATUS_SUCCESS or STATUS_VARIABLE_NOT_FOUND. info.c:380: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:383: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:386: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:389: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:392: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:395: Test failed: Expected STATUS_SUCCESS. info.c:398: Test failed: Expected STATUS_SUCCESS. info.c:401: Test failed: Expected STATUS_SUCCESS.
=== w10pro64 (32 bit report) ===
ntdll: info.c:369: Test failed: Expected STATUS_NOT_IMPLEMENTED on non-UEFI boots. info.c:377: Test failed: Expected STATUS_SUCCESS or STATUS_VARIABLE_NOT_FOUND. info.c:380: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:383: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:386: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:389: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:392: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:395: Test failed: Expected STATUS_SUCCESS. info.c:398: Test failed: Expected STATUS_SUCCESS. info.c:401: Test failed: Expected STATUS_SUCCESS.
=== w10pro64_en_AE_u8 (32 bit report) ===
ntdll: info.c:369: Test failed: Expected STATUS_NOT_IMPLEMENTED on non-UEFI boots. info.c:377: Test failed: Expected STATUS_SUCCESS or STATUS_VARIABLE_NOT_FOUND. info.c:380: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:383: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:386: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:389: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:392: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:395: Test failed: Expected STATUS_SUCCESS. info.c:398: Test failed: Expected STATUS_SUCCESS. info.c:401: Test failed: Expected STATUS_SUCCESS.
=== w11pro64 (32 bit report) ===
ntdll: info.c:369: Test failed: Expected STATUS_NOT_IMPLEMENTED on non-UEFI boots. info.c:377: Test failed: Expected STATUS_SUCCESS or STATUS_VARIABLE_NOT_FOUND. info.c:380: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:383: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:386: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:389: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:392: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:395: Test failed: Expected STATUS_SUCCESS. info.c:398: Test failed: Expected STATUS_SUCCESS. info.c:401: Test failed: Expected STATUS_SUCCESS.
=== w7pro64 (64 bit report) ===
ntdll: info.c:348: Test failed: Expected ret_size == sizeof(SYSTEM_BOOT_ENVIRONMENT_INFORMATION).
=== w1064_2qxl (64 bit report) ===
ntdll: info.c:369: Test failed: Expected STATUS_NOT_IMPLEMENTED on non-UEFI boots. info.c:377: Test failed: Expected STATUS_SUCCESS or STATUS_VARIABLE_NOT_FOUND. info.c:380: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:383: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:386: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:389: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:392: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:395: Test failed: Expected STATUS_SUCCESS. info.c:398: Test failed: Expected STATUS_SUCCESS. info.c:401: Test failed: Expected STATUS_SUCCESS.
=== w1064_adm (64 bit report) ===
ntdll: info.c:369: Test failed: Expected STATUS_NOT_IMPLEMENTED on non-UEFI boots. info.c:377: Test failed: Expected STATUS_SUCCESS or STATUS_VARIABLE_NOT_FOUND. info.c:380: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:383: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:386: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:389: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:392: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:395: Test failed: Expected STATUS_SUCCESS. info.c:398: Test failed: Expected STATUS_SUCCESS. info.c:401: Test failed: Expected STATUS_SUCCESS.
=== w1064_tsign (64 bit report) ===
ntdll: info.c:369: Test failed: Expected STATUS_NOT_IMPLEMENTED on non-UEFI boots. info.c:377: Test failed: Expected STATUS_SUCCESS or STATUS_VARIABLE_NOT_FOUND. info.c:380: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:383: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:386: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:389: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:392: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:395: Test failed: Expected STATUS_SUCCESS. info.c:398: Test failed: Expected STATUS_SUCCESS. info.c:401: Test failed: Expected STATUS_SUCCESS.
=== w10pro64 (64 bit report) ===
ntdll: info.c:369: Test failed: Expected STATUS_NOT_IMPLEMENTED on non-UEFI boots. info.c:377: Test failed: Expected STATUS_SUCCESS or STATUS_VARIABLE_NOT_FOUND. info.c:380: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:383: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:386: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:389: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:392: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:395: Test failed: Expected STATUS_SUCCESS. info.c:398: Test failed: Expected STATUS_SUCCESS. info.c:401: Test failed: Expected STATUS_SUCCESS.
=== w10pro64_ar (64 bit report) ===
ntdll: info.c:369: Test failed: Expected STATUS_NOT_IMPLEMENTED on non-UEFI boots. info.c:377: Test failed: Expected STATUS_SUCCESS or STATUS_VARIABLE_NOT_FOUND. info.c:380: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:383: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:386: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:389: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:392: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:395: Test failed: Expected STATUS_SUCCESS. info.c:398: Test failed: Expected STATUS_SUCCESS. info.c:401: Test failed: Expected STATUS_SUCCESS.
=== w10pro64_ja (64 bit report) ===
ntdll: info.c:369: Test failed: Expected STATUS_NOT_IMPLEMENTED on non-UEFI boots. info.c:377: Test failed: Expected STATUS_SUCCESS or STATUS_VARIABLE_NOT_FOUND. info.c:380: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:383: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:386: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:389: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:392: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:395: Test failed: Expected STATUS_SUCCESS. info.c:398: Test failed: Expected STATUS_SUCCESS. info.c:401: Test failed: Expected STATUS_SUCCESS.
=== w10pro64_zh_CN (64 bit report) ===
ntdll: info.c:369: Test failed: Expected STATUS_NOT_IMPLEMENTED on non-UEFI boots. info.c:377: Test failed: Expected STATUS_SUCCESS or STATUS_VARIABLE_NOT_FOUND. info.c:380: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:383: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:386: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:389: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:392: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:395: Test failed: Expected STATUS_SUCCESS. info.c:398: Test failed: Expected STATUS_SUCCESS. info.c:401: Test failed: Expected STATUS_SUCCESS.
=== w11pro64_amd (64 bit report) ===
ntdll: info.c:369: Test failed: Expected STATUS_NOT_IMPLEMENTED on non-UEFI boots. info.c:377: Test failed: Expected STATUS_SUCCESS or STATUS_VARIABLE_NOT_FOUND. info.c:380: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:383: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:386: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:389: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:392: Test failed: Expected STATUS_INVALID_PARAMETER. info.c:395: Test failed: Expected STATUS_SUCCESS. info.c:398: Test failed: Expected STATUS_SUCCESS. info.c:401: Test failed: Expected STATUS_SUCCESS.
On Mon Sep 9 17:00:26 2024 +0000, Grigory Vasilyev wrote:
changed this line in [version 29 of the diff](/wine/wine/-/merge_requests/6423/diffs?diff_id=131031&start_sha=674087a2487a905178bf2145625a7642f4efb902#ab0e96cab0eba5d12a1176c358d39434c6919313_766_743)
Done.
On Mon Sep 9 16:03:17 2024 +0000, Grigory Vasilyev wrote:
@Alcaro it works as expected and sets a BootIdentifier that does not change across reboots. This behavior is similar to Windows. But there are fewer possible variations. If you find data sources that do not change and are unique to the system, I can improve the variability.
I checked, hostid is not suitable for encoding a unique ID, since it simply 4 bytes which contains encoded IP address. Probably the best option would be to use the MAC address of the first interface in the system. But the MAC address is easy to change. https://www.unknowncheats.me/forum/apex-legends/644651-hwid-banned-linux.htm...
On Mon Sep 9 20:58:18 2024 +0000, Grigory Vasilyev wrote:
I checked, hostid is not suitable for encoding a unique ID, since it simply 4 bytes which contains encoded IP address. Probably the best option would be to use the MAC address of the first interface in the system. But the MAC address is easy to change. https://www.unknowncheats.me/forum/apex-legends/644651-hwid-banned-linux.htm...
I believe we proposed on IRC that wineboot should generate a GUID (unless present already) and store somewhere (registry probably), and return that here.
Sure, still easy to change if you know where you're looking, but so is that machine-id.
On Mon Sep 9 21:04:51 2024 +0000, Alfred Agrell wrote:
I believe we proposed on IRC that wineboot should generate a GUID (unless present already) and store somewhere (registry probably), and return that here. Sure, still easy to change if you know where you're looking, but so is that machine-id.
@Alcaro I would suggest a not so healthy idea, use a server and make a `get_prefix_id` request, randomly generate a guid and store it in a file in `system32/wineguid.dll`, the format is 16 bytes guid and 4 bytes Jenkins hash for guid. The server will read the file on startup, cache the contents and return the value. If the file does not exist, then generate a new file and guid. Ideally, we can use TPM 2.0 for this purpose.
On Tue Sep 10 23:16:34 2024 +0000, Grigory Vasilyev wrote:
@Alcaro I would suggest a not so healthy idea, use a server and make a `get_prefix_id` request, randomly generate a guid and store it in a file in `system32/wineguid.dll`, the format is 16 bytes guid and 4 bytes Jenkins hash for guid. The server will read the file on startup, cache the contents and return the value. If the file does not exist, then generate a new file and guid. Ideally, we can use TPM 2.0 for this purpose.
Registry or file both sound good to me. Small binary pieces usually go in registry, but I have no strong preference. The registry is just a file, anyways.
I do, however, question why you're proposing (1) appending a hash (I can't see what that would accomplish) (2) storing something other than a DLL in a file named .dll (I'd use something generic, like .bin or .dat) (3) using a TPM (unlike some win32 implementations, Wine doesn't require TPM - and there's no public key cryptography or boot measurement involved here, so TPM accomplishes nothing even if available) (4) going via wineserver (I can't see what that would accomplish either, files and registry are available to everyone).
If you want to prevent users from resetting or customizing the boot ID, you're gonna have a bad time. Wine is open source, a dedicated user could simply modify ntdll. You cannot prevent that.
On Wed Sep 11 00:09:40 2024 +0000, Alfred Agrell wrote:
Registry or file both sound good to me. Small binary pieces usually go in registry, but I have no strong preference. The registry is just a file, anyways. I do, however, question why you're proposing (1) appending a hash (I can't see what that would accomplish) (2) storing something other than a DLL in a file named .dll (I'd use something generic, like .bin or .dat) (3) using a TPM (unlike some win32 implementations, Wine doesn't require TPM - and there's no public key cryptography or boot measurement involved here, so TPM accomplishes nothing even if available) (4) going via wineserver (I can't see what that would accomplish either, files and registry are available to everyone). If you want to prevent users from resetting or customizing the boot ID, you're gonna have a bad time. Wine is open source, a dedicated user could simply modify ntdll. You cannot prevent that.
Why would we store it in a file? The point of my suggestion was that the boot identifier isn't stable past a single boot. If that's the case it would make the most sense to put it in a volatile registry key.
On Wed Sep 11 00:36:31 2024 +0000, Elizabeth Figura wrote:
Why would we store it in a file? The point of my suggestion was that the boot identifier isn't stable past a single boot. If that's the case it would make the most sense to put it in a volatile registry key.
@Alcaro The file can be encrypted, for example, using TPM, the checksum allows you to prohibit changing the file manually. Slightly better protection against counterfeiting and changing the ID. Will complicate the task a little. TPM can completely solve the problem, but for TPM there must be something like system trust levels, as is done in Windows. TPM is not required, but it can increase the level of trust in the system. The presence of TPM in wine can help game and anti-cheat creators to port games to Linux.
@zfigura In Windows, boot id is a unique bcd entry that does not change, is constant, and can only change after reinstalling the system or bootloader. I assume that anti-cheats can ban cheaters by boot id, so it is advisable to make a unique id that is difficult to simply change. But in fact, they ban most often by the serial number of the disk, the MAC of the network card, the serial number of the motherboard, the TPM module. Even if they ban based on other unique system features, boot id can help catch cheaters who most often change the serial number of the HDD and the MAC address of the network card. Thus, the more unique features a system has, the better.
Reference: https://www.unknowncheats.me/forum/apex-legends/644651-hwid-banned-linux.htm...
Reference: https://www.unknowncheats.me/forum/apex-legends/644651-hwid-banned-linux.htm...
I'm not seeing anything in there about the boot identifier?
I was previously led to believe that the boot identifier is not stable.
On Wed Sep 11 01:48:13 2024 +0000, Elizabeth Figura wrote:
Reference: https://www.unknowncheats.me/forum/apex-legends/644651-hwid-banned-linux.htm...
I'm not seeing anything in there about the boot identifier? I was previously led to believe that the boot identifier is not stable.
@zfigura they don't know about its existence because it's still not in wine. But think anti-cheats in Windows read it through GetFirmwareEnvironmentVariableExW. Not many games with anti-cheat work on Linux. In those games that work on Linux, there is an epidemic of cheaters, and cheaters have started to use Linux more often. For example Apex Legends game. A unique ID will not save from cheaters and it can be bypassed, but while no one knows about it, it can help identify some cheaters.