SetVolumeMountPoint don't work with GetLastError = 87

IT’S NOT my driver which return STATUS_NO_MEDIA_IN_DEVICE ,Why ?
IRP IRP_MN_MOUNT_VOLUME is called in internal windows because is a disk driver rawdisk and not filesystem.

Something in your status is making the upper layers believe there is no media in the device.

@Gova_Gimer said:

@craig_howard said:
@Gova_Gimer You’re missing the point … there are potentially three IOCTL’s that the OS is sending to you that it’s expecting a response from, and since it’s not getting one it happily shuts you down. @Tim_Roberts was good enough to decode them, you have three options for handling this …

  • Complain to MS that they are sending the IOCTL’s in error
  • Figure out why MS is sending those IOCTL’s (maybe you’ve told the OS that your are something that you’re not)
  • Handle them, usually by either completing them or by passing them down to the lower level

Short answer:
There is no need to implement them because truecrypt does not implement them.
And Setvolumemountpoint work in truecrypt and not in my driver.

ALSO :
FileSpy utility work good and return error :
4 21:11:30.897 devenv.exe IRP_MJ_FILE_SYSTEM_CONTROL/IRP_MN_MOUNT_VOLUME 00000042 STATUS_NO_MEDIA_IN_DEVICE
5 21:11:34.286 StandardCollector.Service.exe IRP_MJ_FILE_SYSTEM_CONTROL/IRP_MN_MOUNT_VOLUME 00000042 STATUS_NO_MEDIA_IN_DEVICE
6 21:11:34.451 StandardCollector.Service.exe IRP_MJ_FILE_SYSTEM_CONTROL/IRP_MN_MOUNT_VOLUME 00000042 STATUS_NO_MEDIA_IN_DEVICE

Sorry , i return never STATUS_NO_MEDIA_IN_DEVICE in my driver !!

ALSO :
Question:
I would like to submit a bug to microsoft because normally SetVolumeMountPoint is supposed to work in my device, which it is not, it gives me error 87 (ERROR_INVALID_PARAMETER) and the path exists!
How to submit?

Hmm … the OS is making three IOCTL’s to you, the STORAGE_QUERY_PROPERTY one (that you’re not handling, as you stated) and STORAGE_GET_HOTPLUG_INFO (which you’re also not handling) both look suspiciously like the OS is asking “what are you?”. You don’t say, so the OS will pass that IOCTL to the next driver in the stack which also replies “I have no clue”. Ultimately the result of these IOCTL’s are that the OS has no idea what kind of device you might be, so it makes perfect sense that when you attempted to SetVolumeMountPoint() the OS would fail that call … because again, the OS has no idea what kind of media you are and that there is therefore STATUS_NO_MEDIA_IN_DEVICE

You seem to be really resistant to implementing a return to those three simple little calls, is that a philosophical difference with how you feel your driver works or is there a programmatic reason for that reason? Personally, if the OS asked if my device was a chicken (when I am actually a duck) and was only happy if it thought my duck was a chicken then I would say “yep, it’s a chicken!” … because at the end of the day, the OS is going to win …

1 Like

I will try to implement IOCTL_STORAGE_GET_HOTPLUG_INFO.
Yet truecrypt does not implement it yet!

For SetVolumeMountPoint to work correctly then
what are the ‘_STORAGE_PROPERTY_ID’ command lists should i implement for this ‘IOCTL_STORAGE_QUERY_PROPERTY’ ioctl?

