Problem calling mount manager to mount a file

I have been working on this for some time and can’t figure out what’s going
wrong. I am trying to mount a file as a drive using IOCTL_MOUNTMGR_CREATE_POINT
sent to the mount manager. The call keeps causing a system crash So far here is
what I have done:

  1. I create a FILE_DEVICE_DISK object with name \Device\EncDiskVolume. This
    works correctly, I verified the creation using DeviceTree.
  2. I open the file using ZwCreateFile, use IoGetRelatedDeviceObject to get the
    related device object and add its stack size to the FILE_DEVICE_DISK’s stack
    size.
  3. I open the mount manager device and initialize the
    PMOUNTMGR_CREATE_POINT_INPUT structure. I followed the msdn pseudo code for
    this and create the irp using IoBuildDeviceIoControlRequest.
  4. I send the irp using IoCallDriver but every time, my system crashes here. The
    error report says that a “Thread is stuck in the device driver.”

Things I’ve tried:
i) I was also sending IOCTL_MOUNTMGR_VOLUME_ARRIVAL_NOTIFICATION but I deleted
this code since I read that the mount manager will take care of it regardless.

ii) I wrote support for IOCTL_MOUNTDEV_QUERY_UNIQUE_ID,
IOCTL_MOUNTDEV_QUERY_SUGGESTED_LINK_NAME and IOCTL_MOUNTDEV_QUERY_DEVICE_NAME
as the mount manager is supposed to query the client with these three codes,
but these requests are never received.

iii) I have returned before I run IoCallDriver and there is no crash but the
program does not close. It finishes in that it prints my success message which
occurs after the call to DeviceIoControl (I’m using a mount control code I
defined myself) in the test application.

iv) Every function I call, if it returns an error, I call IoCompleteRequest and
sets the irp’s IoStatus. This solved my crashes in the beginning of development,
but not this one.

v) I played with deleting handles and device object pointers in case mount
manager was unable to gain access to my device this did nothing. I also wrote a
driver unload routine.

I know this is a somewhat vague question but I would appreciate any help, I
started doing this for the first time about a month ago and have progressed and
continued learning but I have been stuck on this one error for some time and
have no idea where I am going wrong. Any insight would be greatly appreciated.

Thank you in advance


This message was sent using IMP, the Internet Messaging Program.

Try using DefineDosDevice instead.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From:
To: “Windows System Software Devs Interest List”
Sent: Saturday, July 02, 2005 1:14 AM
Subject: [ntdev] Problem calling mount manager to mount a file

> I have been working on this for some time and can’t figure out what’s going
> wrong. I am trying to mount a file as a drive using
IOCTL_MOUNTMGR_CREATE_POINT
> sent to the mount manager. The call keeps causing a system crash So far here
is
> what I have done:
> 1) I create a FILE_DEVICE_DISK object with name \Device\EncDiskVolume. This
> works correctly, I verified the creation using DeviceTree.
> 2) I open the file using ZwCreateFile, use IoGetRelatedDeviceObject to get
the
> related device object and add its stack size to the FILE_DEVICE_DISK’s stack
> size.
> 3) I open the mount manager device and initialize the
> PMOUNTMGR_CREATE_POINT_INPUT structure. I followed the msdn pseudo code for
> this and create the irp using IoBuildDeviceIoControlRequest.
> 4) I send the irp using IoCallDriver but every time, my system crashes here.
The
> error report says that a “Thread is stuck in the device driver.”
>
> Things I’ve tried:
> i) I was also sending IOCTL_MOUNTMGR_VOLUME_ARRIVAL_NOTIFICATION but I
deleted
> this code since I read that the mount manager will take care of it
regardless.
>
> ii) I wrote support for IOCTL_MOUNTDEV_QUERY_UNIQUE_ID,
> IOCTL_MOUNTDEV_QUERY_SUGGESTED_LINK_NAME and IOCTL_MOUNTDEV_QUERY_DEVICE_NAME
> as the mount manager is supposed to query the client with these three codes,
> but these requests are never received.
>
> iii) I have returned before I run IoCallDriver and there is no crash but the
> program does not close. It finishes in that it prints my success message
which
> occurs after the call to DeviceIoControl (I’m using a mount control code I
> defined myself) in the test application.
>
> iv) Every function I call, if it returns an error, I call IoCompleteRequest
and
> sets the irp’s IoStatus. This solved my crashes in the beginning of
development,
> but not this one.
>
> v) I played with deleting handles and device object pointers in case mount
> manager was unable to gain access to my device this did nothing. I also wrote
a
> driver unload routine.
>
> I know this is a somewhat vague question but I would appreciate any help, I
> started doing this for the first time about a month ago and have progressed
and
> continued learning but I have been stuck on this one error for some time and
> have no idea where I am going wrong. Any insight would be greatly
appreciated.
>
> Thank you in advance
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com