.INF文件和NCF_HAS_UI:如何编写.dll以显示网络驱动程序的高级属性选项卡? [英] .INF files and NCF_HAS_UI: how to write .dll for displaying advanced properties tab of network driver?

查看:298
本文介绍了.INF文件和NCF_HAS_UI:如何编写.dll以显示网络驱动程序的高级属性选项卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

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

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?

如果有人可以将这个问题转发到eggheadcafe/osr的ntdev列表,那将是一件令人愉快的事情.

推荐答案

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

If you want your network driver to have some UI in the LAN Properties dialog, then you need to do these things:

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

Create a NotifyObject (if you don't have one already)

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

A NotifyObject is essentially a COM object associated with your driver. To make one,

  1. 制作一个可以创建新COM类的DLL. (如果您使用 ATL的类工厂,则只有几行代码我强烈建议使用ATL来实现COM对象,这是LAN属性GUI的范围,但是您应该查找DllGetClassObject,这是一个从CComObjectRootCComCoClass继承的C ++类,它是对OBJECT_ENTRY_AUTOBEGIN_COM_MAP(如果您是COM的新手).
  2. 关联您的COM对象通过将ClsId={guid}ComponentDll=filename放入INF中与驱动程序配合使用.
  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.

在COM对象上实施 INetCfgComponentPropertyUi >

Implement INetCfgComponentPropertyUi on your COM object

  1. 关键方法是MergePropPages.在此方法中,您分配属性表页面并将其合并到适配器属性中.此操作类似于此伪代码:

  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);

  • 该API旨在具有事务性.确保在ApplyProperties方法中应用所有更改,然后(如果适用)在CancelProperties中撤消它们.

  • The API is meant to be transactional. Make sure to apply any changes in the ApplyProperties method, and (if applicable) undo them in CancelProperties.

    测试您的更改

    如果一切顺利,则每次网络配置发生更改时,都会加载新的通知对象.如果正在显示GUI,则Windows将在类中查询INetCfgComponentPropertyUi接口并调用MergePropPages.

    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.

    我发现将硬编码的断点放在关键位置的DLL中,然后附加一个内核调试器,这样无论加载哪个进程,我都可以找到DLL,这很有帮助. (在Windows 7上,您将加载到drvinst.exe中,使用用户模式调试器可能很难找到它.)

    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.)

    这篇关于.INF文件和NCF_HAS_UI:如何编写.dll以显示网络驱动程序的高级属性选项卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