Hmmm … this is another time that you’ve mentioned TrueCrypt [ https://en.wikipedia.org/wiki/TrueCrypt ] you do realize that this was/ is an open source file encryption method that had the final nails put into it’s coffin in 2014, yes? Veracrypt is still around but TrueCrypt is long dead and dust … which is likely why it doesn’t support those functions, and I can assure you never will support those functions … or anything else for that matter …

Are you trying to use Veracrypt? Probably asked a little later than should have been, but what problem are you attempting to solve?

@craig_howard said:
Hmmm … this is another time that you’ve mentioned TrueCrypt [ https://en.wikipedia.org/wiki/TrueCrypt ] you do realize that this was/ is an open source file encryption method that had the final nails put into it’s coffin in 2014, yes? Veracrypt is still around but TrueCrypt is long dead and dust … which is likely why it doesn’t support those functions, and I can assure you never will support those functions … or anything else for that matter …

Are you trying to use Veracrypt? Probably asked a little later than should have been, but what problem are you attempting to solve?

Yet truecrypt still works fine on windows 7,8,10.

@Gova_Gimer said:

@craig_howard said:
Hmmm … this is another time that you’ve mentioned TrueCrypt [ https://en.wikipedia.org/wiki/TrueCrypt ] you do realize that this was/ is an open source file encryption method that had the final nails put into it’s coffin in 2014, yes? Veracrypt is still around but TrueCrypt is long dead and dust … which is likely why it doesn’t support those functions, and I can assure you never will support those functions … or anything else for that matter …

Are you trying to use Veracrypt? Probably asked a little later than should have been, but what problem are you attempting to solve?

Yet truecrypt still works fine on windows 7,8,10.

Hmm … and yet here you are, totally unable to convince MS to mount your volume and essentially politely giving you the middle finger when you do …

At this point I think I’m done here (and as a sidenote, ZFS for Windows which is another open source filesystem [a mighty fine one too IMHO] mounts volumes very happily) …

EOF

Well, his point is legitimate. Whether the code is a marvel of modern engineering or a crusty dustbin relic, the TrueCrypt driver runs on Windows 10 and responds correctly to SetVolumeMountPoint. He is implementing the same ioctls in his driver, and the API doesn’t work for him. So, what’s the difference? I’m just not good enough in the storage stack to know what else there is. There must be some configuration or parameter structure that gets returns, where he’s missing some key element.

@Tim_Roberts The point I was (trying) to make was that he was conflating the response the OS was giving him with the response that TrueCrypt was giving, and rather than trying to understand what the OS was looking for he was complaining that “but it works for that other driver, why not for me??”

That’s like the guy pulled over for speeding saying “why are you giving me a ticket, look at everyone else that is speeding!”

The fact that another driver is able to communicate successfully with the OS (like ZFS for Windows, I have no experience with VeraCrypt or TrueCrypt so can’t speak to them) when your driver can’t simply means it would be more valuable to examine the IRP traffic going to the drivers that work and compare that to what’s happening in your driver, not that you should open a ticket with MS asking to fix the OS …

I’am implemented ioctl :
IOCTL_STORAGE_GET_HOTPLUG_INFO
IOCTL_STORAGE_QUERY_PROPERTY
I lost a lot of time !!
IOCTL ARE NOT DOCUMENTED !
0x2D1084
0x2d1190
0x4d0018 = IOCTL_MOUNTDEV_QUERY_STABLE_GUID NO DOCUMENTED

DefineDosDevice work ! but not SetVolumeMountPoint which return error ERROR_INVALID_PARAMETER !
I join a part source code.
For information the ioctl are implemented in user and worked my driver.
The IOCTL are work correctly with out exception ! NO BSOD !
https://dropbox.com/s/gz2rtw32h9kcjha/fntioctl.cc?dl=0

IoCompleteRequest is called AFTER in my driver .
IoCompleteRequest is called afterwards in my driver otherwise the system would be frozen.
The user mode function ‘BuildIOCTL’ works!

I defined the ioctl IOCTL_MOUNTDEV_QUERY_STABLE_GUID !
THEN same problem !
SetVolumeMountPoint return always error 87 (ERROR_INVALID_PARAMETER)
HOW DO I DO FOR TRACE ERROR ?

Also these ioctl (0x2D1084,0x2d1190) is not documented !
Please help
Thank !

This is a tough situation, and I don’t think there are any easy answers. It can sometimes be useful to look at the Windows clones for hints. The Wine implementation of SetVolumeMountPoint only returns ERROR_INVALID_PARAMETER if one of the two parameters is null. Otherwise, it just returns the result of IOCTL_MOUNTMGR_CREATE_POINT. The ReactOS IOCTL_MOUNTMGR_CREATE_POINT returns that if the ioctl buffers are the wrong size, or the drive letter is already occupied. That’s pretty much it.

@Tim_Roberts said:
This is a tough situation, and I don’t think there are any easy answers. It can sometimes be useful to look at the Windows clones for hints. The Wine implementation of SetVolumeMountPoint only returns ERROR_INVALID_PARAMETER if one of the two parameters is null. Otherwise, it just returns the result of IOCTL_MOUNTMGR_CREATE_POINT. The ReactOS IOCTL_MOUNTMGR_CREATE_POINT returns that if the ioctl buffers are the wrong size, or the drive letter is already occupied. That’s pretty much it.

I Want mount a volume disk of my driver into directory

From my research ,I’m thinking there is a bug on Windows! and it was never solved!
Sorry, that’s my point of view!
I tried the makelink example
https://www.codeproject.com/Articles/194/Windows-2000-Junction-Points then it work but when i click on my
directory mounted THEN it does not work , any ioctl are called.
I test command line mountvol which return parameter incorrect !
I wasted time defining the ioctl functions that windows needed.
Whether these ioctl functions are defined or not, always error 87.
For me windows is not able to mount a volume on a directory except diskmgd (panel control → admin system-> disk manager, virtual disk included in disk manager).

Is my driver at fault?
No because API definedosdevice work but not SetVolumeMountPoint.

Well, your last ditch effort is to submit a Support Incident through Microsoft Support. They will get you in touch with the Microsoft development team for that area. You’ll have to pay a fee with a credit card to get started, but if it turns out to be an operating system bug (which I doubt), then they’ll refund the money.

Excuse me but OS bug because
SetVolumeMountPoint call only ONE ioctl IOCTL_MOUNTDEV_QUERY_DEVICE_NAME of my device disk to which the iOCTL works VERY WELL and tested!
So Bugger Section → Mountmgr.
THEN Why SetVolumeMountPoint return error ERROR_INVALID_PARAMETER ???
The ioctl IOCTL_MOUNTDEV_QUERY_DEVICE_NAME return yet the good name of my disk device !

See post url :
https://community.osr.com/discussion/293283/how-submit-bug-os-and-cost/p1?new=1

PARDON Excuse me i forgotten i also tried ! :
wcscpy_s(szUniqueVolumeName, L"\\\\?\\Volume{cd4ccea8-484c-8042-550e-919e0206fb8f}\\"); //the name volume should be registered by your driver ! with IoCreateSymbolicLink !
wchar_t* lo =(wchar_t*)L"\\??\\companydiskVolume0"; //the name should be registered by your driver with IoCreateDevice
LSTATUS rr=SHSetValueW(HKEY_LOCAL_MACHINE, L"SYSTEM\\MountedDevices", _szUniqueVolumeName, REG_BINARY, lo, wcslen(lo)*2);

Do not dream, this line writes well in the Registry.

  1. You must be a administrator (root) → it’s quite normal for security measures
  2. SetvolumeMountPoint will not work and will always return the error 87 which is ERROR_INVALID_PARAMETER !
    It would be too good if it works!

ALSO :
In event log (Panel control → Administration tools-> Event Log) I don’t view about detail error which returned by function SetVolumeMountPoint

Thank.

Honestly, this is the point at which I usually have to step into the OS code with a debugger and look at the assembly code and see what it is testing right before it returns the error code. It’s pretty much a given that the code is checking all the parameters that you are passing to it, and deciding that it doesn’t like one of them.

Figuring out which parameter it doesn’t like and justifying why it should like that parameter would probably be part of filing a bug report as well.

Excuse me but OS bug because

You cannot conclude that. It’s possible, for example, that SetVolumeMountPoint is looking up other information that’s been registered for your device, and part of that isn’t right. You just don’t know until you single step through the code. Microsoft just doesn’t make announcements about implementation.

@Tim_Roberts said:

Excuse me but OS bug because

You cannot conclude that. It’s possible, for example, that SetVolumeMountPoint is looking up other information that’s been registered for your device, and part of that isn’t right. You just don’t know until you single step through the code. Microsoft just doesn’t make announcements about implementation.

Then How do i do ?