유니버설 Windows 드라이버 유효성 검사

[일부 정보는 상업용으로 출시되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 명시적 또는 묵시적 보증을 하지 않습니다.]

ApiValidator.exe도구를 사용하여 드라이버가 호출하는 API가 유니버설 Windows 드라이버에 대해 유효한지 확인할 수 있습니다. 이 도구는 드라이버가 유니버설 Windows 드라이버에 대해 유효한 API 집합을 벗어난 API를 호출하는 경우 오류를 반환합니다. 이 도구는 Windows 10용 WDK(Windows 드라이버 키트)의 일부입니다.

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(ko-kr,VS.85).gif유효성 검사 오류 수정

  1. 레거시 데스크톱 드라이버를 범용으로 바꾼 경우 올바른 라이브러리를 포함하는지 확인해야 합니다. 프로젝트를 마우스 오른쪽 단추로 클릭하고 속성을 선택합니다. 링커->입력으로 이동합니다. 추가 종속성에 다음이 포함되어야 합니다:

    %AdditionalDependencies);$(SDK_LIB_PATH)\mincore.lib;$(SDK_LIB_PATH)\WppRecorderUM.lib
    
  2. 비-범용 API 호출을 하나씩 제거하거나 교체하고 오류가 발생하지 않을 때까지 도구를 다시 실행합니다.

명령 프롬프트에서 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. 프로젝트 속성을 열고 일반으로 이동한 다음 출력 디렉터리 이름을 다음과 같이 변경합니다:

    $(SolutionDir)$(Platform)\$(ConfigurationName)\
    
  2. 솔루션을 다시 빌드합니다.