A held directory handle can documentably anchor a relative NtCreateFile lookup, but the published Windows API contract does not establish that the exact metadata-only profile also provides atomic reparse rejection and immutable-ancestor guarantees against concurrent namespace changes.
1. Metadata-only directory handle
NtCreateFile documents that when OBJECT_ATTRIBUTES.RootDirectory is non-null, ObjectName is interpreted relative to the directory represented by that handle. It does not require the directory to be reopened by pathname for each child.^1^
Your access and option combination is internally consistent in these respects:
-
FILE_READ_ATTRIBUTESpermits attribute queries. -
SYNCHRONIZEis required byFILE_SYNCHRONOUS_IO_NONALERT. -
FILE_OPEN_REPARSE_POINTsuppresses normal reparse processing for the object being opened and attempts to open that reparse-point object itself. - Omitting
FILE_DIRECTORY_FILEavoids its documented restricted compatibility list.
However, the documentation does not expressly certify that a directory opened type-neutrally with only FILE_READ_ATTRIBUTES | SYNCHRONIZE is sufficient for every subsequent relative lookup. It lists FILE_TRAVERSE as the directory right for including a directory in a pathname, but does not explicitly state whether RootDirectory use requires that right on the already-open handle.^1^
Traversal checks also depend on the caller’s token:
-
FILE_TRAVERSEandFILE_EXECUTEshare bit value0x20, so adding it to a type-neutral open has the ambiguity you identified.^2^ - Enabled
SeChangeNotifyPrivilegecauses traversal access checks to be skipped and is enabled by default for users.^3^ - Without that privilege, the file system performs traverse checks on directories along the path.^4^
Therefore, FILE_READ_ATTRIBUTES | SYNCHRONIZE may work on current NTFS implementations, but the supplied documentation is insufficient to elevate that exact access profile to the requested cross-version contract.
2. What the share mode does—and does not—stabilize
A successful open with only FILE_SHARE_READ normally prevents another handle from being opened on that same directory object for incompatible write or delete access. Compatibility is reciprocal and checked against all outstanding opens. Consequently, the proposed open ordinarily cannot succeed while an existing incompatible DELETE-access handle remains open.^1^
The guarantees stop short of freezing the namespace:
- Rename or deletion of the held directory itself: rename requires
DELETEaccess to the object, and omittingFILE_SHARE_DELETEnormally blocks a newly requested incompatible delete open.^5^ - Attribute/reparse changes: attribute and extended-attribute access is expressly not governed by
CreateFilesharing flags. Therefore, omittingFILE_SHARE_WRITEis not a documented lock against all metadata changes.^6^ - Children within the held directory: sharing applies to the opened directory object, not every child entry. It does not freeze additions, removals, renames, or replacements of child names.
- Replacement of an entry in the parent: authorization can involve
DELETEon the object or delete-child rights on its parent. The documentation does not establish that parent authorization bypasses share-delete checking, so it should not be treated as either a guaranteed bypass or guaranteed protection.^7^ - POSIX replacement: the documented rename flag allows replacement of an existing target while handles to that replaced target remain valid. That establishes old-handle continuity, not that your held ancestor can necessarily be replaced despite its share mode.^5^
A data-read handle does not inherently provide stronger namespace stability. Its main difference is requested access and the resulting reciprocal share compatibility; neither FILE_READ_DATA nor FILE_READ_ATTRIBUTES is documented as a namespace lock.
3. Reparse rejection scope
FILE_OPEN_REPARSE_POINT applies to the object opened by that particular call. If each call contains exactly one validated component, it lets you inspect that component without normal reparse processing. It does not establish an atomic “validate every ancestor, then final-open” transaction across multiple calls.^8^
Keep each ObjectName to a single component and reject separators, ".", and ".."; multi-component input can introduce unvalidated intermediate processing.
4. No documented equivalent composition
None of the documented alternatives supplies all requested properties:
-
OpenFileByIdpreserves identity-based reopening and supportsFILE_FLAG_OPEN_REPARSE_POINT, but it does not validate that the object remains at the expected allowlisted location.^9^ - A directory RH oplock requires acknowledgment before directory rename or deletion, but changes to directory contents can be advisory-only and proceed without acknowledgment. It is therefore not an immutable-namespace transaction.^10^
- Post-open identity and final-path checks detect some substitutions but cannot make the multi-call sequence atomic.
For a defensible user-mode design, combine handle-relative single-component opens, FILE_OPEN_REPARSE_POINT, handle-based identity/type checks, restrictive ACLs on every mutable ancestor, and fail-closed pre/post checks. Deny untrusted principals the relevant DELETE, parent FILE_DELETE_CHILD, child creation/replacement, and reparse-modification rights; also account for enabled backup/restore or other privileged tokens. This reduces exposure but is not the undocumented atomic guarantee requested.
Obtaining that guarantee requires a Microsoft Support confirmation covering the exact access mask, option set, Windows versions, local NTFS behavior, and installed file-system filters. A closely related Microsoft Q&A clarification likewise concludes that public documentation does not define the required atomic object/effect boundary.^11^
References
- NtCreateFile function (winternl.h)
- File Access Rights Constants
- Privilege Constants (Authorization)
- Checking for Traverse Privilege on IRP_MJ_CREATE
- FILE_RENAME_INFORMATION structure (ntifs.h)
- CreateFileW function (fileapi.h)
- DeleteFile function (winbase.h)
- Reparse Points and File Operations
- OpenFileById function (winbase.h)
- FSCTL_REQUEST_OPLOCK IOCTL (winioctl.h)
- NTFS single-component NtCreateFile relative to a held directory during junction conversion: original-object-or-refusal contract? - Microsoft Q&A