Analysis on the principle of fixed U disk letter

Source: Internet
Author: User
Tags numeric value what interface zip

What types of disks are available:

This is the first clear concept, distinguish the categories, we can go to find the appropriate letter. Needless to say, according to the physical category can be divided into magnetic disk (such as hard disk, floppy disk, tape drive), compression disk (CD/DVD), Flash disk (U disk), Zip disk (basic elimination), etc., from the interface classification can be divided into idesatascsiusb and other types; Windows is classified as a local disk (also known as fixed disk fix), removable disk (removable, such as U disk, CD-ROM, floppy disk, zip disk, etc.) two broad categories. For optical discs, no matter what type, what interface, are all Cdrom/dvdrom, and local disk, including internal hard disk, also includes USB mobile hard disk or volume production for USB_HDD flash drive, removable disk, such as we buy a U disk is generally removable type.

  Second, which location in the registry accurately records the name, type and quantity of the erasable disk?

Hklmsystemcurrentcontrolsetservicesdiskenum

The key name here is 0,1,2 ... that is the serial number of the disk in the system and the count is the total number of disks. If my system has a corresponding value of ide,usbtor, and so on, the corresponding SCSI, which represents the type of IDE hard disk, SCSI disk (fixed or removable), USB disk (fixed or removable). If you go except for a disk, then, the key name here will soon be reduced by one, assuming that there are 3 disks, you go in addition to the middle of the 1, then the original 2 value will not become 1, therefore, in selecting the hard drive number, you should note that although only 2 disk, but also not sequential numbering. The hard drive serial number is the basis for selecting its corresponding letter.

  Third, which location in the registry records the mount point and mount points of the disk?

Hklmsystemmounteddevices

The key names here are only two, one is similar to "?? volume{07c229a8-4b84-11de-8e8d-00e04c3e821b} "the section in {}, which is the ID of the partition, is the basis of the adjustment letter and is unchanged. The other is our form of the letter, such as A:C: and so on. Careful observation will find that the key value of each key will be found in the key value of another key, this value is unique, what the specific content, please see the next figure and the final summary. This position is the most important, all the letter and type information are here, then will be explained in detail.

  How do I find the partitions and the disk characters that a local disk (or a fixed disk) contains?

In a word, through disk signature, which can be translated into hard disk markings, this thing is starting from Winnt 3.5. Windows is the only token that is established for disk in the master boot partition MBR and is generally not duplicated. It is a numeric value of 16 in 4 bytes. For example, disk signature for A8 E1 B9 D2, we can find in the Hklmsystemmounteddevices item value for the D2 B9 E1 the A8 the beginning of the item name is the letter after the dosdevices, through this value, can also get this to get its corresponding beginning for?? Volume mount point, under which the disk signature is reversed. So how do we get disk signature? By searching for A8E1B9D2, you'll find an item like this: Hkey_local_ Machinehardwaredescriptionsystemmultifunctionadapter9diskcontrollerdiskperipheral (different computers, the red numbers may be different in the above items), Under the item there is a value named identifier "00c72b95-a8e1b9d2-a", if the system has only one hard drive, then, to be sure, this a8e1b9d2 is disk signature. Conversely, that is, if we find this value, we can find its letter and Mount point. So, if you have a few fixed disks, which signature corresponds to which disk?

  Disk Signature:

Under normal windows, this problem is a good solution, under the WinPE system is not. Therefore, the WinPE system must first get disk signature or use low-level DiskPart commands, but the general WinPE system does not install the corresponding services for DiskPart. Under Windows this device class entry Hkey_local_machinesystemcurrentcontrolsetenumstoragevolume, all connected fixed disk signature are recorded here and cannot be deleted. For example: This is a subkey, the 1&30a96598&0&signaturea8e1b9d2offset7e00lengthxxxxxxxx part of the Scarlet Letter is the child signature, The following offset7e00 is the offset value of the disk is also the starting partition flag, lengthxxxxxxxx refers to the size of the partition, of course, here we do not need to know it. So, in the end how to determine the signature of the disk, ah, the letter order is based on such as the value of the partition under the volume to determine, the partition from the previous to, the offset value from small to large, therefore, Disk Division offset Value Order, is the basis for determining the order of the letter.

  To summarize: Windows gets a fixed disk letter method:

1. Get Disk Signature

