.INF文件和NCF_HAS_UI:如何编写.dll来显示网络驱动程序的高级属性选项卡?

发布于 2024-12-16 01:18:43 字数 344 浏览 6 评论 0原文

我有一个 NDIS 驱动程序,它会在连接属性的已安装项目列表和设备管理器中列出;问题是,如何编写一个用于管理驱动程序属性的扩展,以及如何安装它?

当然,一个普通的 GUI 程序可以与驱动程序通信、设置属性、获取版本号和其他统计信息等,这就是 DeviceIoControl 存在的目的;但是,这是否意味着不存在专用接口来通知驱动程序有关配置更改的信息?

NDIS 驱动程序配置屏幕截图

如果有人可以将此问题转发到 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?

NDIS driver configuration screenshot

It would be pleasant if someone can forward this question to eggheadcafe/osr's ntdev lists.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拔了角的鹿 2024-12-23 01:18:43

如果您希望网络驱动程序在 LAN 属性对话框中具有一些 UI,那么您需要执行以下操作:

创建一个 NotifyObject(如果您还没有)

NotifyObject 本质上是一个 COM与您的驱动程序关联的对象。要制作一个,

  1. 请制作一个可以创建新 COM 类的 DLL。 (如果您使用ATL的类工厂,则只需几行代码我强烈建议使用 ATL 来实现 COM 对象,这超出了 LAN Properties GUI 的范围,但您应该查找继承自 的 C++ 类。 CComObjectRootCComCoClass、对 OBJECT_ENTRY_AUTO 的调用以及 BEGIN_COM_MAP(如果您是 COM 新手)。)
  2. < a href="http://msdn.microsoft.com/en-us/library/ff543729%28v=VS.85%29.aspx" rel="noreferrer">通过将 ClsId={guid}ComponentDll=filename 放入 INF 中,将 COM 对象 与驱动程序关联起来。

在 COM 对象上实现 INetCfgComponentPropertyUi

  1. 关键方法是MergePropPages。在此方法中,您分配属性表页面并将它们合并到适配器属性中。这个操作看起来像这样的伪代码:

    HPROPSHEETPAGE *psharray = CoTaskMemAlloc(NUMBER_OF_PAGES * sizeof(HPROPSHEETPAGE);
    for (i = 0; i < NUMBER_OF_PAGES; i++)
        psharray[i] = CreatePropertySheetPage(&psp);
    
  2. API 旨在进行事务处理。确保在 ApplyProperties 方法中应用任何更改,并(如果适用)在 CancelProperties 中撤消它们。

  3. 您无需在 QueryPropertyUiSetContext 中执行任何操作,但如果需要获取注册表项位置,您可能需要保存上下文。

测试您的更改

如果一切顺利,那么每次网络配置发生更改时都会加载您的新通知对象。如果正在显示 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,

  1. Make a DLL that can create your new COM class. (If you use ATL's class factory, it's only a couple lines of code. I highly recommend using ATL for implementing COM objects. This is out-of-scope of the LAN Properties GUI, but you should look up DllGetClassObject, a C++ class that inherits from CComObjectRoot and CComCoClass, a call to OBJECT_ENTRY_AUTO, and a BEGIN_COM_MAP if you're new to COM.)
  2. Associate your COM object with the driver by putting ClsId={guid} and ComponentDll=filename into your INF.

Implement INetCfgComponentPropertyUi on your COM object

  1. 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:

    HPROPSHEETPAGE *psharray = CoTaskMemAlloc(NUMBER_OF_PAGES * sizeof(HPROPSHEETPAGE);
    for (i = 0; i < NUMBER_OF_PAGES; i++)
        psharray[i] = CreatePropertySheetPage(&psp);
    
  2. The API is meant to be transactional. Make sure to apply any changes in the ApplyProperties method, and (if applicable) undo them in CancelProperties.

  3. You don't need to do anything in QueryPropertyUi or SetContext, 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.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文