Commit Graph

54 Commits

Author SHA1 Message Date
Pete Batard 6dac531552
[misc] don't pass an output size in DeviceIoControl() when not needed
* Also improve partition creation and address 2 Coverity warnings.
2024-04-01 14:56:06 +01:00
Pete Batard 8a5a5a318a
[misc] improve readability of error code handling
* Also don't pass a read size value in WriteFileWithRetry() if we don't use it.
2024-04-01 02:16:41 +01:00
Pete Batard 0f23c47184
[misc] refactor partition creation 2024-02-08 14:17:03 +00:00
Pete Batard ebe01cc7b6
[dev] filter out Microsoft Dev Drives
* Microsoft Dev Drives are VHDs consisting of a small MSR followed by a large (50 GB or more)
  ReFS partition. See https://learn.microsoft.com/en-us/windows/dev-drive/.
* Closes #2395.
2024-01-08 16:43:52 +00:00
Pete Batard 5b6574d6f6
[misc] add S Mode detection to Windows version reporting
* With thanks to @Wack0
2023-08-18 17:38:12 +01:00
Pete Batard 0b1c68635a
[vhd] add experimental save to Full Flash Update (FFU) image support
* Full Flash Update (FFU) image support was added to dism with Windows 10 1709
  and is an alternate way to save a virtual hard disk for restoration.
* While more modern than VHD/VHDX, FFU creation only works for drives with file
  systems that Windows natively recognizes (FAT, NTFS) and that look like Windows
  installation media, so you can forget about FFU'ing a Linux disk.
* The other *intentional* drawback that Microsoft added is that they don't want
  anybody but themselves being able to create and restore FFU images, so, even
  as they have nice FfuApplyImage()/FfuCaptureImage() calls in FfuProvider.dll
  they have decided not to make these public.
* This means that, since we don't have time to spend on figuring and direct
  hooking internal DLL calls for x86_32, x86_64, ARM and ARM64 (and worrying
  that Microsoft may ever so slightly change their DLL between revs to break
  our hooks), we just call on dism.exe behind the scenes to create the FFU.
2023-07-03 23:57:04 +01:00
Pete Batard c76327f96e
[ui] list drives by increasing order of size
* Also silence MSVC and MinGW obnoxious warnings about bidirectional Unicode characters.
2022-05-25 13:22:47 +01:00
Pete Batard 8ec570570f
[core] reassign a letter for drives written in DD mode that don't have an ESP
* This should help with the CoreELEC usage case described in #1842
* Also add MBR handling for ESP ↔ FAT cheat mode (Alt-P)
* Also set rufus-next to 3.19
2022-03-24 17:24:39 +00:00
Pete Batard d07ec87b3a
[mingw] fix compilation breakage due to MinGW header screwup
* See https://github.com/pbatard/rufus/actions/runs/1900092904
* Guys, I know VDS is fundamentally broken... but that's no reason to break it further!
2022-02-28 22:00:41 +00:00
Pete Batard 00a802ca1d
[iso] fix ISO→ESP creation for Windows 11
* In their great "wisdom", Microsoft made it even harder to access ESPs on Windows 11,
  meaning that we have to use even more convoluted ways of providing the ISO→ESP feature.
* Closes #1855
2022-01-20 15:24:35 +01:00
Pete Batard ce8aaa99f7
[core] add VDS detection and print a notice if VDS is unavailable 2021-10-04 14:29:09 +02:00
Pete Batard 20b8a84595
[core] fix potential "loss" of disk after writing Ubuntu 20.10 in DD mode
* Due to the partition gymnastic that is required by the hack that is ISOHybrid,
  some ISOHybrid images that are written in DD mode, such as Ubuntu 20.10, may
  result in Windows somehow "losing" the target disk from some of its listings.
* This "removal" can be seen for instance if you have diskpart already open and
  issue 'list disk' after Rufus 3.13 completed its image writing.
* In the worst case scenario, Windows may flat out refuse to access the disk at
  the sector level be it in diskpart or disk manager, which forces ones to clear
  the partition tables on Linux or some other OS to be able to "recover" the disk.
