NtSetBootEntryOrder
Writes the firmware boot-attempt order — the array of BOOT_ENTRY IDs the platform will try in sequence.
Prototype
NTSTATUS NtSetBootEntryOrder( PULONG Ids, ULONG Count );
Arguments
| Name | Type | Dir | Description |
|---|---|---|---|
| Ids | PULONG | in | Array of BOOT_ENTRY identifiers in the desired attempt order. Index 0 is tried first. |
| Count | ULONG | in | Number of entries in Ids. Must match every ID currently registered — partial orderings are rejected. |
Syscall IDs by Windows version
| Windows version | Syscall ID | Build |
|---|---|---|
| Win10 1507 | 0x16C | win10-1507 |
| Win10 1607 | 0x174 | win10-1607 |
| Win10 1703 | 0x17A | win10-1703 |
| Win10 1709 | 0x17D | win10-1709 |
| Win10 1803 | 0x17F | win10-1803 |
| Win10 1809 | 0x180 | win10-1809 |
| Win10 1903 | 0x181 | win10-1903 |
| Win10 1909 | 0x181 | win10-1909 |
| Win10 2004 | 0x187 | win10-2004 |
| Win10 20H2 | 0x187 | win10-20h2 |
| Win10 21H1 | 0x187 | win10-21h1 |
| Win10 21H2 | 0x189 | win10-21h2 |
| Win10 22H2 | 0x189 | win10-22h2 |
| Win11 21H2 | 0x191 | win11-21h2 |
| Win11 22H2 | 0x194 | win11-22h2 |
| Win11 23H2 | 0x194 | win11-23h2 |
| Win11 24H2 | 0x196 | win11-24h2 |
| Server 2016 | 0x174 | winserver-2016 |
| Server 2019 | 0x180 | winserver-2019 |
| Server 2022 | 0x18F | winserver-2022 |
| Server 2025 | 0x196 | winserver-2025 |
Kernel module
Related APIs
Syscall stub
4C 8B D1 mov r10, rcx B8 96 01 00 00 mov eax, 0x196 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
The write companion to NtQueryBootEntryOrder. On UEFI the kernel ultimately calls `EFI_SET_VARIABLE` against the global `BootOrder` variable (vendor GUID `{8BE4DF61-93CA-11d2-AA0D-00E098032B8C}`) with `EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS`. SeSystemEnvironmentPrivilege is mandatory and the call fails STATUS_INVALID_PARAMETER if any supplied ID does not currently exist.
Common malware usage
The capstone of BCD-based bootkit installation: once a rogue `Boot####` has been registered via NtAddBootEntry, this is the call that **wins** the next reboot for the attacker by promoting that ID to position 0. Without this step, the attacker's entry is dormant — UEFI tries the existing Windows Boot Manager first and never reaches it. The reorder is what makes the implant active. BlackLotus, ESPecter, and the TrickBoot module each end their install path with this primitive.
Detection opportunities
**Highest-fidelity BCD signal in the family.** Any modification to `BootOrder` that promotes a non-Microsoft, non-OEM-recovery entry to slot 0 is essentially diagnostic of a bootkit attempt. Monitor: ETW Microsoft-Windows-Kernel-Boot order-change events, Sysmon registry events on BCD writes, and the EFI `BootOrder` variable through a periodic CHIPSEC or Eclypsium scan. Defenders should also enroll endpoints in **Measured Boot + remote attestation** — PCR[4] (boot manager image hash) and PCR[7] (Secure Boot policy + signature DB hash) measurements diverge from the expected baseline on the very first compromised boot, before the user is even logged in.
Direct syscall examples
asmx64 direct stub (Win11 24H2, SSN 0x196)
NtSetBootEntryOrder PROC
mov r10, rcx ; PULONG Ids
mov eax, 0196h ; Win11 24H2
syscall
ret
NtSetBootEntryOrder ENDPcPromote attacker ID to slot 0 (PoC)
// PoC: read order, move our_id to the front, write back.
extern NTSTATUS NTAPI NtQueryBootEntryOrder(PULONG, PULONG);
extern NTSTATUS NTAPI NtSetBootEntryOrder(PULONG, ULONG);
NTSTATUS promote(ULONG our_id) {
ULONG count = 0;
NtQueryBootEntryOrder(NULL, &count);
PULONG ids = (PULONG)HeapAlloc(GetProcessHeap(), 0, count * sizeof(ULONG));
NtQueryBootEntryOrder(ids, &count);
// find our_id, swap to front
for (ULONG i = 0; i < count; ++i) {
if (ids[i] == our_id) {
memmove(&ids[1], &ids[0], i * sizeof(ULONG));
ids[0] = our_id;
break;
}
}
NTSTATUS s = NtSetBootEntryOrder(ids, count);
HeapFree(GetProcessHeap(), 0, ids);
return s;
}rustNaked stub
use std::arch::asm;
#[unsafe(naked)]
unsafe extern "system" fn nt_set_boot_entry_order(_ids: *const u32, _count: u32) -> i32 {
asm!(
"mov r10, rcx",
"mov eax, 0x196", // Win11 24H2
"syscall",
"ret",
options(noreturn),
);
}MITRE ATT&CK mappings
Last verified: 2026-05-20