This post expands on the adapter context issue discussed in the thread
“Debugging DRIVER_IRQL_NOT_LESS_OR_EQUAL”.
Over the past few days I’ve been going through my driver and cleaned it up
tremendously based on the excellent advice I’ve received in this newsgroup.
Furthermore, I added support for multiple adapters by using a global,
spinlock-protected linked list containing the adapter context areas.
As stated earlier, my driver acts as a virtual network adapter which can
receive packets from a user-mode application and indicate them up to NDIS.
In the netvmini sample, Eliyas only registers a single, global device object
(not sure why, really) which is used by all adapter instances.
Now, if I send a packet down to the driver and multiple adapters are
running, which adapter should receive the IRP request? Earlier on, when I
was assuming only a single adapter would be installed, I would just insert
the IRP request in that adapter’s IRP safe-cancel queue.
I imagine one could register a device object for each adapter, but is this
the correct and desired approach?
Continuing on…
Imagine the above problem is solved; how do I gain access to the desired
adapter from the dispatch routine? Only the device object is passed as an
argument… This question is, of course, dependent on the solution above, and
such may be rendered superfluous.
Also, I’d like to take the opportunity to say a big thank you to the entire
community here. The excellent help is greatly appreciated.
Thanks!