I am relatively new to windows but for certain tests, I would like to create or fake a virtual disk that maps to certain location of existing disk.
For example, I want to see F: drive that maps to C:/tmp_disk so when I open file browser or explorer, I can see F: drive and whatever I put in F: drive will direct to C:/tmp_disk.
Obviously, in reality there is no physical F: drive.
So my question is to know if it is possible to create this new drive somehow so that I can see it in the file browser.
I have found out that all the drive mappings are recorded in registry. For instance, my harddisk C: drive is at \Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\CPC\Volume.
According to what I understand, windows opens up this registry key and get the necessary information and get the drive letter to display. Please correct me if I am mistaken.
So fundamentally, should I then insert some data into registry key or how should I approach this task so that I can display it in file browser.
Perhaps I guess that this can be done via virtual disk but I do not know how to go about and I am not sure if that is the case.
Please kindly give me some suggestions. Thank you.
This is supported for 20 years or more the same way:
d:\>subst /?
Associates a path with a drive letter.
SUBST [drive1: [drive2:]path]
SUBST drive1: /D
drive1: Specifies a virtual drive to which you want to assign a path.
[drive2:]path Specifies a physical drive and path you want to assign to
a virtual drive.
/D Deletes a substituted (virtual) drive.
Type SUBST with no parameters to display a list of current virtual drives.
If you want to do it programatically, examine DefineDosDevice() API docs.
From: xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com] on behalf of xxxxx@gmail.com[SMTP:xxxxx@gmail.com]
Reply To: Windows System Software Devs Interest List
Sent: Thursday, October 18, 2007 4:18 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] virtual disk
Dear experts,
I am relatively new to windows but for certain tests, I would like to create or fake a virtual disk that maps to certain location of existing disk.
For example, I want to see F: drive that maps to C:/tmp_disk so when I open file browser or explorer, I can see F: drive and whatever I put in F: drive will direct to C:/tmp_disk.
Obviously, in reality there is no physical F: drive.
So my question is to know if it is possible to create this new drive somehow so that I can see it in the file browser.
I have found out that all the drive mappings are recorded in registry. For instance, my harddisk C: drive is at \Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\CPC\Volume.
According to what I understand, windows opens up this registry key and get the necessary information and get the drive letter to display. Please correct me if I am mistaken.
So fundamentally, should I then insert some data into registry key or how should I approach this task so that I can display it in file browser.
Perhaps I guess that this can be done via virtual disk but I do not know how to go about and I am not sure if that is the case.
Please kindly give me some suggestions. Thank you.
Thank you very much for your reply.
Just out of curiosity, I noticed that if I create a drive using ‘subst’ command, windows does not enter any data into registry, I mean under \Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\CPC\Volume
I also looked at DefineDosDevice and it eventually calls NtDeviceIoControlFile() but I have not figured out which control code it uses though.
So could you briefly describe how windows then retrieve information regarding this new drive when it is not stored in \Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\CPC\Volume?
Thank you very much.
Maybe you should be more concerned about how things are supposed to works than about implementation details I understand your interest but it should be the second step, not the first one. Sometimes it is good to read docs before digging into software guts
Well, substed drives are just symbolic links. You can use WinObj tool to examine them (see current logon session namespace). They are unique per current user/logon session similarly as mapped network drives. They won’t survive reboot so there is no need to store them in the registry. Mount points created using SetVolumeMountPoint are different. They’re (AFAIK) global i.e. visible to all logon session which in turn means symbolic links are created in global namespace (see WinObj again). They’re persistent and that’s why info is stored in the registry where you found it. OS reads it during boot and creates symbolic links according to this info.
From: xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com] on behalf of xxxxx@gmail.com[SMTP:xxxxx@gmail.com]
Reply To: Windows System Software Devs Interest List
Sent: Thursday, October 18, 2007 6:41 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] virtual disk
Thank you very much for your reply.
Just out of curiosity, I noticed that if I create a drive using ‘subst’ command, windows does not enter any data into registry, I mean under \Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\CPC\Volume
I also looked at DefineDosDevice and it eventually calls NtDeviceIoControlFile() but I have not figured out which control code it uses though.
So could you briefly describe how windows then retrieve information regarding this new drive when it is not stored in \Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\CPC\Volume?
Thank you very much.