* This appears to be mostly due to Windows VDS cache (which Microsoft assures
  should be able to do a proper job of refreshing itself on its own, in the same
  stride as they also feel the need to introduce IVdsService::Refresh whose sole
  purpose appears to work around a limitation that Microsoft knows exists) not
  being in sync with the actual disk layout.
* So we now add calls to VDS layout refresh where needed, to work around the issue.
* Also fix an ext2fs Coverity warning.
2021-01-15 17:50:57 +00:00
Pete Batard 0e43c5f2ea
[vds] improve VDS error reporting 2020-11-13 17:51:48 +00:00
Pete Batard 2538974318
[core] improve VDS calls
* Factorize error setting.
* Use break so as to not leak resources on error.
* Ensure that the error codes are set properly.
2020-11-09 16:48:53 +00:00
Pete Batard e8c717c394
[ui] always use fake units for proposed labels
* Also improve log messages
2020-11-03 12:49:08 +00:00
Pete Batard b2b621cec7
[core] improve mounting/unmounting of volumes
* Factorize drive letter removal into a RemoveDriveLetters() call.
* Improve MountVolume() and RemountVolume() calls.
* Also bump Rufus version to 3.13
2020-10-26 11:48:33 +00:00
Pete Batard 3758f84b17
[vds] improve VDS calls
* Make sure that instantiated objects are released.
* Factorize the instantiating of disk interfaces.
* Allow the provision of an offset to delete a single partition.
* Add a ListVdsVolumes() call (which is pointless since Microsoft *CRIPPLED* its VDS implementation).
2020-10-25 13:09:32 +00:00
Pete Batard 8085a2846d
[misc] fix small issues
* SetAutoMount()/GetAutoMount() should check for INVALID_HANDLE_VALUE and not NULL.
  Also we don't actually need to open MOUNTMGR_DOS_DEVICE_NAME rw to issue an IOCTL.
* ToggleEsp() failed to exit properly when an ESP offset was specified.
* Introduce PI_MAX to explicitly set the size of the partition_information table.
* write_sectors() has write retry, so there's no need to perform one on top of it.
* When we exit FormatThread(), GetLogicalName() should attempt to look for the the
  main partition and be silent.
