+
+ /* Copy all the partitions */
+ for (; PartitionIndex < SectorsForPartitions; ++PartitionIndex)
+ {
+ /* First, read the partition from the first table */
+ Status = FstubReadSector(Disk->DeviceObject,
+ Disk->SectorSize,
+ ReadPosition + PartitionIndex,
+ Disk->Buffer);
+ if (!NT_SUCCESS(Status))
+ {
+ goto Cleanup;
+ }
+
+ /* Then, write it in the other table */
+ Status = FstubWriteSector(Disk->DeviceObject,
+ Disk->SectorSize,
+ WritePosition + PartitionIndex,
+ Disk->Buffer);
+ if (!NT_SUCCESS(Status))
+ {
+ goto Cleanup;
+ }
+ }
+
+ /* Now we're done, write the header */
+ Status = FstubWriteHeaderEFI(Disk,
+ SectorsForPartitions,
+ EFIHeader->DiskGUID,
+ EFIHeader->NumberOfEntries,
+ EFIHeader->FirstUsableLBA,
+ EFIHeader->LastUsableLBA,
+ EFIHeader->PartitionEntryCRC32,
+ WriteBackup);
+
+Cleanup:
+ ExFreePoolWithTag(EFIHeader, TAG_FSTUB);
+ return Status;