Readings datas from the config files in IM driver

Hi,
i want to access one configuartion file and read the data’s form the file in New IM driver.
is there any NDIS Api’'s are avilable(i have searched apis but i dint get in msdn)
i ahve also referred the WDK samples , but i dint get.

have anyone used?

Thanks,
Balaji S

An IM driver can use the ZwXXXFiles() functions to access files.

There are other ways to pass configuration data to an IM driver. You can place configuration info in the Registry under the path that is passed to your DriverEntry(), the problem to solve is if the the Registry info changes after start up how you let the driver know to re-read the Registry.

The other way is to make a Property Page for your IM that contains the configuration info. When you change the info and properly colse the Property Page your driver can be automatically sent a ‘reconfigure’ notification.

We use all three methods in our IM driver depending on what info needs to be conveyed either in or out of the driver.

Larry C

Hi,
Thanks for your responses.
is it possible to use .ini file in the driver and accessing the configuartion datas from the .INI file.
ZwCreatefile is just accessing a file., i have a seen some of the examples they are talking about system.ini and protocol.ini.

Here is an example of a PROTOCOL.INI file:

[PROTMGR]
DRIVERNAME = PROTMAN$

[NE2000_NIF]
DRIVERNAME = MS2000$
INTERRUPT = 5
IOBASE = 0x340

[TBPROTO]
DRIVERNAME = TBPROTO$
BINDINGS = NE2000_NIF
., i want to create like this type of things and but my content changes.

i hve not tried other options and i will try and let you the result.

need your comment on the above query.

Thanks,
Balaji S

Why do you want to use .ini file? The best approach is to use your *.inf file , which you need anyway, and put a section which would write your custom data in Windows Registry. When the driver will be installed it could read these data from your driver settings in Windows Registry. A path to access data would be following: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services<your driver name>

Igor Sharovar

It is better to use the second parameter passed into DriverEntry() unless
you are a NDIS miniport where you have a specific call to obtain access to
your specialized registry parameters, which are not located under the
service entry.

<igor.sharovar> wrote in message news:xxxxx@ntdev…
> Why do you want to use .ini file? The best approach is to use your *.inf
> file , which you need anyway, and put a section which would write your
> custom data in Windows Registry. When the driver will be installed it
> could read these data from your driver settings in Windows Registry. A
> path to access data would be following:
> HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services<your driver name>
>
> Igor Sharovar
>
>
></igor.sharovar>

> Here is an example of a PROTOCOL.INI file:

[PROTMGR]
DRIVERNAME = PROTMAN$

[NE2000_NIF]
DRIVERNAME = MS2000$
INTERRUPT = 5
IOBASE = 0x340

Oh good old days… NDIS for DOS, NE2000 coaxial cable network card, Windows for Workgroups 3.1…

:slight_smile:

INI files are obsolete. Yes, really so, since Win95 release.

Move your information to the SYSTEM registry instead.


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

Maxim S. Shatskih wrote:

INI files are obsolete. Yes, really so, since Win95 release.

Move your information to the SYSTEM registry instead.

This assertion is false. For configuration information that you want
the user to be able to edit occasionally, INI files are great. Easy to
understand, low overhead, commentable, simpler to access and transport
than a registry key, much easier to understand than XML. Plus, INI
files work just as good in Linux.

For information to be shared with a driver, you might be able to
convince me, but overall the death of INI files has been greatly
exaggerated.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Quite true, but nowhere near as much as the virtues of the registry have been exaggerated, nor as much as the problems that its use has caused have been understated, in my opinion.

Actually, it’s not so much the registry itself in most cases - though some things like REG_MULTI_SZ are just inherently problematic - but the way it has been/was aggressively pushed for use for everything under the sun, which has resulted in the truly staggering bloat that has turned it in to a wasteland of security & usability problems, and in the case of some of the truly horrific abuses like HKEY_CLASSES_ROOT, did so almost immediately.

It was supposed to save us from ‘ini hell,’ save space and solve installation & versioning problems.

Not so much.

This is a recurring theme in Windows and I think the single largest cause of problems, most of which are incurred in support of things that are totally unnecessary in the first placed. That is, forced sharing/integration/centralization of things that often don’t have a lot to do with each other and/or haven’t been designed to be shared really in any way other than what the grossly oversimplified docs present as all that’s necessary to leverage the technology at no cost - DLLs, SxS (a true disaster), and especially the various installer technologies, with patching and their own personal file caches, et. c.

mm

“The best approach is to use your *.inf file ,
which you need anyway, and put a section which would write your custom data in
Windows Registry. When the driver will be installed it could read these data
from your driver settings in Windows Registry. A path to access data would be
following: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services<your driver>name>”

would it be posible to get any reference to creat e above method.

Thanks,
Balaji S

>would it be posible to get any reference to creat e above method.
You could look sample in WinDDK..\src\network\ndis\passthru\driver. It is a sample of IM NDIS driver.
Look at netsf.inf file. The section [Passthru.AddReg] adds Param1 into existing Registry Key Parameters. The DriverEntry of your driver has a parameters, called RegistryPath, which contains a path to your driver Registry settings. Using this path you could call ZwXXXX functions to get information from driver Registry settings.

Igor Sharovar

Hi Igor Sharovar,
Thanks for your suggestions, will implement let you know if i face problem.

