How can I get volume name for EFI system partition

2019-07-14 20:57发布

问题:

I have a Windows machine with GPT drives.
I have a DOS device name of EFI system partition as output from bcdedit.
I want to open handle for this partition and get DOS name by QueryDosDevice() to compare with DOS name which I already have.
I tried to use FindFirstVolume/FindNextVolume to find volume name to get DOS name from QueryDosDevice, but I didn't find volume for EFI system partition. WMI also doesn't have volume for this partition.

How can I get volume name of EFI system partition from C++ code to use it in QueryDosDevice?

回答1:

Try this. Download and install WinObj (from MS technet). Look through the \Device directory for the logical device name of the EFI system partition. Note that logical device names in the \Device directory are of the form \Device\Harddisk<N>\Partition<M> where N is the harddisk number and M is the partition number. Note M equal to zero means whole harddisk, and M > 0 refers to individual partitions. THe number N is the same number you will see in disk manager (diskmgmt.msc) and in diskpart.

Once you get the logical device name look in the \GLOBAL?? directory for an alias to that name. If you find an alias, then you're good to go. If you don't find an alias, then you'll need to use a Win32 API that can access \Device names. I think there is at least one such API, because I wrote a program many years ago that took \Device names as an argument.