Hello all.
Well, probably you are tired of my WDM questions. But I would like to ask one more. Reading Toaster’s bus example I wonder why FDO’s REMOVE_DEVICE handler cares about PDO’s SurpriseRemovalPending state?
case REMOVE_DEVICE:
// Typically the system removes all the children before
// removing the parent FDO. If for any reason child Pdos are
// still present we will destroy them explicitly, with one exception -
// we will not delete the PDOs that are in SurpriseRemovePending state.
//
ExAcquireFastMutex (&DeviceData->Mutex);
listHead = &DeviceData->ListOfPDOs;
for(entry = listHead->Flink,nextEntry = entry->Flink;
entry != listHead;
entry = nextEntry,nextEntry = entry->Flink) {
pdoData = CONTAINING_RECORD (entry, PDO_DEVICE_DATA, Link);
RemoveEntryList (&pdoData->Link);
if (SurpriseRemovePending == pdoData->DevicePnPState)
{
InitializeListHead (&pdoData->Link);
pdoData->ParentFdo = NULL;
pdoData->ReportedMissing = TRUE;
continue;
}
DeviceData->NumPDOs–;
Bus_DestroyPdo (pdoData->Self, pdoData);
}
AFAIK IRP sequence for remove is the following: QUERY_REMOVE ->REMOVE, SURPRISE_REMOVAL ->REMOVE. The thing I don’t get is why FDO handles PDO’s SR state in some special way.
Again, I am not trying to understand and remember all the complexity of WDM. Just would like to have general understanding.
–
Thanking In Advance,
Mikae.