.INF文件和NCF_HAS_UI:如何编写.dll来显示网络驱动程序的高级属性选项卡?
我有一个 NDIS 驱动程序,它会在连接属性的已安装项目列表和设备管理器中列出;问题是,如何编写一个用于管理驱动程序属性的扩展,以及如何安装它?
当然,一个普通的 GUI 程序可以与驱动程序通信、设置属性、获取版本号和其他统计信息等,这就是 DeviceIoControl 存在的目的;但是,这是否意味着不存在专用接口来通知驱动程序有关配置更改的信息?
如果有人可以将此问题转发到 Eggheadcafe/osr 的 ntdev 列表,那就太好了。
I have a NDIS driver, which gets listed both in connection properties's installed items list and in device manager; the question is, how do I write an extension which will be used for managing driver's properties, and how to install it?
Of course, a plain GUI program may communicate with the driver, set properties, get version numbers and other statistical info etc, that's what DeviceIoControl exists for; but, does this means that no dedicated interface exists to inform the driver about configuration changes?
It would be pleasant if someone can forward this question to eggheadcafe/osr's ntdev lists.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您希望网络驱动程序在 LAN 属性对话框中具有一些 UI,那么您需要执行以下操作:
创建一个 NotifyObject(如果您还没有)
NotifyObject 本质上是一个 COM与您的驱动程序关联的对象。要制作一个,
CComObjectRoot
和CComCoClass
、对OBJECT_ENTRY_AUTO
的调用以及BEGIN_COM_MAP
(如果您是 COM 新手)。)ClsId={guid}
和ComponentDll=filename
放入 INF 中,将 COM 对象 与驱动程序关联起来。在 COM 对象上实现 INetCfgComponentPropertyUi
关键方法是
MergePropPages
。在此方法中,您分配属性表页面并将它们合并到适配器属性中。这个操作看起来像这样的伪代码:API 旨在进行事务处理。确保在
ApplyProperties
方法中应用任何更改,并(如果适用)在CancelProperties
中撤消它们。QueryPropertyUi
或SetContext
中执行任何操作,但如果需要获取注册表项位置,您可能需要保存上下文。测试您的更改
如果一切顺利,那么每次网络配置发生更改时都会加载您的新通知对象。如果正在显示 GUI,则 Windows 将查询您的类以获取 INetCfgComponentPropertyUi 接口并调用
MergePropPages
。我发现在 DLL 的关键位置放置硬编码断点,然后附加内核调试器,这样我总能找到 DLL,无论哪个进程正在加载它,这很有帮助。 (在 Windows 7 上,您将被加载到 drvinst.exe 中,使用用户模式调试器很难找到它。)
If you want your network driver to have some UI in the LAN Properties dialog, then you need to do these things:
Create a NotifyObject (if you don't have one already)
A NotifyObject is essentially a COM object associated with your driver. To make one,
DllGetClassObject
, a C++ class that inherits fromCComObjectRoot
andCComCoClass
, a call toOBJECT_ENTRY_AUTO
, and aBEGIN_COM_MAP
if you're new to COM.)ClsId={guid}
andComponentDll=filename
into your INF.Implement INetCfgComponentPropertyUi on your COM object
The key method is
MergePropPages
. In this method, you allocate propertysheet pages and merge them into the adapter properties. This operation looks something like this pseudocode:The API is meant to be transactional. Make sure to apply any changes in the
ApplyProperties
method, and (if applicable) undo them inCancelProperties
.QueryPropertyUi
orSetContext
, although you might want to save the context if you need to get the registry key location.Test your changes
If all goes well, then your new Notify Object will be loaded up every time there are any network configuration changes. If the GUI is being displayed, then Windows will query your class for the INetCfgComponentPropertyUi interface and call
MergePropPages
.I find it helpful to put hardcoded breakpoints in my DLL at key locations, and then attach a kernel debugger so that I can always find the DLL, no matter which process is loading it. (On Windows 7, you'll be loaded in drvinst.exe, which can be hard to find with a usermode debugger.)