Discussion:
Using NDISProto protocol
(too old to reply)
NYA
2006-07-21 01:56:09 UTC
Permalink
Hello

There are 2 ways of opening a handle to the network card.

[1] By first opening a stream to the ndisuio/clone of ndisprot protocol
driver and then binding it to the underlying mac--
handle=CreateFile("\\\\.\\\\ndisprot",......);
DeviceIoControl(handle, IOCTL_NDISUIO_BIND_WAIT.....);

//After enumerating and selecting a device, a
DeviceIoControl(Handle, IOCTL_NDISPROT_OPEN_DEVICE,
(LPVOID)&wNdisDeviceName[0]......);


[2] But if we already know the device name we can use the name to open
a handle to thre adapter.
createfile("\\\\.\\{2AA42F55-F......


What is the difference between the two methods? Will a protocol driver
be used internally or for further deviceiocontrol request if the handle
is opened by the second method?
If yes, then supposing if i have an ndisprot cloned protocol driver
(from win2k3 server ddk) installed. then which protocol driver will be
used internally the ndisuio (default xp installed) or the ndisprot
clone(installed by user)? This is beacuse both of the drivers could be
used. How can i make sure that in this case my calls are passed through
ndisproto clone?

If no then will any protocol driver be used for further OID Requests
from deviceiocontrol

Thanks
Nishchal
Thomas F. Divine [DDK MVP]
2006-07-21 02:24:24 UTC
Permalink
Post by NYA
Hello
There are 2 ways of opening a handle to the network card.
[1] By first opening a stream to the ndisuio/clone of ndisprot protocol
driver and then binding it to the underlying mac--
handle=CreateFile("\\\\.\\\\ndisprot",......);
DeviceIoControl(handle, IOCTL_NDISUIO_BIND_WAIT.....);
//After enumerating and selecting a device, a
DeviceIoControl(Handle, IOCTL_NDISPROT_OPEN_DEVICE,
(LPVOID)&wNdisDeviceName[0]......);
This is an open on NDISPROT.
Post by NYA
[2] But if we already know the device name we can use the name to open
a handle to thre adapter.
createfile("\\\\.\\{2AA42F55-F......
Don't have a clue as to what you are opening here.
Post by NYA
What is the difference between the two methods? Will a protocol driver
be used internally or for further deviceiocontrol request if the handle
is opened by the second method?
If yes, then supposing if i have an ndisprot cloned protocol driver
(from win2k3 server ddk) installed. then which protocol driver will be
used internally the ndisuio (default xp installed) or the ndisprot
clone(installed by user)? This is beacuse both of the drivers could be
used. How can i make sure that in this case my calls are passed through
ndisproto clone?
In your "clone" NDISPROT change the NT_DEVICE_NAME and DOS_DEVICE_NAME to
something of your own.

See the notes at this page:

http://www.ndis.com/pcakb/KB01010301.htm

Thomas F. Divine, Windows DDK MVP
www.ndis.com
Post by NYA
If no then will any protocol driver be used for further OID Requests
from deviceiocontrol
Thanks
Nishchal
NYA
2006-07-21 03:08:13 UTC
Permalink
Thanks Thomas.

In the 2nd option instead of opening a handle to the protocol driver
then binding it to the network adapter if we know the device name of
the network adapter then we can open a handle to this directly. In
this CreateFile call, the application should pass a pointer to a
null-terminated string that specifies the name of the device that NDIS
registered. For NT-based operating systems, the application can
retrieve the name from the ServiceName value of the
"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows
NT\CurrentVersion\NetworkCards\Nnn" key in the registry, where Nnn is
the string for the adapter's instance number. The string should be of
the form "\\.\Xxx", where Xxx is the string for the adapter's service
name.

So in the call createfile("\\\\.\\{2AA42F55-F......") so we pass the
name of the device here. And thus this do not use any protcol driver to
access the adapter.

-Nishchal
Post by Thomas F. Divine [DDK MVP]
Post by NYA
Hello
There are 2 ways of opening a handle to the network card.
[1] By first opening a stream to the ndisuio/clone of ndisprot protocol
driver and then binding it to the underlying mac--
handle=CreateFile("\\\\.\\\\ndisprot",......);
DeviceIoControl(handle, IOCTL_NDISUIO_BIND_WAIT.....);
//After enumerating and selecting a device, a
DeviceIoControl(Handle, IOCTL_NDISPROT_OPEN_DEVICE,
(LPVOID)&wNdisDeviceName[0]......);
This is an open on NDISPROT.
Post by NYA
[2] But if we already know the device name we can use the name to open
a handle to thre adapter.
createfile("\\\\.\\{2AA42F55-F......
Don't have a clue as to what you are opening here.
Post by NYA
What is the difference between the two methods? Will a protocol driver
be used internally or for further deviceiocontrol request if the handle
is opened by the second method?
If yes, then supposing if i have an ndisprot cloned protocol driver
(from win2k3 server ddk) installed. then which protocol driver will be
used internally the ndisuio (default xp installed) or the ndisprot
clone(installed by user)? This is beacuse both of the drivers could be
used. How can i make sure that in this case my calls are passed through
ndisproto clone?
In your "clone" NDISPROT change the NT_DEVICE_NAME and DOS_DEVICE_NAME to
something of your own.
http://www.ndis.com/pcakb/KB01010301.htm
Thomas F. Divine, Windows DDK MVP
www.ndis.com
Post by NYA
If no then will any protocol driver be used for further OID Requests
from deviceiocontrol
Thanks
Nishchal
Steve Dispensa
2006-07-21 05:49:01 UTC
Permalink
What are you trying to accomplish here?

You really aren't supposed to be directly opening the device objects created
for network adapters. They're NDIS-owned device objects, and even the
protocols themselves don't directly open those device objects - they use
NDIS APIs so that NDIS can stay in the middle. Different miniport drivers
have different capabilities, and you can't know by doing a direct device
open what capabilities a given miniport driver has without poking around in
undocumented NDIS internals. Also, miniport drivers register a set of
callbacks once in their DriverEntry for use in miniport operations, and
again, you can't get that list without doing undocumented things.

Furthermore, if you were to try to open miniport driver device objects
directly, you would almost certainly screw up some state somewhere. If you
made direct calls to entry points, for example, you might make them at wrong
IRQL (hard to do right if you don't know if the miniport is serialized or
not), or you might overlap calls that the miniport depends on being
serialized (impossible to protect against, unless you're NDIS).

So, again, what are you trying to accomplish here?

-sd


On 7/20/06 8:56 PM, in article
Post by NYA
Hello
There are 2 ways of opening a handle to the network card.
[1] By first opening a stream to the ndisuio/clone of ndisprot protocol
driver and then binding it to the underlying mac--
handle=CreateFile("\\\\.\\\\ndisprot",......);
DeviceIoControl(handle, IOCTL_NDISUIO_BIND_WAIT.....);
//After enumerating and selecting a device, a
DeviceIoControl(Handle, IOCTL_NDISPROT_OPEN_DEVICE,
(LPVOID)&wNdisDeviceName[0]......);
[2] But if we already know the device name we can use the name to open
a handle to thre adapter.
createfile("\\\\.\\{2AA42F55-F......
What is the difference between the two methods? Will a protocol driver
be used internally or for further deviceiocontrol request if the handle
is opened by the second method?
If yes, then supposing if i have an ndisprot cloned protocol driver
(from win2k3 server ddk) installed. then which protocol driver will be
used internally the ndisuio (default xp installed) or the ndisprot
clone(installed by user)? This is beacuse both of the drivers could be
used. How can i make sure that in this case my calls are passed through
ndisproto clone?
If no then will any protocol driver be used for further OID Requests
from deviceiocontrol
Thanks
Nishchal
NYA
2006-07-21 15:12:21 UTC
Permalink
I want to access the network adapter by simple DeviceIOControl calls
with the help of standard OIDs. Also as advised by various persons I
also do not want to use the default OS supplied ndisuio protocol
driver, instead have compiled a protocol driver from the ndisprot
example in the Win2k3 Server DDK (after changing NT and DOS device
names) and want to make sure that my DeviceIOControl requests are
handled through my protocol driver and not the XP supplied ndisuio
driver.

I found out that the handle to the network adapter can be opened in 2
ways. In the first it is clear that we can specify which protocol
driver we want to use. But in the second (which i found out from the
DDK help in the entry of IOCTL_NDIS_QUERY_GLOBAL_STATS, bottom of the
page) it is not clear that which protocol driver (if any) will be used
to handle the DeviceIOControl requests. Other than that i do not want
to make any direct calls to the driver object in the 2nd method, but I
want to make sure my protocol driver is used, if one is ever being
used.

Thanks for the reply.

Nishchal
Post by Steve Dispensa
What are you trying to accomplish here?
You really aren't supposed to be directly opening the device objects created
for network adapters. They're NDIS-owned device objects, and even the
protocols themselves don't directly open those device objects - they use
NDIS APIs so that NDIS can stay in the middle. Different miniport drivers
have different capabilities, and you can't know by doing a direct device
open what capabilities a given miniport driver has without poking around in
undocumented NDIS internals. Also, miniport drivers register a set of
callbacks once in their DriverEntry for use in miniport operations, and
again, you can't get that list without doing undocumented things.
Furthermore, if you were to try to open miniport driver device objects
directly, you would almost certainly screw up some state somewhere. If you
made direct calls to entry points, for example, you might make them at wrong
IRQL (hard to do right if you don't know if the miniport is serialized or
not), or you might overlap calls that the miniport depends on being
serialized (impossible to protect against, unless you're NDIS).
So, again, what are you trying to accomplish here?
-sd
On 7/20/06 8:56 PM, in article
Post by NYA
Hello
There are 2 ways of opening a handle to the network card.
[1] By first opening a stream to the ndisuio/clone of ndisprot protocol
driver and then binding it to the underlying mac--
handle=CreateFile("\\\\.\\\\ndisprot",......);
DeviceIoControl(handle, IOCTL_NDISUIO_BIND_WAIT.....);
//After enumerating and selecting a device, a
DeviceIoControl(Handle, IOCTL_NDISPROT_OPEN_DEVICE,
(LPVOID)&wNdisDeviceName[0]......);
[2] But if we already know the device name we can use the name to open
a handle to thre adapter.
createfile("\\\\.\\{2AA42F55-F......
What is the difference between the two methods? Will a protocol driver
be used internally or for further deviceiocontrol request if the handle
is opened by the second method?
If yes, then supposing if i have an ndisprot cloned protocol driver
(from win2k3 server ddk) installed. then which protocol driver will be
used internally the ndisuio (default xp installed) or the ndisprot
clone(installed by user)? This is beacuse both of the drivers could be
used. How can i make sure that in this case my calls are passed through
ndisproto clone?
If no then will any protocol driver be used for further OID Requests
from deviceiocontrol
Thanks
Nishchal
Steve Dispensa
2006-07-21 15:56:36 UTC
Permalink
There are other, documented ways to read information from network adapters.
WMI is designed for this purpose, for example.

You can certainly do what ndisprot does, but it is far better to not write a
driver if you can avoid it. Regardless, you certainly should NOT directly
send IOCTLs to a miniport driver (unless you register a management device
with NdisMRegisterDevice).

What information do you need about the NIC? Can you get it from usermode?

-sd


On 7/21/06 10:12 AM, in article
Post by NYA
I want to access the network adapter by simple DeviceIOControl calls
with the help of standard OIDs. Also as advised by various persons I
also do not want to use the default OS supplied ndisuio protocol
driver, instead have compiled a protocol driver from the ndisprot
example in the Win2k3 Server DDK (after changing NT and DOS device
names) and want to make sure that my DeviceIOControl requests are
handled through my protocol driver and not the XP supplied ndisuio
driver.
I found out that the handle to the network adapter can be opened in 2
ways. In the first it is clear that we can specify which protocol
driver we want to use. But in the second (which i found out from the
DDK help in the entry of IOCTL_NDIS_QUERY_GLOBAL_STATS, bottom of the
page) it is not clear that which protocol driver (if any) will be used
to handle the DeviceIOControl requests. Other than that i do not want
to make any direct calls to the driver object in the 2nd method, but I
want to make sure my protocol driver is used, if one is ever being
used.
Thanks for the reply.
Nishchal
Post by Steve Dispensa
What are you trying to accomplish here?
You really aren't supposed to be directly opening the device objects created
for network adapters. They're NDIS-owned device objects, and even the
protocols themselves don't directly open those device objects - they use
NDIS APIs so that NDIS can stay in the middle. Different miniport drivers
have different capabilities, and you can't know by doing a direct device
open what capabilities a given miniport driver has without poking around in
undocumented NDIS internals. Also, miniport drivers register a set of
callbacks once in their DriverEntry for use in miniport operations, and
again, you can't get that list without doing undocumented things.
Furthermore, if you were to try to open miniport driver device objects
directly, you would almost certainly screw up some state somewhere. If you
made direct calls to entry points, for example, you might make them at wrong
IRQL (hard to do right if you don't know if the miniport is serialized or
not), or you might overlap calls that the miniport depends on being
serialized (impossible to protect against, unless you're NDIS).
So, again, what are you trying to accomplish here?
-sd
On 7/20/06 8:56 PM, in article
Post by NYA
Hello
There are 2 ways of opening a handle to the network card.
[1] By first opening a stream to the ndisuio/clone of ndisprot protocol
driver and then binding it to the underlying mac--
handle=CreateFile("\\\\.\\\\ndisprot",......);
DeviceIoControl(handle, IOCTL_NDISUIO_BIND_WAIT.....);
//After enumerating and selecting a device, a
DeviceIoControl(Handle, IOCTL_NDISPROT_OPEN_DEVICE,
(LPVOID)&wNdisDeviceName[0]......);
[2] But if we already know the device name we can use the name to open
a handle to thre adapter.
createfile("\\\\.\\{2AA42F55-F......
What is the difference between the two methods? Will a protocol driver
be used internally or for further deviceiocontrol request if the handle
is opened by the second method?
If yes, then supposing if i have an ndisprot cloned protocol driver
(from win2k3 server ddk) installed. then which protocol driver will be
used internally the ndisuio (default xp installed) or the ndisprot
clone(installed by user)? This is beacuse both of the drivers could be
used. How can i make sure that in this case my calls are passed through
ndisproto clone?
If no then will any protocol driver be used for further OID Requests
from deviceiocontrol
Thanks
Nishchal
NYA
2006-07-21 18:35:56 UTC
Permalink
I am making an application which accesses information from the wlan
card. So basically from the application i am making DeviceIOControl
calls and accessing various information by specifying various OIDs.
While accessing the wlan card through DeviceIOControl calls it is
advised that we should use a clone of the ndisprot protocol driver and
not the OS supplied ndisuio driver. That is why i am asking that how do
i make sure that my protocol driver is used instead of the ndisuio
driver.

Also by the second method am I opening a handle to the miniport driver
object directly? So I am not using a protocol driver?

Thanks
Nishchal
Post by Steve Dispensa
There are other, documented ways to read information from network adapters.
WMI is designed for this purpose, for example.
You can certainly do what ndisprot does, but it is far better to not write a
driver if you can avoid it. Regardless, you certainly should NOT directly
send IOCTLs to a miniport driver (unless you register a management device
with NdisMRegisterDevice).
What information do you need about the NIC? Can you get it from usermode?
-sd
On 7/21/06 10:12 AM, in article
Post by NYA
I want to access the network adapter by simple DeviceIOControl calls
with the help of standard OIDs. Also as advised by various persons I
also do not want to use the default OS supplied ndisuio protocol
driver, instead have compiled a protocol driver from the ndisprot
example in the Win2k3 Server DDK (after changing NT and DOS device
names) and want to make sure that my DeviceIOControl requests are
handled through my protocol driver and not the XP supplied ndisuio
driver.
I found out that the handle to the network adapter can be opened in 2
ways. In the first it is clear that we can specify which protocol
driver we want to use. But in the second (which i found out from the
DDK help in the entry of IOCTL_NDIS_QUERY_GLOBAL_STATS, bottom of the
page) it is not clear that which protocol driver (if any) will be used
to handle the DeviceIOControl requests. Other than that i do not want
to make any direct calls to the driver object in the 2nd method, but I
want to make sure my protocol driver is used, if one is ever being
used.
Thanks for the reply.
Nishchal
Post by Steve Dispensa
What are you trying to accomplish here?
You really aren't supposed to be directly opening the device objects created
for network adapters. They're NDIS-owned device objects, and even the
protocols themselves don't directly open those device objects - they use
NDIS APIs so that NDIS can stay in the middle. Different miniport drivers
have different capabilities, and you can't know by doing a direct device
open what capabilities a given miniport driver has without poking around in
undocumented NDIS internals. Also, miniport drivers register a set of
callbacks once in their DriverEntry for use in miniport operations, and
again, you can't get that list without doing undocumented things.
Furthermore, if you were to try to open miniport driver device objects
directly, you would almost certainly screw up some state somewhere. If you
made direct calls to entry points, for example, you might make them at wrong
IRQL (hard to do right if you don't know if the miniport is serialized or
not), or you might overlap calls that the miniport depends on being
serialized (impossible to protect against, unless you're NDIS).
So, again, what are you trying to accomplish here?
-sd
On 7/20/06 8:56 PM, in article
Post by NYA
Hello
There are 2 ways of opening a handle to the network card.
[1] By first opening a stream to the ndisuio/clone of ndisprot protocol
driver and then binding it to the underlying mac--
handle=CreateFile("\\\\.\\\\ndisprot",......);
DeviceIoControl(handle, IOCTL_NDISUIO_BIND_WAIT.....);
//After enumerating and selecting a device, a
DeviceIoControl(Handle, IOCTL_NDISPROT_OPEN_DEVICE,
(LPVOID)&wNdisDeviceName[0]......);
[2] But if we already know the device name we can use the name to open
a handle to thre adapter.
createfile("\\\\.\\{2AA42F55-F......
What is the difference between the two methods? Will a protocol driver
be used internally or for further deviceiocontrol request if the handle
is opened by the second method?
If yes, then supposing if i have an ndisprot cloned protocol driver
(from win2k3 server ddk) installed. then which protocol driver will be
used internally the ndisuio (default xp installed) or the ndisprot
clone(installed by user)? This is beacuse both of the drivers could be
used. How can i make sure that in this case my calls are passed through
ndisproto clone?
If no then will any protocol driver be used for further OID Requests
from deviceiocontrol
Thanks
Nishchal
Maxim S. Shatskih
2006-07-21 19:26:27 UTC
Permalink
Post by NYA
I am making an application which accesses information from the wlan
card. So basically from the application i am making DeviceIOControl
calls and accessing various information by specifying various OIDs.
While accessing the wlan card through DeviceIOControl calls it is
advised that we should use a clone of the ndisprot protocol driver and
not the OS supplied ndisuio driver. That is why i am asking that how do
Are you sure this information is not available via WMI?
--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
***@storagecraft.com
http://www.storagecraft.com
Gianluca Varenni
2006-07-21 19:34:51 UTC
Permalink
Post by NYA
I am making an application which accesses information from the wlan
card. So basically from the application i am making DeviceIOControl
calls and accessing various information by specifying various OIDs.
While accessing the wlan card through DeviceIOControl calls it is
advised that we should use a clone of the ndisprot protocol driver and
not the OS supplied ndisuio driver. That is why i am asking that how do
i make sure that my protocol driver is used instead of the ndisuio
driver.
You need to use an NDIS IM driver. With an IM driver you can basically
filter all the requests done by the protocols (like ndisuio) to the
miniport. If you don't use an IM driver, there's no way to block the other
protocol drivers from issuing requests to the wireless miniport.

If your concern is just ndisuio, a solution is basically disabling wireless
zero configuration (although I usually don't like it too much, as users can
reenable it easily...)

Hope it helps
GV
Post by NYA
Also by the second method am I opening a handle to the miniport driver
object directly? So I am not using a protocol driver?
Thanks
Nishchal
Post by Steve Dispensa
There are other, documented ways to read information from network adapters.
WMI is designed for this purpose, for example.
You can certainly do what ndisprot does, but it is far better to not write a
driver if you can avoid it. Regardless, you certainly should NOT directly
send IOCTLs to a miniport driver (unless you register a management device
with NdisMRegisterDevice).
What information do you need about the NIC? Can you get it from usermode?
-sd
On 7/21/06 10:12 AM, in article
Post by NYA
I want to access the network adapter by simple DeviceIOControl calls
with the help of standard OIDs. Also as advised by various persons I
also do not want to use the default OS supplied ndisuio protocol
driver, instead have compiled a protocol driver from the ndisprot
example in the Win2k3 Server DDK (after changing NT and DOS device
names) and want to make sure that my DeviceIOControl requests are
handled through my protocol driver and not the XP supplied ndisuio
driver.
I found out that the handle to the network adapter can be opened in 2
ways. In the first it is clear that we can specify which protocol
driver we want to use. But in the second (which i found out from the
DDK help in the entry of IOCTL_NDIS_QUERY_GLOBAL_STATS, bottom of the
page) it is not clear that which protocol driver (if any) will be used
to handle the DeviceIOControl requests. Other than that i do not want
to make any direct calls to the driver object in the 2nd method, but I
want to make sure my protocol driver is used, if one is ever being
used.
Thanks for the reply.
Nishchal
Post by Steve Dispensa
What are you trying to accomplish here?
You really aren't supposed to be directly opening the device objects created
for network adapters. They're NDIS-owned device objects, and even the
protocols themselves don't directly open those device objects - they use
NDIS APIs so that NDIS can stay in the middle. Different miniport drivers
have different capabilities, and you can't know by doing a direct device
open what capabilities a given miniport driver has without poking around in
undocumented NDIS internals. Also, miniport drivers register a set of
callbacks once in their DriverEntry for use in miniport operations, and
again, you can't get that list without doing undocumented things.
Furthermore, if you were to try to open miniport driver device objects
directly, you would almost certainly screw up some state somewhere. If you
made direct calls to entry points, for example, you might make them at wrong
IRQL (hard to do right if you don't know if the miniport is serialized or
not), or you might overlap calls that the miniport depends on being
serialized (impossible to protect against, unless you're NDIS).
So, again, what are you trying to accomplish here?
-sd
On 7/20/06 8:56 PM, in article
Post by NYA
Hello
There are 2 ways of opening a handle to the network card.
[1] By first opening a stream to the ndisuio/clone of ndisprot protocol
driver and then binding it to the underlying mac--
handle=CreateFile("\\\\.\\\\ndisprot",......);
DeviceIoControl(handle, IOCTL_NDISUIO_BIND_WAIT.....);
//After enumerating and selecting a device, a
DeviceIoControl(Handle, IOCTL_NDISPROT_OPEN_DEVICE,
(LPVOID)&wNdisDeviceName[0]......);
[2] But if we already know the device name we can use the name to open
a handle to thre adapter.
createfile("\\\\.\\{2AA42F55-F......
What is the difference between the two methods? Will a protocol driver
be used internally or for further deviceiocontrol request if the handle
is opened by the second method?
If yes, then supposing if i have an ndisprot cloned protocol driver
(from win2k3 server ddk) installed. then which protocol driver will be
used internally the ndisuio (default xp installed) or the ndisprot
clone(installed by user)? This is beacuse both of the drivers could be
used. How can i make sure that in this case my calls are passed through
ndisproto clone?
If no then will any protocol driver be used for further OID Requests
from deviceiocontrol
Thanks
Nishchal
Thomas F. Divine [DDK MVP]
2006-07-21 20:17:09 UTC
Permalink
If you are looking for a way to guarantee that your software is the only
software controlling a 802.11 adapter, then here is the answer:

There is no way to guarantee that your software is the only software
controlling an 802.11 adapter.

That is the answer. There is no other answer. You can ask as many times as
you like, but there are no techniques that can provide this guarantee.

The problem is so bad that some folks have built NDIS IM filter drivers that
"hide" the 802.11 capabilities from the OS (Gianluca mentioned this
approach...). That way WZC and many (but not all) third-party Wi-Fi
management tools will not even know the 802.11 adapter actually has 802.11
capabilities.

HOWEVER, even that approach provides no guarantee. Yet-another-vendor may
elect to use the same approach. Your hiding IM driver would battle with
other hiding IM drivers and who knows whether your hiding IM driver would
win over another.

Good luck,

Thomas F. Divine, Windows DDK MVP
http://www.rawether.net
Post by NYA
I am making an application which accesses information from the wlan
card. So basically from the application i am making DeviceIOControl
calls and accessing various information by specifying various OIDs.
While accessing the wlan card through DeviceIOControl calls it is
advised that we should use a clone of the ndisprot protocol driver and
not the OS supplied ndisuio driver. That is why i am asking that how do
i make sure that my protocol driver is used instead of the ndisuio
driver.
Also by the second method am I opening a handle to the miniport driver
object directly? So I am not using a protocol driver?
Thanks
Nishchal
Post by Steve Dispensa
There are other, documented ways to read information from network adapters.
WMI is designed for this purpose, for example.
You can certainly do what ndisprot does, but it is far better to not write a
driver if you can avoid it. Regardless, you certainly should NOT directly
send IOCTLs to a miniport driver (unless you register a management device
with NdisMRegisterDevice).
What information do you need about the NIC? Can you get it from usermode?
-sd
On 7/21/06 10:12 AM, in article
Post by NYA
I want to access the network adapter by simple DeviceIOControl calls
with the help of standard OIDs. Also as advised by various persons I
also do not want to use the default OS supplied ndisuio protocol
driver, instead have compiled a protocol driver from the ndisprot
example in the Win2k3 Server DDK (after changing NT and DOS device
names) and want to make sure that my DeviceIOControl requests are
handled through my protocol driver and not the XP supplied ndisuio
driver.
I found out that the handle to the network adapter can be opened in 2
ways. In the first it is clear that we can specify which protocol
driver we want to use. But in the second (which i found out from the
DDK help in the entry of IOCTL_NDIS_QUERY_GLOBAL_STATS, bottom of the
page) it is not clear that which protocol driver (if any) will be used
to handle the DeviceIOControl requests. Other than that i do not want
to make any direct calls to the driver object in the 2nd method, but I
want to make sure my protocol driver is used, if one is ever being
used.
Thanks for the reply.
Nishchal
Post by Steve Dispensa
What are you trying to accomplish here?
You really aren't supposed to be directly opening the device objects created
for network adapters. They're NDIS-owned device objects, and even the
protocols themselves don't directly open those device objects - they use
NDIS APIs so that NDIS can stay in the middle. Different miniport drivers
have different capabilities, and you can't know by doing a direct device
open what capabilities a given miniport driver has without poking around in
undocumented NDIS internals. Also, miniport drivers register a set of
callbacks once in their DriverEntry for use in miniport operations, and
again, you can't get that list without doing undocumented things.
Furthermore, if you were to try to open miniport driver device objects
directly, you would almost certainly screw up some state somewhere. If you
made direct calls to entry points, for example, you might make them at wrong
IRQL (hard to do right if you don't know if the miniport is serialized or
not), or you might overlap calls that the miniport depends on being
serialized (impossible to protect against, unless you're NDIS).
So, again, what are you trying to accomplish here?
-sd
On 7/20/06 8:56 PM, in article
Post by NYA
Hello
There are 2 ways of opening a handle to the network card.
[1] By first opening a stream to the ndisuio/clone of ndisprot protocol
driver and then binding it to the underlying mac--
handle=CreateFile("\\\\.\\\\ndisprot",......);
DeviceIoControl(handle, IOCTL_NDISUIO_BIND_WAIT.....);
//After enumerating and selecting a device, a
DeviceIoControl(Handle, IOCTL_NDISPROT_OPEN_DEVICE,
(LPVOID)&wNdisDeviceName[0]......);
[2] But if we already know the device name we can use the name to open
a handle to thre adapter.
createfile("\\\\.\\{2AA42F55-F......
What is the difference between the two methods? Will a protocol driver
be used internally or for further deviceiocontrol request if the handle
is opened by the second method?
If yes, then supposing if i have an ndisprot cloned protocol driver
(from win2k3 server ddk) installed. then which protocol driver will be
used internally the ndisuio (default xp installed) or the ndisprot
clone(installed by user)? This is beacuse both of the drivers could be
used. How can i make sure that in this case my calls are passed through
ndisproto clone?
If no then will any protocol driver be used for further OID Requests
from deviceiocontrol
Thanks
Nishchal
NYA
2006-07-24 16:21:20 UTC
Permalink
Thanks everyone for the reply.

I do not want to use WMI to access the driver.

Actually I do not want to ensure that only my software is able to
access the miniport driver and the rest cant. All I want to ensure is
that whenever my application makes a DeviceIOControl call I want to
ensure that the call is handled through my protocol driver(compiled
from the ndisprot example) and not through the system supplied ndisuio
driver. Because of compatibility issues as mentioned in various
websites.

The problem here is that the handle which I use to make my
DeviceIOControl call with is not created by me, so i dont know how the
handle is created and i dont know if and which(if any) a protocol
driver is being used. I searched up Net and found out that there are 2
ways by which a handle to the network adapter can be created.

The first one (mentioned in my previous posts) uses a protocol driver,
so there is NO confusion about whether a protocol driver is being used
or not.

In the second method we use the device name (of the miniport) to create
the handle and use this handle to make DeviceIOControl calls to access
information about the adapter using different OIDs. The confusion which
I have over here is that whether a protocol driver will ever be used in
handling various call which use/create this handle or is the miniport
over here being accessed directly an no protocol driver is being used?
If a protocol driver is being used then I need to provide my protocol
driver (compiled from ndisprot example) so that all the calls take
place through my protocol driver and not the system supplied ndisuio
protocol driver (to take care of compatibility issues). Now even if I
compile and install my protocol driver (with the method given on
ndis.com) how can I know or ensure that my protocol driver is veing
used to handle the requests made by my application?

My hunch is that the handle is being provided to me by the second
method, now I am confused whether to compile and use a protocol driver
from ndisprot or not?

Thanks
Nishchal
Post by Thomas F. Divine [DDK MVP]
If you are looking for a way to guarantee that your software is the only
There is no way to guarantee that your software is the only software
controlling an 802.11 adapter.
That is the answer. There is no other answer. You can ask as many times as
you like, but there are no techniques that can provide this guarantee.
The problem is so bad that some folks have built NDIS IM filter drivers that
"hide" the 802.11 capabilities from the OS (Gianluca mentioned this
approach...). That way WZC and many (but not all) third-party Wi-Fi
management tools will not even know the 802.11 adapter actually has 802.11
capabilities.
HOWEVER, even that approach provides no guarantee. Yet-another-vendor may
elect to use the same approach. Your hiding IM driver would battle with
other hiding IM drivers and who knows whether your hiding IM driver would
win over another.
Good luck,
Thomas F. Divine, Windows DDK MVP
http://www.rawether.net
Post by NYA
I am making an application which accesses information from the wlan
card. So basically from the application i am making DeviceIOControl
calls and accessing various information by specifying various OIDs.
While accessing the wlan card through DeviceIOControl calls it is
advised that we should use a clone of the ndisprot protocol driver and
not the OS supplied ndisuio driver. That is why i am asking that how do
i make sure that my protocol driver is used instead of the ndisuio
driver.
Also by the second method am I opening a handle to the miniport driver
object directly? So I am not using a protocol driver?
Thanks
Nishchal
Post by Steve Dispensa
There are other, documented ways to read information from network adapters.
WMI is designed for this purpose, for example.
You can certainly do what ndisprot does, but it is far better to not write a
driver if you can avoid it. Regardless, you certainly should NOT directly
send IOCTLs to a miniport driver (unless you register a management device
with NdisMRegisterDevice).
What information do you need about the NIC? Can you get it from usermode?
-sd
On 7/21/06 10:12 AM, in article
Post by NYA
I want to access the network adapter by simple DeviceIOControl calls
with the help of standard OIDs. Also as advised by various persons I
also do not want to use the default OS supplied ndisuio protocol
driver, instead have compiled a protocol driver from the ndisprot
example in the Win2k3 Server DDK (after changing NT and DOS device
names) and want to make sure that my DeviceIOControl requests are
handled through my protocol driver and not the XP supplied ndisuio
driver.
I found out that the handle to the network adapter can be opened in 2
ways. In the first it is clear that we can specify which protocol
driver we want to use. But in the second (which i found out from the
DDK help in the entry of IOCTL_NDIS_QUERY_GLOBAL_STATS, bottom of the
page) it is not clear that which protocol driver (if any) will be used
to handle the DeviceIOControl requests. Other than that i do not want
to make any direct calls to the driver object in the 2nd method, but I
want to make sure my protocol driver is used, if one is ever being
used.
Thanks for the reply.
Nishchal
Post by Steve Dispensa
What are you trying to accomplish here?
You really aren't supposed to be directly opening the device objects created
for network adapters. They're NDIS-owned device objects, and even the
protocols themselves don't directly open those device objects - they use
NDIS APIs so that NDIS can stay in the middle. Different miniport drivers
have different capabilities, and you can't know by doing a direct device
open what capabilities a given miniport driver has without poking around in
undocumented NDIS internals. Also, miniport drivers register a set of
callbacks once in their DriverEntry for use in miniport operations, and
again, you can't get that list without doing undocumented things.
Furthermore, if you were to try to open miniport driver device objects
directly, you would almost certainly screw up some state somewhere. If you
made direct calls to entry points, for example, you might make them at wrong
IRQL (hard to do right if you don't know if the miniport is serialized or
not), or you might overlap calls that the miniport depends on being
serialized (impossible to protect against, unless you're NDIS).
So, again, what are you trying to accomplish here?
-sd
On 7/20/06 8:56 PM, in article
Post by NYA
Hello
There are 2 ways of opening a handle to the network card.
[1] By first opening a stream to the ndisuio/clone of ndisprot protocol
driver and then binding it to the underlying mac--
handle=CreateFile("\\\\.\\\\ndisprot",......);
DeviceIoControl(handle, IOCTL_NDISUIO_BIND_WAIT.....);
//After enumerating and selecting a device, a
DeviceIoControl(Handle, IOCTL_NDISPROT_OPEN_DEVICE,
(LPVOID)&wNdisDeviceName[0]......);
[2] But if we already know the device name we can use the name to open
a handle to thre adapter.
createfile("\\\\.\\{2AA42F55-F......
What is the difference between the two methods? Will a protocol driver
be used internally or for further deviceiocontrol request if the handle
is opened by the second method?
If yes, then supposing if i have an ndisprot cloned protocol driver
(from win2k3 server ddk) installed. then which protocol driver will be
used internally the ndisuio (default xp installed) or the ndisprot
clone(installed by user)? This is beacuse both of the drivers could be
used. How can i make sure that in this case my calls are passed through
ndisproto clone?
If no then will any protocol driver be used for further OID Requests
from deviceiocontrol
Thanks
Nishchal
Thomas F. Divine [DDK MVP]
2006-07-24 18:32:54 UTC
Permalink
I stand by my reply. There is no way that you can assure that your driver is
the only one managing an adapter.

Now to clear up your idea about DeviceIoControl.

Just take a look at the DDK miniport driver samples. Take a hard look, and
you will see that there are no IOCTL handlers. What this means is that
although you can open the symbolic link, there is nothing that you can do
with it! 802.11 adapters are the same way (with some proprietary
exceptions...).

When handle is opened using the IOCTL_NDIS_QUERY_GLOBAL_STATISTICS approach,
you are not actually opening a handle to the adapter miniport. In reality,
NDIS is a wrapper around the miniport drivers and actually creates these
symbolic links on behalf of the miniport. So, your query goes through NDIS.
And NDIS uses OIDs to fetch the information - just like a NDIS protocol
driver would do.

Going further, IOCTL_NDIS_QUERY_GLOBAL _STATISTICS is one of the few NDIS
IOCTLs that is publicly documented. There isn't a big family of publicly
available IOCTL_NDIS_SET_INFORMATION (I just made that up...) or others for
you to use. If there are any, then Microsoft has not made them public. If
they were public, then anyone could use them - not just you. So, there isn't
any advantage there.

Now some miniport developers just may add a _private_ IOCTL interface to
their miniport. They would use this to do extra things that only the
miniport writer knows about. So, if this sort of IOCTL interface exists for
some miniports, then it is only of use to you if you are friends with the
miniport driver writer.

Good luck,

Thomas F. Divine, Windows DDK MVP
http://www.pcausa.com
Post by NYA
Thanks everyone for the reply.
I do not want to use WMI to access the driver.
Actually I do not want to ensure that only my software is able to
access the miniport driver and the rest cant. All I want to ensure is
that whenever my application makes a DeviceIOControl call I want to
ensure that the call is handled through my protocol driver(compiled
from the ndisprot example) and not through the system supplied ndisuio
driver. Because of compatibility issues as mentioned in various
websites.
The problem here is that the handle which I use to make my
DeviceIOControl call with is not created by me, so i dont know how the
handle is created and i dont know if and which(if any) a protocol
driver is being used. I searched up Net and found out that there are 2
ways by which a handle to the network adapter can be created.
The first one (mentioned in my previous posts) uses a protocol driver,
so there is NO confusion about whether a protocol driver is being used
or not.
In the second method we use the device name (of the miniport) to create
the handle and use this handle to make DeviceIOControl calls to access
information about the adapter using different OIDs. The confusion which
I have over here is that whether a protocol driver will ever be used in
handling various call which use/create this handle or is the miniport
over here being accessed directly an no protocol driver is being used?
If a protocol driver is being used then I need to provide my protocol
driver (compiled from ndisprot example) so that all the calls take
place through my protocol driver and not the system supplied ndisuio
protocol driver (to take care of compatibility issues). Now even if I
compile and install my protocol driver (with the method given on
ndis.com) how can I know or ensure that my protocol driver is veing
used to handle the requests made by my application?
My hunch is that the handle is being provided to me by the second
method, now I am confused whether to compile and use a protocol driver
from ndisprot or not?
Thanks
Nishchal
Post by Thomas F. Divine [DDK MVP]
If you are looking for a way to guarantee that your software is the only
There is no way to guarantee that your software is the only software
controlling an 802.11 adapter.
That is the answer. There is no other answer. You can ask as many times as
you like, but there are no techniques that can provide this guarantee.
The problem is so bad that some folks have built NDIS IM filter drivers that
"hide" the 802.11 capabilities from the OS (Gianluca mentioned this
approach...). That way WZC and many (but not all) third-party Wi-Fi
management tools will not even know the 802.11 adapter actually has 802.11
capabilities.
HOWEVER, even that approach provides no guarantee. Yet-another-vendor may
elect to use the same approach. Your hiding IM driver would battle with
other hiding IM drivers and who knows whether your hiding IM driver would
win over another.
Good luck,
Thomas F. Divine, Windows DDK MVP
http://www.rawether.net
Post by NYA
I am making an application which accesses information from the wlan
card. So basically from the application i am making DeviceIOControl
calls and accessing various information by specifying various OIDs.
While accessing the wlan card through DeviceIOControl calls it is
advised that we should use a clone of the ndisprot protocol driver and
not the OS supplied ndisuio driver. That is why i am asking that how do
i make sure that my protocol driver is used instead of the ndisuio
driver.
Also by the second method am I opening a handle to the miniport driver
object directly? So I am not using a protocol driver?
Thanks
Nishchal
Post by Steve Dispensa
There are other, documented ways to read information from network adapters.
WMI is designed for this purpose, for example.
You can certainly do what ndisprot does, but it is far better to not write a
driver if you can avoid it. Regardless, you certainly should NOT directly
send IOCTLs to a miniport driver (unless you register a management device
with NdisMRegisterDevice).
What information do you need about the NIC? Can you get it from usermode?
-sd
On 7/21/06 10:12 AM, in article
Post by NYA
I want to access the network adapter by simple DeviceIOControl calls
with the help of standard OIDs. Also as advised by various persons I
also do not want to use the default OS supplied ndisuio protocol
driver, instead have compiled a protocol driver from the ndisprot
example in the Win2k3 Server DDK (after changing NT and DOS device
names) and want to make sure that my DeviceIOControl requests are
handled through my protocol driver and not the XP supplied ndisuio
driver.
I found out that the handle to the network adapter can be opened in 2
ways. In the first it is clear that we can specify which protocol
driver we want to use. But in the second (which i found out from the
DDK help in the entry of IOCTL_NDIS_QUERY_GLOBAL_STATS, bottom of the
page) it is not clear that which protocol driver (if any) will be used
to handle the DeviceIOControl requests. Other than that i do not want
to make any direct calls to the driver object in the 2nd method, but I
want to make sure my protocol driver is used, if one is ever being
used.
Thanks for the reply.
Nishchal
Post by Steve Dispensa
What are you trying to accomplish here?
You really aren't supposed to be directly opening the device
objects
created
for network adapters. They're NDIS-owned device objects, and even the
protocols themselves don't directly open those device objects -
they
use
NDIS APIs so that NDIS can stay in the middle. Different miniport drivers
have different capabilities, and you can't know by doing a direct device
open what capabilities a given miniport driver has without poking around in
undocumented NDIS internals. Also, miniport drivers register a set of
callbacks once in their DriverEntry for use in miniport operations, and
again, you can't get that list without doing undocumented things.
Furthermore, if you were to try to open miniport driver device objects
directly, you would almost certainly screw up some state somewhere.
If
you
made direct calls to entry points, for example, you might make them
at
wrong
IRQL (hard to do right if you don't know if the miniport is
serialized
or
not), or you might overlap calls that the miniport depends on being
serialized (impossible to protect against, unless you're NDIS).
So, again, what are you trying to accomplish here?
-sd
On 7/20/06 8:56 PM, in article
Post by NYA
Hello
There are 2 ways of opening a handle to the network card.
[1] By first opening a stream to the ndisuio/clone of ndisprot protocol
driver and then binding it to the underlying mac--
handle=CreateFile("\\\\.\\\\ndisprot",......);
DeviceIoControl(handle, IOCTL_NDISUIO_BIND_WAIT.....);
//After enumerating and selecting a device, a
DeviceIoControl(Handle, IOCTL_NDISPROT_OPEN_DEVICE,
(LPVOID)&wNdisDeviceName[0]......);
[2] But if we already know the device name we can use the name to open
a handle to thre adapter.
createfile("\\\\.\\{2AA42F55-F......
What is the difference between the two methods? Will a protocol driver
be used internally or for further deviceiocontrol request if the handle
is opened by the second method?
If yes, then supposing if i have an ndisprot cloned protocol driver
(from win2k3 server ddk) installed. then which protocol driver
will
be
used internally the ndisuio (default xp installed) or the ndisprot
clone(installed by user)? This is beacuse both of the drivers
could
be
used. How can i make sure that in this case my calls are passed through
ndisproto clone?
If no then will any protocol driver be used for further OID Requests
from deviceiocontrol
Thanks
Nishchal
s***@hotmail.com
2006-07-22 23:06:41 UTC
Permalink
Hi mate

Any driver that registers itself as miniport one cannot be accessed via
the regular dispatch interface, so that you cannot open a handle to
miniport driver and sent IOCTs to it. The only system component that is
allowed to access miniport drivers is NDIS library - miniport driver
registers its callbacks that get called by NDIS when protocol drivers
call NDIS library functions

This is a rule, and, as any rule, it has an exception - if miniport
driver developer wants to make his driver available to non-NDIS
components (i.e. OS and user applications), it may register stand-alone
device and symbolic link to it with NdisMRegisterDevice(). If it does
so, you are able to open handles and send IOCTLs to this device
(sometimes they call it management interface). This feature is optional
- miniport drivers are NOT required to expose this management interface


To summarize, everything depends on particular card, i.e whether it
exposes its management interface. I don't really know what you want to
do, but if you want your code to work with all network cards, you
should write a protocol driver. This driver will deal with user
application on its upper edge and with NDIS library on its lower one.

This is how you are supposed to work with miniports.

Anton Bassov
Post by NYA
Hello
There are 2 ways of opening a handle to the network card.
[1] By first opening a stream to the ndisuio/clone of ndisprot protocol
driver and then binding it to the underlying mac--
handle=CreateFile("\\\\.\\\\ndisprot",......);
DeviceIoControl(handle, IOCTL_NDISUIO_BIND_WAIT.....);
//After enumerating and selecting a device, a
DeviceIoControl(Handle, IOCTL_NDISPROT_OPEN_DEVICE,
(LPVOID)&wNdisDeviceName[0]......);
[2] But if we already know the device name we can use the name to open
a handle to thre adapter.
createfile("\\\\.\\{2AA42F55-F......
What is the difference between the two methods? Will a protocol driver
be used internally or for further deviceiocontrol request if the handle
is opened by the second method?
If yes, then supposing if i have an ndisprot cloned protocol driver
(from win2k3 server ddk) installed. then which protocol driver will be
used internally the ndisuio (default xp installed) or the ndisprot
clone(installed by user)? This is beacuse both of the drivers could be
used. How can i make sure that in this case my calls are passed through
ndisproto clone?
If no then will any protocol driver be used for further OID Requests
from deviceiocontrol
Thanks
Nishchal
NYA
2006-07-24 16:37:17 UTC
Permalink
Thanks Anton!! Being a novice to driver development this has solved
many of my doubts. But I have some more.

Please can you read my todays reply to Thomas's post to put the problem
into perspective.

Now you say that a symbolic link to the driver obl is created with
NdisMRegisterDevice(), and we can send IOCTLs directly to the driver.
By this do you mean that I can access the driver directly and no
protocol driver (like ndisuio) is used to handle my request in any way
to foward them to the miniport? Also if a protocol driver is being
used, if I want that all calls made by my application are handled
through my protocol driver, then how can I know/ensure that? This will
help me to know whether I need to compile a protocol driver or not.

Also is there any way by which I can verify that a particular miniport
has exposed itself through a mangement interface, say by looking up a
place in registry or by calling some API, from the user-mode? I think i
know the device name of the miniport. I need to support my application
only for a particular network card.

Thanks again
Nishchal
Post by s***@hotmail.com
Hi mate
Any driver that registers itself as miniport one cannot be accessed via
the regular dispatch interface, so that you cannot open a handle to
miniport driver and sent IOCTs to it. The only system component that is
allowed to access miniport drivers is NDIS library - miniport driver
registers its callbacks that get called by NDIS when protocol drivers
call NDIS library functions
This is a rule, and, as any rule, it has an exception - if miniport
driver developer wants to make his driver available to non-NDIS
components (i.e. OS and user applications), it may register stand-alone
device and symbolic link to it with NdisMRegisterDevice(). If it does
so, you are able to open handles and send IOCTLs to this device
(sometimes they call it management interface). This feature is optional
- miniport drivers are NOT required to expose this management interface
To summarize, everything depends on particular card, i.e whether it
exposes its management interface. I don't really know what you want to
do, but if you want your code to work with all network cards, you
should write a protocol driver. This driver will deal with user
application on its upper edge and with NDIS library on its lower one.
This is how you are supposed to work with miniports.
Anton Bassov
Post by NYA
Hello
There are 2 ways of opening a handle to the network card.
[1] By first opening a stream to the ndisuio/clone of ndisprot protocol
driver and then binding it to the underlying mac--
handle=CreateFile("\\\\.\\\\ndisprot",......);
DeviceIoControl(handle, IOCTL_NDISUIO_BIND_WAIT.....);
//After enumerating and selecting a device, a
DeviceIoControl(Handle, IOCTL_NDISPROT_OPEN_DEVICE,
(LPVOID)&wNdisDeviceName[0]......);
[2] But if we already know the device name we can use the name to open
a handle to thre adapter.
createfile("\\\\.\\{2AA42F55-F......
What is the difference between the two methods? Will a protocol driver
be used internally or for further deviceiocontrol request if the handle
is opened by the second method?
If yes, then supposing if i have an ndisprot cloned protocol driver
(from win2k3 server ddk) installed. then which protocol driver will be
used internally the ndisuio (default xp installed) or the ndisprot
clone(installed by user)? This is beacuse both of the drivers could be
used. How can i make sure that in this case my calls are passed through
ndisproto clone?
If no then will any protocol driver be used for further OID Requests
from deviceiocontrol
Thanks
Nishchal
Maxim S. Shatskih
2006-07-24 17:24:51 UTC
Permalink
Post by NYA
Now you say that a symbolic link to the driver obl is created with
NdisMRegisterDevice(), and we can send IOCTLs directly to the driver.
By this do you mean that I can access the driver directly and no
protocol driver (like ndisuio) is used to handle my request in any way
to foward them to the miniport?
Yes. IOCTLs to NdisMRegisterDevice are not filtered neither by protocols nor by
IMs.
--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
***@storagecraft.com
http://www.storagecraft.com
Steve Dispensa
2006-07-24 22:13:39 UTC
Permalink
Post by NYA
Now you say that a symbolic link to the driver obl is created with
NdisMRegisterDevice(), and we can send IOCTLs directly to the driver.
By this do you mean that I can access the driver directly and no
protocol driver (like ndisuio) is used to handle my request in any way
to foward them to the miniport? Also if a protocol driver is being
used, if I want that all calls made by my application are handled
through my protocol driver, then how can I know/ensure that? This will
help me to know whether I need to compile a protocol driver or not.
Also is there any way by which I can verify that a particular miniport
has exposed itself through a mangement interface, say by looking up a
place in registry or by calling some API, from the user-mode? I think i
know the device name of the miniport. I need to support my application
only for a particular network card.
As Thomas pointed out elsewhere, you can't just find a random miniport
with an IOCTL interface and start using it. You have to know what
IOCTLs it implements, and that is driver-specific. So it would be
useless as a general approach to just go around finding registered
devices and trying to IOCTL them.

What is the overall problem your'e trying to solve here? Take a step
back and think about it; maybe someone here can suggest something
workable.

-sd
s***@hotmail.com
2006-07-24 23:27:16 UTC
Permalink
Hi mate

Try to think logically. Let's say you know the name of the miniport
that supports management interface, so you managed to open its handle
and are about to start sending IOCTLs to it. What is your next
step???? Which particular IOCTL are you going to send???? Don't forget
that miniport drivers are not required to support this interface, which
means that driver writer may define ANY(!!!!) IOCTLs he decides that
his driver needs it.

If you think about it carefully, you will understand that you are on
the wrong venue from the very, very beginning - you should not work
with miniport drivers this way (unless you write your own miniport
driver and access it from you application)

Anton Bassov
Post by NYA
Thanks Anton!! Being a novice to driver development this has solved
many of my doubts. But I have some more.
Please can you read my todays reply to Thomas's post to put the problem
into perspective.
Now you say that a symbolic link to the driver obl is created with
NdisMRegisterDevice(), and we can send IOCTLs directly to the driver.
By this do you mean that I can access the driver directly and no
protocol driver (like ndisuio) is used to handle my request in any way
to foward them to the miniport? Also if a protocol driver is being
used, if I want that all calls made by my application are handled
through my protocol driver, then how can I know/ensure that? This will
help me to know whether I need to compile a protocol driver or not.
Also is there any way by which I can verify that a particular miniport
has exposed itself through a mangement interface, say by looking up a
place in registry or by calling some API, from the user-mode? I think i
know the device name of the miniport. I need to support my application
only for a particular network card.
Thanks again
Nishchal
Post by s***@hotmail.com
Hi mate
Any driver that registers itself as miniport one cannot be accessed via
the regular dispatch interface, so that you cannot open a handle to
miniport driver and sent IOCTs to it. The only system component that is
allowed to access miniport drivers is NDIS library - miniport driver
registers its callbacks that get called by NDIS when protocol drivers
call NDIS library functions
This is a rule, and, as any rule, it has an exception - if miniport
driver developer wants to make his driver available to non-NDIS
components (i.e. OS and user applications), it may register stand-alone
device and symbolic link to it with NdisMRegisterDevice(). If it does
so, you are able to open handles and send IOCTLs to this device
(sometimes they call it management interface). This feature is optional
- miniport drivers are NOT required to expose this management interface
To summarize, everything depends on particular card, i.e whether it
exposes its management interface. I don't really know what you want to
do, but if you want your code to work with all network cards, you
should write a protocol driver. This driver will deal with user
application on its upper edge and with NDIS library on its lower one.
This is how you are supposed to work with miniports.
Anton Bassov
Post by NYA
Hello
There are 2 ways of opening a handle to the network card.
[1] By first opening a stream to the ndisuio/clone of ndisprot protocol
driver and then binding it to the underlying mac--
handle=CreateFile("\\\\.\\\\ndisprot",......);
DeviceIoControl(handle, IOCTL_NDISUIO_BIND_WAIT.....);
//After enumerating and selecting a device, a
DeviceIoControl(Handle, IOCTL_NDISPROT_OPEN_DEVICE,
(LPVOID)&wNdisDeviceName[0]......);
[2] But if we already know the device name we can use the name to open
a handle to thre adapter.
createfile("\\\\.\\{2AA42F55-F......
What is the difference between the two methods? Will a protocol driver
be used internally or for further deviceiocontrol request if the handle
is opened by the second method?
If yes, then supposing if i have an ndisprot cloned protocol driver
(from win2k3 server ddk) installed. then which protocol driver will be
used internally the ndisuio (default xp installed) or the ndisprot
clone(installed by user)? This is beacuse both of the drivers could be
used. How can i make sure that in this case my calls are passed through
ndisproto clone?
If no then will any protocol driver be used for further OID Requests
from deviceiocontrol
Thanks
Nishchal
Loading...