hi.

i am currently developing a NDIS IM and i want to bind it to only one
specific underlying adapter.

the adapter is chosen at the user-level control program (it's okay if
this operation requires administrative rights).

problem is, at the very moment i install the IM, NDIS binds it to all
adapters. i'm currently installing it through INF files.

some people told me to try the CreateService() API function, but it
doesn't seem to work (apparently it gets created alright, but when i
try to start it, StartService() returns 0 (false = failure), and the
subsequent GetLastError() gives 0 (no error)).

the CreateService() solution seems to be a better one, because i can
first start the driver, then tell it which interface to bind to (via
IOCtl, for example), and it will register with NDIS only at this
moment, refusing all the bindings except the desired one.

from out the following two questions, EITHER one might be helpful.

Q1:
can i not register with NDIS in the driver's DriverEntry() function,
and follow the INF installation?

Q2:
how should i correctly register the IM driver with CreateService()?

thanks in advance.

--
vv

RE: selectively bind a NDIS IM by AntonBassov

AntonBassov
Sat Apr 21 19:40:01 CDT 2007

> Q1:
> can i not register with NDIS in the driver's DriverEntry() function,
> and follow the INF installation?

What do you mean??? Are you asking us whether you can avoid calling so vital
to NDIS IM functions as NdisMInitializeWrapper(),
NdisIMRegisterLayeredMiniport() and NdisRegisterProtocol() altogether, or you
just want to avoid doing it in DriverEntry() and subsequently call them upon
receiving IOCTL from the user??? In any case, the answer to both questions
is the same, and it is negative....


> Q2:
> how should i correctly register the IM driver with CreateService()?

You cannot do it - the only thing CreateService() does is something what its
name suggests, i.e. creates a key for your service. However, in addition to
that, NDIS IM registration requires quite a few changes under
HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318} and HKLM\SYSTEM\CurrentControlSet\Control\Network
regsitry keys. This is why you install NDIS IM with INF file. Certainly, you
can try to
update the above mentioned registry keys manually, but you are more than
likely to screw up the registry.....

Anton Bassov

"Vitalie Vrabie" wrote:

> hi.
>
> i am currently developing a NDIS IM and i want to bind it to only one
> specific underlying adapter.
>
> the adapter is chosen at the user-level control program (it's okay if
> this operation requires administrative rights).
>
> problem is, at the very moment i install the IM, NDIS binds it to all
> adapters. i'm currently installing it through INF files.
>
> some people told me to try the CreateService() API function, but it
> doesn't seem to work (apparently it gets created alright, but when i
> try to start it, StartService() returns 0 (false = failure), and the
> subsequent GetLastError() gives 0 (no error)).
>
> the CreateService() solution seems to be a better one, because i can
> first start the driver, then tell it which interface to bind to (via
> IOCtl, for example), and it will register with NDIS only at this
> moment, refusing all the bindings except the desired one.
>
> from out the following two questions, EITHER one might be helpful.
>
> Q1:
> can i not register with NDIS in the driver's DriverEntry() function,
> and follow the INF installation?
>
> Q2:
> how should i correctly register the IM driver with CreateService()?
>
> thanks in advance.
>
> --
> vv
>
>

Re: selectively bind a NDIS IM by Pankaj

Pankaj
Sun Apr 22 02:09:27 CDT 2007

You should take a look at the NDIS IM MUX driver sample in DDK. The sample
has a notify object with the driver. You can create a custom notify object
for your driver. With this custom notify object, you can deny binding to
all the adapters.

Then once your user mode application starts, it can explicitly bind your
IM driver to which ever adapter you want.

Notify object in MUX sample has code that shows how to play with adapter
bindings as well. You will need to use INetCfg API (documented in DDK) to
do bind/unbind operations.

Don't go via the CreateService route, i know some people make it work
mainly for Protocol driver, but it is not supported way of doing what you
want.

Good Luck,
--
Pankaj Garg
2007-04-22 at 12:03am
http://www.intellectualheaven.com


On Sat, 21 Apr 2007, Vitalie Vrabie wrote:

