以编程方式安装NDIS筛选器驱动程序 [英] programmatically installing NDIS filter driver
问题描述
我正在尝试编写C ++代码,以编程方式安装NDIS 6.0轻量级筛选器驱动程序. 在回顾了WinDDK,在线示例和MSDN文档之后,我最终得到了 下面的代码示例. (为清楚起见,跳过了错误处理) 问题是INetCfgClassSetup :: Install总是返回错误0x8004a024. (我在头文件中找不到错误代码.)
I am trying to write C++ code programmatically installing NDIS 6.0 lightweight filter driver. After reviewing WinDDK, online examples and MSDN documentation I ended up with the code sample below. (Error handling is skipped for clarity) The problem is that INetCfgClassSetup::Install always returns error 0x8004a024. (I could not find the error code in header files.)
使用相同的.inf文件手动安装驱动程序就可以了.
Manual installation of the driver using the same .inf file works just fine.
WinDDK的Bindview示例只要安装了驱动程序就可以了 它采用调用INetCfgClassSetup :: SelectAndInstall的路径.替代品 INetCfgClassSetup :: Install的路径无效.
The Bindview sample from WinDDK installs the driver just fine as long as it takes the path calling INetCfgClassSetup::SelectAndInstall. The alternative path using INetCfgClassSetup::Install does not work.
我的计算机上启用了内核调试,因此不需要驱动程序签名.
Kernel debugging is enabled on my machine so driver signing is not required.
下面的代码有什么问题吗?
Is anything wrong with the code below?
谢谢.
....
isCopied = SetupCopyOEMInfA(pathToInf, // path to inf file
pathToBin, // dir containing driver binary
SPOST_PATH,
0,
DestinationInfFileName,
256,
NULL,
NULL);
....
INetCfg *pnc = NULL;
INetCfgClassSetup *pncClassSetup = NULL;
HRESULT hr;
OBO_TOKEN OboToken;
....
hr = CoCreateInstance( CLSID_CNetCfg,
NULL, CLSCTX_INPROC_SERVER,
IID_INetCfg,
(void**)&pnc );
....
hr = pnc->QueryNetCfgClass ( &GUID_DEVCLASS_NETSERVICE,
IID_INetCfgClassSetup,
(void**)&pncClassSetup );
....
ZeroMemory( &OboToken, sizeof(OboToken) );
OboToken.Type = OBO_USER;
//
// this call fails:
hr = pncClassSetup->Install(COMPONENT_ID,
&OboToken,
0,
0,
0,
0,
NULL);
推荐答案
错误代码0x8004a024代表NETCFG_E_NO_WRITE_LOCK.安装功能需要写锁定,因此请尝试使用INetCfg-> AcquireWriteLock获得一个.不要忘记最终释放锁,然后释放界面.
Error code 0x8004a024 stands for NETCFG_E_NO_WRITE_LOCK. The Install function requires a write-lock so try obtaining one with INetCfg->AcquireWriteLock. Don't forget to eventually release the lock and then the interface.
这篇关于以编程方式安装NDIS筛选器驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!