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
| Name | Type | Dir | Description |
|---|---|---|---|
| DriverEntry | PEFI_DRIVER_ENTRY | in | Pointer 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 version | Syscall ID | Build |
|---|---|---|
| Win10 1507 | 0x103 | win10-1507 |
| Win10 1607 | 0x108 | win10-1607 |
| Win10 1703 | 0x10C | win10-1703 |
| Win10 1709 | 0x10D | win10-1709 |
| Win10 1803 | 0x10F | win10-1803 |
| Win10 1809 | 0x110 | win10-1809 |
| Win10 1903 | 0x111 | win10-1903 |
| Win10 1909 | 0x111 | win10-1909 |
| Win10 2004 | 0x116 | win10-2004 |
| Win10 20H2 | 0x116 | win10-20h2 |
| Win10 21H1 | 0x116 | win10-21h1 |
| Win10 21H2 | 0x117 | win10-21h2 |
| Win10 22H2 | 0x117 | win10-22h2 |
| Win11 21H2 | 0x11D | win11-21h2 |
| Win11 22H2 | 0x11E | win11-22h2 |
| Win11 23H2 | 0x11E | win11-23h2 |
| Win11 24H2 | 0x120 | win11-24h2 |
| Server 2016 | 0x108 | winserver-2016 |
| Server 2019 | 0x110 | winserver-2019 |
| Server 2022 | 0x11C | winserver-2022 |
| Server 2025 | 0x120 | winserver-2025 |
Kernel module
Related APIs
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 ENDPcRedirect 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