Windows Kernel File System API Reference

Comprehensive documentation for the Windows Kernel's file system interface.

File System API Reference

The Windows Kernel File System (NTFS, FAT, etc.) APIs provide the core mechanisms for applications and drivers to interact with the underlying file system structures. This section details the functions, structures, and concepts essential for file system operations within the Windows kernel.

Core Concepts

Understanding the following concepts is crucial for effective use of the file system APIs:

Key API Functions

Here are some of the most frequently used API functions for file system operations:

Function Name Description Parameters Return Value
ZwCreateFile Creates a new file or opens an existing one. PUNICODE_STRING FileName
PHANDLE FileHandle
ACCESS_MASK DesiredAccess
POBJECT_ATTRIBUTES ObjectAttributes
PIO_STATUS_BLOCK IoStatusBlock
PLARGE_INTEGER AllocationSize
ULONG FileAttributes
ULONG ShareAccess
ULONG CreateDisposition
ULONG CreateOptions
PVOID EaBuffer
ULONG EaLength
NTSTATUS
ZwReadFile Reads data from a file. HANDLE FileHandle
PVOID Buffer
ULONG Length
PLARGE_INTEGER ByteOffset
PULONG Key
NTSTATUS
ZwWriteFile Writes data to a file. HANDLE FileHandle
PVOID Buffer
ULONG Length
PLARGE_INTEGER ByteOffset
PULONG Key
NTSTATUS
ZwQueryInformationFile Retrieves information about a file. HANDLE FileHandle
PIO_STATUS_BLOCK IoStatusBlock
PVOID FileInformation
ULONG Length
FILE_INFORMATION_CLASS FileInformationClass
NTSTATUS
ZwClose Closes a handle to an object. HANDLE Handle NTSTATUS
IoCreateFile Creates or opens a file object. (Driver specific) PDEVICE_OBJECT DeviceObject
PIRP Irp
PUNICODE_STRING FileName
ACCESS_MASK DesiredAccess
ULONG FileAttributes
ULONG ShareAccess
ULONG CreateDisposition
ULONG CreateOptions
NTSTATUS

File System Structures

Common structures used in file system operations:

Note on Driver Development

When developing file system filter drivers or mini-filter drivers, you will extensively use IRPs and the FSRTL library. The Zw* (Native API) functions are typically used by user-mode applications and kernel-mode components that directly interact with the executive, while drivers often work with IRPs directly or through higher-level driver framework APIs.

Further Reading