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.
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_EXto read the disk's partition table. It specifically looks for a GPT partition with the type GUIDC12A7328-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
Diskparthelper class.- To mount the EFI partition, the program generates a
diskpartscript with commands to select the disk and its EFI partition, and then toassigna new, randomly selected drive letter to it. - To unmount the partition, a similar
diskpartscript is created toremovethe 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.
- To mount the EFI partition, the program generates a
-
Elevated Privileges: The
diskpartutility requires administrator privileges to run. The application usesShellExecuteExwith the"runas"verb to launchdiskpart.exe, which prompts the user for administrator rights. Alldiskpartcommands 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.).
- Launch the application: Run the
EFIMounter.exeexecutable. The application will require administrator privileges and will prompt you to accept this. - Select a drive: Use the dropdown combo box to select the disk drive containing the EFI partition you want to access.
- 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.
- 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.
- 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.
