Access Denied opening device with CreateFile?

J

Joe B.

I have been wading through using SetupDi... API to get a device path to use
in CreateFile so that I could open a USB HID device.
I can now get a device path, but when I try to open for
GENERIC_READ|GENERIC_WRITE, I get an error that only tells me "Access
Denied". If I use zero in dwDesiredAccess, I get a valid handle that I can
use for device query access and use HidD_GetAttributes to read the Vendor ID
and Product ID so on that level I know I am accessing the correct devices.
However, I am not sure how to debug the "Access Denied" error so that I can
open the devices to use WriteFile and ReadFile.
I have tried various combinations of DesiredAccess and ShareMode.
The documentation on CreateFile indicates that the SecurityAttributes are
ignored. I am using Vis Studio 2005, working in C, op system is XP.
Anyone have ideas?
Thanks
Joe
 
W

William DePalo [MVP VC++]

Joe B. said:
I have been wading through using SetupDi... API to get a device path to use
in CreateFile so that I could open a USB HID device.
I can now get a device path, but when I try to open for
GENERIC_READ|GENERIC_WRITE, I get an error that only tells me "Access
Denied". If I use zero in dwDesiredAccess, I get a valid handle that I
can use for device query access and use HidD_GetAttributes to read the
Vendor ID and Product ID so on that level I know I am accessing the
correct devices. However, I am not sure how to debug the "Access Denied"
error so that I can open the devices to use WriteFile and ReadFile.

To be honest, I have no experience with USB devices. If you were getting
that error on file access, I'd suggest looking into the sharing parameter.
If no one responds with more definitive information here you might try
posting again in the kernel group:

microsoft.public.win32.programmer.kernel

Regards.
Will
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top