Thanks

For what it is worth (and perhaps not much) an NDIS Miniport that wishes to
gain access to registry information using the NdisXxxConfiguration() APIs
and specifically to keys under the
HKEY_LOCAL_MACHINE\SystemCurrentControlSet\Services key can use
NdisOpenProtocolConfiguration().

The last argument to NdisOpenProtocolConfiguration(), ProtocolSection, is
simply an NDIS_STRING (UNICODE_STRING) of the registry subkey path *below*
HKLM.…\Services.

While using the ZwXxxx() routines is always good fun or using the Rtlxxxx()
helpers for reading the registry is also good fun, sometimes us NDIS
curmudgeons like to just use NDIS DDIs uniformly for global, per-adapter,
and per-binding configuration access.

NdisOpenProtocolConfiguration() is pretty easy to ‘tame’ into opening your
driver Parameters key.

NDIS_STATUS status;
NDIS_HANDLE paramCfg;
NDIS_STRING paramCfgName = NDIS_STRING_CONST(“passthru\Parameters”);

NdisOpenProtocolConfiguration(&status, &paramCfg, &paramCfgName);

NdisCloseConfiguration(parmCfg);

Good Luck,
Dave Cattley

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of igor.sharovar@hp.com
Sent: Thursday, September 10, 2009 11:05 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Readings datas from the config files in IM driver

would it be posible to get any reference to creat e above method.
You could look sample in WinDDK..\src\network\ndis\passthru\driver. It is a
sample of IM NDIS driver.
Look at netsf.inf file. The section [Passthru.AddReg] adds Param1 into
existing Registry Key Parameters. The DriverEntry of your driver has a
parameters, called RegistryPath, which contains a path to your driver
Registry settings. Using this path you could call ZwXXXX functions to get
information from driver Registry settings.

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

xxxxx@hcl.in wrote:

“The best approach is to use your *.inf file ,
which you need anyway, and put a section which would write your custom data in
Windows Registry. When the driver will be installed it could read these data
from your driver settings in Windows Registry. A path to access data would be
following: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services<your driver>> name>”
>
> would it be posible to get any reference to creat e above method.
>

IoOpenDeviceRegistryKey with PLUGPLAY_REGKEY_DRIVER gets you to the
Services key for your driver.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Hi,
am really confused about implementation method, i there any document talks about that, i have added the my config datas under [Passthru.Addreg], can i directly access the Zwreadfile to access the variables.

Thanks,
Balaji S

You could use both implementation methods, either ZwXXXXFile or NdisXXXConfiguration.
As David points using NdisXXXConfiguration functions would be better because it preserves NDIS style in your driver. I believe NdisXXXConfiguration functions are just wrappers around ZwXXX functions.

Igor Sharovar

> IoOpenDeviceRegistryKey with PLUGPLAY_REGKEY_DRIVER gets you to the

Services key for your driver.

IIRC it opens …\CurrentControlSet\Control\Class{guid}%04d

PLUGPLAY_REGKEY_DEVICE opens …\CurrentControlSet\Enum\Bus\HwId\InstanceId\Device Parameters


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

Hi,
i have registered the config details like this in the .inf file.

[Passthru.AddReg]
; The following key is Required
; The following key is Passthru specific
HKR, Parameters, Param1, 0, 4

[VL_INDEX] =
[VL_ID]
[BAG_TIMER]
[SKEW_MAXTIMER]
[REDUNDANCY_MANAGEMENT_TX]
[INTEGRITY_CHECKING]
[REDUNDANCY_MANAGEMENT_RX]
[MAX_FRAMESIZE]

NDIS_STRING VL_ID = VL_ID // defined in the code
i used NdisOpenConfiguartionEx API to get theHandle for the registry Key. i am using NdisReadConfiguration API to read the configuration details from the INF file.

MY Question is that, in the NdisReadConfiguration APIs one parameter name called Keyword, what i have to pass in that, whether i have to pass VL_ID or anything mentioned above.

Request anyone to clarify

Thanks,
Balaji S

I think you should write as following:

HKR, Parameters, Param1, 0x10000, “MultiSz”, “Param1”, “Value1”

and so on.

A parameter which you will specify in your NdisReadConfiguration as Keyword would be “Param1”.
You could do the same for others values.

Igor Sharovar

Hi Igor,
i want to specify like this because under each section it will have many values
[VL_INDEX] =
[VL_ID]
[BAG_TIMER]
[SKEW_MAXTIMER]
[REDUNDANCY_MANAGEMENT_TX]
[INTEGRITY_CHECKING]
[REDUNDANCY_MANAGEMENT_RX]
[MAX_FRAMESIZE]
is it possible to do like this?

xxxxx@hcl.in wrote:

Hi Igor,
i want to specify like this because under each section it will have many values
[VL_INDEX] =
[VL_ID]
[BAG_TIMER]
[SKEW_MAXTIMER]
[REDUNDANCY_MANAGEMENT_TX]
[INTEGRITY_CHECKING]
[REDUNDANCY_MANAGEMENT_RX]
[MAX_FRAMESIZE]
is it possible to do like this?

Of course it is possible to open files and read them in a kernel
driver. However, there are no INI file APIs in kernel mode, so in
parsing the files you would be completely on your own.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.