NtDeleteValueKey
Removes a single named value from an open registry key, leaving the key itself intact.
Prototype
NTSTATUS NtDeleteValueKey( HANDLE KeyHandle, PUNICODE_STRING ValueName );
Arguments
| Name | Type | Dir | Description |
|---|---|---|---|
| KeyHandle | HANDLE | in | Handle to an open key, opened with KEY_SET_VALUE access. |
| ValueName | PUNICODE_STRING | in | Name of the value to delete. An empty UNICODE_STRING deletes the unnamed (default) value. |
Syscall IDs by Windows version
| Windows version | Syscall ID | Build |
|---|---|---|
| Win10 1507 | 0xC8 | win10-1507 |
| Win10 1607 | 0xCB | win10-1607 |
| Win10 1703 | 0xCE | win10-1703 |
| Win10 1709 | 0xCF | win10-1709 |
| Win10 1803 | 0xD0 | win10-1803 |
| Win10 1809 | 0xD1 | win10-1809 |
| Win10 1903 | 0xD2 | win10-1903 |
| Win10 1909 | 0xD2 | win10-1909 |
| Win10 2004 | 0xD6 | win10-2004 |
| Win10 20H2 | 0xD6 | win10-20h2 |
| Win10 21H1 | 0xD6 | win10-21h1 |
| Win10 21H2 | 0xD7 | win10-21h2 |
| Win10 22H2 | 0xD7 | win10-22h2 |
| Win11 21H2 | 0xDC | win11-21h2 |
| Win11 22H2 | 0xDD | win11-22h2 |
| Win11 23H2 | 0xDD | win11-23h2 |
| Win11 24H2 | 0xDF | win11-24h2 |
| Server 2016 | 0xCB | winserver-2016 |
| Server 2019 | 0xD1 | winserver-2019 |
| Server 2022 | 0xDB | winserver-2022 |
| Server 2025 | 0xDF | winserver-2025 |
Kernel module
Related APIs
Syscall stub
4C 8B D1 mov r10, rcx B8 DF 00 00 00 mov eax, 0xDF 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
Removes a single value cell from the parent key's value list. The kernel deletes the corresponding CM_KEY_VALUE and frees the value's data cell — there is no soft-delete or recycle. Returns STATUS_OBJECT_NAME_NOT_FOUND if no value with the name exists, which means probing for a value's presence by trying to delete it is *not* safe (it really deletes). The Win32 wrapper RegDeleteValueW is a thin shim.
Common malware usage
Anti-forensics and *selective* persistence cleanup. Where an operator's Run value sits next to ten legitimate Run values, deleting the whole `Run` key would be obvious; NtDeleteValueKey lets the implant remove only its own value during graceful uninstall or when an EDR detection has fired and the operator wants to limit the trail. Also used to revert configuration tampering — e.g. delete a persistence value just before the SOC analyst's triage script runs and re-create it afterwards from a memory-resident copy.
Detection opportunities
High-fidelity when the target is a *known persistence path*: Sysmon Event 12 (RegistryEvent DeleteValue) on `HKLM\Software\Microsoft\Windows\CurrentVersion\Run\*`, `RunOnce`, `Image File Execution Options`, or any `HKLM\SYSTEM\CurrentControlSet\Services\<X>\ImagePath` is anomalous outside of Group Policy / SCCM contexts. ETW Microsoft-Windows-Kernel-Registry emits DeleteValue with both the parent key path and the value name. EDRs hook CmRegisterCallbackEx → RegNtPreDeleteValueKey for cheap visibility. A delete-then-recreate pair (Event 12 followed by Event 13 with the same value name) within seconds is a near-canonical persistence-cleanup pattern.
Direct syscall examples
cSelective Run-value cleanup
// Delete only our value, leaving the host's other Run entries untouched.
UNICODE_STRING valueName;
RtlInitUnicodeString(&valueName, L"OneDriveUpdate");
NTSTATUS st = NtDeleteValueKey(hRunKey, &valueName);
if (st == STATUS_OBJECT_NAME_NOT_FOUND) {
// Already gone; nothing to clean.
}asmx64 direct stub (Win11 24H2 SSN 0xDF)
NtDeleteValueKey PROC
mov r10, rcx
mov eax, 0DFh
syscall
ret
NtDeleteValueKey ENDPrustTear-down on shutdown signal
// Cargo: ntapi = "0.4", widestring = "1"
fn cleanup_persistence(h_run_key: HANDLE) {
for name in ["OneDriveUpdate", "WinStoreHelper"] {
let w = U16CString::from_str(name).unwrap();
let mut us = UNICODE_STRING {
Length: (w.len() * 2) as u16,
MaximumLength: ((w.len() + 1) * 2) as u16,
Buffer: w.as_ptr() as _,
};
unsafe { NtDeleteValueKey(h_run_key, &mut us); }
}
}MITRE ATT&CK mappings
Last verified: 2026-05-20