Hello,

I need to create a driver for a virtual network adapter, the prupose
being to allow softwares to communicate on it asif it was a real
connection, while in fact it is controlled by a running application
(packets sent to it are read by this application, and the same
application sometimes needs to send packets "trough" this interface to
answer).

I'm new to driver coding, so I have some questions:

1 - I'm using the latest Windows DDK to develop this, is it correct ?
(I've seen another framework for vista drivers, but I guess it isn't
backward compatible out of the box ?)

2 - to do this, I'm studying the "netvmini" sample provided by
microsoft, since it creates a virtual adapter that, well, do nothing.
Am I correct ? (I'm a little lost between the different kind of NDIS
drivers)

3 - How to make it write and read its packet to an application ? What I
would like to know is both the best way to share data between them
(shared memory ? ioctl control ?), and the two "base" fonction I should
look at for sending/receiving packets (I've found no how to, so all I
can do is study the api for this function).

Thanks a lot for any anwser

--
Lepidosteus / Vianney Devreese
mail: lepidosteus at gmail dot com

Re: Create a virtual network adapter ? by Don

Don
Sat Jun 02 10:41:56 CDT 2007


"Lepidosteus" <lepidosteus@gmail.com> wrote in message
news:xn0f6zcacukahq000@msnews.microsoft.com...
> Hello,
>
> I need to create a driver for a virtual network adapter, the prupose
> being to allow softwares to communicate on it asif it was a real
> connection, while in fact it is controlled by a running application
> (packets sent to it are read by this application, and the same
> application sometimes needs to send packets "trough" this interface to
> answer).
>
> I'm new to driver coding, so I have some questions:
>
> 1 - I'm using the latest Windows DDK to develop this, is it correct ?
> (I've seen another framework for vista drivers, but I guess it isn't
> backward compatible out of the box ?)

No, get the Vista WDK, it has the latest sources, tools and docs and will
build drivers that work from Windows 2000 to Vista.

> 2 - to do this, I'm studying the "netvmini" sample provided by
> microsoft, since it creates a virtual adapter that, well, do nothing.
> Am I correct ? (I'm a little lost between the different kind of NDIS
> drivers)

Take a look at NDIS edge and PCIDRV. You should be able to use NDISEDGE
unchanged with a simplified PCIDRV. There is a version of this in KMDF
which will be simpler for you to start with, and long term is the new
model.

> 3 - How to make it write and read its packet to an application ? What I
> would like to know is both the best way to share data between them
> (shared memory ? ioctl control ?), and the two "base" fonction I should
> look at for sending/receiving packets (I've found no how to, so all I
> can do is study the api for this function).

Use IOCTL's shared memory is a lot of trouble for little gain except in the
most performance demanding situations. If you send IOCTL's to the driver
and pend them there, the driver can release these to return packets to the
application.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply



Re: Create a virtual network adapter ? by Lepidosteus

Lepidosteus
Sat Jun 02 14:27:05 CDT 2007

Don Burn wrote:
> > 2 - to do this, I'm studying the "netvmini" sample provided by
> > microsoft, since it creates a virtual adapter that, well, do
> > nothing. Am I correct ? (I'm a little lost between the different
> > kind of NDIS drivers)
>
> Take a look at NDIS edge and PCIDRV. You should be able to use
> NDISEDGE unchanged with a simplified PCIDRV. There is a version of
> this in KMDF which will be simpler for you to start with, and long
> term is the new model.

Do you mean I need both ?
From what I've understood so far, in a simple way, NDISEGDE get the
requests, and then forwards it to the driver managing the hardware.

Since my system is not based on any hardware but on a pure software
solution, do I still need a "pcidrv" running at the bottom and what is
it goind to do ?

Thanks for the help

--
Lepidosteus / Vianney Devreese
mail: lepidosteus at gmail dot com
url: http://lepidosteus.com

Re: Create a virtual network adapter ? by Don

Don
Sat Jun 02 14:32:14 CDT 2007

I suggested using both, since then you would not need to deal with learning
both regular windows driver development and NDIS. Yes PCIDRV in its
current form manages hardware, in your model the "hardware" would be the
interactions with the user program.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

"Lepidosteus" <lepidosteus@gmail.com> wrote in message
news:xn0f6zipc139xqy000@msnews.microsoft.com...
> Don Burn wrote:
>> > 2 - to do this, I'm studying the "netvmini" sample provided by
>> > microsoft, since it creates a virtual adapter that, well, do
>> > nothing. Am I correct ? (I'm a little lost between the different
>> > kind of NDIS drivers)
>>
>> Take a look at NDIS edge and PCIDRV. You should be able to use
>> NDISEDGE unchanged with a simplified PCIDRV. There is a version of
>> this in KMDF which will be simpler for you to start with, and long
>> term is the new model.
>
> Do you mean I need both ?
> From what I've understood so far, in a simple way, NDISEGDE get the
> requests, and then forwards it to the driver managing the hardware.
>
> Since my system is not based on any hardware but on a pure software
> solution, do I still need a "pcidrv" running at the bottom and what is
> it goind to do ?
>
> Thanks for the help
>
> --
> Lepidosteus / Vianney Devreese
> mail: lepidosteus at gmail dot com
> url: http://lepidosteus.com



Re: Create a virtual network adapter ? by AntonBassov

AntonBassov
Sun Jun 03 09:33:00 CDT 2007

Don,

> I suggested using both, since then you would not need to deal with learning
> both regular windows driver development and NDIS.

I've got a couple of comments here.....

1. Although NDIS is pretty much a world on its own, still there is no way to
write a NDIS driver without knowing general kernel-mode concepts (IRQL,
spinlocks, paged vs unpaged memory, etc). In order to learn these things, it
is better to start with conventional WDM drivers, and to read WDM-related
documentation. If you look at NDIS documentation, you will see that it
assumes the reader is familiar with general kernel-mode concepts