>
> hi.
>
> i am currently developing a NDIS IM and i want to bind it to only one
> specific underlying adapter.
>
> the adapter is chosen at the user-level control program (it's okay if
> this operation requires administrative rights).
>
> problem is, at the very moment i install the IM, NDIS binds it to all
> adapters. i'm currently installing it through INF files.
>
> some people told me to try the CreateService() API function, but it
> doesn't seem to work (apparently it gets created alright, but when i
> try to start it, StartService() returns 0 (false = failure), and the
> subsequent GetLastError() gives 0 (no error)).
>
> the CreateService() solution seems to be a better one, because i can
> first start the driver, then tell it which interface to bind to (via
> IOCtl, for example), and it will register with NDIS only at this
> moment, refusing all the bindings except the desired one.
>
> from out the following two questions, EITHER one might be helpful.
>
> Q1:
> can i not register with NDIS in the driver's DriverEntry() function,
> and follow the INF installation?
>
> Q2:
> how should i correctly register the IM driver with CreateService()?
>
> thanks in advance.
>
> --
> vv
>
>

Re: selectively bind a NDIS IM by Vitalie

Vitalie
Sun Apr 22 02:29:45 CDT 2007

> You should take a look at the NDIS IM MUX driver sample in DDK. The sample
> has a notify object with the driver. You can create a custom notify object
> for your driver. With this custom notify object, you can deny binding to
> all the adapters.

point taken. thanks. i'll look at that.

> Then once your user mode application starts, it can explicitly bind your
> IM driver to whichever adapter you want.

yes, this is exactly what i want.

--
vv


Re: selectively bind a NDIS IM by Vitalie

Vitalie
Sun Apr 22 02:59:44 CDT 2007

> Certainly, you can try to
> update the above mentioned registry keys manually, but you are more than
> likely to screw up the registry.....

no, i didn't intend to to that. those registry keys are documented for
reading only, and it obviously isn't sufficient to afford writing.

--
vv


Re: selectively bind a NDIS IM by Maxim

Maxim
Sun Apr 22 05:47:16 CDT 2007

> some people told me to try the CreateService() API function, but it

Impossible. You cannot install an IM using CreateService. You can install an
NDIS _protocol_ this way, but not an IM.

Installing an IM requires lots of updates to the network registry except
CreateSevice, these updates can only be done by INetCfg calls or by INF
interpreting.

To solve your initial task, the easiest way is to bind an IM to _all_ adapters
in a no-op pass-thru mode, and then activate your operations only on 1 adapter
by using some sideband communication channel (custom OID, WMI,
NdisMRegisterDevice).

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com


Re: selectively bind a NDIS IM by Vitalie

Vitalie
Sun Apr 22 08:08:06 CDT 2007

> To solve your initial task, the easiest way is to bind an IM to _all_ adapters
> in a no-op pass-thru mode, and then activate your operations only on 1 adapter
> by using some sideband communication channel (custom OID, WMI,
> NdisMRegisterDevice).

this option was in consideration already, but it doesn't seem to be
the easiest way. and not the cleanest either.


Re: selectively bind a NDIS IM by Thomas

Thomas
Sun Apr 22 11:05:57 CDT 2007

How do you select the adapter?

If is is a specific adapter identified by hardware ID (e.g., Vendor
ID/Product ID), the you can write a NDIS "Notify Object" that is run at
install time. A Notify Object can restrict bindings to a specific VID/PID.

If the binding is not based on VID/HID, then you should look at the DDK
BindView application and the INetCfg API. With some (well, a LOT...) of work
you should be able to achieve your goal.

Do understand that your binding may become "lost" if the user removes and
adapter and reinstalls another. Or, if other NDIS components are
added/removed from the system.

Good luck,

Thomas F. Divine


"Vitalie Vrabie" <vitalie.vrabie@gmail.com> wrote in message
news:1177190899.148122.34550@e65g2000hsc.googlegroups.com...
> hi.
>
> i am currently developing a NDIS IM and i want to bind it to only one
> specific underlying adapter.
>
> the adapter is chosen at the user-level control program (it's okay if
> this operation requires administrative rights).
>
> problem is, at the very moment i install the IM, NDIS binds it to all
> adapters. i'm currently installing it through INF files.
>
> some people told me to try the CreateService() API function, but it
> doesn't seem to work (apparently it gets created alright, but when i
> try to start it, StartService() returns 0 (false = failure), and the
> subsequent GetLastError() gives 0 (no error)).
>
> the CreateService() solution seems to be a better one, because i can
> first start the driver, then tell it which interface to bind to (via
> IOCtl, for example), and it will register with NDIS only at this
> moment, refusing all the bindings except the desired one.
>
> from out the following two questions, EITHER one might be helpful.
>
> Q1:
> can i not register with NDIS in the driver's DriverEntry() function,
> and follow the INF installation?
>
> Q2:
> how should i correctly register the IM driver with CreateService()?
>
> thanks in advance.
>
> --
> vv
>


