Re: NDIS Drivers, Symbolic Names, Ethernet send/receive etc.

From: Skybuck Flying (nospam_at_hotmail.com)
Date: 01/19/05


Date: Wed, 19 Jan 2005 16:54:18 +0100


"Arkady Frenkel" <arkadyf@hotmailxdotxcom> wrote in message
news:uXM0aWS$EHA.824@TK2MSFTNGP11.phx.gbl...
> Hi!
> "Skybuck Flying" <nospam@hotmail.com> wrote in message
> news:csgk1d$8sg$1@news4.zwoll1.ov.home.nl...
> > Hi,
> >
> > Suppose a user has a computer with a network card and windows xp
> > pre-installed.
> >
> > Now I want to write a program to send and receive ethernet packets for
> this
> > kind of computer.
> >
> > To do this I would need to call CreateFile and then use some sort of
> > symbolic name.
>
> Usually you can't do this because not driver but NDIS created security
> setting for device
> due to Security Descriptor Definition Language (SDDL) in the driver
calling
> IoCreateDeviceSecure() inside.
> >
> > Maybe something like:

( I retrieved these NDIS and IP strings from QueryDosDevice )

> > \\.\\NDIS
> >
> > What is this specific symbolic name ?
> >
> > Or maybe
> >
> > \\.\\IP
> >
> > ?
> >
>
> No , you have to use GUID as a name for device device
>
> > Does windows xp automatically install NDIS drivers for detected network
> > cards ?
> >
> Yes , but if default driver don't match the device , Device manager will
ask
> you about
> driver for NIC
>
> > If so how can I use these drivers ? How do I find out their symbolic
names
> ?
> >
> You'll see them in registry

Yes after my original post I found some information about how to retrieve
"the string" that has to be passed to CreateFile. It took me a day to find
out that information since MSDN library does not mention it.

I finally found it by following many links in posts and finally found it in
the online version of the Windows DDK by searching for:

"IOCTL_NDIS_QUERY_GLOBAL_STATS"

http://www.osronline.com/ddkx/network/107ioctl_24fm.htm

Text:

"
IOCTL_NDIS_QUERY_GLOBAL_STATS
An application can use IOCTL_NDIS_QUERY_GLOBAL_STATS to obtain information
from a network adapter. The application passes
IOCTL_NDIS_QUERY_GLOBAL_STATS, along with an Object Identifier (OID), in the
DeviceIoControl function.

Operation
IOCTL_NDIS_QUERY_GLOBAL_STATS directs NDIS to use the specified OID to
obtain information from the specified network adapter.

BOOL DeviceIoControl(
  IN HANDLE hDevice,
  IN DWORD dwIoControlCode,
  IN LPVOID lpInBuffer,
  IN DWORD nInBufferSize,
  OUT LPVOID lpOutBuffer,
  IN DWORD nOutBufferSize,
  OUT LPDWORD lpBytesReturned,
  IN LPOVERLAPPED lpOverlapped
);
Parameters
hDevice
Handle to the network adapter on which to obtain information. To retrieve
this handle, use the CreateFile function.
dwIoControlCode
Specifies IOCTL_NDIS_QUERY_GLOBAL_STATS.
lpInBuffer
Pointer to a buffer that contains the query OID that NDIS should use.
nInBufferSize
Specifies the size, in bytes, of the query OID at lpInBuffer.
lpOutBuffer
Pointer to a buffer that receives the data that was requested by the query
OID at lpInBuffer.
nOutBufferSize
Specifies the size, in bytes, of the buffer that the caller allocated for
lpOutBuffer.
lpBytesReturned
Pointer to a variable that receives the actual size, in bytes, of the data
stored at lpOutBuffer.
lpOverlapped
Specifies NULL if the query is to be performed synchronously or can be a
pointer to a valid OVERLAPPED structure if the query is to be performed
asynchronously. Whether the query is synchronous or asynchronous depends on
whether the handle in hDevice was created with the FILE_FLAG_OVERLAPPED
flag, which indicates overlapped (or asynchronous) operation. Both
FILE_FLAG_OVERLAPPED and OVERLAPPED are described in the Platform SDK
documentation.
Return Values
If the query succeeds, DeviceIoControl returns a nonzero value.