2. Frameworks are meant just to speed up the development - one should not
think of them as of convenient way of avoiding learning underlying concepts.
This is particularly true for kernel-level development. In general, I think
frameworks are OK for the user-mode apps but not for drivers. Someone who has
has no clue about kernel-mode concepts is very unlikely to produce a workable
driver - no matter how well a framework shields him from everything that
happens behind the scenes, sooner or later you will see a post like " I
modify xxx sample..... my driver don't work.... please help.... excuse my bad
english" ( I think that introduction
of kernel-mode frameworks must be quite beneficial for outsourcers - people
will start thinking that frameworks make driver development easy, and try to
outsource more and more projects)

Anton Bassov





"Don Burn" wrote:

> I suggested using both, since then you would not need to deal with learning
> both regular windows driver development and NDIS. Yes PCIDRV in its
> current form manages hardware, in your model the "hardware" would be the
> interactions with the user program.
>
>
> --
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
> Website: http://www.windrvr.com
> Blog: http://msmvps.com/blogs/WinDrvr
> Remove StopSpam to reply
>
> "Lepidosteus" <lepidosteus@gmail.com> wrote in message
> news:xn0f6zipc139xqy000@msnews.microsoft.com...
> > Don Burn wrote:
> >> > 2 - to do this, I'm studying the "netvmini" sample provided by
> >> > microsoft, since it creates a virtual adapter that, well, do
> >> > nothing. Am I correct ? (I'm a little lost between the different
> >> > kind of NDIS drivers)
> >>
> >> Take a look at NDIS edge and PCIDRV. You should be able to use
> >> NDISEDGE unchanged with a simplified PCIDRV. There is a version of
> >> this in KMDF which will be simpler for you to start with, and long
> >> term is the new model.
> >
> > Do you mean I need both ?
> > From what I've understood so far, in a simple way, NDISEGDE get the
> > requests, and then forwards it to the driver managing the hardware.
> >
> > Since my system is not based on any hardware but on a pure software
> > solution, do I still need a "pcidrv" running at the bottom and what is
> > it goind to do ?
> >
> > Thanks for the help
> >
> > --
> > Lepidosteus / Vianney Devreese
> > mail: lepidosteus at gmail dot com
> > url: http://lepidosteus.com
>
>
>

Re: Create a virtual network adapter ? by Don

Don
Sun Jun 03 10:18:08 CDT 2007

Comments inline:
"Anton Bassov" <AntonBassov@discussions.microsoft.com> wrote in message
news:5CD36772-1A0C-4612-996B-BE1CBB2B22B8@microsoft.com...
> 1. Although NDIS is pretty much a world on its own, still there is no way
> to
> write a NDIS driver without knowing general kernel-mode concepts (IRQL,
> spinlocks, paged vs unpaged memory, etc). In order to learn these things,
> it
> is better to start with conventional WDM drivers, and to read WDM-related
> documentation. If you look at NDIS documentation, you will see that it
> assumes the reader is familiar with general kernel-mode concepts

Yes you need the NDIS knowledge if you go there, which is why I recomended
using NDISedge unchanged. The problem for the OP with NDIS is that
creating an NDIS/WDM driver with a path for the application to access the
driver is in an area where a lot of people mess up. In this case, by using
NDISedge the OP does not need to deal with the NDIS stuff right away.


> 2. Frameworks are meant just to speed up the development - one should not
> think of them as of convenient way of avoiding learning underlying
> concepts.
> This is particularly true for kernel-level development. In general, I
> think
> frameworks are OK for the user-mode apps but not for drivers. Someone who
> has
> has no clue about kernel-mode concepts is very unlikely to produce a
> workable
> driver - no matter how well a framework shields him from everything that
> happens behind the scenes, sooner or later you will see a post like " I
> modify xxx sample..... my driver don't work.... please help.... excuse my
> bad
> english" ( I think that introduction
> of kernel-mode frameworks must be quite beneficial for outsourcers -
> people
> will start thinking that frameworks make driver development easy, and try
> to
> outsource more and more projects)

Sorry, but I strongly disagree when you come to KMDF. Most of the previous
frameworks are a nightmare, in part because the vendor is seperate from the
OS provides. KMDF should be thought of as a new set of DDI's, that remove
some of the drudgery. In particular I would never go back to a WDM driver
if it needed PnP and Power, the bottom line is that writing a good state
machine for PnP and Power is almost impossible, so letting Microsoft
provide a blessed one is a great step forward.

Yes there will be a certain amount of framework makes this easy so lets get
somebody inhouuse or out of house without a lot of experience to do it.
This is showing up a lot in File System Minifilters, and unfortunately that
framwork leaves a lot more of the hard parts to the developer than KMDF.
KMDF can for simple drivers make it easy to develop or maintain a driver,
hopefully people will recognize that more complex drivers still need
expertise, though there is enough crap out there with Compuware and Jungo
frameworks to assure me that idiots will still be there.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply



Re: Create a virtual network adapter ? by Lepidosteus

Lepidosteus
Mon Jun 04 17:45:46 CDT 2007

And do you guys have any link to a good documentation about all of this
? I tried searching but all I can get is

1 - documentation about filesystem drivers (that's cool, but totally
irrevelant to learn ndis)

2 - api listing (cool too, but not the best learning support if you
don't know what to look for)

3 - microsoft samples

I'm still lacking some kind of "here is how this thing works" text, if
there is any ... Thanks for your help anyway.


--
Lepidosteus / Vianney Devreese
mail: lepidosteus at gmail dot com
url: http://lepidosteus.com