Hi @SkullyHIT Rios ,
Thank you for the clear write up and for your questions.
Public Microsoft documentation establishes individual guarantees for this operation, but it does not establish a complete API contract covering all of your stated requirements.
1. If only the original handle must be closed
- There is a documented way to preserve binding to the exact file object: retain a duplicate created before closing that handle. The DuplicateHandle documentation explicitly states that the duplicate refers to the same object as the original.
- That surviving handle can identify the source for SetFileInformationByHandle, provided it has the permissions required for the operation. With FileRenameInfo, the FILE_RENAME_INFO documentation states that ReplaceIfExists = FALSE causes an error if the target exists. This combines documented source-object binding with documented existing-destination refusal. It does not, however, establish the stronger concurrent-linearizability or lost-completion guarantees you describe.
2. If all handles to the staged file must be closed before publication
- OpenFileById is a documented alternative to reopening the source by pathname. It opens the file matching a specified identifier. The file-ID documentation states that an NTFS file retains its ID until deletion, but also warns that file IDs are not guaranteed unique over time because file systems may reuse them.
- Consequently, reopening by ID is relevant when the intended file survives the closed-handle interval. A saved ID does not establish an unconditional guarantee of binding to the original file if other actors may delete it and the identifier may subsequently be reused.
3. Regarding handle-based linking
- FileLinkInformation is not listed among the supported classes for the Win32 SetFileInformationByHandle function. However, the NtSetInformationFile documentation lists that class and explicitly discusses calls from user mode. It would therefore be too strong to describe handle-based linking as entirely undocumented for user mode. Nevertheless, that reference does not establish the complete stronger publication contract you are seeking, and its user-mode guidance should not be treated as making FileLinkInformation supported by the Win32 function.
In conclusion, closing the original handle is compatible with preserving exact object binding through a surviving duplicate. If the requirement instead mandates closing every handle and allowing unrestricted deletion or replacement during that interval, the cited documentation does not establish a supported combination that guarantees subsequent publication of the exact original staged file. Nor does it establish the full concurrent-publication and outcome-recovery guarantees.
If you need an authoritative, supported statement on whether Windows provides stronger guarantees for this publication pattern, including the concurrency and exact-file-identity cases described above, I’d recommend opening a support request with Microsoft through Support for Business. If you don’t have a business support plan, you can instead contact Microsoft Support. This would be the appropriate route for obtaining guidance on behavior or guarantees that are not explicitly established by the public API documentation.
I hope this helps clarifying your requirements and answering your questions. If you find my response helpful, I would greatly appreciate it if you could follow the guide here so others experiencing similar behavior or issue can benefit from it as well.