So I have been using chatGPT to try to debug why my code does not work when creating a volume mounted on a directory.
I create a top device, which is assigned "\DosDevices\E:".
then I create a sub-device, which I want to mount on "\DosDevices\E:\dataset".
So according to chatGPT, I should do:
Create my new (sub)device;
"\Device\Volume{3fe4a1af-988f-3c6a-93c0-6c75d96902db}"
First we check the device is ready.
IOCTL_MOUNTMGR_QUERY_POINTS:
# DeviceName # SymbolicLinkName
point 4: '\Device\Volume{0b1bb601-af0b-32e8-a1d2-54c167af6277}' '\??\Volume{df46d386-2857-11ef-82bd-58961d57db67}'
point 5: '\Device\Volume{0b1bb601-af0b-32e8-a1d2-54c167af6277}' '\DosDevices\E:'
point 6: '\Device\Volume{3fe4a1af-988f-3c6a-93c0-6c75d96902db}' '\??\Volume{df46d39b-2857-11ef-82bd-58961d57db67}'
point 7: '\Device\Volume{3fe4a1af-988f-3c6a-93c0-6c75d96902db}' '\DosDevices\F:'
Excellent, so it was assigned "\DosDevices\F:".
Then we remove mapping "\DosDevices\F:".
IOCTL_MOUNTMGR_DELETE_POINTS:
struct PMOUNTMGR_MOUNT_POINT, PMOUNTMGR_MOUNT_POINTS
point->SymbolicLinkName: "\DosDevices\F:"
point->SymbolicLinkNameOffset: 0x18
point->SymbolicLinkNameLength: 0x1c
point->DeviceName: "\Device\Volume{3fe4a1af-988f-3c6a-93c0-6c75d96902db}"
point->DeviceNameOffset: 0x34
point->DeviceNameLength: 0x68
totalLength: 0x9c
** ntstatus = STATUS_SUCCESS;
IOCTL_MOUNTMGR_QUERY_POINTS:
# DeviceName # SymbolicLinkName
point 4: '\Device\Volume{0b1bb601-af0b-32e8-a1d2-54c167af6277}' '\??\Volume{df46d386-2857-11ef-82bd-58961d57db67}'
point 5: '\Device\Volume{0b1bb601-af0b-32e8-a1d2-54c167af6277}' '\DosDevices\E:'
point 6: '\Device\Volume{3fe4a1af-988f-3c6a-93c0-6c75d96902db}' '\??\Volume{df46d39b-2857-11ef-82bd-58961d57db67}'
So far, so good. We managed to affect a change with MountMgr.
We create the reparsepoint junction, probably does not get used yet.
FSCTL_SET_REPARSE_POINT:
poa.ObjectName: "\??\E:\\dataset"
MountPointReparseBuffer.PathBuffer: "\??\Volume{df46d39b-2857-11ef-82bd-58961d57db67}\"
MountPointReparseBuffer.PrintName: "BOOM/dataset"
** ntstatus = STATUS_SUCCESS;
Then chatGPT says I should create point, and then announce it. It also
claims I should use a trailing backslash.
IOCTL_MOUNTMGR_CREATE_POINT
struct MOUNTMGR_CREATE_POINT_INPUT
point->DeviceName: "\??\Volume{df46d3a7-2857-11ef-82bd-58961d57db67}\"
point->DeviceNameOffset : 8
point->DeviceNameLength : 0x62
point->SymbolicLinkName: "\DosDevices\E:\dataset"
point->SymbolicLinkNameOffset : 0x6a
point->SymbolicLinkNameLength : 0x2c
totalLength: 0x96
** ntstatus = STATUS_SUCCESS;
and the second call:
IOCTL_MOUNTMGR_VOLUME_MOUNT_POINT_CREATED:
struct MOUNTMGR_VOLUME_MOUNT_POINT_INPUT
mountpoint->SourceVolumeName: "\??\Volume{df46d39b-2857-11ef-82bd-58961d57db67}\"
mountpoint->SourceVolumeNameOffset: 8
mountpoint->SourceVolumeNameLength: 0x64
mountpoint->TargetVolumeName: "\DosDevices\E:\dataset"
mountpoint->TargetVolumeNameOffset: 0x6c
mountpoint->TargetVolumeNameLength: 0x2e
ntstatus = STATUS_SUCCESS;
So finally, we call IOCTL_MOUNTMGR_QUERY_POINTS again to list:
point 4: '\Device\Volume{0b1bb601-af0b-32e8-a1d2-54c167af6277}' '\??\Volume{ba95a227-3694-11ef-82bd-58961d57db67}'
point 5: '\Device\Volume{0b1bb601-af0b-32e8-a1d2-54c167af6277}' '\DosDevices\E:'
point 6: '\Device\Volume{3fe4a1af-988f-3c6a-93c0-6c75d96902db}' '\??\Volume{df46d3a7-2857-11ef-82bd-58961d57db67}'
And I was hoping for another line, for "\DosDevices\E:\dataset" but I appeared to have failed.
$ mountvol
\\?\Volume{ba95a227-3694-11ef-82bd-58961d57db67}\
E:\
\??\Volume{df46d3a7-2857-11ef-82bd-58961d57db67}\
*** NOT MOUNTABLE UNTIL A VOLUME MOUNT POINT IS CREATED ***
Only hint I have so far, I thought I had "created a volume mount point".
I have tried using "device_name", instead of the "symboliclinkname". No errors, but no progress.
Can anyone see what could be wrong? Are the IOCTL calls used the ones I am supposed to use?
I don't suppose FileSpy can capture requests to MountMgr? Would be most useful to be able to see NTFS communication when mounting a sub-volume.
Could our AI overlords not be as imposing as we thought?
(Edit, it was eating too many backslashes, so put in code blocks)