> Windows Syscalls
ntoskrnl.exeT1542.001T1542.003T1547

NtSetDriverEntryOrder

Rewrites the platform's UEFI DriverOrder list, controlling which UEFI drivers load first at boot.

Prototype

NTSTATUS NtSetDriverEntryOrder(
  PULONG Ids,
  ULONG  Count
);

Arguments

NameTypeDirDescription
IdsPULONGinArray of Driver#### IDs in the desired new load order.
CountULONGinNumber of entries in the Ids array.

Syscall IDs by Windows version

Windows versionSyscall IDBuild
Win10 15070x174win10-1507
Win10 16070x17Dwin10-1607
Win10 17030x183win10-1703
Win10 17090x186win10-1709
Win10 18030x188win10-1803
Win10 18090x189win10-1809
Win10 19030x18Awin10-1903
Win10 19090x18Awin10-1909
Win10 20040x190win10-2004
Win10 20H20x190win10-20h2
Win10 21H10x190win10-21h1
Win10 21H20x192win10-21h2
Win10 22H20x192win10-22h2
Win11 21H20x19Awin11-21h2
Win11 22H20x19Dwin11-22h2
Win11 23H20x19Dwin11-23h2
Win11 24H20x19Fwin11-24h2
Server 20160x17Dwinserver-2016
Server 20190x189winserver-2019
Server 20220x198winserver-2022
Server 20250x19Fwinserver-2025

Kernel module

ntoskrnl.exeNtSetDriverEntryOrder

Related APIs

NtQueryDriverEntryOrderNtAddDriverEntryNtModifyDriverEntryNtDeleteDriverEntryNtEnumerateDriverEntriesbcdedit /set {fwbootmgr} displayorder

Syscall stub

4C 8B D1            mov r10, rcx
B8 9F 01 00 00      mov eax, 0x19F
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

Write counterpart to NtQueryDriverEntryOrder. Together with NtAddDriverEntry / NtModifyDriverEntry / NtDeleteDriverEntry it forms the full programmatic surface for the UEFI DriverOrder NVRAM variable. Requires SeSystemEnvironmentPrivilege. On modern UEFI hardware with Secure Boot enforcing, planting a malicious Driver#### entry that the firmware will actually execute still requires the EFI binary itself to be signed by a key in db — so this syscall is necessary but not sufficient for firmware persistence. STATUS_NOT_IMPLEMENTED on legacy BIOS / CSM-only systems.

Common malware usage

Persistence-promotion step for UEFI-aware threats: after planting a Driver#### entry (via NtAddDriverEntry) the attacker calls NtSetDriverEntryOrder to ensure their entry runs *before* the trusted OS-loader handoff, giving a malicious UEFI driver the chance to hook critical EFI boot services (LoadImage, StartImage, ExitBootServices) and survive into kernel context. BlackLotus's chain conceptually relies on this kind of ordering manipulation, though its primary persistence used a separate `revocations.efi`/MOK pathway. CosmicStrand modified firmware boot order at the chip level rather than via this syscall; the syscall path is more typical of supply-chain implants distributed through OEM update tooling.

Detection opportunities

Any successful call is high-fidelity. Microsoft-Windows-Kernel-General ETW fires firmware-write events. Compare DriverOrder before/after via baseline snapshots — Microsoft Defender for Endpoint Boot Integrity dashboards alert on changes. The privilege-enable trace (SeSystemEnvironmentPrivilege) is the cheapest defensive checkpoint. Windows 11 24H2 / Server 2025's System Guard Secure Launch detects unexpected DriverOrder changes via the measured-boot log and reports through Microsoft-Windows-Kernel-Boot.

Direct syscall examples

asmx64 direct stub (Win11 24H2)

; Direct syscall stub for NtSetDriverEntryOrder (SSN 0x19F, Win11 24H2)
NtSetDriverEntryOrder PROC
    mov  r10, rcx
    mov  eax, 19Fh
    syscall
    ret
NtSetDriverEntryOrder ENDP

cPromote a freshly-added driver entry to first slot

// Educational. Real bootkits still need a signed (or signature-bypass) EFI binary.
// 1. attacker added Driver1234 via NtAddDriverEntry pointing at \EFI\evil.efi
// 2. query current order, prepend 0x1234, write it back.
BOOLEAN was;
RtlAdjustPrivilege(SE_SYSTEM_ENVIRONMENT_PRIVILEGE, TRUE, FALSE, &was);

ULONG existing[32];
ULONG count = ARRAYSIZE(existing);
if (!NT_SUCCESS(NtQueryDriverEntryOrder(existing, &count))) return -1;

ULONG reordered[33] = { 0x1234 };
RtlCopyMemory(&reordered[1], existing, count * sizeof(ULONG));

NTSTATUS s = NtSetDriverEntryOrder(reordered, count + 1);

MITRE ATT&CK mappings

Last verified: 2026-05-20