Share via


IrqlZwPassive 규칙(wdm)

IrqlZwPassive 규칙은 드라이버가 IRQL = PASSIVE_LEVEL 실행되는 경우에만 ZwClose를 호출한다고 지정합니다.

드라이버 모델: WDM

버그 검사 0xC4: DRIVER_VERIFIER_DETECTED_VIOLATION(0x2001F) 규칙으로 발견된 버그 검사

예제

다음 코드는 이 규칙을 위반합니다.

NTSTATUS 
DriverCloseResources (
    _In_ PDRIVER_CONTEXT Context
    )
{
    …

    NT_ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);

    //
    // ExAcquireFastMutex sets the IRQL to APC_LEVEL, and the caller continues 
    // to run at APC_LEVEL after ExAcquireFastMutex returns.
    //
  
    ExAcquireFastMutex(&Context->FastMutex);
    
    ....
    
    if (NULL != Context->Handle) {

            //
            // RULE VIOLATION! - ZwClose can be called only at PASSIVE_LEVEL 
            //
            
            ZwClose(Context->Handle);      
            Context->Handle = NULL;
    }
    
    ....

    //
    // N.B. ExReleaseFastMutex restores the original IRQL.
    //
     
    ExReleaseFastMutex(&Context->FastMutex);
    
    ....
}

테스트 방법

컴파일 시

정적 드라이버 검증 도구를 실행하고 IrqlZwPassive 규칙을 지정합니다.

다음 단계를 사용하여 코드 분석을 실행합니다.
  1. 코드를 준비합니다(역할 형식 선언 사용).
  2. 정적 드라이버 검증 도구를 실행합니다.
  3. 결과를 보고 분석합니다.

자세한 내용은 정적 드라이버 검증 도구를 사용하여 드라이버에서 결함 찾기를 참조하세요.

런타임 시

드라이버 검증 도구를 실행하고 DDI 규정 준수 확인 옵션을 선택합니다.

적용 대상

ZwCloseZwCreateKeyZwDeleteKeyZwEnumerateKeyZwEnumerateValueKeyZwFlushKeyZwOpenKeyZwQueryKeyZwQueryValueKeyZwSetValueKey