HRESULT CMuxVirtualMiniport::DeInstall (VOID) { INetCfgClass *pncClass; INetCfgClassSetup *pncClassSetup; INetCfgComponent *pnccMiniport; HRESULT hr; LPWSTR *pmszwRefs=NULL; OBO_TOKEN *pOboToken=NULL; TraceMsg( L"-->CMuxVirtualMiniport::DeInstall.\n" ); hr = m_pnc->QueryNetCfgClass( &GUID_DEVCLASS_NET, IID_INetCfgClass, (void **)&pncClass ); if ( hr == S_OK ) { hr = pncClass->QueryInterface( IID_INetCfgClassSetup, (void **)&pncClassSetup ); if ( hr == S_OK ) { hr = HrFindInstance( m_pnc, m_guidMiniport, &pnccMiniport ); if ( hr == S_OK ) { TraceMsg( L" Found the miniport instance to uninstall.\n" ); hr = pncClassSetup->DeInstall( pnccMiniport, pOboToken, pmszwRefs ); ReleaseObj( pnccMiniport ); } else { TraceMsg( L" Didn't find the miniport instance to uninstall.\n" ); } ReleaseObj( pncClassSetup ); } else { TraceMsg( L" QueryInterface failed.\n" ); } ReleaseObj( pncClass ); } else { TraceMsg( L" QueryNetCfgClass failed.\n" ); } TraceMsg( L"<--CMuxVirtualMiniport::DeInstall(HRESULT = %x).\n", hr ); return hr; }
HRESULT CMuxPhysicalAdapter::ApplyPnpChanges( INetCfgPnpReconfigCallback *pfCallback, ConfigAction eApplyAction) { CMuxVirtualMiniport *pMiniport = NULL; GUID guidMiniport; DWORD dwMiniportCount; DWORD i; HRESULT hr; #ifdef CUSTOM_EVENTS LPWSTR lpDevice; WCHAR szMiniportGuid[MAX_PATH+1]; DWORD dwBytes; INetCfgComponent *pncc; LPWSTR lpszBindName; PNOTIFY_CUSTOM_EVENT lppnpEvent; #endif UNREFERENCED_PARAMETER(eApplyAction); TraceMsg( L"-->CMuxPhysicalAdapter::ApplyPnpChanges.\n" ); #ifdef CUSTOM_EVENTS // // Find the instance of the adapter to get its bindname. // hr = HrFindInstance( m_pnc, m_guidAdapter, &pncc ); if ( hr == S_OK ) { hr = pncc->GetBindName( &lpszBindName ); if ( hr != S_OK ) { TraceMsg( L" GetBindName failed.(HRESULT = %x). PnP changes will not " L"be applied and the driver will not be notified.\n", hr ); } ReleaseObj( pncc ); } else { TraceMsg( L" PnP changes will not " L"be applied and the driver will not be notified.\n", hr ); } #endif dwMiniportCount = m_MiniportsToAdd.ListCount(); TraceMsg( L" Applying PnP changes to %d new miniports.\n", dwMiniportCount ); for (i=0; i < dwMiniportCount; ++i) { pMiniport = NULL; m_MiniportsToAdd.Remove( &pMiniport ); pMiniport->GetMiniportGUID( &guidMiniport ); m_MiniportList.Insert( pMiniport, guidMiniport ); // // Do miniport specific Pnp Changes when they are added. // hr = pMiniport->ApplyPnpChanges( pfCallback, eActAdd ); if( hr != S_OK) { // you may do something } #ifdef CUSTOM_EVENTS // // Notify the driver that one or more virtual miniports have been added. // StringFromGUID2( guidMiniport, szMiniportGuid, MAX_PATH+1 ); lpDevice = AddDevicePrefix( szMiniportGuid ); if ( lpDevice ) { dwBytes = sizeof(NOTIFY_CUSTOM_EVENT) + ((wcslen(lpDevice) + 1) * sizeof(WCHAR)); lppnpEvent = (PNOTIFY_CUSTOM_EVENT)malloc( dwBytes ); if ( lppnpEvent ) { lppnpEvent->uSignature = NOTIFY_SIGNATURE; lppnpEvent->uEvent = MUX_CUSTOM_EVENT; wcscpy( lppnpEvent->szMiniport, lpDevice ); hr = pfCallback->SendPnpReconfig( NCRL_NDIS, c_szMuxService, lpszBindName, (PVOID)lppnpEvent, dwBytes ); TraceMsg( L" INetCfgPnpReconfigCallback->SendPnpReconfig returned " L"%#x.\n", hr ); if ( hr != S_OK ) { TraceMsg( L" Failed to apply Pnp changes, miniport(%d).\n", i ); } free( lppnpEvent ); } free( lpDevice ); } #endif } dwMiniportCount = m_MiniportsToRemove.ListCount(); TraceMsg( L" Applying PnP changes to %d removed miniports.\n", dwMiniportCount ); for (i=0; i < dwMiniportCount; ++i) { pMiniport = NULL; m_MiniportsToRemove.Remove( &pMiniport ); pMiniport->GetMiniportGUID( &guidMiniport ); // // Do miniport specific Pnp Changes when they are uninstalled. // hr = pMiniport->ApplyPnpChanges( pfCallback, eActRemove ); if( hr != S_OK) { // you may do something } delete pMiniport; #ifdef CUSTOM_EVENTS // // Notify the driver that one or more virtual miniports have been // uninstalled. // // We can't notify the driver in case the adapter or the protocol is // being uninstalled because the binding handle doesn't exist. // if ( eApplyAction != eActRemove ) { StringFromGUID2( guidMiniport, szMiniportGuid, MAX_PATH+1 ); lpDevice = AddDevicePrefix( szMiniportGuid ); if ( lpDevice ) { dwBytes = sizeof(NOTIFY_CUSTOM_EVENT) + ((wcslen(lpDevice) + 1) * sizeof(WCHAR)); lppnpEvent = (PNOTIFY_CUSTOM_EVENT)malloc( dwBytes ); if ( lppnpEvent ) { lppnpEvent->uSignature = NOTIFY_SIGNATURE; lppnpEvent->uEvent = MUX_CUSTOM_EVENT; wcscpy( lppnpEvent->szMiniport, lpDevice ); hr = pfCallback->SendPnpReconfig( NCRL_NDIS, c_szMuxService, lpszBindName, (PVOID)lppnpEvent, dwBytes ); TraceMsg( L" INetCfgPnpReconfigCallback->SendPnpReconfig returned " L"%#x.\n", hr ); if ( hr != S_OK ) { TraceMsg( L" Failed to apply Pnp changes, miniport(%d).\n", i ); } free( lppnpEvent ); } free( lpDevice ); } } #endif } #ifdef CUSTOM_EVENTS CoTaskMemFree( lpszBindName ); #endif TraceMsg( L"<--CMuxPhysicalAdapter::ApplyPnpChanges(HRESULT = %x).\n", S_OK ); return S_OK; }