We have a driver which allows to mount files as encrypted virtual disks. It works with no problem for years. Nowadays USB drives became widely available and users started to store our files/disks there. There are several problems which I’d like to solve:
-
when user clicks on Safely Remove Hardware icon, it doesn’t allow to eject USB drive when our disk is mounted because driver has opened a file there. Ideal solution would be to intercept this request and dismount virtual drive before. Is there any way how to get notified about it?
-
users tend to unplug USB drives without using above mentioned way. MS solved this situation by making volumes write-through. However, if virtual disk is mounted there, it isn’t write through which can cause problems (base file is opened in write-through mode but filesystem above uses cache). Is there some way how to force write-through mode on virtual volumes?
-
when base drive is removed, virtual drives stored there become unusable so they should be automatically dismounted. It can be done from user mode if an application or service intercepts WM_DEVICECHANGE broadcasts. I wonder if there are some kernel mode or alternative user mode ways.
Thanks.
Best regards,
Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http:://www.upek.com]
In the kernel, once you have a handle, you can call
IoRegisterPlugPlayNotifications on the handle. You will then be
notified when the stack representing the handle is being asked to be
removed (ie safely remove the hw). You will also be notified if this
fails so that you can reopen the handle. Look at the toastmon example
in the ddk on how to use this API. Kbdclass in the ddk also shows this.
(This is the same api you use to register for being told about device
interface GUID arrivals, but that is a different notification type
passed to this API.) This api answer the first and third questions you
have about when to close the handle you have open to the disk.
I think if you report the volume as removable (perhaps that is only an
attribute of the disk, I don’t kow), it becomes write through by
default. I am really not familiar with this area, so I can’t tell you
for sure.
d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Michal Vodicka
Sent: Thursday, May 20, 2004 9:27 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Virtual disk on USB drive
We have a driver which allows to mount files as encrypted virtual disks.
It works with no problem for years. Nowadays USB drives became widely
available and users started to store our files/disks there. There are
several problems which I’d like to solve:
-
when user clicks on Safely Remove Hardware icon, it doesn’t allow to
eject USB drive when our disk is mounted because driver has opened a
file there. Ideal solution would be to intercept this request and
dismount virtual drive before. Is there any way how to get notified
about it?
-
users tend to unplug USB drives without using above mentioned way. MS
solved this situation by making volumes write-through. However, if
virtual disk is mounted there, it isn’t write through which can cause
problems (base file is opened in write-through mode but filesystem above
uses cache). Is there some way how to force write-through mode on
virtual volumes?
-
when base drive is removed, virtual drives stored there become
unusable so they should be automatically dismounted. It can be done from
user mode if an application or service intercepts WM_DEVICECHANGE
broadcasts. I wonder if there are some kernel mode or alternative user
mode ways.
Thanks.
Best regards,
Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http:://www.upek.com]
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
Doron,
thanks, PNP notifications seem very promising, I didn’t know it can be used also for handles. As for removable volumes, I believe our drives are already flagged that way but my tests show at least NTFS is cached. Needs more investigation.
Best regards,
Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http:://www.upek.com]
From: xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com] on behalf of Doron Holan[SMTP:xxxxx@windows.microsoft.com]
Reply To: Windows System Software Devs Interest List
Sent: Friday, May 21, 2004 9:54 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Virtual disk on USB drive
In the kernel, once you have a handle, you can call
IoRegisterPlugPlayNotifications on the handle. You will then be
notified when the stack representing the handle is being asked to be
removed (ie safely remove the hw). You will also be notified if this
fails so that you can reopen the handle. Look at the toastmon example
in the ddk on how to use this API. Kbdclass in the ddk also shows this.
(This is the same api you use to register for being told about device
interface GUID arrivals, but that is a different notification type
passed to this API.) This api answer the first and third questions you
have about when to close the handle you have open to the disk.
I think if you report the volume as removable (perhaps that is only an
attribute of the disk, I don’t kow), it becomes write through by
default. I am really not familiar with this area, so I can’t tell you
for sure.
d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Michal Vodicka
Sent: Thursday, May 20, 2004 9:27 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Virtual disk on USB drive
We have a driver which allows to mount files as encrypted virtual disks.
It works with no problem for years. Nowadays USB drives became widely
available and users started to store our files/disks there. There are
several problems which I’d like to solve:
-
when user clicks on Safely Remove Hardware icon, it doesn’t allow to
eject USB drive when our disk is mounted because driver has opened a
file there. Ideal solution would be to intercept this request and
dismount virtual drive before. Is there any way how to get notified
about it?
-
users tend to unplug USB drives without using above mentioned way. MS
solved this situation by making volumes write-through. However, if
virtual disk is mounted there, it isn’t write through which can cause
problems (base file is opened in write-through mode but filesystem above
uses cache). Is there some way how to force write-through mode on
virtual volumes?
-
when base drive is removed, virtual drives stored there become
unusable so they should be automatically dismounted. It can be done from
user mode if an application or service intercepts WM_DEVICECHANGE
broadcasts. I wonder if there are some kernel mode or alternative user
mode ways.
Thanks.
Best regards,
Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http:://www.upek.com]
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@upek.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
>automatically dismounted. It can be done from user mode if an application or
service
intercepts WM_DEVICECHANGE broadcasts. I wonder if there are some kernel mode
or
IoRegisterPlugPlayNotification is the kernel-mode analog for WM_DEVICECHANGE.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
> ----------
From: xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com] on behalf of Maxim S. Shatskih[SMTP:xxxxx@storagecraft.com]
Reply To: Windows System Software Devs Interest List
Sent: Sunday, May 23, 2004 1:46 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Virtual disk on USB drive
>automatically dismounted. It can be done from user mode if an application or
service
>intercepts WM_DEVICECHANGE broadcasts. I wonder if there are some kernel mode
or
IoRegisterPlugPlayNotification is the kernel-mode analog for WM_DEVICECHANGE.
Yes, it was already advised and works well for me (it is great file handle can be used there). Actually, I’d say WM_DEVICECHANGE is a small subset of this functionality.
Best regards,
Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http:://www.upek.com]