Devices - Locate

NOTE - thanks to everyone at reboot.pro who contributed to the Create a Windows System From Scratch Using Linux thread - in particular cdob, erwan.l and Wonko the Sane.

This page contains the following sections -


Locate Type Devices

With the release of Windows 7 a new device type was added - locate. This is used to scan drives for a path that has been set in another element within the same Object. The following output from running bcdedit illustrates this -

The BCD store containing the data in the above example was taken from a sysprepped system - using the Sysprep tool on Windows 7 automatically sets the device to use locate. Unfortunately I have not found any way of duplicating this using the bcdedit tool that shipped with Windows 7. Using the Windows 8.1 version of bcdedit it was possible to set a device element to use locate by using the following command syntax -
bcdedit /set {guid} device LOCATE=custom:0x12000002

In multiboot environments the locate device may not load the desired operating system as the scanning process will stop as soon as the first path\file is found - if for example there are two versions of Windows on the same disk on partitions 1 and 2, then the operating system on partition 1 will be booted as this is scanned first.




Manually Adding the Locate Device to a BCD Store

Although the Windows 7 version of BCDEdit does not support using the locate device, it is possible to use alternative methods - special thanks here to cdob, erwan.l and Wonko the Sane at reboot.pro.

A quick note here - the locate device is not supported in versions of Windows released prior to Windows 7. Consequently you will need to make sure that the Windows Boot Manager used on your system supports this device - any version of bootmgr or bootmgfw.efi from Windows 7 or newer should work.

Remember that a BCD store is a Windows registry hive type file. To edit entries you can therefore use reg.exe or a third party application such as offlinereg. I'd recommend working on a backup of your BCD store just in case something goes wrong!

You will need to find the GUID of Object whose element you want to edit. Use the following command syntax to check the entries in the BCD store (in this example the path to the BCD store is C:\BCD_backup\BCD) -

Note the use of /enum OSLOADER to limit the output to Operating System entries only (see here). This will return output similar to the following -

In this example the {069317d9-50d7-11df-9241-001d925a73cf} object will be used.


reg.exe method

The following batch file can be used to simplify the process - bcd_locate_reg_exe (GUID and path to the BCD store will need editing) - special thanks here to cdob.


offlinereg method

reboot.pro forum member erwan.l's offlinereg can also be used to edit a BCD store. Usage is not covered here, however the following batch file will change the data in the objects device (to locate=custom:12000002 ) and osdevice (to locate=custom:22000002 ) elements (edit the batch file and change the GUID, path to the BCD store and path to offlinereg.exe) -




The Locate Device Element Data

The following data is from a BCD store mounted in regedit - more specifically the \Objects\{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\Elements\11000001 key for an application osloader type Object -

00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,08,00,00,00,00,00,00,00,1e,00,00,00,00,00,00,00,00,00,00,00,02,00,00,12,00,00,00,00,00,00

Now let's take a closer look at the above data -

This element is displayed as the following in bcdedit -




Using the Locate Device in Multiboot Setups

A special thanks (again) here to reboot.pro forum member cdob for detailing this method (the relevant posts are here)

This particular method is a hack - it makes use of a unique file that is used to locate the relevant operating system partition. Due to the possibility of the wrong system being loaded in a multiboot setup with two (or more) windows operating systems we can add a unique tag file and edit the BCD store to search for it - this method will only function correctly if the file being searched for is in fact unique and exists only in the relevant OS.

Using the file/path \Windows\windows7.tag in this example, we would add the relevant file to the operating system and then run the following batch file (remember to edit the GUID and path to the BCD store) -

As previously stated, this is a hack. Details are posted here - essentially the device and osdevice elements in the relevant object are set as locate=custom:32000004 (ramdisksdipath) and an entry for element 32000004 is created with the relevant path to the unique file. cdob states that this works as the 32000004 element is ignored in an application osloader type object as it shouldn't be there.

As an alternative to using reg.exe, the following batch file can be used in offlinereg (edit the batch file and change the GUID, path to the BCD store and path to offlinereg.exe) -