Gestione di un controllo di bug quando è abilitata la verifica del driver

Driver Verifier rileva gli errori del driver in fase di esecuzione. È possibile usare Driver Verifier insieme al comando !analyze debugger per rilevare e visualizzare informazioni sugli errori nel driver.

In Windows 8, Driver Verifier è stato migliorato con nuove funzionalità, incluso il controllo della conformità DDI. Di seguito viene illustrato un esempio che illustra il controllo della conformità DDI.

Utilizzare la procedura seguente per configurare.

  1. Stabilire una sessione di debug in modalità kernel tra un host e un computer di destinazione.
  2. Installare il driver nel computer di destinazione.
  3. Nel computer di destinazione aprire una finestra del prompt dei comandi e immettere il verificatore del comando. Usare Gestione verifica driver per abilitare Driver Verifier per il driver.
  4. Riavviare il computer di destinazione.

Quando Driver Verifier rileva un errore, genera un controllo di bug. Windows si interrompe quindi nel debugger e visualizza una breve descrizione dell'errore. Di seguito è riportato un esempio in cui Driver Verifier genera il controllo dei bug 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

Nel debugger immettere !analyze -v per ottenere una descrizione dettagliata dell'errore.

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

Nell'output precedente è possibile visualizzare il nome e la descrizione della regola IrqlExApcLte1 violata ed è possibile selezionare un collegamento alla pagina di riferimento che descrive la regola IrqlExApcLte1 (wdm). È anche possibile selezionare un collegamento al comando del debugger, !ruleinfo 0x20005, per ottenere informazioni sulla regola. In questo caso, la regola indica che non è possibile chiamare ExAcquireFastMutex se il livello di richiesta di interrupt (IRQL) è maggiore di APC_LEVEL. L'output mostra che l'IRQL corrente è 9 e in wdm.h è possibile vedere che APC_LEVEL ha un valore pari a 1. Per altre informazioni sui runtime di integrazione, vedere Gestione delle priorità hardware.

L'output di !analyze -v continua con un'analisi dello stack e informazioni sul codice che ha causato l'errore. Nell'output seguente è possibile notare che la routine OnInterrupt in MyDriver.sys denominata ExAcquireFastMutex. OnInterrupt è una routine del servizio di interruzione eseguita in un irQL maggiore di APC_LEVEL, pertanto si tratta di una violazione per questa routine di chiamare 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

Vedere anche

Driver Verifier statico