Hi Guys,
I am trying to uninstall a virtual network adapter added by a malware (ndisvvan.sys). I have already removed the driver file and rebooted the computer. My code looks something like this:
hr = CoInitializeEx(NULL, COINIT_DISABLE_OLE1DDE | COINIT_APARTMENTTHREADED );
hr = pnc->QueryInterface(IID_INetCfgLock, (LPVOID *)&pncLock);
hr = pncLock->AcquireWriteLock(c_cmsTimeout, c_szSampleNetcfgApp, &szLockedBy);
hr = pnc->Initialize(NULL);
pnc->AddRef();
OboToken.Type = OBO_USER;
hr = pnc->FindComponent(szComponentId, &pncc);
hr = pncc->GetClassGuid(&guidClass);
hr = pnc->QueryNetCfgClass(&guidClass, IID_INetCfgClass, (void**)&pncClass);
hr = pncClass->QueryInterface(IID_INetCfgClassSetup, (void**)&pncClassSetup);
hr = pncClassSetup->DeInstall(pncc, &OboToken, NULL);
I have removed all error checking code for simplicity and shown only the functions to let you have an idea of what function sequence I am writing.
Now the problem:
The DeInstall() function fails with error code: NETCFG_S_STILL_REFERENCED
When I go to MyComputer> Properties> Hardware> DeviceManager> NetworkAdapters
I can see those adapters with yellow mark and when I try to right click uninstall from there it uninstalls properly. (I need to change the characteristics to 1 in reg key, otherwise it gives error saying this device may be required for booting.)
My Configuration is VS2008 on WinXP SP2.
In MSDN I came across these two things which I dont know will be helpfull or not.
- INetCfgComponentSetup::Removing will this be required before DeInstall()
- Shall I use INetCfgClass::EnumComponents instead of INetCfgClass::FindComponent
I am new to this and got this code from net, so I will request you to explain your solution. Thanks for your time.
Regards
Anand