SetVolumeMountPoint don't work with GetLastError = 87

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 ?

The function SetVolumeMountPointW contains several checks which will result in SetLastError(ERROR_INVALID_PARAMETER). For example:

  • if GetDriveTypeW(lpszVolumeMountPoint) is not DRIVE_FIXED
  • if IsThisAVolumeName(lpszVolumeName, ) says no

Run the same checks that SetVolumeMountPointW runs on the input parameters to figure out which check fails. Just disassemble SetVolumeMountPointW of kernel32.dll.