Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


SetVolumeMountPoint don't work with GetLastError = 87

Gova_GimerGova_Gimer Member - All Emails Posts: 64

hello ,
I developped a driver for mount virtual disk RAW ,
and SetVolumeMountPoint don't work !
It return GetLastError = 87.

I implemented ioctl 'IOCTL_MOUNTDEV_QUERY_DEVICE_NAME' but SetVolumeMountPoint don't work with error 87 !
How trace error ?
Thank !

Thank you help.

«1

Comments

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,289

    Did you copy the driver from the web somewhere? Where? Does a drive letter get assigned for it?

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Gova_GimerGova_Gimer Member - All Emails Posts: 64
    edited December 2021

    @Tim_Roberts said:
    Did you copy the driver from the web somewhere? Where? Does a drive letter get assigned for it?

    It's a driver that I made myself, to mount disks with drive (eg drive g: ) it works (win 7,10) but when I use SetVolumeMountPoint in my path of my device \device\volume{guid}... then it doesn't work.
    It gives me error 87.
    Why ?????

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,289

    Error 87 is ERROR_INVALID_PARAMETER. Have you triple-checked all the parameters in your call? Perhaps you could post your app code. Does your app work with other devices?

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Gova_GimerGova_Gimer Member - All Emails Posts: 64
    edited December 2021

    @Tim_Roberts said:
    Error 87 is ERROR_INVALID_PARAMETER. Have you triple-checked all the parameters in your call? Perhaps you could post your app code. Does your app work with other devices?

    SetVolumeMountPoint work on other device (eg. Truecrypt) but NOT WORK on my device !
    What interests me is using this function on MY device!

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,289

    Have you added debug prints of every ioctl you get? I'm not a disk guy, so I don't know what ioctls are generated by the call, but it seems like you must be getting one you don't handle.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Gova_GimerGova_Gimer Member - All Emails Posts: 64

    @Tim_Roberts said:
    Have you added debug prints of every ioctl you get? I'm not a disk guy, so I don't know what ioctls are generated by the call, but it seems like you must be getting one you don't handle.

    Ioctl list supported by my driver and it"s conform and verified :
    IOCTL_MOUNTDEV_QUERY_DEVICE_NAME which return \device\ddisk_vdisk_index_0

    other ioctl supported by my device :
    IOCTL_DISK_CHECK_VERIFY
    IOCTL_DISK_GET_PARTITION_INFO_EX
    IOCTL_DISK_UPDATE_DRIVE_SIZE
    IOCTL_STORAGE_GET_DEVICE_NUMBER
    IOCTL_DISK_CHECK_VERIFY
    IOCTL_DISK_IS_WRITABLE
    IOCTL_DISK_GET_LENGTH_INFO
    IOCTL_VOLUME_GET_GPT_ATTRIBUTES
    IOCTL_STORAGE_GET_DEVICE_NUMBER which return fixe number for trying mount disk into empty directory .

    List code ioctl which is not supported by driver :
    0x2d0c14
    0x2d1400
    0x4d0018

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,289

    0x2d0c14 is IOCTL_STORAGE_GET_HOTPLUG_INFO
    0x2d1400 is IOCTL_STORAGE_QUERY_PROPERTY
    0x4d0018 is IOCTL_MOUNTDEV_QUERY_STABLE_GUID

    It'll take a disk driver guy to tell us which one is the key one.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Gova_GimerGova_Gimer Member - All Emails Posts: 64

    IOCTL_MOUNTDEV_QUERY_STABLE_GUID is not documented and not implemented on truecrypt !
    IOCTL_STORAGE_GET_HOTPLUG_INFO is documented but not implemented on truecrypt because so no need for this function to be able to mount a disk on a directory
    IOCTL_STORAGE_QUERY_PROPERTY s documented but not implemented on truecrypt because so no need for this function to be able to mount a disk on a directory

  • craig_howardcraig_howard Member Posts: 238

    @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
  • Gova_GimerGova_Gimer Member - All Emails Posts: 64
    edited December 2021

    @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?

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,289

    So, FileSpy says your device is returning an error, and you don't believe it? Is that what you're saying?

    You can certainly open a support ticket, but that costs money, and if the problem is not a Windows problem (which this is not), then they won't refund the money.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Gova_GimerGova_Gimer Member - All Emails Posts: 64

    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.

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,289

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

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • craig_howardcraig_howard Member Posts: 238

    @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 ...

  • Gova_GimerGova_Gimer Member - All Emails Posts: 64

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

  • Gova_GimerGova_Gimer Member - All Emails Posts: 64

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

  • craig_howardcraig_howard Member Posts: 238

    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?

  • Gova_GimerGova_Gimer Member - All Emails Posts: 64

    @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.

  • craig_howardcraig_howard Member Posts: 238

    @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

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,289

    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, [email protected]
    Providenza & Boekelheide, Inc.

  • craig_howardcraig_howard Member Posts: 238

    @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 ...

  • Gova_GimerGova_Gimer Member - All Emails Posts: 64

    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!

  • Gova_GimerGova_Gimer Member - All Emails Posts: 64

    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 !

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,289

    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, [email protected]
    Providenza & Boekelheide, Inc.

  • Gova_GimerGova_Gimer Member - All Emails Posts: 64

    @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

  • Gova_GimerGova_Gimer Member - All Emails Posts: 64
    edited December 2021

    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.

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,289

    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.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Gova_GimerGova_Gimer Member - All Emails Posts: 64
    edited December 2021

    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.

    Post edited by Gova_Gimer on
  • Jeremy_HurrenJeremy_Hurren Member - All Emails Posts: 25

    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.

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,289

    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, [email protected]
    Providenza & Boekelheide, Inc.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Internals & Software Drivers 7 February 2022 Live, Online
Kernel Debugging 21 March 2022 Live, Online
Developing Minifilters 23 May 2022 Live, Online
Writing WDF Drivers 12 September 2022 Live, Online