ユニバーサル Windows ドライバーの検証

[一部の情報はリリース前の製品に関することであり、正式版がリリースされるまでに大幅に変更される可能性があります。本書に記載された情報について、Microsoft は明示または黙示を問わずいかなる保証をするものでもありません。]

ApiValidator.exe ツールを使うと、ドライバーから呼び出される API が、ユニバーサル Windows ドライバーにとって有効であるかどうかを確認できます。ユニバーサル Windows ドライバーにとって有効な API セットの外部にある API を呼び出すと、エラーが返されます。 このツールは、Windows Driver Kit (WDK) for Windows 10 の一部です。

Visual Studio での ApiValidator の実行

ドライバー プロジェクトの "ターゲット プラットフォーム" プロパティが [ユニバーサル] に設定されていれば、Visual Studio がビルド後の手順として自動的に ApiValidator を実行します。

ApiValidator で表示されたメッセージをすべて確認するには、[ツール]、[オプション]、[プロジェクトおよびソリューション]、[ビルド/実行] の順に移動して、[MSBuild プロジェクト ビルドの出力の詳細][詳細] に設定します。 コマンド ラインからビルドする場合は、ビルド コマンドに /v:detailed スイッチまたは /v:diag スイッチを追加すると、詳しい出力を得ることができます。

umdf2_fx2 ドライバー サンプルに対して API の検証を実行すると、次のようなエラーが表示されます。

Warning   1   warning : API DecodePointer in kernel32.dll is not supported. osrusbfx2um.dll calls this API.   C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\driver\ApiValidator.exe    osrusbfx2um
Warning 2   warning : API DisableThreadLibraryCalls in kernel32.dll is not supported. osrusbfx2um.dll calls this API.   C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\driver\ApiValidator.exe    osrusbfx2um
Warning 3   warning : API EncodePointer in kernel32.dll is not supported. osrusbfx2um.dll calls this API.   C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\driver\ApiValidator.exe    osrusbfx2um
Warning 4   warning : API GetCurrentProcessId in kernel32.dll is not supported. osrusbfx2um.dll calls this API. C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\driver\ApiValidator.exe    osrusbfx2um
Warning 5   warning : API GetCurrentThreadId in kernel32.dll is not supported. osrusbfx2um.dll calls this API.  C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\driver\ApiValidator.exe    osrusbfx2um
Warning 6   warning : API GetSystemTimeAsFileTime in kernel32.dll is not supported. osrusbfx2um.dll calls this API. C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\driver\ApiValidator.exe    osrusbfx2um
Warning 7   warning : API IsDebuggerPresent in kernel32.dll is not supported. osrusbfx2um.dll calls this API.   C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\driver\ApiValidator.exe    osrusbfx2um
Warning 8   warning : API IsProcessorFeaturePresent in kernel32.dll is not supported. osrusbfx2um.dll calls this API.   C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\driver\ApiValidator.exe    osrusbfx2um
Warning 9   warning : API QueryPerformanceCounter in kernel32.dll is not supported. osrusbfx2um.dll calls this API. C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\driver\ApiValidator.exe    osrusbfx2um
Error   10  error MSB3721: The command ""C:\Program Files (x86)\Windows Kits\10\bin\x64\ApiValidator.exe" -DriverPackagePath:"C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\Debug\\" -SupportedApiXmlFiles:"C:\Program Files (x86)\Windows Kits\10\build\universalDDIs\x86\UniversalDDIs.xml" -ApiExtractorExePath:"C:\Program Files (x86)\Windows Kits\10\bin\x64"" exited with code -1.    C:\Program Files (x86)\Windows Kits\10\build\WindowsDriver.common.targets   1531    5   osrusbfx2um

Dn941247.wedge(ja-jp,VS.85).gif検証エラーの修正

  1. レガシ デスクトップ ドライバーをユニバーサルに切り替えた場合は、適切なライブラリが含まれていることを確認します。プロジェクトを右クリックし、プロパティを選択します。 [リンカー]、[入力] の順に移動します。 [追加の依存ファイル]

    %AdditionalDependencies);$(SDK_LIB_PATH)\mincore.lib;$(SDK_LIB_PATH)\WppRecorderUM.lib
    

    を含める必要があります。

  2. 非ユニバーサル API の呼び出しを一度に 1 つずつ削除または置換し、エラーがなくなるまでツールを再実行します。

コマンド プロンプトからの ApiValidator の実行

Apivalidator.exe をコマンド プロンプトで実行することもできます。 WDK のインストールで、C:\Program Files (x86)\Windows Kits\10\bin\<arch> に移動します。

使用する構文は以下のとおりです。

Apivalidator.exe -DriverPackagePath:<driver folder path> -SupportedApiXmlFiles:<path to XML files containing supported APIs for universal drivers>

たとえば、WDK のアクティビティ サンプルから呼び出される API を検証するには、まず Visual Studio でサンプルをビルドします。 次に、コマンド プロンプトを開き、ツールが存在するディレクトリ (例: C:\Program Files (x86)\Windows Kits\10\bin\x64) に移動します。次のコマンドを入力します。

apivalidator.exe -DriverPackagePath:"C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\Debug\\" -SupportedApiXmlFiles:"c:\Program Files (x86)\Windows Kits\10\build\universalDDIs\x64\UniversalDDIs.xml"

このコマンドを実行すると、次の出力が生成されます。

ApiValidator.exe: Warning: API DecodePointer in kernel32.dll is not supported. osrusbfx2um.dll calls this API.
ApiValidator.exe: Warning: API DisableThreadLibraryCalls in kernel32.dll is not supported. osrusbfx2um.dll calls this API.
ApiValidator.exe: Warning: API EncodePointer in kernel32.dll is not supported. osrusbfx2um.dll calls this API.
ApiValidator.exe: Warning: API GetCurrentProcessId in kernel32.dll is not supported. osrusbfx2um.dll calls this API.
ApiValidator.exe: Warning: API GetCurrentThreadId in kernel32.dll is not supported. osrusbfx2um.dll calls this API.
ApiValidator.exe: Warning: API GetSystemTimeAsFileTime in kernel32.dll is not supported. osrusbfx2um.dll calls this API.
ApiValidator.exe: Warning: API IsDebuggerPresent in kernel32.dll is not supported. osrusbfx2um.dll calls this API.
ApiValidator.exe: Warning: API IsProcessorFeaturePresent in kernel32.dll is not supported. osrusbfx2um.dll calls this API.
ApiValidator.exe: Warning: API QueryPerformanceCounter in kernel32.dll is not supported. osrusbfx2um.dll calls this API.

ApiValidator.exe Driver located at C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\Debug is NOT a Universal Driver

ユニバーサル Windows ドライバーの有効な API を列挙した XML ファイルは C:\Program Files (x86)\Windows Kits\10\build\universalDDIs\<arch> にあります。

トラブルシューティング

ApiValidator.exe で、形式が正しくないことを示す次のようなエラーが出力された場合:

Error      1              error : AitStatic output file has incorrect format or analysis run on incorrect file types.     C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\driver\ApiValidator.exe            osrusbfx2um

次の回避策を実行します。

  1. Project プロパティを開き、[全般] に移動して、[出力ディレクトリ] の名前を

    $(SolutionDir)$(Platform)\$(ConfigurationName)\
    

    に変更します。

  2. ソリューションをリビルドします。