- Registering a Device Interface Class: CreateFile fails
- Posted by Tareq on June 30th, 2004
Hi All,
I've registered an interface for my filter driver and and it produces
the messy name for the device. Now, from the client application,
CreateFile fails returning 2 (GetLastError) which is "The system cannot
find the file specified".
In my AddDevice routine, i'm using the following line of code.
IoRegisterDeviceInterface(pdo, &GUID_MY_DEVICE, NULL,
&pdx->SymbolicLinkName);
and in IRP_MN_START_DEVICE
IoSetDeviceInterfaceState(&pdx->SymbolicLinkName, TRUE);
both of returns success. Is there anything else i need to include in the
driver? Also, i've modified the ddk\src\wdm\usb\isousb\exe sample and
replaced the guid with GUID_MY_DEVICE. Here, CreateFile also fails. I'm
assuming i have to write more code in my driver. Anything wrong i am
doing? Thanks in advance.
-t
- Posted by Maxim S. Shatskih on June 30th, 2004
Maybe something is wrong in user mode code. Use WinObj to check whether the
name you're trying to open really exists.
--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com
"Tareq" <tareq@example.net> wrote in message
news:uD4o2PqXEHA.2816@TK2MSFTNGP11.phx.gbl...
- Posted by Doron Holan [MS] on June 30th, 2004
which type of device stack are you filtering? certains stacks do not allow
user mode creates to succeed, or more then one create to succeed, etc etc...
d
--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"Tareq" <tareq@example.net> wrote in message
news:uD4o2PqXEHA.2816@TK2MSFTNGP11.phx.gbl...
- Posted by Tareq on July 1st, 2004
Doron Holan [MS] wrote:
Its a filter driver for USB audio card. The symbolic link is present in
WinObj. the create file api goes like this:
m_hDevice = ::CreateFile(m_linkname,
0,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);
here m_linkname is something like this:
\\?\usb#vid_xxxx&pid_xxxx&mi_xx#x&xxxxxxx&x&x#{xxx xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
- Posted by Doron Holan [MS] on July 1st, 2004
what does GetLastError() return?
--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"Tareq" <tareq@example.net> wrote in message
news:%23Vep38yXEHA.2812@TK2MSFTNGP11.phx.gbl...
xxxxxxx}
- Posted by Tareq on July 1st, 2004
Doron Holan [MS] wrote:
- Posted by Tareq on July 1st, 2004
Doron Holan [MS] wrote:
Ok ... let me explain it from the start. I have a "lower filter" driver
for a usb audio device. Now, In my AddDevice routine, i'm using:
IoRegisterDeviceInterface(pdo, &GUID_MY_FILTER_DEVICE, NULL,
&pdx->SymbolicLinkName);
and in the PNP functions: IRP_MN_START_DEVICE a IRP_MN_REMOVE_DEVICE i'm
using the following lines:
IoSetDeviceInterfaceState(&pdx->SymbolicLinkName, TRUE);
and,
IoSetDeviceInterfaceState(&pdx->SymbolicLinkName, FALSE);
RtlFreeUnicodeString(&pdx->SymbolicLinkName);
all these functions are checked for success. Now, in my user mode client
program, I'm using:
m_hDevice = ::CreateFile(m_linkname,
0,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);
where m_linkname is generated by SetupDiXXX functions and is something
like this:
\\?\usb#vid_xxxx&pid_xxxx&mi_xx#x&xxxxxxx&x&x#{xxx xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
Now, in WinObj, this link is present when i plug in the device. But
CreateFile returns INVALID_HANDLE_VALUE and GetLastError returns 2 which
is ERROR_FILE_NOT_FOUND.
Lastly, I've found this MSDN KB article
(http://support.microsoft.com/default...;EN-US;Q262305) saying
that this approach wont work for "lower filter" devices (unfortunately
mine is a lowerfilter). So going for the alternative suggested in that
article. But registering the device interface was a quite easy and
required much less code. Is this the only way for "lower filter"
drivers? Thank you all for your help.
- Posted by Doron Holan [MS] on July 1st, 2004
my guess is that the driver on top of you does not support IRP_MJ_CREATE and
it fails the create irp, so your filter will never see it. the control
device object is a good alternative.
d
--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"Tareq" <tareq@example.net> wrote in message
news:eX8d5w1XEHA.3420@TK2MSFTNGP12.phx.gbl...
xxxxxxx}
- Posted by Tareq on July 1st, 2004
Doron Holan [MS] wrote:
context with the filter driver?
- Posted by Doron Holan [MS] on July 2nd, 2004
thread context doesn't matter. the layered stack of device objects is what
matters. creates go to specific devices, not the driver itself that created
them. since you create a device object on the side, the device stack above
you that you are filtering does not know about it.
d
--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"Tareq" <tareq@example.net> wrote in message
news:OzAe5Q4XEHA.2672@tk2msftngp13.phx.gbl...