Discussion:
What is the most reliable way to get the handle for a DVD/CD drive ?
(too old to reply)
bilm
2009-06-22 16:14:53 UTC
Permalink
I've read the MS SDK & DDK on the subject and it seems to contain
information that conflicts with some of the posts from experts about
whether "claimed" status is relevant or not.

Some say these devices are always claimed by the port driver
early in the boot process so you always need to use the drive letter
"\\.\D:" with DevIO and others say you need to check the port driver
"claimed" status and if it's not claimed use "\\.\ScsiN:" where N = 0, 1, 2,
etc. but if it is already claimed then use the drive letter.

The handle is used most often for the SPTI
IOCTL_SCSI_PASS_THROUGH_DIRECT
but I also use it for other IOCTLs related to DVD & CD devices.

There is also the other related issue of user access. I know a user does not
have to have full Admin. Privs. for apps using the SPTI but they do have to
have write access ... ? Right ? How do I deal with that ?
Do I have to write my own kernel mode device driver ? Please say no.

bilm
JJ
2009-06-23 15:55:10 UTC
Permalink
Post by bilm
I've read the MS SDK & DDK on the subject and it seems to contain
information that conflicts with some of the posts from experts about
whether "claimed" status is relevant or not.
Some say these devices are always claimed by the port driver
Do you mean "claimed" as for "opened but shared" or "opened
exclusively"? Port drivers never open storage devices exclusively.
Post by bilm
early in the boot process so you always need to use the drive letter
"\\.\D:" with DevIO and others say you need to check the port driver
"claimed" status and if it's not claimed use "\\.\ScsiN:" where N = 0, 1, 2,
etc. but if it is already claimed then use the drive letter.
A drive letter is a DOS device name that is merely a mapper to the
actual device name. Both may refer to the same device. If opening by
device name fails, it'll be the same for its drive letter (if assigned).
Post by bilm
There is also the other related issue of user access. I know a user does not
have to have full Admin. Privs. for apps using the SPTI but they do have to
have write access ... ? Right ? How do I deal with that ?
Do I have to write my own kernel mode device driver ? Please say no.
That's incorrect. Everytime data needs to be sent via DeviceIoControl by
using the lpInBuffer parameter, the handle must be opened for write
access. Sending data (not just the IOCTL command) to a device counts as
writing it. For storage devices (and probably all devices), only users
that belong to Administrators group (or higher group) have write access
rights to those devices.

So if a user don't have enough access rights, there is no reliable way
to get access to a restricted device.

Loading...