Question

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);
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top