In Hkey_local_machinehardwaredescriptionsystemmultifunctionadapter9diskcontrollerdiskperipheral (different computers, The red number in the above item may be different, under the item there is a key named identifier, find two "-" the middle part is disk signature value, such as "00c72b95-a8e1b9d2-a".

Note: Signature can also be obtained by Mfbfix software or Windows self-brought DiskPart.

2, according to signature find the corresponding disk serial number

According to signature, find this place hkey_local_machinesystemcurrentcontrolsetenum

Storagevolume1&30a96598&0&signaturea8e1b9d2offset7e00lengthxxxxxxxx, according to the offset value from small to large order to determine the order of the letter!

3, according to signature get the letter

Arrange the signature in reverse order, and find the value in the Hklmsystemmounteddevices item that starts with a reverse-ordered number is the letter followed by the dosdevices and the appropriate mount point. Here is a question, assuming that a disk has 3 partitions, corresponding to 3 letter, how to determine the order of the letter? See-

  Six, fixed disk letter order:

The correct letter order is obtained based on the offset value of the disk partition, which is sorted from small to large. The value of the offset value is reversed under the Hklmsystemmounteddevices item to get the ID of the corresponding partition, and the disk character of the partition is obtained. So here's the way to get the disk character of a fixed disk. Say, how do I get the drive letter for removable disk?

  Vii. get removable disk letter:

1, forward access

The last part of the value "", starting with hklmsystemcurrentcontrolsetservicesdiskenum,usbtor, such as Usbstordisk&ven_yan&prod_do&rev_ 1.006&99c7d70&0, by the Red Word section, here hklmsystemcurrentcontrolsetenumusbstordisk&ven_yan&prod_do&rev_ 1.006&99c7d70&0 find a value named Parenidprefix, such as 7&cfa80fe&0. Here 7&cfa80fe&0, is what we want, according to it, we can find the letter. OK, convert it to 16, and then find the key in the hklmsystemmounteddevices that contains the value of 16, OK, the letter and Mount point are found. Of course, here I only lift the situation of u disk, in fact, the same disc, please find your own.

2, Reverse access

Double-click the Hklmsystemmounteddevices entry, the value begins with the 5c003f003f005c00, what is it? Double-click the key name, you will find that it is haha found what, it is the corresponding character is ".?.?..", what's in it, There are CDROM words, there are removable words, there are floppy words, see the following figure:

This is the type of disk we want Ah, we take a few corresponding 16 of the number is enough, how, the letter and type have been, simple. As shown below:

if/i!tpcode! Equ 00470045004E Set flpdrv=!flpdrv! %%a

if/i!tpcode! Equ 004300640052 Set dvddrv=!dvddrv! %%a

if/i!tpcode! Equ 00520065006D Set remdrv=!remdrv! %%a

The first line above, if there is a G.E.N, it is a floppy disk; the second line, if there is a C.D.R, is the disc; the third line, if there is a R.E.M, is a U disk.

Note that for removable u disk, in Vista under the 5f003f00 (decimal as "_ ...") Starting with, this is the only mark on the U disk. The main things have been said, to adjust the letter, there are necessary things to say:

  Viii. get all of the drive characters:

Under Windows, fsutil and WMIC commands are OK, but because the former XP and Vista are not the same, the conversion is a bit cumbersome, so use the latter, all the letter, whether virtual or non-virtual, can be obtained.

Under WinPE, if using WMIC is not possible, because there is no WMI service, in the order that WMIC is a powerful command-line tool, you can query and modify almost all the information about the computer, hardware information, software information, and disk information.

So what do we do? The registry provides us with, here: HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerMountPoints2 here are all the letter. Here, some people will ask why Windows does not do so ah, hey, not the same Ah, Windows recorded all the previous disk, whether there is no, but WinPE is not the same, just started the PE, the registry records of all the letter is there.

  Get the drive letter with Mount point:

It is also said, why not from the hklmsystemmounteddevices? This is not believable, so all the disk and mount points of the inserted disks are recorded here, what is believable? mountvol, this guy. In addition to getting mount points, you can also change the drive letter, That's exactly what we need.

  Get the letter (virtual letter) that does not have a mount point:

Think about it? Eight-nine = 10. It is to be noted that here the virtual letter, refers to all the no mount point of the letter, almost all virtual software virtual out of the disk characters are not mount points, such as subst, NET use, ImDisk, RAMDisk and virtual optical drive, etc., but there is a virtual optical drive software exception, Is Daemon TOOLS. It has a mount point, which should also be able to change the letter, but ask the conditional person to test it.

  The disk character of USB fixed disk is also obtained through disk signature step by step?

This, that is, excluding all removable disk and built-in hard drive letter, the remaining is a USB fixed disk letter, and then according to the reverse signature, that is, the first 8 characters in Hklmsystemmounteddevices is the same as the same disk to judge, very simple, Thanks to Cn-dos's hat, he gave the simplest statement of his kind in the batch process. This also involves a problem of the order of the disk, we can not like the hard disk to get through the value of the offset, why? Because USB hard drive, as long as you plug in, Windows to partition the letter is continuous, in the registry volume ID value is also continuously distributed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.