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.)
Manual installation of the driver using the same .inf file works just fine.
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?
Thanks.
....
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);