드라이버 검증 도구가 사용하도록 설정된 경우 버그 검사 처리

드라이버 검증 도구 는 런타임에 드라이버 오류를 검색합니다. 드라이버 검증 도구와 !analyze 디버거 명령을 사용하여 드라이버의 오류에 대한 정보를 검색하고 표시할 수 있습니다.

Windows 8 드라이버 검증 도구DDI 규정 준수 검사를 비롯한 새로운 기능으로 향상되었습니다. 여기서는 DDI 규정 준수 검사를 보여 주는 예제를 제공합니다.

다음 절차를 사용하여 설정합니다.

  1. 호스트와 대상 컴퓨터 간에 커널 모드 디버깅 세션을 설정합니다.
  2. 대상 컴퓨터에 드라이버를 설치합니다.
  3. 대상 컴퓨터에서 명령 프롬프트 창을 열고 명령 확인자를 입력합니다. 드라이버 검증 도구 관리자를 사용하여 드라이버에 대해 드라이버 검증을 사용하도록 설정합니다.
  4. 대상 컴퓨터를 다시 부팅합니다.

드라이버 검증 도구가 오류를 감지하면 버그 검사 생성됩니다. 그런 다음 Windows가 디버거에 침입하여 오류에 대한 간략한 설명을 표시합니다. 다음은 드라이버 검증 도구가 버그 검사 DRIVER_VERIFIER_DETECTED_VIOLATION(C4)를 생성하는 예제입니다.

Driver Verifier: Extension abort with Error Code 0x20005
Error String ExAcquireFastMutex should only be called at IRQL <= APC_LEVEL.

*** Fatal System Error: 0x000000c4
                       (0x0000000000020005,0xFFFFF88000E16F50,0x0000000000000000,0x0000000000000000)

Break instruction exception - code 80000003 (first chance)

A fatal system error has occurred.
Debugger entered on first try; Bugcheck callbacks have not been invoked.

A fatal system error has occurred.

nt!DbgBreakPointWithStatus:
fffff802`a40ef930 cc              int     3

디버거에서 !analyze -v 를 입력하여 오류에 대한 자세한 설명을 가져옵니다.

0: kd> !analyze -v
Connected to Windows 8 9200 x64 target at (Thu Oct 11 13:48:31.270 2012 (UTC - 7:00)), ptr64 TRUE
Loading Kernel Symbols
...............................................................
................................................................
...................
Loading User Symbols
..................................................
Loading unloaded module list
............
*******************************************************************************
*                                                                             *
*                        Bugcheck Analysis                                    *
*                                                                             *
*******************************************************************************

DRIVER_VERIFIER_DETECTED_VIOLATION (c4)
A device driver attempting to corrupt the system has been caught.  This is
because the driver was specified in the registry as being suspect (by the
administrator) and the kernel has enabled substantial checking of this driver.
If the driver attempts to corrupt the system, bugchecks 0xC4, 0xC1 and 0xA will
be among the most commonly seen crashes.
Arguments:
Arg1: 0000000000020005, ID of the 'IrqlExApcLte1' rule that was violated.
Arg2: fffff88000e16f50, A pointer to the string describing the violated rule condition.
Arg3: 0000000000000000, An optional pointer to the rule state variable(s).
Arg4: 0000000000000000, Reserved (unused)

## Debugging Details:

...

DV_VIOLATED_CONDITION:  ExAcquireFastMutex should only be called at IRQL <= APC_LEVEL.

DV_MSDN_LINK: !url https://go.microsoft.com/fwlink/p/?linkid=216022

DV_RULE_INFO: !ruleinfo 0x20005

BUGCHECK_STR:  0xc4_IrqlExApcLte1_XDV

DEFAULT_BUCKET_ID:  WIN8_DRIVER_FAULT

PROCESS_NAME:  TiWorker.exe

CURRENT_IRQL:  9

앞의 출력에서 위반된 규칙 IrqlExApcLte1의 이름과 설명을 볼 수 있으며, IrqlExApcLte1 규칙(wdm)을 설명하는 참조 페이지에 대한 링크를 선택할 수 있습니다. 디버거 명령 링크 !ruleinfo 0x20005 선택하여 규칙에 대한 정보를 가져올 수도 있습니다. 이 경우 규칙은 IRQL(인터럽트 요청 수준)이 APC_LEVEL보다 큰 경우 ExAcquireFastMutex 를 호출할 수 없다고 명시합니다. 출력은 현재 IRQL이 9이며 wdm.h에서 APC_LEVEL 값이 1임을 확인할 수 있습니다. IRQL에 대한 자세한 내용은 하드웨어 우선 순위 관리를 참조하세요.

!analyze -v의 출력은 스택 추적과 오류를 발생시킨 코드에 대한 정보를 계속 사용합니다. 다음 출력에서는 MyDriver.sys OnInterrupt 루틴이 ExAcquireFastMutex라는 것을 확인할 수 있습니다. OnInterrupt 는 APC_LEVEL보다 큰 IRQL에서 실행되는 인터럽트 서비스 루틴이므로 이 루틴에서 ExAcquireFastMutex를 호출하는 것은 위반입니다.

LAST_CONTROL_TRANSFER:  from fffff802a41f00ea to fffff802a40ef930

STACK_TEXT:  
... : nt!DbgBreakPointWithStatus ...
... : nt!KiBugCheckDebugBreak+0x12 ...
... : nt!KeBugCheck2+0x79f ...
... : nt!KeBugCheckEx+0x104 ...
... : VerifierExt!SLIC_abort+0x47 ...
... : VerifierExt!SLIC_ExAcquireFastMutex_entry_irqlexapclte1+0x25 ...
... : VerifierExt!ExAcquireFastMutex_wrapper+0x1a ...
... : nt!ViExAcquireFastMutexCommon+0x1d ...
... : nt!VerifierExAcquireFastMutex+0x1a ...
... : MyDriver!OnInterrupt+0x69 ...
... : nt!KiScanInterruptObjectList+0x6f ...
... : nt!KiChainedDispatch+0x19a ...
...

STACK_COMMAND:  kb

FOLLOWUP_IP: 
MyDriver!OnInterrupt+69 ...
fffff880`16306649 4c8d0510040000  lea     r8,[MyDriver! ?? ::FNODOBFM::`string' (fffff880`16306a60)]

FAULTING_SOURCE_LINE:  c:\MyDriverwdm03\cpp\MyDriver\pnp.c

FAULTING_SOURCE_FILE:  c:\MyDriverwdm03\cpp\MyDriver\pnp.c

FAULTING_SOURCE_LINE_NUMBER:  26

FAULTING_SOURCE_CODE:  
    22:    if(1 == interruptStatus)
    23:    {
    24:       ...
    25:       ExAcquireFastMutex( &(fdoExt->fastMutex) );
>   26:       ...
    27:       ExReleaseFastMutex( &(fdoExt->fastMutex) );
    28:       ...
    29:       return TRUE;
    30:    }
    31:    else


SYMBOL_STACK_INDEX:  9

SYMBOL_NAME:  MyDriver!OnInterrupt+69

FOLLOWUP_NAME:  ...

MODULE_NAME: MyDriver

IMAGE_NAME:  MyDriver.sys

DEBUG_FLR_IMAGE_TIMESTAMP:  50772f37

BUCKET_ID_FUNC_OFFSET:  69

FAILURE_BUCKET_ID:  0xc4_IrqlExApcLte1_XDV_VRF_MyDriver!OnInterrupt

BUCKET_ID:  0xc4_IrqlExApcLte1_XDV_VRF_MyDriver!OnInterrupt

참고 항목

정적 드라이버 검증 도구