How to attach to an unnamed device? Well typically the way you do this
is that you are registered as a filter or service for a particular
device stack and you use IoAttachDeviceToDeviceStack (as others have
correctly pointed out). Note that as a filter/service you are attaching
while the stack is being built up vs after the stack has been started
like your code below depends on (since IoAttachDevice sends an open to
the device you want to attach to and opens do not succeed until the
entire stack has been started).
Also, you are pointlessly converting from ansi to Unicode. You can
easily do this
UNICODE_STRING uHEARTDeviceName =
DECLARE_CONST_UNICODE_STRING(L"\Device\Heart");
Or this
UNICODE_STRING uHEARTDeviceName;
RtlInitUnicodeString(&uHEARTDeviceName, L"\Device\Heart");
Furthermore, it is a bit better to declare stack based strings without a
length, this
CCHAR ntNameBuffer[64] = “\Device\HEART”;
Should look like
CCHAR ntNameBuffer = “\Device\HEART”;
D
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Friday, July 06, 2007 2:39 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] [FILTER DRIVER][AGAIN][NOOB Level2] Unamed device
Hello,
i’ve got a new question about filters driver.
here’s a part of the code i used with success in some case
(…)
CCHAR ntNameBuffer[64] = “\Device\HEART”;
STRING ntNameString;
UNICODE_STRING uHEARTDeviceName;
RtlInitAnsiString( &ntNameString, ntNameBuffer );
NTSTATUS unicode_status = RtlAnsiStringToUnicodeString(
&uHEARTDeviceName, &ntNameString, TRUE );
(…) some debug print messages
status =
IoAttachDevice(pHEARTDeviceObject,&uHEARTDeviceName,&pHEARTDeviceExtensi
on->pHEARTDevice);
(etc…)
So, know i want to so the same with another edvice but when i want to
have the name of the device, th DeviceTree toll says (Unamed)
So i really don’t know what to do instead
CCHAR ntNameBuffer[64] = “\Device\HEART”;
and of course instead
status =
IoAttachDevice(pHEARTDeviceObject,&uHEARTDeviceName,&pHEARTDeviceExtensi
on->pHEARTDevice);
In a word how to attach my filter to an unamed device?
Thank’s in advance for your help.
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer