#ifndef _NTIOAPI_H
/**
* The NtWriteFile function writes data to an open file.
*
* \param[in] FileHandle A handle to the file object representing the file or directory on which the specified action is to be performed.
* \param[in] Event A handle for a caller-created event. This parameter is optional and can be NULL. It must be NULL if the caller will wait for the FileHandle to be set to the Signaled state.
* \param[in] ApcRoutine Address of a caller-supplied APC routine to be called when the requested operation completes. This parameter is optional and can be NULL.
* \param[in] ApcContext Pointer to a caller-determined context area. This parameter value is used as the APC context if the caller supplies an APC, or is used as the completion context if an I/O completion object has been associated with the file object.
* \param[out] IoStatusBlock Pointer to an IO_STATUS_BLOCK structure that receives the final completion status and information about the operation.
* \param[in] Buffer Pointer to a caller-allocated buffer that contains the data to write to the file.
* \param[in] Length The size, in bytes, of the buffer pointed to by Buffer.
* \param[in] ByteOffset Pointer to a variable that specifies the starting byte offset in the file for beginning the write operation.
* \param[in] Key Device and intermediate drivers should set this pointer to NULL.
* \return NTSTATUS Successful or errant status.
* \sa https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-zwwritefile
*/
NTSYSCALLAPI
NTSTATUS
NTAPI
NtWriteFile(
_In_ HANDLE FileHandle,
_In_opt_ HANDLE Event,
_In_opt_ PIO_APC_ROUTINE ApcRoutine,
_In_opt_ PVOID ApcContext,
_Out_ PIO_STATUS_BLOCK IoStatusBlock,
_In_reads_bytes_(Length) PVOID Buffer,
_In_ ULONG Length,
_In_opt_ PLARGE_INTEGER ByteOffset,
_In_opt_ PULONG Key
);
View code on GitHub
#ifndef _NTZWAPI_H
NTSYSCALLAPI
NTSTATUS
NTAPI
ZwWriteFile(
_In_ HANDLE FileHandle,
_In_opt_ HANDLE Event,
_In_opt_ PIO_APC_ROUTINE ApcRoutine,
_In_opt_ PVOID ApcContext,
_Out_ PIO_STATUS_BLOCK IoStatusBlock,
_In_reads_bytes_(Length) PVOID Buffer,
_In_ ULONG Length,
_In_opt_ PLARGE_INTEGER ByteOffset,
_In_opt_ PULONG Key
);
View code on GitHub
This function is documented in Windows Driver Kit here and here.
(Also described in Win 2000 DDK)
HANDLE
to File Object opened with FILE_WRITE_DATA
access.
HANDLE
to Event Object signaled when write finished.
User APC routine executed after writing is complete.
Parameter to ApcRoutine
.
IO result of call.
Buffer with data to write.
Length of Buffer
, in bytes.
Offset from beginning of file, where write starts.
??? (See NtReadFile
).
WriteFile
(Although it does more than just forwarding the arguments and invoking this procedure.)