Skip to content

A native C++ Windows utility to provides a simple GUI to mount and unmount EFI System Partitions on a selected disk drive.

Notifications You must be signed in to change notification settings

nuloperrito/EFIMounter

Repository files navigation

EFI Partition Mounter

This is a Windows application written in native C++ and built with MFC framework, which provides a simple GUI to mount and unmount EFI System Partitions of a selected disk drive. It's a convenient tool for users who need to access the boot files and configurations on their EFI partition without using command-line tools.

GUI demonstration


How It Works 💻

The application uses a combination of Windows APIs and the diskpart command-line utility to perform its functions.

  • Disk Scanning: The program uses WMI (Windows Management Instrumentation) to query the system for a list of all physical disk drives. For each disk, it checks if an EFI System Partition exists by using IOCTL_DISK_GET_DRIVE_LAYOUT_EX to read the disk's partition table. It specifically looks for a GPT partition with the type GUID C12A7328-F81F-11D2-BA4B-00A0C93EC93B. Only disks that contain a valid EFI partition are displayed in the application's dropdown list.

  • Mounting and Unmounting: The core functionality relies on a Diskpart helper class.

    • To mount the EFI partition, the program generates a diskpart script with commands to select the disk and its EFI partition, and then to assign a new, randomly selected drive letter to it.
    • To unmount the partition, a similar diskpart script is created to remove the assigned drive letter.
    • For removable media, the application has an option to temporarily change the partition's GUID. This is sometimes necessary to bypass certain OS restrictions that prevent mounting of EFI partitions on removable drives.
  • Elevated Privileges: The diskpart utility requires administrator privileges to run. The application uses ShellExecuteEx with the "runas" verb to launch diskpart.exe, which prompts the user for administrator rights. All diskpart commands are written to a temporary script file and executed in a hidden window, ensuring a smooth user experience.

  • Concurrency: Disk scanning, mounting, and unmounting operations are executed on separate worker threads to prevent the main UI from freezing. This keeps the application responsive while it waits for system operations to complete. The threads communicate back to the main UI using custom window messages (WM_DISK_LOAD_COMPLETE, etc.).


How to Use 🖱️

  1. Launch the application: Run the EFIMounter.exe executable. The application will require administrator privileges and will prompt you to accept this.
  2. Select a drive: Use the dropdown combo box to select the disk drive containing the EFI partition you want to access.
  3. Mount the partition: Click the Mount button. A new drive letter will be assigned to the EFI partition, and it will appear in your File Explorer.
    • For removable media, make sure the "Enable compatibility with removable disks" checkbox is checked before mounting.
  4. View contents: Click the View contents button to open a file dialog box that lets you browse the files within the newly mounted EFI partition in case that File Explorer doesn't allow you to access the partition directly due to permission restrictions.
  5. Unmount the partition: When you're finished, select the same drive and click the Unmount button to remove the assigned drive letter and hide the partition from File Explorer. The application also automatically unmounts the partition when the window is closed to prevent any hanging references.

About

A native C++ Windows utility to provides a simple GUI to mount and unmount EFI System Partitions on a selected disk drive.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published