> Windows Syscalls
ntoskrnl.exeT1486T1070.004T1485

NtSetInformationFile

Sets file metadata via FILE_INFORMATION_CLASS — rename, dispose (delete), allocate, end-of-file, etc.

Prototype

NTSTATUS NtSetInformationFile(
  HANDLE                 FileHandle,
  PIO_STATUS_BLOCK       IoStatusBlock,
  PVOID                  FileInformation,
  ULONG                  Length,
  FILE_INFORMATION_CLASS FileInformationClass
);

Arguments

NameTypeDirDescription
FileHandleHANDLEinOpen handle. Required access depends on FileInformationClass (DELETE for dispose/rename).
IoStatusBlockPIO_STATUS_BLOCKoutReceives the operation status and class-specific Information value.
FileInformationPVOIDinBuffer matching the requested class (e.g. FILE_RENAME_INFORMATION, FILE_DISPOSITION_INFORMATION_EX).
LengthULONGinSize in bytes of the FileInformation buffer.
FileInformationClassFILE_INFORMATION_CLASSinEnum selecting the operation, e.g. FileRenameInformation (10), FileDispositionInformation (13), FileDispositionInformationEx (64).

Syscall IDs by Windows version

Windows versionSyscall IDBuild
Win10 15070x27win10-1507
Win10 16070x27win10-1607
Win10 17030x27win10-1703
Win10 17090x27win10-1709
Win10 18030x27win10-1803
Win10 18090x27win10-1809
Win10 19030x27win10-1903
Win10 19090x27win10-1909
Win10 20040x27win10-2004
Win10 20H20x27win10-20h2
Win10 21H10x27win10-21h1
Win10 21H20x27win10-21h2
Win10 22H20x27win10-22h2
Win11 21H20x27win11-21h2
Win11 22H20x27win11-22h2
Win11 23H20x27win11-23h2
Win11 24H20x27win11-24h2
Server 20160x27winserver-2016
Server 20190x27winserver-2019
Server 20220x27winserver-2022
Server 20250x27winserver-2025

Kernel module

ntoskrnl.exeNtSetInformationFile

Related APIs

SetFileInformationByHandleMoveFileExWDeleteFileWNtQueryInformationFileNtCreateFile

Syscall stub

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

Stable at SSN `0x27` across every supported Windows build. The interesting power lies entirely in the `FILE_INFORMATION_CLASS` enum — over 70 classes, but four matter most operationally: `FileRenameInformation` / `FileRenameInformationEx` (move/rename, even atop locked names with FLAGS_POSIX_SEMANTICS on modern builds), `FileDispositionInformation` / `FileDispositionInformationEx` (mark for delete; the Ex variant added in Win10 RS1 supports `FILE_DISPOSITION_FORCE_PERMANENTLY_CHECK_ACCESS` and `FILE_DISPOSITION_POSIX_SEMANTICS` for unlink-while-open semantics), `FileAllocationInformation` (preallocate disk for fast ransomware writes), and `FileEndOfFileInformation` (truncate). Dispose/rename go through IRP_MJ_SET_INFORMATION and are seen by every minifilter in the stack.

Common malware usage

Two dominant abuses: (1) **ransomware extension swaps and atomic rename**. Encrypt a file in place, then `FileRenameInformation` to `<original>.locked` — works even when the file is opened by another process if `FILE_RENAME_POSIX_SEMANTICS` is set. (2) **Self-deletion that survives EDR holding the handle open**. Open the running EXE, call `NtSetInformationFile` with `FileRenameInformationEx` to a long alternate path, then `FileDispositionInformationEx` with `FILE_DISPOSITION_POSIX_SEMANTICS | FILE_DISPOSITION_DELETE` — the file unlinks immediately even though the handle is still in use, a technique documented by Jonas Lykkegaard / LloydLabs as `delete-self-poc`. Also used by wipers to truncate critical files to zero before final disposition.

LockBitContiRoyalBlackCat (ALPHV)PlayAkira

Detection opportunities

Sysmon Event ID 23 (FileDelete) and 26 (FileDeleteDetected — captures content of deleted files when archive store is enabled) detect dispose operations after the fact. Microsoft-Windows-Kernel-File ETW `SetInformation` event carries the FileInformationClass; filtering on classes 10, 13, 64, and 65 (FileRenameInformationEx) gives a focused signal. Mass renames in a short window with consistent new-extension patterns (`.locked`, `.encrypted`, random 5-char suffixes) is the classic ransomware indicator — most EDRs implement this as a minifilter heuristic since user-mode hooks miss direct syscalls. The self-delete technique specifically appears as a rename of a process's main image followed by FileDispositionInformationEx while the image section is still mapped — an extremely high-fidelity tell.

Direct syscall examples

cRansomware-style rename (`x.docx` -> `x.docx.locked`)

// FileRenameInformation == 10
typedef struct _FILE_RENAME_INFORMATION {
    BOOLEAN ReplaceIfExists;
    HANDLE  RootDirectory;
    ULONG   FileNameLength;
    WCHAR   FileName[1];
} FILE_RENAME_INFORMATION, *PFILE_RENAME_INFORMATION;

WCHAR newName[] = L"\\??\\C:\\Users\\v\\report.docx.locked";
SIZE_T nameLen = wcslen(newName) * sizeof(WCHAR);
SIZE_T size = FIELD_OFFSET(FILE_RENAME_INFORMATION, FileName) + nameLen;

PFILE_RENAME_INFORMATION info = LocalAlloc(LPTR, size);
info->ReplaceIfExists = TRUE;
info->RootDirectory   = NULL;
info->FileNameLength  = (ULONG)nameLen;
memcpy(info->FileName, newName, nameLen);

IO_STATUS_BLOCK iosb;
NtSetInformationFile(hFile, &iosb, info, (ULONG)size, FileRenameInformation);

cSelf-delete (POSIX semantics)

// LloydLabs delete-self-poc primitive.
// FileRenameInformationEx == 65, FileDispositionInformationEx == 64
typedef struct _FILE_DISPOSITION_INFORMATION_EX {
    ULONG Flags;
} FILE_DISPOSITION_INFORMATION_EX, *PFILE_DISPOSITION_INFORMATION_EX;

#define FILE_DISPOSITION_DELETE                       0x1
#define FILE_DISPOSITION_POSIX_SEMANTICS              0x2
#define FILE_DISPOSITION_FORCE_IMAGE_SECTION_CHECK    0x4
#define FILE_DISPOSITION_ON_CLOSE                     0x8

// 1) Open current image with DELETE | SYNCHRONIZE.
// 2) Rename to an ADS (`:wat`) via FileRenameInformationEx.
// 3) Re-open with DELETE access.
// 4) Mark for delete:
FILE_DISPOSITION_INFORMATION_EX d = {
    .Flags = FILE_DISPOSITION_DELETE | FILE_DISPOSITION_POSIX_SEMANTICS
};
IO_STATUS_BLOCK iosb;
NtSetInformationFile(hSelf, &iosb, &d, sizeof(d), FileDispositionInformationEx);

asmDirect stub (SSN 0x27)

NtSetInformationFile PROC
    mov  r10, rcx
    mov  eax, 27h
    syscall
    ret
NtSetInformationFile ENDP

MITRE ATT&CK mappings

Last verified: 2026-05-20