KsWriteFile function (ks.h)

The KsWriteFile function performs a write against the specified file object. It is assumed that the caller is serializing access to the file for operations against a FO_SYNCHRONOUS_IO file object. The function attempts to use FastIoDispatch if possible, or it generates a write request against the device object. All relevant statistics are updated.

Syntax

KSDDKAPI NTSTATUS KsWriteFile(
  [in]           PFILE_OBJECT     FileObject,
  [in, optional] PKEVENT          Event,
  [in, optional] PVOID            PortContext,
  [out]          PIO_STATUS_BLOCK IoStatusBlock,
  [in]           PVOID            Buffer,
  [in]           ULONG            Length,
  [in, optional] ULONG            Key,
  [in]           KPROCESSOR_MODE  RequestorMode
);

Parameters

[in] FileObject

Specifies the file object to perform the read against.

[in, optional] Event

Optionally contains the event to use in the write. If no event is passed, the call is assumed to be on a synchronous file object or the caller is waiting for the file object's event. If the call is not on a synchronous file object, it can be asynchronously completed. If the file has been opened for synchronous I/O, this variable must be NULL. If this variable is used, it must be an event allocated by the object manager.

[in, optional] PortContext

Optionally contains context information for a completion port.

[out] IoStatusBlock

Indicates the location in which to return the status information. This is always assumed to be a valid address, regardless of the requester mode.

[in] Buffer

Specifies the buffer from which to write the data. If the buffer needs to be probed and locked, an exception handler is used, along with RequesterMode.

[in] Length

Specifies the size of the buffer passed.

[in, optional] Key

Optionally contains a key, or zero if none.

[in] RequestorMode

Indicates the processor mode to place in the read IRP if one needs to be generated. Additionally, it is used if a buffer needs to be probed and locked. This variable also determines if a fast I/O call can be performed. If the requester mode is not KernelMode, but the previous mode was, then fast I/O cannot be used.

Return value

The KsWriteFile function returns STATUS_SUCCESS if successful, STATUS_PENDING if action is pending, or it returns a read error if unsuccessful.

Requirements

Requirement Value
Target Platform Universal
Header ks.h (include Ks.h)
Library Ks.lib