2020-10-25 12:31:30 +00:00
Pete Batard f04ed61805
[ext2fs] use physical + offset always for extfs partition creation 2020-09-10 17:50:06 +01:00
Pete Batard 3f0d574657
[misc] improve ToggleEsp() call to take an offset
* Also fix a MinGW warning
2020-08-15 14:58:55 +01:00
Pete Batard 23057f6124
[core] add a cheat mode (Alt-P) to toggle GPT ESP to Basic Data
* Windows 10 or later *ONLY*
* Also don't report a GPT partition name if it's empty
2020-06-06 16:37:25 +01:00
Pete Batard 88be86d3d4
[core] improve reporting of partition types
* Add GPT partition types and improve MBR partition type handling
2020-02-06 18:23:19 +00:00
Pete Batard bf8d888b21
[ext2fs] fix creation of persistent partitions for pre-1703 platforms
* Windows platforms prior to Windows 10 1703 cannot access any logical partition besides the
  first one (we don't even get a volume for those).
* This fix enables the use of physical + offset for ext# formatting to work around this,
  which is file since we don't actually need to mount the partition.
* Also fix ext2fs_open2() not handling normalized versions of Windows drive paths ("\\?\...")
* Also fix an issue where we would make the drive letter unavailable after formatting a
  standalone partition to ext#.
* Also ensure that we return an error if the drive we attempt to locate a partition on
  through an offset does not match the currently selected one.
* Also remove some unused calls in drive.c.
* Closes #1374
2019-09-14 23:33:46 +01:00
Pete Batard 94e2015edf
[core] use offset rather than index to identify a partition
* Also fix potential bcdboot invocation failure by introducing a new AltGetLogicalName() call.
* Also use the AltMount calls for ext# formatting
2019-08-18 14:13:09 +01:00
Pete Batard fcb15ab6e9
[ext2fs] automated persistence set up for Debian Live & Ubuntu
* Only UEFI boot for now (GRUB) & requires a post 2019.07.26 ISO for Ubuntu.
* This adds the relevant persistence/persistent kernel option to the conf file, sets the
  expected volume label and creates a /persistence.conf file where needed.
* Also improve token parsing by ensuring a token is followed by at least one white space.
2019-08-02 17:57:10 +01:00
Pete Batard 8b18d8ce1d
[core] add CycleDevice and VDS layout refresh
* Also fix some minor issues
2019-05-23 13:09:25 +01:00
Pete Batard 2ff6da49f0
[extfs] add standalone ext2/ext3 formatting
* Only enabled when Advanced format options are shown
* Also enable reading of extfs volume label
* Also improve GRUB lookup fallback
* Also fix possible truncation when sanitizing labels
* Also write a zeroed MBR when non-bootable is selected
2019-05-03 23:51:05 +01:00
Pete Batard 5f9e65707f
[core] partitioning improvements
* Improve report and make sure we zero leftovers from the start of a partition
* Also add VDS error codes
* Also fix Coverity warnings
2019-04-27 16:04:47 +01:00
Pete Batard 1c39a80d72
[core] partial overhaul of the partitioning and formatting facilities
* Add VDS formatting support (through an Alt-V cheat mode)
* Add partition index support
* Improve(?) Windows To Go support by following Microsoft recommended partition order
* Code refactoring & cleanup
2019-04-25 18:58:55 +01:00
Pete Batard 0ad3f8c1d3
[ext2fs] integrate ext3 formatting into UI operations
* Add display of persistence controls on relevant images
* Add progress on ext3 formatting and improve error reporting
* Also improve MountVolume() and fix some Coverity warnings
2019-04-16 20:44:13 +01:00
Pete Batard ccf0f1bf3c
[ext2fs] add journal support for ext3 formatting
* Also clean up code, handle errors and fix issues
2019-04-15 17:04:39 +01:00
Pete Batard cda716c1ff
[ext2fs] initial ext2fs support 2019-04-12 21:32:40 +01:00
Pete Batard c0526b3e8b
[core] invoke VDS to delete all partitions before format/write 2018-11-28 10:50:00 +00:00
Pete Batard 790b188b3d [ui] fix disabling of Quick Format checkbox
* Closes #1211
* Also fix MBR analysis report displayed each time the user changes boot selection
2018-10-03 19:14:40 +02:00
Pete Batard 9545123711 [core] eliminate querying of floppy drives during enumeration 2018-04-02 14:57:39 +01:00
Pete Batard 1dbbe69a4b [ui] improve partition scheme default selection
* Also rename our variable to PartitionStyle/ps for clarity
2018-03-26 19:06:55 +01:00
Pete Batard 23390bf911 [core] relax the FILE_SHARE_WRITE rules during enumeration
* Should allow enumeration of drives, that other process have open
  with RW access, back again (looking at you, Paragon!!!)
2017-05-02 00:56:07 +01:00
Pete Batard 477ff95f93 [core] display device paths in GetHandle()
* Also reorder bLockDrive and bWriteAccess parameters
2017-04-08 21:58:10 +01:00
Pete Batard 2f81e4f177 [core] avoid the use of FILE_SHARE_WRITE
* Not having FILE_SHARE_WRITE on a disk or volume handle helps
  prevent spurious accesses from the OS or other apps while we
  are repartitioning/refomatting.
2017-02-16 14:13:30 +00:00
Pete Batard 91eec034b1 [core] try not to clear MBR/GPT sectors higher than the lowest partition
* This ensures that a drive can be reformatted without error after writing
  an image such as super_grub2_disk_x86_64_efi_2.02s4.iso
2016-07-07 18:13:01 +01:00
Pete Batard 81673ade26 [core] clean up the RUFUS_DRIVE_INFO struct
* Remove the duplication of DISK_GEOMETRY to keep only the variables we actually use
* Also set rufus-next to 2.10
2016-05-23 12:19:43 +01:00
Pete Batard 258a4f7ca0 [core] work around a Windows bug that may render a disk inaccessible on cleanup
* The root of the issue is that Windows IOCTL_DISK_CREATE_DISK does not properly
  zero all of the MBR/GPT/PBR structure with PARTITION_STYLE_RAW (which is what
  diskpart uses to clean a disk), and leaves plenty of partition artefacts behind.
* This means that, when an image with complex partitioning has been applied, such
  as Chromium/ChromeOS, you may end up with a drive that can not be repartitioned
  or reformatted in Windows (and this is completely independent of whether Rufus
  was used to perform these operations - For instance you will get the same issue
  if you use Win32DiskImager and diskpart + clean).
* The only option left for users then is to reset/repartition their drives in Linux
  or some other OS, as Windows' VDS becomes incapacitated to handle the drive, as
  the problem persists independently of reset/re-plug/Windows platform being used.
* To work around this, we ensure that we zero the MBR/GPT/PBR sectors BEFORE calling
  IOCTL_DISK_CREATE_DISK.
* Also move zeroing of the drive before partition reset.
* Closes #759
2016-05-21 16:34:34 +01:00
Pete Batard ade5639c00 [misc] more headers cleanup 2016-02-25 18:21:31 +00:00
Pete Batard 66edd53b2c [core] add x86_32 boot for UEFI:NTFS
* NB: This increases the compressed executable size by 25K :(
* Also set rufus-next to 2.1
2015-03-16 20:34:04 +00:00
Pete Batard 4b76cb2555 [togo] Add Windows To Go support - part 4
* Ignore partitions we don't care about
* Fix issues with AltMountVolume()
* Try to support 4k drives when setting up MS EFI partition
* Zero the start of the MSR partition to prevent leftover detection
* Fix unwanted use of MBR hidden sectors and redundant CloseHandle()
* Fix addon of BIOS compatibility extra partition
* Print apply image progress to info box
2015-01-20 21:54:29 +00:00
Pete Batard ed9fae7c81 [togo] Add Windows To Go support - part 2
* Enable the creation of MSR and MS EFI partition in GPT mode
* Closes #432
2015-01-20 02:56:17 +00:00
Pete Batard d81f83c110 [core] enable UEFI NTFS support
* This allows no-sweat UEFI support of Windows installation ISOs
  that contain a >4GB file for instance
* This is done through UEFI:TOGO (https://github.com/pbatard/uefi-togo)
  and the efifs NTFS driver (http://efi.akeo.ie)
* Closes #414
* This will also be part of our implementation of #126
2014-12-20 00:22:00 +00:00
Pete Batard d46342c16c [core] ensure AutoMount is enabled while the app is running
* Having AutoMount disabled when a Fixed drive is being used can
  result in a failure during formatting (issue #386).
* Also set explicit FILE_ATTRIBUTE_NORMAL flag an normalize CreateFile usage
* Closes #386
2014-11-11 19:17:39 +00:00
Pete Batard 79a871be63 [core] improve handling of DD images and formatting task order
* Add logic to mount/remount a DD image if it contains a partition we can handle
* Clear GPT structures before copying DD image in case it doesn't overwrites them
* Add a call to refresh the drive layout after copying a DD image
* Move the unlocking of logical drive further down. This may help with the
  infamous "device in use by another process" error.
2014-08-07 01:45:46 +01:00
Pete Batard 8c1dd2ca91 [core] fix detection of fixed drives
* Thanks to MS' shortsightedness, neither of IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
  or IOCTL_STORAGE_GET_DEVICE_NUMBER alone are enough to retrieve a disk number:
  IOCTL_STORAGE_GET_DEVICE_NUMBER doesn't work for LVM drives and
  IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS doesn't work for USB fixed drives, so we
  must use both. Isn't it great?
* Closes #292
2014-02-27 19:53:53 +00:00