How to identify a disk in Windows kernel driver?

Hi professionals, I’m a newer to windows kernel driver development and I’m working on a disk filter driver which is a boot driver.
Firstly let me try describing the problem as I could. For the driver, in ‘DriverEntry’ routine, the driver just loads its parameters from registry and initializes the driver entry points, at the end registers a routine to trigger “BootDriverReInitialization” action. The critical filtering function stack is setup in “BootDriverReInitialization” routine. In order to make the parameters to be configurated for different VMs, I’d like to read the settings from file on a specific small VHD disk created by ourselves, and override the default values that read from registry earlier. Then we can setup filtering function with different settings per VM(shared OS image with same registry settings). The job that I have to do next is to identify the disk, read the configuration from this disk and override the default settings with new values.

Here are my questions:

  1. Is it safe to load configuration from disk file at that point?
  2. How can I identify the VHD disk in a safe and simpler way but not to enumerate all disks by checking if the specific config file exists on the disk?

Any help or suggestion would be appreciated.

(Moved to appropriate location)

If the VHD is not located on the disk you are filtering, then I believe there are no guarantees of disk order. It’s somewhat problematic to have the driver for disk A assume the presence of and rely on disk B. Even if it the drive you are filtering, how are you going to mount the VHD?

the short answer is no, you cannot store your configuration anywhere except in the designated registry key

@Tim_Roberts said:
If the VHD is not located on the disk you are filtering, then I believe there are no guarantees of disk order. It’s somewhat problematic to have the driver for disk A assume the presence of and rely on disk B. Even if it the drive you are filtering, how are you going to mount the VHD?

One thing is that the VMs are created by Hypervisor or Azure platform with the same OS image and a small VHD is attached to each VM as a data disk as well. The disk we’re filtering is not the VHD disk, generally the OS disk. As I know, ‘BootDriverReInitialization’ is entered when all devices have been enumerated and started. Now in this reinitialization routine, we can read the configure file in the right disk with symbolic link like ‘\Device\Harddisk{1,2,3}\Partition1\configfile.ini’. But we worry if we access the disks like this, it will change the disk initialization order and make something unexpected.

@MBond2 said:
the short answer is no, you cannot store your configuration anywhere except in the designated registry key

Thanks for your answer, then any way to make the driver dynamically configured?

Of course you can store config data on your own (vhd) disk attached to the vm. I know of at least two commercial products that do this and they are deployed all over the planet. As you noted, you can just enumerate all the disks and look for your config data signature. Accessing the disk is not going to change the initialization order. It has to have been initialized in order to access it.

If you have an immutable boot/system disk (for example it gets reset on each boot) the registry is obviously out as a way to customize each instance.

@Mark_Roddy said:
Of course you can store config data on your own (vhd) disk attached to the vm. I know of at least two commercial products that do this and they are deployed all over the planet. As you noted, you can just enumerate all the disks and look for your config data signature. Accessing the disk is not going to change the initialization order. It has to have been initialized in order to access it.

If you have an immutable boot/system disk (for example it gets reset on each boot) the registry is obviously out as a way to customize each instance.

Thanks for your answer. Yes, you’re right, we just have an immutable system disk and it gets reset on each boot.