> Windows Syscalls
ntoskrnl.exeT1542.003T1082T1542

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

NameTypeDirDescription
IdsPULONGoutCaller-allocated array receiving the ordered BOOT_ENTRY identifiers. May be NULL to query the required Count.
CountPULONGin/outOn 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 versionSyscall IDBuild
Win10 15070x128win10-1507
Win10 16070x12Ewin10-1607
Win10 17030x133win10-1703
Win10 17090x135win10-1709
Win10 18030x137win10-1803
Win10 18090x138win10-1809
Win10 19030x139win10-1903
Win10 19090x139win10-1909
Win10 20040x13Fwin10-2004
Win10 20H20x13Fwin10-20h2
Win10 21H10x13Fwin10-21h1
Win10 21H20x140win10-21h2
Win10 22H20x140win10-22h2
Win11 21H20x146win11-21h2
Win11 22H20x148win11-22h2
Win11 23H20x148win11-23h2
Win11 24H20x14Awin11-24h2
Server 20160x12Ewinserver-2016
Server 20190x138winserver-2019
Server 20220x145winserver-2022
Server 20250x14Awinserver-2025

Kernel module

ntoskrnl.exeNtQueryBootEntryOrder

Related APIs

GetFirmwareEnvironmentVariableW (BootOrder)bcdedit.exe /enumBcdGetElementData (Boot Order GUID)NtSetBootEntryOrderNtEnumerateBootEntries

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 ENDP

cRead 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