共用方式為


usbKmdfIrqlExplicit 規則 (kmdf)

UsbKmdfIrqlExplicit 規則會確認 KMDF DIS 是在正確的 IRQL 層級呼叫。 此規則適用於所有 EvtIoCallback 函式。

如果您的驅動程式使用 WDF_OBJECT_ATTRIBUTES 結構呼叫 WdfIoQueueCreate 函式,並使用預設屬性 (WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE 或 VOID WDF_OBJECT_ATTRIBUTES_INIT) 建立传入此 DDI 的裝置物件,則您可能需要以下列其中一種方式修改驅動程式,讓 靜態驅動程式驗證器 不會回報與此規則相關的瑕疵:

藉由變更驅動程式程式代碼,藉由呼叫使用 WDF_OBJECT_ATTRIBUTES 結構做為參數的函式,將裝置屬性明確設定為 WdfExecutionLevelPassive 或 WdfExecutionLevelDispatch。

明確假設/判斷提示,以便分析 WdfExecutionLevelPassive 或 WdfExecutionLevelDispatch 是在裝置屬性中使用 __analysis_assume 宏來設定。 以下是範例:__analysis_assume (deviceAttributes.ExecutionLevel==WdfExecutionLevelPassive)

如果您的驅動程式在 PASSIVE_LEVEL 處理一些 IOCTL,而DISPATCH_LEVEL的其他 IOCTL,您可能需要從驗證中排除在DISPATCH_LEVEL處理的 IOCTL。 您可以使用 __analysis_assume 來執行此動作。 以下是範例:__analysis_assume (IoControlCode != IOCTL_RH_QUERY_DUMMY_TRANSLATOR_INTERFACE) ,其中IOCTL_RH_QUERY_DUMMY_TRANSLATOR_INTERFACE會在驅動程式 EvtIoDeviceControlCallback 的DISPATCH_LEVEL處理。

驅動程式模型:KMDF

測試方法

在編譯時期

執行 靜態驅動程式驗證器 ,並指定 UsbKmdfIrqlExplicit 規則。

使用下列步驟來執行程式碼的分析:
  1. 準備程式代碼 (使用角色類型宣告) 。
  2. 執行靜態驅動程式驗證程式。
  3. 檢視和分析結果。

如需詳細資訊,請參閱 使用靜態驅動程式驗證器在驅動程式中尋找瑕疵

適用於

WdfUsbInterfaceGetConfiguredPipeWdfUsbInterfaceGetConfiguredSettingIndexWdfUsbInterfaceGetDescriptorWdfUsbInterfaceGetEndpointInformationWdfUsbInterfaceGetInterfaceNumberWdfUsbInterfaceGetNumConfiguredPipesWdfUsbInterfaceGetNumEndpointsWdfUsbInterfaceGetNumSettingsWdfUsbInterfaceSelectSettingsWdfUsbTargetDeviceAllocAndQueryStringWdfUsbTargetDeviceCreateWdfUsbTargetDeviceCyclePortSynchronouslyWdfUsbTargetDeviceFormatRequestForControlTransferWdfUsbTargetDeviceFormatRequestForCyclePortWdfUsbTargetDeviceFormatRequestForStringWdfUsbTargetDeviceFormatRequestForUrbWdfUsbTargetDeviceGetDeviceDescriptorWdfUsbTargetDeviceGetInterfaceWdfUsbTargetDeviceGetNumInterfacesWdfUsbTargetDeviceIsConnectedSynchronousWdfUsbTargetDeviceQueryStringWdfUsbTargetDeviceResetPortSynchronouslyWdfUsbTargetDeviceRetrieveConfigDescriptorWdfUsbTargetDeviceRetrieveCurrentFrameNumberWdfUsbTargetDeviceRetrieveInformationWdfUsbTargetDeviceSelectConfigWdfUsbTargetDeviceSendControlTransferSynchronouslyWdfUsbTargetDeviceSendUrbSynchronouslyWdfUsbTargetDeviceWdmGetConfigurationHandleWdfUsbTargetPipeAbortSynchronouslyWdfUsbTargetPipeConfigContinuousReaderWdfUsbTargetPipeFormatRequestForAbortWdfUsbTargetPipeFormatRequestForReadWdfUsbTargetPipeFormatRequestForResetWdfUsbTargetPipeFormatRequestForUrbWdfUsbTargetPipeFormatRequestForWriteWdfUsbTargetPipeGetInformationWdfUsbTargetPipeGetTypeWdfUsbTargetPipeIsInEndpointWdfUsbTargetPipeIsOutEndpointWdfUsbTargetPipeReadSynchronouslyWdfUsbTargetPipeResetSynchronouslyWdfUsbTargetPipeSendUrbSynchronouslyWdfUsbTargetPipeSetNoMaximumPacketSizeCheckWdfUsbTargetPipeWdmGetPipeHandleWdfUsbTargetPipeWriteSynchronously