NtQueryInformationByName
Fragt Dateiinformationen per Pfad ohne offenes Handle ab, eingeführt in Windows 10 RS5.
Prototyp
NTSTATUS NtQueryInformationByName( POBJECT_ATTRIBUTES ObjectAttributes, PIO_STATUS_BLOCK IoStatusBlock, PVOID FileInformation, ULONG Length, FILE_INFORMATION_CLASS FileInformationClass );
Argumente
| Name | Type | Dir | Description |
|---|---|---|---|
| ObjectAttributes | POBJECT_ATTRIBUTES | in | Objektattribute, die den Dateipfad beschreiben. ObjectName ist der NT-Pfad. |
| IoStatusBlock | PIO_STATUS_BLOCK | out | Empfängt den Endstatus und die Anzahl der in FileInformation geschriebenen Bytes. |
| FileInformation | PVOID | out | Aufrufer-Buffer, der die angeforderte Informationsklasse aufnimmt. |
| Length | ULONG | in | Größe von FileInformation in Bytes. |
| FileInformationClass | FILE_INFORMATION_CLASS | in | Klasse, die die zurückzugebende Information identifiziert (z. B. FileStatInformation, FileStatBasicInformation). |
Syscall-IDs pro Windows-Version
| Windows-Version | Syscall-ID | Build |
|---|---|---|
| Win10 1703 | 0x13B | win10-1703 |
| Win10 1709 | 0x13E | win10-1709 |
| Win10 1803 | 0x140 | win10-1803 |
| Win10 1809 | 0x141 | win10-1809 |
| Win10 1903 | 0x142 | win10-1903 |
| Win10 1909 | 0x142 | win10-1909 |
| Win10 2004 | 0x148 | win10-2004 |
| Win10 20H2 | 0x148 | win10-20h2 |
| Win10 21H1 | 0x148 | win10-21h1 |
| Win10 21H2 | 0x149 | win10-21h2 |
| Win10 22H2 | 0x149 | win10-22h2 |
| Win11 21H2 | 0x14F | win11-21h2 |
| Win11 22H2 | 0x151 | win11-22h2 |
| Win11 23H2 | 0x151 | win11-23h2 |
| Win11 24H2 | 0x153 | win11-24h2 |
| Server 2019 | 0x141 | winserver-2019 |
| Server 2022 | 0x14E | winserver-2022 |
| Server 2025 | 0x153 | winserver-2025 |
Kernel-Modul
Verwandte APIs
Syscall-Stub
4C 8B D1 mov r10, rcx B8 53 01 00 00 mov eax, 0x153 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
In Windows 10 1709 eingeführt (offiziell dokumentierte Nutzung ab RS5/1803), faltet NtQueryInformationByName das alte Tripel `NtCreateFile → NtQueryInformationFile → NtClose` zu einem einzigen Syscall, wenn der Aufrufer nur Metadaten braucht. Intern muss der Kernel weiterhin den Filesystem-Stack des Elternverzeichnisses durchlaufen und ein transientes FILE_OBJECT akquirieren, installiert aber nie ein Handle in der Handle-Tabelle des Aufrufers — was weniger laute Sysmon-Event-ID-11/15-Events und keinerlei Handle-Tabellen-Churn bedeutet. Nur eine Handvoll `FILE_INFORMATION_CLASS`-Werte werden akzeptiert (FileStatInformation, FileStatBasicInformation, FileStatLxInformation, FileCaseSensitiveInformation, FileStorageReserveIdInformation).
Häufige Malware-Nutzung
Wird von Scannern, Environment-Keying-Loadern und EDR-bewussten Staged-Payload-Droppern verwendet, um die Existenz von Marker-Dateien zu prüfen (z. B. Beleg für einen bestimmten EDR-Build auf der Platte oder eine Opfer-Fingerprint-Datei), ohne eine Open-Handle-Telemetriespur zu hinterlassen. Da kein Handle erzeugt wird, sehen Filesystem-Minifilter, die auf `IRP_MJ_CREATE` aufsetzen, die Öffnung als transient und flüchtig; User-Mode-Hooks auf `NtCreateFile`/`NtOpenFile` werden komplett umgangen — der Syscall-Pfad ist direkt `NtQueryInformationByName`. Das Signal ist schwächer als NtCreateFile-basierte Aufklärung, was genau der Punkt ist. Einige Commodity-Scanner (Profiler im CCleaner-Stil, aber auch jüngere Infostealer) sind auf diese API umgezogen, um Open-File-Rauschen zu reduzieren.
Erkennungsmöglichkeiten
Filesystem-Minifilter sehen weiterhin das transiente IRP_MJ_CREATE — Sysmon-File-Events mit `IncludeTransientHandles=true` (relativ neue Option) bringen sie zutage. ETW-Microsoft-Windows-Kernel-File-`Create`-Events feuern mit gesetztem `TransitionTrace`-Flag, das die By-Name-Abfrage von einem gehaltenen-Handle-Open unterscheidet. Hunting auf `NtQueryInformationByName`-Aufrufe gegen `*.exe`, `*.dll` oder spezifische EDR-Installationspfade aus einem Nicht-Systemprozess ist ein stärkeres Anomalie-Signal als der Syscall selbst. Sysmon Event ID 11 (FileCreate) und Event ID 15 (FileCreateStreamHash) feuern *nicht* — diese Abwesenheit, gekoppelt mit dateiexistenz-bedingtem Verhalten, ist die Erkennung.
Direkte Syscall-Beispiele
cCheck for EDR install marker without opening a handle
// Probe for the presence of an EDR DLL on disk using the new RS5+ syscall.
#include <windows.h>
#include <winternl.h>
typedef struct _FILE_STAT_BASIC_INFORMATION {
LARGE_INTEGER FileId;
LARGE_INTEGER CreationTime;
LARGE_INTEGER LastAccessTime;
LARGE_INTEGER LastWriteTime;
LARGE_INTEGER ChangeTime;
LARGE_INTEGER AllocationSize;
LARGE_INTEGER EndOfFile;
ULONG FileAttributes;
ULONG ReparseTag;
ULONG NumberOfLinks;
ULONG DeviceType;
ULONG DeviceCharacteristics;
ULONG Reserved;
LARGE_INTEGER VolumeSerialNumber;
FILE_ID_128 FileId128;
} FILE_STAT_BASIC_INFORMATION;
typedef NTSTATUS (NTAPI *PNTQUERYINFORMATIONBYNAME)(
POBJECT_ATTRIBUTES, PIO_STATUS_BLOCK, PVOID, ULONG, ULONG);
BOOL FileExistsQuietly(LPCWSTR ntPath) {
UNICODE_STRING us;
RtlInitUnicodeString(&us, ntPath);
OBJECT_ATTRIBUTES oa;
InitializeObjectAttributes(&oa, &us, OBJ_CASE_INSENSITIVE, NULL, NULL);
FILE_STAT_BASIC_INFORMATION info;
IO_STATUS_BLOCK iosb;
PNTQUERYINFORMATIONBYNAME f = (PNTQUERYINFORMATIONBYNAME)GetProcAddress(
GetModuleHandleA("ntdll.dll"), "NtQueryInformationByName");
return f && f(&oa, &iosb, &info, sizeof(info), 75 /* FileStatBasicInformation */) == 0;
}asmx64 direct stub (Win11 24H2, SSN 0x153)
NtQueryInformationByName PROC
mov r10, rcx
mov eax, 153h
syscall
ret
NtQueryInformationByName ENDPMITRE ATT&CK-Mappings
Last verified: 2026-05-20