Need a little guidance

Hi folks,

I’m a little new to Windows driver development – although at least I now have the Windows Internals book. I’m working on writing my first Storport Miniport driver, but as it turns out, I’m going to need to call in to NDIS as I need to communicate with an underlying NIC.

I’ve done a decent amount of reading on NDIS, but I’m still left a bit confused. From everything I’ve read, it looks like there are 3 types of NDIS drivers:

* NDIS intermediate driver
* NDIS protocol driver
* NDIS miniport driver

Since what I’m working on is sort of on the “top edge” of NDIS, presumably – and maybe this is where I’m going wrong – I’m going to want to implement an NDIS protocol driver.

I guess my question is, can a Storport Miniport driver *also* be an NDIS protocol driver? No matter what, there are certain things that have to take place in the DriverEntry() routine – and right now, everything I’m doing there is Storport specific. Perhaps I’m making this a lot more difficult than I need to. If someone could point me in the right direction, that would be tremendous.

Super confused,
RB

> * NDIS intermediate driver

A combination of a protocol and miniport in single binary. More so, it is kinda a miniport which uses the underlying miniports (and accesses them as a protocol) to do its job.

General case of NDIS IM is called MUX IM.

The simplified case where there is an 1:1 mapping of upper edge “adapter” instances (implemented by the IM) to the underlying adapters is called Filter IM. Their difference in code is IIRC limited to a single NdisIMAssociateMiniport call, but their difference in INF, installation and registry data is huge.

Filter IMs are deprecated in NDIS 6 (i.e. Vista+). Instead, the new concept of NDIS Filter appeared.

MUX IMs are still alive. They are just “miniport implemented as protocol” thing.

* NDIS protocol driver

Any driver talking (get/set property, send/receive packet) to network adapters. Such a talk mandates the rather complicated lower egde.

Any driver built with any framework can have a protocol lower edge as its part. Just put the necessary stuff to the registry (INF can be used) and use the protocol name in NdisRegisterProtocol which will match the name in this registry stuff.

* NDIS miniport driver

Network adapter driver. Implements the “network adapter” object.

Must be written based on an NDIS framework. Other frameworks like SCSIPORT cannot be used, KMDF can only be used in miniport mode.

Always a PnP driver. Must be installed by a PnP INF.

where I’m going wrong – I’m going to want to implement an NDIS protocol driver.

Yes.

I guess my question is, can a Storport Miniport driver *also* be an NDIS protocol driver?

Yes.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

Maxim, thanks for getting back to me. I appreciate the detailed responses – particularly the elaborations on the different kinds of NDIS drivers.

In summary, it sounds like I actually *can* do what I was asking – have a Storport-Miniport driver behave as an NDIS protocol driver too. In my sources file, I have storport.lib included in my list of targetlibs; will I need to include ndis.lib too?

Thanks!

>targetlibs; will I need to include ndis.lib too?

This should work.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

> I guess my question is, can a Storport Miniport driver *also* be an NDIS protocol driver?

No.

When an NDIS miniport driver calls NdisMRegisterMiniport, that sets IRP dispatch functions in the DRIVER_OBJECT.

When a storport miniport driver calls StorPortInitialize, STORPORT.SYS sets its own IRP dispatch functions in the DRIVER_OBJECT.

These can’t be called for the same driver.

>In summary, it sounds like I actually *can* do what I was asking – have a Storport-Miniport driver >behave as an NDIS protocol driver too.
You should design at least two drivers. One driver would be a Virtual miniport StorPort driver and the second a NDIS Protocol driver. Both drivers will communicate with each other by using IOCallDriver.
This would be a standard design for your solution.

Igor Sharovar

And it will get very “interesting” if it’s desired to boot from as
a requisite, hibernate/crashdump to such LUN:)

On Mon, Nov 7, 2011 at 10:09 AM, wrote:

> >In summary, it sounds like I actually can do what I was asking – have
> a Storport-Miniport driver >behave as an NDIS protocol driver too.
> You should design at least two drivers. One driver would be a Virtual
> miniport StorPort driver and the second a NDIS Protocol driver. Both
> drivers will communicate with each other by using IOCallDriver.
> This would be a standard design for your solution.
>
> Igor Sharovar
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

wrote in message news:xxxxx@ntdev…
>> I guess my question is, can a Storport Miniport driver also be an NDIS
>> protocol driver?
>
> No.
>
> When an NDIS miniport driver calls NdisMRegisterMiniport, that sets IRP
> dispatch functions in the DRIVER_OBJECT.
>
> When a storport miniport driver calls StorPortInitialize, STORPORT.SYS
> sets its own IRP dispatch functions in the DRIVER_OBJECT.
>
> These can’t be called for the same driver.

But the OP needs a NDIS protocol, not miniport. Will your verdict still
hold?
Connecting drivers in two unrelated stacks is a difficult task for beginner.
– pa

>Connecting drivers in two unrelated stacks is a difficult task for beginner.
Making a miniport StorPort driver as a NDIS driver also is more difficult task than using two drivers.
Microsoft introduces Virtual miniport storPort driver especially for such type of designs which OP asked.

Igor Sharovar

If you need to talk to a NIC (rather than act like a NIC) then I think something like Winsock Kernel might be more appropriate: http://blogs.msdn.com/b/wndp/archive/2006/02/24/538746.aspx

-p

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@live.com
Sent: Sunday, November 06, 2011 12:10 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Need a little guidance

Hi folks,

I’m a little new to Windows driver development – although at least I now have the Windows Internals book. I’m working on writing my first Storport Miniport driver, but as it turns out, I’m going to need to call in to NDIS as I need to communicate with an underlying NIC.

I’ve done a decent amount of reading on NDIS, but I’m still left a bit confused. From everything I’ve read, it looks like there are 3 types of NDIS drivers:

* NDIS intermediate driver
* NDIS protocol driver
* NDIS miniport driver

Since what I’m working on is sort of on the “top edge” of NDIS, presumably – and maybe this is where I’m going wrong – I’m going to want to implement an NDIS protocol driver.

I guess my question is, can a Storport Miniport driver *also* be an NDIS protocol driver? No matter what, there are certain things that have to take place in the DriverEntry() routine – and right now, everything I’m doing there is Storport specific. Perhaps I’m making this a lot more difficult than I need to. If someone could point me in the right direction, that would be tremendous.

Super confused,
RB


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Awesome, thank you all for such detailed feedback. It looks like the big questions I had have now been answered. I was skeptical that it could be done with a single module to begin with – largely for the reasons that Alex had mentioned.

Incidentally, I actually do plan to act as an adapter (rather than just interact with one), so it sounds like the two-driver-minimum approach is the way to go.

Many thanks!
RB