2.3 NDIS Library Functions Used by Protocol Drivers
In addition to the NdisXxx listed here, highest-level NDIS protocol drivers that are Windows NT transport protocols call the TdiXxx functions described later in Part II.
Acquires a spin lock so the caller can synchronize access to resources shared among nonISR driver routines in a multiprocessor-safe way.
Modifies the length specified in a given buffer descriptor that was allocated or copied by the caller.
Creates a buffer descriptor describing a specified virtual (sub)range within an already allocated, nonpaged memory block, given a handle returned by NdisAllocateBufferPool or NdisAllocateMemory.
Returns a handle with which the caller can allocate buffer descriptors with NdisAllocateBuffer.
Allocates resident (nonpaged) system-space memory, optionally within a specified address limit, as a physically contiguous allocation, and/or as a noncached allocation.
Allocates a packet descriptor, given a handle returned by a preceding call to NdisAllocatePacketPool.
Allocates and initializes a block of nonpaged packet pool, given the number of packet descriptors and how many bytes each fixed-size packet descriptor should contain.
Initializes a variable of type NDIS_SPIN_LOCK, used to synchronize access to data shared among driver routines. An initialized spin lock, for which the caller supplies resident storage, is a required parameter to the Ndis..SpinLock and NdisInterlockedXxx functions.
Converts a given counted ANSI string into a counted Unicode string.
Returns a pointer to a linked buffer, given a pointer to an NDIS buffer descriptor.
Links a given buffer descriptor at the end of the chain of buffer descriptors for a given packet descriptor.
Links a given buffer descriptor at the start of the chain of buffer descriptors for a given packet descriptor.
Releases the binding set up with NdisOpenAdapter, given the binding handle that it previously returned.
Releases the handle returned by NdisOpenProtocolConfiguration after the caller has retrieved configuration information and/or, possibly, stored additional information about itself in the registry.
Completes a binding operation when the driver returned NDIS_STATUS_PENDING from its ProtocolBindAdapter function.
Completes a close-adapter operation when the driver returned NDIS_STATUS_PENDING from its ProtocolUnbindAdapter function.
Creates a buffer descriptor for a specified virtual (sub)range, given a handle for a block of already allocated memory and a pointer to the memory descriptor for the block.
Copies a specified number of bytes of data from one packet to another, starting at a specified offset in a given source packet’s data and copying the data to a specified offset in the target packet. Returns the number of bytes actually copied, which can be less than the requested number, depending on the source packet and specified starting offset for the copy operation.
Releases the resources allocated when the driver called NdisRegisterProtocol, given the protocol handle it returned at initialization.
Allocates and initializes a packet descriptor when the caller is running at IRQL DISPATCH_LEVEL, given a handle returned by a preceding call to NdisAllocatePacketPool.
NdisDprAllocatePacketNonInterlocked
Allocates a packet descriptor when the caller is running at IRQL DISPATCH_LEVEL and that caller provides internal synchronization for accessing packet pool, given a handle returned by a preceding call to NdisAllocatePacketPool.
Releases a driver-allocated packet descriptor and returns it to the free list when the caller is running at IRQL DISPATCH_LEVEL.
NdisDprFreePacketNonInterlocked
Releases a packet descriptor that was allocated with NdisDprAllocatePacketNonInterlocked and returns it to the free list.
Compares two strings to determine whether they are equal.
Releases a buffer descriptor obtained in a preceding call to NdisAllocateBuffer or NdisCopyBuffer.
Releases a handle obtained in a preceding call to NdisAllocateBufferPool.
Releases a handle that was obtained in a preceding call to NdisAllocateMemory.
Releases a packet descriptor that was allocated from packet pool with NdisAllocatePacket and returns it to the free list.
Releases a handle to a block of packet pool that was allocated with NdisAllocatePacketPool.
Releases a spin lock initialized in a preceding call to NdisAllocateSpinLock, usually when a driver is unloading.
Frees the storage for a buffered string.
NdisGetBufferPhysicalArraySize
Returns the number of physical discontiguities in a buffer, given the buffer descriptor.
NdisGetCurrentProcessorCpuUsage
Returns how busy the current processor is as a percentage.
Returns the current system time, suitable for use as a timestamp.
Returns pointers to the buffer descriptor and base virtual address for the initial buffer chained to a given packet, along with the sizes of the initial buffer and full buffer, in case the buffer is fragmented.
Returns the next buffer descriptor in a chain, given the current buffer descriptor.
Returns the flags, if any, set by a higher-level protocol driver in a given packet.
Returns the number of bytes in a received net packet header from the HeaderSize set in the NDIS_PACKET_OOB_DATA block associated with a given packet descriptor by the indicating miniport.
NDIS_GET_PACKET_MEDIA_SPECIFIC_INFO
Returns a pointer to buffered out-of-band information, such as packet priority, and the number of bytes in the buffer from the MediaSpecificInformation and SizeMediaSpecificInfo set in the NDIS_PACKET_OOB_DATA block associated with a given packet descriptor by the indicating miniport.
Returns the TimeReceived timestamp from the NDIS_PACKET_OOB_DATA block associated with an indicated receive packet.
Returns the TimeSent timestamp from the associated NDIS_PACKET_OOB_DATA block associated with an indicated receive packet.
NdisIMDeInitializeDeviceInstance
Calls an NDIS intermediate driver's MiniportHalt function to tear down the driver's virtual NIC.
NdisIMInitializeDeviceInstance
Calls an NDIS intermediate driver’s MiniportInitialize function to set up the driver’s virtual NIC for I/O operations bound for an underlying NIC driver to which the intermediate driver is bound.
Calls an intermediate driver’s callback function to when it can execute in a MiniportXxx context, as, for example, to forward an indication to higher-level protocols.
Registers an NDIS intermediate driver’s MiniportXxx entry points and name with the NDIS library when the driver initializes.
Returns the function of an intermediate driver to the context in which it was executing before it called NdisIMSwitchToMiniport.
Allows an intermediate driver function to call NdisMXxx normally called only from MiniportXxx functions, as, for example, to make indications up to higher-level protocols.
Initializes a counted ANSI string.
Marks a given driver function as initialization-only code to be discarded after the function has run once.
Sets up an event object during driver initialization to be used subsequently as a synchronization mechanism.
Sets up a queue header for a driver’s internal queue, given a pointer to driver-supplied resident storage for the queue header and queue. Then, entries (usually packets) can be added to and removed from the doubly-linked queue with the NdisInterlocked..List functions.
Allocates a buffer for and initializes a counted string in the system-default character set, given a source string and a NULL pointer.
Initializes a counted Unicode string.
Adds an unsigned long value to a given unsigned integer as an atomic operation, using a caller-supplied and initialized spin lock.
Inserts an entry, usually a packet, at the head of a doubly linked list using a caller-supplied and initialized spin lock so that access to queued entries is synchronized in a multiprocessor-safe way among driver functions.
Inserts an entry, usually a packet, at the end of a doubly linked list using a caller-supplied and initialized spin lock so that access to queued entries is synchronized in a multiprocessor-safe way among driver functions.
Removes an entry, usually a packet, from the head of a doubly linked list using a caller-supplied and initialized spin lock so that access to queued entries is synchronized in a multiprocessor-safe way among driver functions.
Copies a specified number of bytes from one caller-supplied location to another.
Informs the NDIS library about significant features of an intermediate driver’s virtual NIC and prevents NDIS from timing out sends and requests in the intermediate driver.
Returns a pointer to the NDIS_PACKET_OOB_DATA block associated with a given packet descriptor.
Sets up a binding between the caller and an underlying NIC driver, given an array of medium types that the protocol driver supports, the number of elements in the supplied array, the handle already returned by NdisRegisterProtocol, a handle to a protocol-supplied context area to be passed back to the protocol in subsequent receive indications, the name of the NIC to be opened, a mask set with the caller’s preferred open options, and, possibly, a pointer to some caller-supplied addressing information, as well as four caller-specified locations at which NdisOpenAdapter returns values. If the call succeeds, NdisOpenAdapter returns a binding handle for the protocol to use in subsequent NdisXxx calls that forward device I/O requests to the NIC driver, an index specifying the NIC driver’s preferred medium type, and NDIS_STATUS_SUCCESS; otherwise, it returns both a general failure status and an informational error status.
Returns a handle for a driver’s HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services
\NICDriverInstance\Parameters\ProtocolName registry key. This handle is a required parameter to other NdisXxx configuration functions.
Marks a driver function as pageable code.
Displays a given string in the debugging window.
Retrieves the size of the range, and optionally its base virtual address, specified in a given buffer descriptor.
Retrieves the base virtual address of the range specified in a given buffer descriptor.
Returns any or all of the following information about a given packet descriptor: a count of buffer descriptors chained to the packet descriptor, the total number of bytes in all buffers mapped by the buffer descriptor chained to the packet descriptor, the total number of physically discontiguous blocks for all such buffers, and a pointer to the initial buffer descriptor in the chain.
Returns information from the out-of-band data block associated with a given packet descriptor set up by the underlying driver for a receive indication.
Reads the value of a named entry of the specified type, given the registry handle for the ..\Parameters\ProtocolName key returned by NdisOpenProtocolConfiguration.
Resets the valid counts of chained buffer descriptors for a given packet descriptor.
Registers a protocol driver’s upper-edge entry points (ProtocolXxx) and name with the NDIS library, given a pointer to the NDIS_PROTOCOL_CHARACTERISTICS structure set up by the caller and the size in bytes of this structure. NDIS returns the status of the registration attempt and, if the call is successful, a protocol handle representing the driver, which can be passed in a subsequent call to NdisOpenAdapter.
Sets to NULL the queue head for any chained buffers in a given packet descriptor and reinitializes it for reuse.
Releases a spin lock that was acquired in a preceding call to NdisAcquireSpinLock.
Forwards a caller-initialized NDIS_REQUEST-type query or set request to the underlying NIC driver, given the binding handle previously returned by NdisOpenAdapter.
Forwards a reset request to the underlying NIC driver, given the binding handle and a pointer to a variable in which the status of the reset operation is returned.
Clears the Signaled state of a given event.
Retrieves a ULONG value from the source address, avoiding alignment faults.
Releases ownership of one or more receive packets after a protocol driver has consumed the receive data.
Forwards a packet to the NIC driver for transmission over the wire, given the binding handle, a pointer to the packet to be sent, and a pointer to a variable in which the status of the send is returned.
Forwards a multipacket send request, possibly specifying out-of-band information for each packet in the array, such as packet priority, to the underlying driver.
Sets a given event to the Signaled state if it was not already Signaled, thereby causing waits on the event to be satisfied.
Sets the Flags member in a given packet descriptor to the given value, before the protocol calls NdisSendPackets or NdisSend.
NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO
Sets the MediaSpecificInformation and SizeMediaSpecificInfo in the NDIS_PACKET_OOB_DATA block, specifying out-of-band information associated with a protocol-allocated packet descriptor for a send request.
Sets the TimeToSend timestamp in the NDIS_PACKET_OOB_DATA block associated with a protocol-allocated packet descriptor, specifying when the underlying driver should transmit the packet data over the wire.
NdisSetSendFlags
See NdisSetPacketFlags.
Stores a ULONG value at a particular address, avoiding alignment faults.
Forwards a request that the underlying NIC driver transfer (copy) received data to a supplied packet, given the binding handle, the receive-context handle passed to the protocol when the receive was indicated, the byte offset in the indication at which to start the transfer and the number of bytes to transfer, and pointers to variables in which the status of the completed transfer operation and the number of bytes actually transferred are returned.
Removes a given buffer descriptor at the end of the chain of buffer descriptors for a given packet descriptor and returns a pointer to the buffer descriptor.
Removes a given buffer descriptor at the start of the chain of buffer descriptors for a given packet descriptor and returns a pointer to the buffer descriptor.
Converts a given counted Unicode string into a counted ANSI string.
Puts the caller into a wait state until the given event is set to the Signaled state or the wait times out.
Writes a caller-supplied value entry in the registry, given the handle for the ..\Parameters\ProtocolName key returned by NdisOpenProtocolConfiguration.
Allocates an error-log record, fills it in, and writes it to the I/O error log, given a binding handle for the underlying NIC, an NDIS_XXX error code, a count of caller-supplied error values, and a corresponding number of ULONGs specifying additional information about the I/O error or configuration error.
Fills a block of memory with zeros, given a pointer to the block and the length in bytes to be filled.
Highest-level NDIS drivers that export only the lower-edge ProtocolXxx functions also can call support routines exported by other Windows NT kernel-mode components. For more information about these support routines, see the Kernel-Mode Driver Reference.