If the query fails, DeviceIoControl returns zero. To get extended error
information, call GetLastError.

Headers
Defined in ntddndis.h. Include ntddndis.h.

Comments
This IOCTL will be deprecated in future OS releases. You should use WMI
interfaces to query miniport information. For more information see, NDIS
Support for WMI.

An application can use IOCTL_NDIS_QUERY_GLOBAL_STATS with any query OID that
is supported by the network adapter and the adapter's miniport driver.

Before an application can use IOCTL_NDIS_QUERY_GLOBAL_STATS, it must call
the CreateFile function to open a handle to the network adapter. In this
CreateFile call, the application passes 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. The
application can use the following registry functions to access the registry:

RegOpenKeyEx to open a key.
RegEnumKeyEx to enumerate the subkeys of a given key.
RegQueryValueEx to retrieve detailed data about a particular subkey.
RegCloseKey to close a key.
For more information on DeviceIoControl, CreateFile, GetLastError, and the
registry functions, see the Platform SDK documentation.

For Windows 2000 and later versions, use the interface name to open the
device. To get the interface name, enumerate the GUID_NDIS_LAN_CLASS device
interfaces by calling the SetupDiEnumDeviceInterfaces function. For
information about enumerating device interfaces, see Device Information
Sets.

Windows 98/Me do not support IOCTL_NDIS_QUERY_GLOBAL_STATS.

Built on Friday, April 11, 2003
"

>
> > If not then the user should install NDIS drivers ?
> >
> I answered on that : one before last
>
> > Again how do I find out their symbolic names ? Or how do I find these
> > drivers ? ( so my application can talk to them ).
> >
> As an example look at http://www.pcausa.com/Utilities/macaddr2.htm
>
> > Is there anything else I need to do with these NDIS drivers... maybe
bind
> > them ? or is that driver specific ?
> >
> Device Manager automatically bind miniport(s) ( driver(s) of NIC ) to
layer
> above : IM or protocol.
> Miniport in NDIS have no knowledge about protocol above it , only NDIS
> manage that.
> HTH
> Arkady
>
> > Bye,
> > Skybuck.
> >
> >
> >
>
>



Relevant Pages

  • Re: Inventory Query Help Needed
    ... So, if the two were combined as is "normal", your query would have worked ... > FROM NetCollect N ... When someone logs into the network the ... >> duplicating it's computername, ipaddress, and username information in each ...
    (microsoft.public.sqlserver.programming)
  • RE: LDAP query for xerox 3545 printer/scanner blocked by SBS 2003?
    ... You also cannot query using the LDP tool. ... Step2:Please ensure the DNS on workstation is pointed to SBS server. ... Run Network Monitor on the SBS server to capture the network traffic ... Monitor will capture some packets which pass through this interface. ...
    (microsoft.public.windows.server.sbs)
  • Re: MAC address
    ... Returns the media access control address and list of network protocols ... Runs the command with the account permissions of the user specified by ... Specifies the password of the user account that is specified in the /u ... Getmac can be useful either when you want to enter the MAC address ...
    (microsoft.public.win2000.general)
  • Re: Profiler sees very different durations for the same SQL select stmt of spid(s) from different c
    ... you've got a network problem with spid 180. ... are then able to test the network without having to install Query Analyzer ... that would still occupy at least 97 MB in memory on the client. ... it may be a connection issue. ...
    (microsoft.public.sqlserver.server)
  • Re: Accessing a paradox table from a C# application...
    ... I would get a copy of Paradox and play around with restructuring the table and indexes and see what happens to query speed. ... There are several threads on the optimal way to set up a network. ... SELECT TOP 1000 * FROM ModelSer ...
    (comp.databases.paradox)