安装未绑定的 NDIS 文件管理器驱动程序

Install NDIS filer driver unbinded

我构建了 "NDIS 6.0 Filter Driver" WinDDK 示例 (ndislwf.sys),并构建了 BindView 示例以安装 "NDIS 6.0 Filter Driver"。 它安装正常,但默认情况下始终绑定到所有网络接口。 是否可以安装 NDIS 过滤器驱动程序并让它与所有网络接口解除绑定,这样我就可以只将它绑定到某些接口?

BindView 中的代码使用 SetupCopyOEMInfW 将驱动程序复制到 OemInfs:

if ( !SetupCopyOEMInfW(lpszInfFullPath,
                               DirWithDrive,  // Other files are in the
                                              // same dir. as primary INF
                               SPOST_PATH,    // First param is path to INF
                               0,             // Default copy style
                               NULL,          // Name of the INF after
                                              // it's copied to %windir%\inf
                               0,             // Max buf. size for the above
                               NULL,          // Required size if non-null
                               NULL) ) {      // Optionally get the filename
                                              // part of Inf name after it is copied.
            dwError = GetLastError();

然后,使用 INetCfgClassSetup::Install():

INetCfgClassSetup   *pncClassSetup = NULL;
INetCfgComponent    *pncc = NULL;
OBO_TOKEN           OboToken;
HRESULT             hr = S_OK;

//
// OBO_TOKEN specifies on whose behalf this
// component is being installed.
// Set it to OBO_USER so that szComponentId will be installed
// on behalf of the user.
//

ZeroMemory( &OboToken,
            sizeof(OboToken) );
OboToken.Type = OBO_USER;

//
// Get component's setup class reference.
//

hr = pnc->QueryNetCfgClass ( pguidClass,
                             IID_INetCfgClassSetup,
                             (void**)&pncClassSetup );
if ( hr == S_OK ) {

    hr = pncClassSetup->Install( szComponentId,
                                 &OboToken,
                                 0,
                                 0,       // Upgrade from build number.
                                 NULL,    // Answerfile name
                                 NULL,    // Answerfile section name
                                 &pncc ); // Reference after the component
    if ( S_OK == hr ) {                   // is installed.

        //
        // we don't need to use pncc (INetCfgComponent), release it
        //

        ReleaseRef( pncc );
    }

    ReleaseRef( pncClassSetup );
}

Windows10 的最新版本具有此功能。将此行放入您的 INF:

HKR, Ndi\Interfaces, DisableDefaultBindings, 0x00010001, 1

将该行添加到具有 FilterMediaTypes 指令的同一部分。

该指令将在禁用状态下为您的过滤器创建所有新绑定。您可以像以前一样手动重新启用它们:

  • 从命令行 (Set-NetAdapterBinding);
  • GUI(运行 ncpa.cpl,打开适配器属性,选中过滤器驱动程序旁边的框);或
  • 来自 INetCfg 代码 (INetCfgBindingPath::Enable)。