I'd like to link my drivers 'DOS' devicename to information I get from the
DDK's 'SetupDi....' functions.
My SPDRP_PHYSICAL_DEVICE_OBJECT_NAME looks somthing like
'\Device\NTPNP_PCI0007'
But I can't find a way to match that to the name I use to access the driver
from usermode.
I tried QueryDosDevice but what I get from that is something like
'\Device\mydevice'.
Is there some (un-) documented api that can help me here ?
thanks Reto
ps: the goal of this is to retrieve information about my device (like
slotnumber, driver-file version ....)
ps2: The application does not need to run on win9x.
- Liming
Disclaimer:
This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net? http://www.gotdotnet.com
--------------------
> From: "Reto Ravasio" <nos...@nowhere.com>
> Subject: Linking 'DOS' device name to 'SetupDi....' functions
> Date: Wed, 3 Jul 2002 10:19:53 +0200
> Lines: 24
> X-Priority: 3
> X-MSMail-Priority: Normal
> X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
> Message-ID: <uzE7SnmICHA.1760@tkmsftngp11>
> Newsgroups: microsoft.public.win32.programmer.kernel
> NNTP-Posting-Host: 194.209.29.33
> Path: cpmsftngxa07!tkmsftngp01!tkmsftngp11
> Xref: cpmsftngxa07 microsoft.public.win32.programmer.kernel:1794
> X-Tomcat-NG: microsoft.public.win32.programmer.kernel
Thanks for the prompt reply.
I tried what you suggested but fail to provide an InterfaceClassGuid for my
device.
We have simple shared-memory pci cards whose driver provides names like
<mydevice>0, <mydevice>1, ...
I've just now read up on device interfaces (I didn't know what they where
for) but I'm still very confused.
Unfortunately it's not possible to change the driver-code as there are
already deployed drivers and applications which rely on the 'old' naming
scheme :-(
reto
"Liming" <LMFAN...@Microsoft.com> wrote in message
news:Q0HTJLzICHA.4244@cpmsftngxa08...
Basically we call IoRegisterDeviceInterface with a InterfaceClassGuid in
WDM driver to register a device interface. And we must use the same GUID to
enumerate the device interfaces with SetupDi routines in user mode apps.
Meanwhile, for legacy NT driver, we call IoCreateSymbolicLink to create a
corresponding symbolic name for an existing DO.
I'm not sure what you what to do. If you just want to query the device
object names for all the symbolic name, QueryDosDevice is enough.
char *p, SymbolicNames[BUFSIZE], DeviceName[BUFSIZE];
QueryDosDevice(NULL, SymbolicNames, BUFSIZE);
p = SymbolicNames;
while(*p){
printf("\nSymbolic Name = %s\n", p);
QueryDosDevice(p, DeviceName, BUFSIZE);
printf("Device Name = %s\n", DeviceName);
p+=strlen(p); p++;
}
Hope helps.
- Liming
Disclaimer:
This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net? http://www.gotdotnet.com
--------------------
> From: "Reto Ravasio" <nos...@nowhere.com>
> References: <uzE7SnmICHA.1760@tkmsftngp11> <Q0HTJLzICHA.4244@cpmsftngxa08>
> Subject: Re: Linking 'DOS' device name to 'SetupDi....' functions
> Date: Thu, 4 Jul 2002 23:15:20 +0200
> Lines: 78
> X-Priority: 3
> X-MSMail-Priority: Normal
> X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
> Message-ID: <uiisLE6ICHA.1784@tkmsftngp12>
> Newsgroups: microsoft.public.win32.programmer.kernel
> NNTP-Posting-Host: 212.254.98.180
> Path: cpmsftngxa07!tkmsftngp01!tkmsftngp12
> Xref: cpmsftngxa07 microsoft.public.win32.programmer.kernel:1828
> X-Tomcat-NG: microsoft.public.win32.programmer.kernel
Obviously what I have here is a 'legacy' driver. I had a look at the
DriverWorks framwork (from NuMega) which we use and it calls
IoCreateSymbolicLink somewhere deep down. The problem I have is that with
the SetupDi.... functions I can get all the information I want but I can't
link this information to the symbolic name I use from usermode.
the following is a table i get by enumerating devices with the SetupDi
functions:
SPDRP_CLASS SPDRP_COMPATIBLEIDS SPDRP_DEVICEDESC SPDRP_DRIVER
SPDRP_HARDWAREID SPDRP_LOCATION_INFORMATION SPDRP_MFG
SPDRP_PHYSICAL_DEVICE_OBJECT_NAME SPDRP_SERVICE SPDRP_UI_NUMBER
Class CompatibleIDs DeviceDesc Driver HardwareID LocationInformation
Mfg PhysicalDeviceObjectName Service UiNumber
ESECDevices PCI\VEN_1618&CC_0B4000 Vipr60 (Carina) TI-C6x Board
{611646A4-48D6-4AB7-BB7A-442F1E561E91}\0000
PCI\VEN_1618&DEV_1002&SUBSYS_00000000&REV_01 PCI bus 0, device 10, function
0 ESEC SA (MACS) \Device\NTPNP_PCI0007 MaCSV60 DW: 3
ESECDevices PCI\VEN_1618&DEV_2001&REV_02 Pio60 TI-C6x Board
{611646A4-48D6-4AB7-BB7A-442F1E561E91}\0002
PCI\VEN_1618&DEV_2001&SUBSYS_BFECEF11&REV_02 PCI bus 0, device 11, function
0 ESEC SA (MACS) \Device\NTPNP_PCI0008 Pio60 DW: 2
ESECDevices PCI\VEN_1618&DEV_2002&REV_02 Pio60 (Carina) TI-C6x Board
{611646A4-48D6-4AB7-BB7A-442F1E561E91}\0007
PCI\VEN_1618&DEV_2002&SUBSYS_BFECEF11&REV_02 PCI bus 0, device 12, function
0 ESEC SA (MACS) \Device\NTPNP_PCI0009 MaCSP60 DW: 1
Unfortunately, none of the entries in the table matches the symbolic name I
use from usermode. I could implement some sort of sophisticated guessing
algoritm. But this would be getting difficult when more the one board of the
same type is plugged in.
(The three above boards have a different board-layout, firmware
configuration)
Reto
Ps:
We have a tool that displays the boards hardware, firmware and software
configuration and I'd like to add some of the information in the above
table.
ps2:
I already tried QueryDosDevice and tried to use the undocumented
NtQuerySymbolicLinkObject but to no avail.
"Liming" <LMFAN...@Microsoft.com> wrote in message
news:UeFwBn#ICHA.3604@cpmsftngxa08...
- Liming
Disclaimer:
This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net? http://www.gotdotnet.com
--------------------
> From: "Reto Ravasio" <nos...@nowhere.com>
> References: <uzE7SnmICHA.1760@tkmsftngp11>
<Q0HTJLzICHA.4244@cpmsftngxa08> <uiisLE6ICHA.1784@tkmsftngp12>
<UeFwBn#ICHA.3604@cpmsftngxa08>
> Subject: Re: Linking 'DOS' device name to 'SetupDi....' functions
> Date: Fri, 5 Jul 2002 11:18:26 +0200
> Lines: 532
> MIME-Version: 1.0
> Content-Type: multipart/alternative;
> boundary="----=_NextPart_000_0041_01C22415.AF153130"
> X-Priority: 3
> X-MSMail-Priority: Normal
> X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
> Message-ID: <eefjTRAJCHA.2232@tkmsftngp12>
> Newsgroups: microsoft.public.win32.programmer.kernel
> NNTP-Posting-Host: 194.209.28.248
> Path: cpmsftngxa08!tkmsftngp01!tkmsftngp12
> Xref: cpmsftngxa08 microsoft.public.win32.programmer.kernel:1847
> X-Tomcat-NG: microsoft.public.win32.programmer.kernel
The physical device name it get from the SetupDi function is
'\Device\NTPNP_PCI0007'
But I get an '\Device\MaCSV600' when I feed 'MaCSV600' into QueryDosDevice.
note: 'MaCSV600 is the name I use with 'CreateFile' (first instance of
MaCSV60)
When looking at the output from WinObj (from www.sysinternals.com) I can see
that the NTPNP_PCI0007 can't be seen anymore.
It seems that when I create a symbolic link from my driver
(IoCreateSymbolicLink) the ObjectManager remembers the new name and
'forgets' the original name. Unfortunately, the SetupDi functions still give
me the original name. I get the feeling that there is something broken deep
inside these functions :-(
'\Device\NTPNP_PCI0007' and '\Device\MaCSV600' refer to the same device
object. I know because I know my hardware. But how can I find out if there
is more then one board of the same type plugged in?
Reto
"Liming" <LMFAN...@Microsoft.com> wrote in message
news:flmUaXlJCHA.1648@cpmsftngxa07...
You may want to check out DDK document on the definition of DevNode / PDO /
FDO first. Basically when you refer to 'device' you are actually talking
about a devnode which composes of several device objects. The lowest
devobj is PDO which is created by the bus driver (PCI); the upper one is
FDO which is created by your driver. That is, the layout will look like
this:
DevNode: Vipr60 (Carina) TI-C6x Board
FDO: \device\MaCSV600 <--- link name: \??\MacCSV600
PDO: \device\NTPNP_PCI0007
If there are multiple adapters, the layout might look like this:
devnode0:
fdo: \device\macsv600 <--- link name: \??\MacCSV600
pdo: \device\ntpnp_pci007
devnode1:
fdo: \device\macsv601 <--- link name: \??\MacCSV601
pdo: \device\ntpnp_pci008
devnode2:
fdo: \device\macsv602 <--- link name: \??\MacCSV602
pdo: \device\ntpnp_pci009
Your driver (and OS, and PCI driver) are free to imeplement symbolic links.
For a 'legacy' driver, it's the driver developer's responsibility to
DOCUMENT his own naming schema to the app developer. e.g. \??\MacCSV60<N>
is the Nth instance of the adapter. SetupDi CANNOT help the app developer
to know / predict / guess the symbol link name of the devices in this
scenario.
As to your other questions:
SetupDi(SPDRP_PHYSICAL_DEVICE_OBJECT_NAME), as documented, returns the
PDO's device name (generated by parent bus driver, pci), which generally
you should not care about.
SetupDi(SPDRP_UI_NUMBER), can be used to determine the slot which the
adapter is plugged into (for PCI adapters only)
WinObj should tell you that there is a ntpnp_pci007 in \device directory
all the time.
IoCreateSymbolicLink simply add an entry in \?? directory (assuming that
your target symbolic contains \?? prefix) which points to another object in
ObjMgr's direcotry hierarchy. It never 'forgets' the original name (unless
you use the same symbolic name to point to a different object).
Hope this helps.
thanks
wei
--
I think I found a solution now :-)
I can implement a new 'DeviceIoControl' function that reads the pdo name
from the lower device (by calling
IoGetDeviceProperty(DevicePropertyPhysicalDeviceObjectName)) .
In usermode I then enumerate all device and match the
'SPDRP_PHYSICAL_DEVICE_OBJECT_NAME' with the name I get from calling my new
IOCTRL function.
The disadvantage of this is that I have to build a new version of the driver
:-(
The advantage is that I can reduce kernel-code to a minimum and do the heavy
lifting in userland :-)
Thanks a lot...
reto
"Wei Mao [MSFT]" <weimao...@microsoft.dot.com> wrote in message
news:7Oh$YmvJCHA.4244@cpmsftngxa08...
I think now I fully understand what you would like to do. :) Your idea is
not bad, because it's quite difficult to address the FDO from a PDO name by
calling SetupDi or other documented way. Have you tried Walter Oney's
DEVVIEW utility? (which is shipped with the book "Programming the Microsoft
Windows Driver Model") It implemented another driver to explore
undocumented link info in kernel mode.
Have a good day!
- Liming
Disclaimer:
This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net? http://www.gotdotnet.com
--------------------
> From: "Reto Ravasio" <nos...@nowhere.com>
>
Getting at the device properties is no problem anymore (thanks a lot, liming
and wei)
Accessing driver information will be the next step, but before that I better
start reading chapter 2 of Walter's book.
cu
reto
"Liming" <LMFAN...@Microsoft.com> wrote in message
news:L#Y9Mz#JCHA.3204@cpmsftngxa08...