[僅適用於 KMDF]
WdfCmResourceListRemoveByDescriptor 方法會從指定的資源清單中移除指定的資源描述元。
語法
void WdfCmResourceListRemoveByDescriptor(
[in] WDFCMRESLIST List,
[in] PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor
);
參數
[in] List
架構資源清單物件的句柄,代表裝置的硬體資源清單。
[in] Descriptor
描述硬體資源的 CM_PARTIAL_RESOURCE_DESCRIPTOR 結構的指標。
傳回值
沒有
言論
如果驅動程式提供無效的物件句柄,就會發生錯誤檢查。
WdfCmResourceListRemoveByDescriptor 方法會移除符合 描述元 參數的資源描述項。 若要尋找相符專案,此方法會比較指定的資源描述元與邏輯組態中的資源描述元,位元組的位元組。
當 WdfCmResourceListRemoveByDescriptor 移除索引值 n的資源描述項時,下一個資源描述元的索引值會從 n+1 變更為 n。
如需資源清單的詳細資訊,請參閱 Framework-Based 驅動程式的硬體資源。
例子
下列程式代碼範例會在裝置的資源清單中搜尋埠資源描述項。 針對範例找到的每個埠資源,它會檢查埠位址是否在特定範圍內。 如果連接埠位址超出範圍,則此範例會從 原始和翻譯的資源清單中移除描述元,。
NTSTATUS
MyEvtDeviceRemoveAddedResources(
WDFDEVICE Device,
WDFCMRESLIST ResourcesRaw,
WDFCMRESLIST ResourcesTranslated
)
{
ULONG i, count;
pDevExt = DeviceGetExtension(Device);
count = WdfCmResourceListGetCount(ResourcesRaw);
for (i = 0; i < count; i++) {
PCM_PARTIAL_RESOURCE_DESCRIPTOR descriptor;
descriptor = WdfCmResourceListGetDescriptor(
ResourcesRaw,
i
);
if (descriptor->Type != CmResourceTypePort) {
continue;
}
if (descriptor->u.Port.Start.QuadPart < pDevExt->Ranges[0].MinAddress ||
descriptor->u.Port.Start.QuadPart > pDevExt->Ranges[0].MaxAddress)
{
WdfCmResourceListRemoveByDescriptor(
ResourcesRaw,
descriptor
);
// The descriptor may not be the same in the raw and translated resource lists, so use an index for the second removal
WdfCmResourceListRemove(
ResourcesTranslated,
i
);
break;
}
}
}
要求
要求 | 價值 |
---|---|
目標平臺 | 普遍 |
最低 KMDF 版本 | 1.0 |
標頭 | wdfresource.h (包括 Wdf.h) |
連結庫 | Wdf01000.sys (請參閱架構連結庫版本控制。) |
IRQL | <=DISPATCH_LEVEL |
DDI 合規性規則 | DriverCreate(kmdf),KmdfIrql(kmdf),KmdfIrql2(kmdf),KmdfIrqlExplicit(kmdf) |