次の方法で共有


UsbKmdfIrqlExplicit ルール (kmdf)

UsbKmdfIrqlExplicit ルールは、KMDF DDI が正しい IRQL レベルで呼び出されているかを検証します。 このルールは、すべての EvtIoCallback 関数に適用されます。

ドライバーが WDF_OBJECT_ATTRIBUTES 構造体を持つ WdfIoQueueCreate 関数を呼び出し、この DDI に渡されるデバイス オブジェクトが既定の属性 (WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE または VOID WDF_OBJECT_ATTRIBUTES_INIT) を使用して作成された場合は、静的ドライバー検証ツールがこの規則に関連する欠陥を報告しないように、次のいずれかの方法でドライバーを変更する必要があります。

ドライバー コードを変更して、WDF_OBJECT_ATTRIBUTES構造体をパラメーターとして使用する関数を呼び出して属性を設定することで、デバイス属性を WdfExecutionLevelPassive または WdfExecutionLevelDispatch に明示的に設定します。

分析のために、__analysis_assume マクロを使用して、WdfExecutionLevelPassive または WdfExecutionLevelDispatch がデバイス属性に設定されていることを明示的に想定/アサートします。 例は次のようになります: __analysis_assume(deviceAttributes.ExecutionLevel==WdfExecutionLevelPassive)

ドライバーが一部の IOCTL を PASSIVE_LEVEL で処理し、他の IOCTL を DISPATCH_LEVEL で処理する場合は、DISPATCH_LEVELで処理される IOCTL を検証から除外することが必要になる場合があります。 __analysis_assume を使用してこれを行うことができます。 IOCTL_RH_QUERY_DUMMY_TRANSLATOR_INTERFACE がドライバー EvtIoDeviceControlCallback の DISPATCH_LEVEL で処理される __analysis_assume(IoControlCode != IOCTL_RH_QUERY_DUMMY_TRANSLATOR_INTERFACE) の例を次に示します。

ドライバー モデル: KMDF

テスト方法

コンパイル時

静的ドライバー検証ツールを実行し、UsbKmdfIrqlExplicit 規則を指定します。

コードの分析を実行するには、次の手順に従います。
  1. コードを準備します (ロール型宣言を使用します)。
  2. 静的ドライバー検証ツールを実行します。
  3. 結果を表示および分析します。

詳細については、「静的ドライバー検証ツールを使用したドライバーの欠陥の検出」を参照してください。

適用対象

WdfUsbInterfaceGetConfiguredPipeWdfUsbInterfaceGetConfiguredSettingIndexWdfUsbInterfaceGetDescriptorWdfUsbInterfaceGetEndpointInformationWdfUsbInterfaceGetInterfaceNumberWdfUsbInterfaceGetNumConfiguredPipesWdfUsbInterfaceGetNumEndpointsWdfUsbInterfaceGetNumSettingsWdfUsbInterfaceSelectSettingWdfUsbTargetDeviceAllocAndQueryStringWdfUsbTargetDeviceCreateWdfUsbTargetDeviceCyclePortSynchronouslyWdfUsbTargetDeviceFormatRequestForControlTransferWdfUsbTargetDeviceFormatRequestForCyclePortWdfUsbTargetDeviceFormatRequestForStringWdfUsbTargetDeviceFormatRequestForUrbWdfUsbTargetDeviceGetDeviceDescriptorWdfUsbTargetDeviceGetInterfaceWdfUsbTargetDeviceGetNumInterfacesWdfUsbTargetDeviceIsConnectedSynchronousWdfUsbTargetDeviceQueryStringWdfUsbTargetDeviceResetPortSynchronouslyWdfUsbTargetDeviceRetrieveConfigDescriptorWdfUsbTargetDeviceRetrieveCurrentFrameNumberWdfUsbTargetDeviceRetrieveInformationWdfUsbTargetDeviceSelectConfigWdfUsbTargetDeviceSendControlTransferSynchronouslyWdfUsbTargetDeviceSendUrbSynchronouslyWdfUsbTargetDeviceWdmGetConfigurationHandleWdfUsbTargetPipeAbortSynchronouslyWdfUsbTargetPipeConfigContinuousReaderWdfUsbTargetPipeFormatRequestForAbortWdfUsbTargetPipeFormatRequestForReadWdfUsbTargetPipeFormatRequestForResetWdfUsbTargetPipeFormatRequestForUrbWdfUsbTargetPipeFormatRequestForWriteWdfUsbTargetPipeGetInformationWdfUsbTargetPipeGetTypeWdfUsbTargetPipeIsInEndpointWdfUsbTargetPipeIsOutEndpointWdfUsbTargetPipeReadSynchronouslyWdfUsbTargetPipeResetSynchronouslyWdfUsbTargetPipeSendUrbSynchronouslyWdfUsbTargetPipeSetNoMaximumPacketSizeCheckWdfUsbTargetPipeWdmGetPipeHandleWdfUsbTargetPipeWriteSynchronously