From 36dc82e926b9bfb35b203256838a2f835b21fc40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 26 Sep 2026 12:56:37 +0800 Subject: [PATCH] Bootmgr: cleans code --- src/common/windows/nt.h | 3 --- src/detection/bootmgr/bootmgr_linux.c | 1 + src/detection/bootmgr/bootmgr_windows.c | 10 ++++++---- src/detection/bootmgr/efi_helper.h | 2 -- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/common/windows/nt.h b/src/common/windows/nt.h index 26b214dc4..539377a80 100644 --- a/src/common/windows/nt.h +++ b/src/common/windows/nt.h @@ -171,9 +171,6 @@ NTSTATUS NTAPI NtQuerySystemEnvironmentValueEx( _Out_opt_ PULONG Attributes // EFI_VARIABLE_* ); -NTSTATUS NTAPI RtlGUIDFromString(IN PCUNICODE_STRING GuidString, OUT GUID* Guid); -NTSTATUS NTAPI RtlStringFromGUIDEx(IN const GUID* Guid, OUT PUNICODE_STRING GuidString, IN BOOLEAN AllocateGuidString); - typedef struct _SYSTEM_SECUREBOOT_INFORMATION { BOOLEAN SecureBootEnabled; BOOLEAN SecureBootCapable; diff --git a/src/detection/bootmgr/bootmgr_linux.c b/src/detection/bootmgr/bootmgr_linux.c index daae9e79e..25934a033 100644 --- a/src/detection/bootmgr/bootmgr_linux.c +++ b/src/detection/bootmgr/bootmgr_linux.c @@ -5,6 +5,7 @@ #include #define FF_EFIVARS_PATH_PREFIX "/sys/firmware/efi/efivars/" +#define FF_EFI_GLOBAL_GUID "8be4df61-93ca-11d2-aa0d-00e098032b8c" const char* ffDetectBootmgr(FFBootmgrResult* result) { alignas(uint16_t) uint8_t buffer[2048]; diff --git a/src/detection/bootmgr/bootmgr_windows.c b/src/detection/bootmgr/bootmgr_windows.c index 0a1a55994..c7cbdb262 100644 --- a/src/detection/bootmgr/bootmgr_windows.c +++ b/src/detection/bootmgr/bootmgr_windows.c @@ -39,10 +39,12 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) { return err; } - GUID efiGlobalGuid; - if (!NT_SUCCESS(RtlGUIDFromString(&(UNICODE_STRING) RTL_CONSTANT_STRING(L"{" FF_EFI_GLOBAL_GUID L"}"), &efiGlobalGuid))) { - return "RtlGUIDFromString() failed"; - } + GUID efiGlobalGuid = { + .Data1 = 0x8be4df61, + .Data2 = 0x93ca, + .Data3 = 0x11d2, + .Data4 = { 0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c }, + }; ULONG size = sizeof(result->order); if (!NT_SUCCESS(NtQuerySystemEnvironmentValueEx(&(UNICODE_STRING) RTL_CONSTANT_STRING(L"BootCurrent"), &efiGlobalGuid, &result->order, &size, nullptr))) { diff --git a/src/detection/bootmgr/efi_helper.h b/src/detection/bootmgr/efi_helper.h index b52ec8a81..cd8ae27a6 100644 --- a/src/detection/bootmgr/efi_helper.h +++ b/src/detection/bootmgr/efi_helper.h @@ -18,5 +18,3 @@ typedef struct FFEfiLoadOption { } FFEfiLoadOption; bool ffEfiFillLoadOption(const FFEfiLoadOption* efiOption, FFBootmgrResult* result); - -#define FF_EFI_GLOBAL_GUID "8be4df61-93ca-11d2-aa0d-00e098032b8c"