- 0, FILE_SUPERSEDE, 0, ctx);
- if (!NT_SUCCESS(status)) {
+ 0, disposition, 0, ctx);
+ if (unlikely(!NT_SUCCESS(status))) {
+ if (status == STATUS_OBJECT_NAME_NOT_FOUND && !retried) {
+ /* Workaround for defect in the Windows PE
+ * in-memory filesystem implementation:
+ * FILE_SUPERSEDE does not create the file, as
+ * expected and documented, when the named file
+ * does not exist. */
+ retried = true;
+ disposition = FILE_CREATE;
+ goto retry;
+ }