CreateFile To Device Interface fails (ACCESS_DENIED)

I have posted this problem before, but due to being diverted onto other work, the boards will not let me add to the thread, as it is too old.

So here is the problem:
I have an upper filter attached to the video device stack (GUID {4D36E968-E325-11CE-BFC1-08002BE10318}). I want to be able to talk to this filter driver. I therefore call IoRegisterDeviceInterface in my AddDevice routine, giving a unique GUID and then call IoSetDeviceInterfaceState to enable the interface.

However when I try and access the interface from my application it fails. I use the SetupDi routines to enumerate the interfaces and get the elaborate name for the interface. This name contains the device name for the video and the GUID for my interface. When I call CreateFile(Device_Name, FILE_ANY_ACCESS, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL) I get an invalid file handle. GetLastError gives 0x5 (ACCESS DENIED).

From responses to my previous request I sumise that parts of the video stack have been allocated exclusively by the GDI system. I thought that the system would allow access to my private interface though.

So my question is “How can I talk to my filter driver from an application?”. I am relatively new to device driver writing, so it is entirely possible I am making a stupid mistake.

Many thanks in advance.

What supported things can you from a video filter driver? What problem are you trying to solve?

if the existing stack doesn’t let you open a handle, enumerate a raw pdo or create a control device and talk to your filter through it.
d

debt from my phone


From: xxxxx@trdeo.co.uk
Sent: 6/19/2012 8:01 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] CreateFile To Device Interface fails (ACCESS_DENIED)

I have posted this problem before, but due to being diverted onto other work, the boards will not let me add to the thread, as it is too old.

So here is the problem:
I have an upper filter attached to the video device stack (GUID {4D36E968-E325-11CE-BFC1-08002BE10318}). I want to be able to talk to this filter driver. I therefore call IoRegisterDeviceInterface in my AddDevice routine, giving a unique GUID and then call IoSetDeviceInterfaceState to enable the interface.

However when I try and access the interface from my application it fails. I use the SetupDi routines to enumerate the interfaces and get the elaborate name for the interface. This name contains the device name for the video and the GUID for my interface. When I call CreateFile(Device_Name, FILE_ANY_ACCESS, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL) I get an invalid file handle. GetLastError gives 0x5 (ACCESS DENIED).

From responses to my previous request I sumise that parts of the video stack have been allocated exclusively by the GDI system. I thought that the system would allow access to my private interface though.

So my question is “How can I talk to my filter driver from an application?”. I am relatively new to device driver writing, so it is entirely possible I am making a stupid mistake.

Many thanks in advance.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

FILE_ANY_ACCESS is NOT a valid access mask argument for CreateFile.

FILE_ANY_ACCESS is ONLY used in CTL_CODE macro.

xxxxx@trdeo.co.uk wrote:

I have an upper filter attached to the video device stack (GUID {4D36E968-E325-11CE-BFC1-08002BE10318}). I want to be able to talk to this filter driver. I therefore call IoRegisterDeviceInterface in my AddDevice routine, giving a unique GUID and then call IoSetDeviceInterfaceState to enable the interface.

Assuming this worked, what is it that you hope to catch? You’re
intercepting requests from the display driver, sent via win32k.sys, into
the video port / miniport pair. There is very little in that exchange
that is useful. There is a flurry of activity at start up time, but
after that, that path is quiet until shutdown. No graphics operations
are ever forwarded to the miniport.

However when I try and access the interface from my application it fails. I use the SetupDi routines to enumerate the interfaces and get the elaborate name for the interface. This name contains the device name for the video and the GUID for my interface. When I call CreateFile(Device_Name, FILE_ANY_ACCESS, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL) I get an invalid file handle. GetLastError gives 0x5 (ACCESS DENIED).

Use GENERIC_READ|GENERIC_WRITE instead of FILE_ANY_ACCESS.

From responses to my previous request I sumise that parts of the video stack have been allocated exclusively by the GDI system. I thought that the system would allow access to my private interface though.

No. A device interface is just a way to assign a name to an existing
device stack, of which your filter is just one part. When you call
CreateFile, the request is sent through you down to the miniport FDO,
and that’s already opened exclusively by the display driver.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

>invalid file handle. GetLastError gives 0x5 (ACCESS DENIED).

Well, at least the name is OK and thus the interface stuff is OK.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com