By their contents.
When Windows boots, the I/O Supervisor VxD (IOS) uses BIOS interrupt 0x13 services to read sector 0 (the Master Boot Record) of each drive. It then looks at two bytes at offset 0x0DA. If they are zeroes, IOS checks the following four bytes: if they are also zeroes (like in the standard MBR code written by Microsoft’s FDISK), IOS overwrites them with an identification signature1, again using interrupt 0x13 services. Otherwise the existing contents are assumed to be a signature that is remembered for later. If any of the above fails, then as a fallback a sum-of-doublewords checksum of the boot sector is computed and remembered instead.
This mechanism is alluded to in the I/O Supervisor Guide for Windows 9x/Me Operating Systems, a document provided by Microsoft to device driver writers (it used to be available from Microsoft; original download preserved by Internet Archive). On page 38, it mentions a list of data structures ‘used to audit and reconcile boot record vs. drive letter when assigning drive letters during IOS conversion from real mode to protected mode drivers’, each containing the BIOS disk number, some checksum and some disk signature. If you extract IOS.VXD
from within VMM32.VXD
and disassemble it, you will find code that performs the very process described above, and stores the result in a data structure matching the description in the I/O Supervisor Guide.
After the above probing process is done, sector 0 of each drive is read again, this time using native disk drivers, and compared against data remembered in the previous step. If the checksum and/or signature bytes match, IOS assumes the disk to be the same. The partitions themselves are then matched to DOS drive letters by their partition offsets, and the drive letters are handed over to the protected-mode driver. Partitions that have not been assigned drive letters by DOS are assigned new ones.
This mechanism is the reason why Windows 9x may be confused by disk cloning software: if at boot time IOS sees two disks with identical MBRs with the signature field filled, it will not write a new signature and will later confuse the two disks for each other. The solution is to rewrite the MBR for either drive so that the signature bytes differ; ideally, they should be cleared back to zero, so that IOS may fill them again.
(The above only applies to hard disks; this method obviously cannot work with floppy and CD-ROM drives, even though Windows native drivers manage to take over from DOS drivers for those as well.)
1 The signature, also referred to as ‘the mystery bytes’, is of the form nn ss mm hh
(where nn
is the BIOS disk number and ss mm hh
is the current time as a binary-coded decimal). The actual contents don’t matter too much, though; the goal is simply to have some identifying value that is hopefully unique among all disks attached to the system.