Hi Raniel,
Please keep the discussion on the list. This ensures answers are
archived, and can be searched by others in the future.
(1) First parameter to CreateFile() for the first handle is
“\\?\USBSTOR#CdRom&Ven…”.
(2) For the second CreateFile(), I think you can use the
GetVolumeNameForVolumeMountPoint() result. However, you should verify
an exclusive handle there also blocks access via the mount points.
(3) “\?\E:” is ‘?\E:’. You need two whacks at the start, so try
“\\?\E:” instead.
Summary (psuedo-code) for using SetupDi functions:
// get a handle to CDROM device class using guid
deviceInfo = SetupDiGetClassDevs(&GUID_DEVINTERFACE_CDROM, NULL, NULL,
(DIGCF_PRESENT | DIGCF_INTERFACEDEVICE) );
// loop through all recorders
BOOL success = TRUE;
for (ULONG i = 0; success; i++)
// Get the device interface data
// loop until GetLastError() == ERROR_NO_MORE_ITEMS
success =
SetupDiEnumDeviceInterfaces(deviceInfo,0,&GUID_DEVINTERFACE_CDROM, I,
&diData);
// Get the device interface data details –
// Normally you call with NULL/0 and then allocate a buffer of
// size usedBuffer + sizeof(TCHAR) (the extra TCHAR ensures
null-terminated path)
success = SetupDiGetDeviceInterfaceDetail(
deviceInfo,&diData,
largeBuffer,largeBufferSize,
&usedBuffer,NULL
);
// The device interface string is part of the result, but may not be
NULL terminated?
((PSP_DEVICE_INTERFACE_DETAIL_DATA)largeBuffer)->DevicePath;
// Open the device, inquiry to detect if it’s one you need to deal
with,
// save in array/list/etc.
Summary for converting SetupDi CDROM paths to volume name and mount
points:
===
Volume name is useful programmatically. Mount points are much more
user-friendly, and most often include the drive letter.
(1) Append a trailing slash character to the SetupDi path.
(2) Call GetVolumeNameForVolumeMountPoint() with large buffer.
- This is the volume name. Easy, eh?
(3) Call GetVolumePathNamesForVolumeName() with large buffer.
- The result is a MULTI_SZ of all path names. The MULTI_SZ could
be empty (‘\0\0’) if no drive letters/mount points, have only
one string (‘F:\\0\0’) or (‘C:\CDDrives\First\\0\0’), or it
could have multiple strings:
(‘F:\\0C:\CDDrives\First\\0\0’) or even
(‘C:\CDDrives\First\\0F:\\0\0’)
Look through MSDN for details on each function. When stuck, guess and
try a few things – there is nothing like experimentation to help flesh
out the details of how stuff works.
.
-----Original Message-----
From: Raneil Ensomo [mailto:xxxxx@eppi.epson.com.ph]
Sent: Friday, January 20, 2006 2:54 AM
To: Henry Gabryjelski
Subject: RE: [ntdev] Question on Exclusive access & Hiding a Special
CD-RO M Drive…
It’s me again. I tried your suggestion the entire day but couldn’t seem
to
make it work. I did the following as you suggested:
During the first CreateFile, I used:
\\?\USBSTOR#CdRom&Ven_PLEXTOR&Prod_DVDR___PX-716A&Rev_1.09#004420350A
&0#{
1186654d-47b8-48b9-beb9-7df113ae3c67} (i manually searched the registry
for
this one)
During the second CreateFile, I used the value I got from
GetVolumeNameForVolumeMountPoint (minus the trailing backslash).
And then I called DeviceIoControl using the handle from the first
CreateFile. Actually, DeviceIoControl succeeded.
I’ve also tried other things like using “\?\E:” for the 2nd CreateFile
and
so forth, but to no avail.
What could I have done wrong?
Thanks a lot, Sir. I really appreciate it.
Best Regards,
Raneil
-----Original Message-----
From: Raneil Ensomo
Sent: Friday, January 20, 2006 2:02 PM
To: ‘Henry Gabryjelski’
Subject: RE: [ntdev] Question on Exclusive access & Hiding a Special
CD-RO M
Drive…
I would like to ask for some clarifications, if you don’t mind…
Regarding #1, what do I use as parameter to CreateFile on the second
call?
On the first, I used the path obtained from SetupDi functions.
On the second, should I use the one returned by
GetVolumeNameForVolumeMountPoint?
And should I send IOCTL_STORAGE_MCN_CONTROL after the second CreateFile?
Thanks a lot. And sorry for the trouble:)
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Henry Gabryjelski
Sent: Friday, January 20, 2006 3:04 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Question on Exclusive access & Hiding a Special
CD-RO M
Drive…
Two super-simple options that avoid drivers altogether:
(1) Open two exclusive handles to the device(*), and disable MCN
(IOCTL_STORAGE_MCN_CONTROL) via the direct-device handle if you want to
disable the driver pinging the device to detect media changes.
(*) Two handles are required for reasons that are too long to describe
here.
The first handle should be opened using CreateFile() with the path
obtained from SetupDi functions. It will look similar to
“\?\ide#cdromvendor_dvd_rom__________________1.02_________#5&23ba5cf8&0
&1.0.0#{53f56308-b6bf-11d0-94f0-00a0c91efb8b}”. If necessary to filter
only your devices, you can open a non-exclusive handle first, and send
an INQUIRY to the device via IOCTL_SCSI_PASS_THROUGH_DIRECT.
The second handle should be opened using CreateFile() only if the device
has at least one volume mount point. Volume mount points include drive
letters, but drive can also be mounted in empty NTFS directories. (You
will need to investigate if you must open an exclusive access handle for
each mount point, or if one is sufficient for all mount points). To
getting the volume mount points, take the PNP ID above, add a trailing
slash '' character, and call GetVolumeNameForVolumeMountPoint(). Then
use that string for a call to GetVolumePathNamesForVolumeName().
(2) Set a strong ACL on the device (such as for a user/group you define
during your software install), and then run the “special” application
under that user/group. (Or, impersonate that user/group just long
enough to get a handle to the device.)
Hope that helps,
.
-----Original Message-----
From: Raneil Ensomo [mailto:xxxxx@eppi.epson.com.ph]
Sent: Wednesday, January 18, 2006 4:47 PM
Subject: RE: Question on Exclusive access & Hiding a Special CD-RO M
Drive…
Our current project is developing a machine that copies DVD/CD in a mass
scale.
This machine includes a printer (for the CD label), DVD/CD drives, etc.
These are all connected
through a USB hub. And so other than our application that manages the
DVD/CD copying, we
don’t want any other applications to access our DVD/CD drive…
Sorry if I’ve misled you with my question. just a newbie driver
developer…
could anyone
help me with my prob? thanks a lot, i’d appreciate it…
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Arlie Davis
Sent: Thursday, January 19, 2006 6:11 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Question on Exclusive access & Hiding a Special
CD-ROM
Drive…
Oh, they ARE trying to benefit their user base. It’s just that the
people
in their user base are not the owners of the computers who will run this
software. They’re the people who will distribute the software.
– arlie
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@probo.com
Sent: Wednesday, January 18, 2006 3:57 PM
To: Windows System Software Devs Interest List
Cc: Tim Roberts
Subject: Re: [ntdev] Question on Exclusive access & Hiding a Special
CD-ROM
Drive…
On Wed, Jan 18, 2006 at 08:49:55AM +0800, Raneil Ensomo wrote:
I have this problem on how to support the following on a special
dedicated CD-ROM drive:
-
Only our user-mode application can access the drive.
Other applications should not be able to access it.
-
The CD-ROM drive should not be displayed through Windows Explorer
under any circumstances (the best case is actually never to display it
anywhere, not even in Device Manager).
What is the POINT of this?
Honestly, there are approximately as many postings on this list from
people
trying to PREVENT the normal operation of their computers, as there are
from
people trying to BENEFIT their user base.
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@stonestreetone.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@eppi.epson.com.ph
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: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com