> Windows Syscalls
ntoskrnl.exeT1542.001T1014T1542.003

NtModifyDriverEntry

Overwrites an existing EFI_DRIVER_ENTRY identified by its ID, rewriting the UEFI Driver#### NVRAM variable in place.

Prototype

NTSTATUS NtModifyDriverEntry(
  PEFI_DRIVER_ENTRY DriverEntry
);

Arguments

NameTypeDirDescription
DriverEntryPEFI_DRIVER_ENTRYinPointer to an EFI_DRIVER_ENTRY whose `Id` field selects the existing entry to overwrite; the remainder of the structure replaces the current contents.

Syscall IDs by Windows version

Windows versionSyscall IDBuild
Win10 15070x103win10-1507
Win10 16070x108win10-1607
Win10 17030x10Cwin10-1703
Win10 17090x10Dwin10-1709
Win10 18030x10Fwin10-1803
Win10 18090x110win10-1809
Win10 19030x111win10-1903
Win10 19090x111win10-1909
Win10 20040x116win10-2004
Win10 20H20x116win10-20h2
Win10 21H10x116win10-21h1
Win10 21H20x117win10-21h2
Win10 22H20x117win10-22h2
Win11 21H20x11Dwin11-21h2
Win11 22H20x11Ewin11-22h2
Win11 23H20x11Ewin11-23h2
Win11 24H20x120win11-24h2
Server 20160x108winserver-2016
Server 20190x110winserver-2019
Server 20220x11Cwinserver-2022
Server 20250x120winserver-2025

Kernel module

ntoskrnl.exeNtModifyDriverEntry

Related APIs

SetFirmwareEnvironmentVariableW (Driver####)BcdSetElementData (Driver Entry GUID)NtAddDriverEntryNtDeleteDriverEntryNtEnumerateDriverEntries

Syscall stub

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

Mirror of NtModifyBootEntry but for the UEFI `Driver####` namespace. The ID is the primary key inside the EFI_DRIVER_ENTRY; the kernel resolves it, locates the corresponding firmware variable, and rewrites it in a single atomic SetVariable call. SeSystemEnvironmentPrivilege is mandatory.

Common malware usage

Used when a legitimate OEM diagnostics or firmware-update DXE driver already exists in `DriverOrder`. Rather than registering a new (suspicious) entry, malware patches the `DriverFilePath` of the existing entry to point at an attacker-controlled `.efi` binary on the ESP, inheriting the OEM's slot in DriverOrder and its plausible FriendlyName. This is one of the techniques documented in the LoJax / MosaicRegressor analyses where APT28 leveraged the firmware's existing infrastructure rather than carving a new entry. Defenders looking only for unknown DRIVER_ENTRY *additions* miss the mutation.

Detection opportunities

Both modification and addition surface on ETW Microsoft-Windows-Kernel-Boot. The diagnostic signal here is **file-content drift**: the registered `Driver####` paths can be enumerated and hashed; a change in the on-disk hash of a previously-known DXE binary (without a corresponding signed firmware update from the OEM) is high-confidence evidence of `DriverFilePath` hijack. Eclypsium, CHIPSEC and Binarly's tooling all baseline DXE driver hashes; Microsoft Defender for Endpoint surfaces UEFI driver telemetry under "Boot driver and firmware" reports.

Direct syscall examples

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

NtModifyDriverEntry PROC
    mov  r10, rcx          ; PEFI_DRIVER_ENTRY (Id inside struct)
    mov  eax, 0120h        ; Win11 24H2
    syscall
    ret
NtModifyDriverEntry ENDP

cRedirect an OEM driver entry to a rogue ESP path

// Defensive analysis: shows the shape of what LoJax-style attackers do.
NTSTATUS hijack_driver(ULONG id, const wchar_t* shim) {
    BYTE buf[1024] = {0};
    PEFI_DRIVER_ENTRY de = (PEFI_DRIVER_ENTRY)buf;
    de->Version = 1;
    de->Length  = sizeof(buf);
    de->Id      = id;                  // existing OEM diagnostic driver
    de->Attributes = LOAD_OPTION_ACTIVE;
    de->BootFilePathOffset = FIELD_OFFSET(EFI_DRIVER_ENTRY, OsOptions);
    // populate FILE_PATH(shim) into buf[BootFilePathOffset..] (omitted)
    return NtModifyDriverEntry(de);
}

rustNaked stub

use std::arch::asm;

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

MITRE ATT&CK mappings

Last verified: 2026-05-20