NtQueryBootEntryOrder
Reads the firmware's ordered list of BOOT_ENTRY IDs — the sequence the platform will attempt at next power-on.
Prototype
NTSTATUS NtQueryBootEntryOrder( PULONG Ids, PULONG Count );
Arguments
| Name | Type | Dir | Description |
|---|---|---|---|
| Ids | PULONG | out | Caller-allocated array receiving the ordered BOOT_ENTRY identifiers. May be NULL to query the required Count. |
| Count | PULONG | in/out | On input: number of ULONG slots in Ids. On output: number of IDs written, or required count when STATUS_BUFFER_TOO_SMALL is returned. |
Syscall IDs by Windows version
| Windows version | Syscall ID | Build |
|---|---|---|
| Win10 1507 | 0x128 | win10-1507 |
| Win10 1607 | 0x12E | win10-1607 |
| Win10 1703 | 0x133 | win10-1703 |
| Win10 1709 | 0x135 | win10-1709 |
| Win10 1803 | 0x137 | win10-1803 |
| Win10 1809 | 0x138 | win10-1809 |
| Win10 1903 | 0x139 | win10-1903 |
| Win10 1909 | 0x139 | win10-1909 |
| Win10 2004 | 0x13F | win10-2004 |
| Win10 20H2 | 0x13F | win10-20h2 |
| Win10 21H1 | 0x13F | win10-21h1 |
| Win10 21H2 | 0x140 | win10-21h2 |
| Win10 22H2 | 0x140 | win10-22h2 |
| Win11 21H2 | 0x146 | win11-21h2 |
| Win11 22H2 | 0x148 | win11-22h2 |
| Win11 23H2 | 0x148 | win11-23h2 |
| Win11 24H2 | 0x14A | win11-24h2 |
| Server 2016 | 0x12E | winserver-2016 |
| Server 2019 | 0x138 | winserver-2019 |
| Server 2022 | 0x145 | winserver-2022 |
| Server 2025 | 0x14A | winserver-2025 |
Kernel module
Related APIs
Syscall stub
4C 8B D1 mov r10, rcx B8 4A 01 00 00 mov eax, 0x14A F6 04 25 08 03 FE 7F 01 test byte ptr [0x7FFE0308], 1 75 03 jne short +3 0F 05 syscall C3 ret CD 2E int 2Eh C3 ret
Undocumented notes
On UEFI this is fundamentally a wrapper over the firmware-defined `BootOrder` NVRAM variable (EFI Global Variable, GUID `{8BE4DF61-93CA-11d2-AA0D-00E098032B8C}`). The array is the *sequence* in which the firmware will try each `Boot####` variable. The first call typically uses a NULL `Ids` buffer to learn the size, the second collects the data. SeSystemEnvironmentPrivilege is required.
Common malware usage
A prerequisite to NtSetBootEntryOrder: bootkit installers read the current order, splice their freshly registered ID into position 0 (or wherever they need it relative to existing entries), and write it back. They also use the query to verify persistence survived a reboot — if `Ids[0]` is not the attacker's GUID anymore, the implant knows a defender or BIOS update has restored the order and re-runs the install. This loop is documented in BlackLotus' persistence module.
Detection opportunities
Same caveats as NtEnumerateBootEntries — read-only and frequently legitimate. The high-fidelity tell is the *pair*: query + set with a delta that promotes a non-Microsoft-signed loader to the head of the order. Compare the result of this syscall to a clean baseline; even better, integrate the EFI `BootOrder` variable into your asset inventory (Eclypsium, CHIPSEC, or Intune device health attestation) and alert on changes.
Direct syscall examples
asmx64 direct stub (Win11 24H2, SSN 0x14A)
NtQueryBootEntryOrder PROC
mov r10, rcx ; PULONG Ids
mov eax, 014Ah ; Win11 24H2
syscall
ret
NtQueryBootEntryOrder ENDPcRead current BootOrder
extern NTSTATUS NTAPI NtQueryBootEntryOrder(PULONG, PULONG);
void show_order(void) {
ULONG count = 0;
NtQueryBootEntryOrder(NULL, &count); // STATUS_BUFFER_TOO_SMALL, fills count
if (!count) return;
PULONG ids = (PULONG)HeapAlloc(GetProcessHeap(), 0, count * sizeof(ULONG));
if (NT_SUCCESS(NtQueryBootEntryOrder(ids, &count))) {
for (ULONG i = 0; i < count; ++i) wprintf(L"%u -> id=%08X\n", i, ids[i]);
}
HeapFree(GetProcessHeap(), 0, ids);
}rustNaked stub
use std::arch::asm;
#[unsafe(naked)]
unsafe extern "system" fn nt_query_boot_entry_order(_ids: *mut u32, _count: *mut u32) -> i32 {
asm!(
"mov r10, rcx",
"mov eax, 0x14A", // Win11 24H2
"syscall",
"ret",
options(noreturn),
);
}MITRE ATT&CK mappings
Last verified: 2026-05-20