Re: selectively bind a NDIS IM by Maxim

Maxim
Sun Apr 22 14:58:29 CDT 2007

> the easiest way. and not the cleanest either.

Note: bind/unbind of your IM will abort all TCP connections done via this
interface. Activation of your logic in your IM - will not.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com


Re: selectively bind a NDIS IM by Vitalie

Vitalie
Mon Apr 23 13:36:16 CDT 2007

> Note: bind/unbind of your IM will abort all TCP connections done via this
> interface.

and this is exactly what i need, because the specifics of the
application turns the 'adapter' into a functionally different one.
practically, it 're-plugs' the adapter into a different network.


Re: selectively bind a NDIS IM by Stephan

Stephan
Tue Apr 24 10:49:10 CDT 2007

Addendum:

The network configuration subsystem (netcfg) always creates bindings
between all adapters and all protocols. There is AFAIK no way to
prevent that.

All you can do is *disable* certain bindings (more precisely: binding
paths) using either INetCfgBindingPath::Enable(FALSE) or
INetCfgComponentBindings::UnbindFrom(), whichever you prefer.

Stephan
---
On Apr 22, 6:05 pm, "Thomas F. Divine" <tdivine@NOpcausaSPAM> wrote:
> How do you select the adapter?
>
> If is is a specific adapter identified by hardware ID (e.g., Vendor
> ID/Product ID), the you can write aNDIS"Notify Object" that is run at
> install time. A Notify Object can restrict bindings to a specific VID/PID.
>
> If the binding is not based on VID/HID, then you should look at the DDK
> BindView application and the INetCfg API. With some (well, a LOT...) of work
> you should be able to achieve your goal.
>
> Do understand that your binding may become "lost" if the user removes and
> adapter and reinstalls another. Or, if otherNDIScomponents are
> added/removed from the system.
>
> Good luck,
>
> Thomas F. Divine


Re: selectively bind a NDIS IM by Stephan

Stephan
Tue Apr 24 10:52:14 CDT 2007

Addendum:

The network configuration subsystem (netcfg) always creates bindings
between all adapters and all protocols. There is AFAIK no way to
prevent that.

All you can do is *disable* certain bindings (more precisely: binding
paths) using either INetCfgBindingPath::Enable(FALSE) or
INetCfgComponentBindings::UnbindFrom(), whichever you prefer.

Stephan
---
On Apr 22, 6:05 pm, "Thomas F. Divine" <tdivine@NOpcausaSPAM> wrote:
> How do you select the adapter?
>
> If is is a specific adapter identified by hardware ID (e.g., Vendor
> ID/Product ID), the you can write aNDIS"Notify Object" that is run at
> install time. A Notify Object can restrict bindings to a specific VID/PID.
>
> If the binding is not based on VID/HID, then you should look at the DDK
> BindView application and the INetCfg API. With some (well, a LOT...) of work
> you should be able to achieve your goal.
>
> Do understand that your binding may become "lost" if the user removes and
> adapter and reinstalls another. Or, if otherNDIScomponents are
> added/removed from the system.
>
> Good luck,
>
> Thomas F. Divine


Re: selectively bind a NDIS IM by Vitalie

Vitalie
Sun May 06 18:30:55 CDT 2007

> The network configuration subsystem (netcfg) always creates bindings
> between all adapters and all protocols. There is AFAIK no way to
> prevent that.

indeed, it is exactly as you said above.

and it, obviously, contradicts the documentation, which clearly says
that
"The network configuration subsystem does not actually install the
component until INetCfg::Apply is called."

in reality, it applies the settings immediately when ::Install() is
called.

if this is because of backwards compatibility of some sort, why didn't
Microsoft supply a flag for ::Install(), so new apps can indicate that
they're expecting the new behavior and not the old one?