IoReplaceFileObjectName function (ntifs.h)

The IoReplaceFileObjectName routine replaces the name of a file object.


NTSTATUS IoReplaceFileObjectName(
  [in] PFILE_OBJECT FileObject,
  [in] PWSTR        NewFileName,
  [in] USHORT       FileNameLength


[in] FileObject

Pointer to the file object whose file name is being replaced.

[in] NewFileName

Pointer to the string buffer for the new name for the file object.

[in] FileNameLength

Length, in bytes, of the new name for the file object.

Return value

Returns STATUS_SUCCESS or one of the following NTSTATUS values otherwise:

Return code Description
Indicates that the file object provided does not have a name to replace.
Indicates that inadequate memory is available to allocate a buffer to complete this operation.


Drivers should use IoReplaceFileObjectName to safely replace the name in a file object. This allows the I/O manager to control the lifetime of the buffer associated with the file object. Replacing a file object name directly without using IoReplaceFileObjectName may conflict with other uses of the name and should be avoided when possible.

This routine should be used to replace the file object name instead of doing so manually to allow the kernel to manage the lifetime of the name correctly.


Minimum supported client Available starting with Windows 7.
Target Platform Universal
Header ntifs.h (include Ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe