Hello @Starlin Concepcion , and thank you for reaching out.
Based on the published Windows API documentation, here is what I can clarify regarding your questions, along with areas where further clarification may be needed.
1. RootDirectory and relative creation
Assuming NtCreateFile is called with a relative ObjectName and a RootDirectory handle:
- The
RootDirectoryhandle must refer to an existing directory, andObjectNamemust specify a path relative to that directory. For FILE_CREATE, the target file must not already exist, although any intermediate directories in the relative path must exist. - Documentation doesn't specify explicitly whether the handle must be opened through
NtCreateFileor not. - FILE_ADD_FILE is the documented directory access right associated with creating files within a directory. However, the documentation does not explicitly establish whether this right must be granted to the
RootDirectoryhandle for relative creation throughNtCreateFile. - Concerning the handle's sharing mode or lifetime, normal Windows file-sharing rules apply, and the directory handle must remain valid while it is being used. Other than that, the documentation does not identify additional sharing or lifetime requirements specific to relative creation.
2. OBJ_DONT_REPARSE
Although OBJ_DONT_REPARSE is described in the general OBJECT_ATTRIBUTES documentation, the NtCreateFile documentation lists a narrower set of supported flags.
The general documentation specifies STATUS_REPARSE_POINT_ENCOUNTERED when a reparse point is encountered. However, I cannot confirm from these references whether NtCreateFile supports this flag with the requested guarantees, including its precise scope during relative-path resolution and any Windows-version or file-system-specific limitations.
3. FILE_DIRECTORY_FILE and FILE_OPEN_REPARSE_POINT
After reviewing the relevant documentation, I could not establish whether this combination is officially supported by NtCreateFile, as FILE_OPEN_REPARSE_POINT is not included among the listed compatible options for FILE_DIRECTORY_FILE.
For the second and third questions, CreateFileW provides a documented way to open a directory reparse point itself using FILE_FLAG_OPEN_REPARSE_POINT together with FILE_FLAG_BACKUP_SEMANTICS. The reparse-point data can then be inspected separately. However, this does not prevent reparse-point processing for intermediate path components.
4. Exclusive creation
When FILE_CREATE is used with a directory-relative name, the following distinctions are relevant:
- FILE_CREATE provides exclusive creation semantics. If the specified name already exists, the operation fails with STATUS_OBJECT_NAME_COLLISION. This provides create-only-if-absent behavior, although the documentation does not explicitly establish broader atomicity guarantees across all file systems and concurrent operations.
- This guarantee concerns the file creation operation itself. It does not independently guarantee that the parent directory has remained unchanged since validation or that every component involved in path resolution retains its original identity.
- If
NtCreateFilecompletes with a failure status such as STATUS_OBJECT_NAME_COLLISION (the name already exists), STATUS_OBJECT_PATH_NOT_FOUND (part of the path was not found), or STATUS_ACCESS_DENIED (access was denied), the creation attempt has failed. However, if the final completion status is unavailable, the caller cannot determine from that information alone whether the file was created. An initial STATUS_PENDING indicates that the operation has not yet completed, rather than that it has failed.
As Microsoft Q&A is a community support forum, I cannot provide authoritative confirmation of undocumented API behavior or guarantees. If you need an authoritative clarification of the API contract, I recommend opening a case with Microsoft Support for Business. If you do not have a business support plan, you can contact Microsoft Support instead.
If you found my response helpful or informative, I would greatly appreciate it if you could follow this guide for your confirmation. Thank you.