diff --git a/vfdynf/fault.c b/vfdynf/fault.c index 295cd79..4fc4ec0 100644 --- a/vfdynf/fault.c +++ b/vfdynf/fault.c @@ -384,12 +384,15 @@ VOID AVrfEnableCurrentThreadFaultInjection( BOOLEAN AVrfpShouldFaultInjectCached( _In_ ULONG FaultType, - _In_ ULONG StackHash + _In_ ULONG StackHash, + _Inout_ PBOOLEAN FaultInject ) { BOOLEAN result; PAVRF_STACK_ENTRY stackEntry; + result = FALSE; + AVrfEnterCriticalSection(&AVrfpFaultContext.CriticalSection); if (AVrfpFaultContext.CriticalSection.RecursionCount > 1) @@ -397,7 +400,8 @@ BOOLEAN AVrfpShouldFaultInjectCached( // // Do not fault inject if we're recursing on this lock. // - result = FALSE; + *FaultInject = FALSE; + result = TRUE; goto Exit; } @@ -415,8 +419,6 @@ BOOLEAN AVrfpShouldFaultInjectCached( { AVrfpFaultContext.LastClear = NtGetTickCount64(); AVrfClearStackTable(&AVrfpFaultContext.StackTable); - - result = TRUE; goto Exit; } } @@ -425,7 +427,6 @@ BOOLEAN AVrfpShouldFaultInjectCached( StackHash); if (!stackEntry || (stackEntry->Hash != StackHash)) { - result = TRUE; goto Exit; } @@ -437,18 +438,20 @@ BOOLEAN AVrfpShouldFaultInjectCached( // if (stackEntry->Excluded) { - result = FALSE; + *FaultInject = FALSE; } else if (!BooleanFlagOn(stackEntry->FaultMask, FaultType)) { SetFlag(stackEntry->FaultMask, FaultType); - result = TRUE; + *FaultInject = TRUE; } else { - result = FALSE; + *FaultInject = FALSE; } + result = TRUE; + Exit: AVrfLeaveCriticalSection(&AVrfpFaultContext.CriticalSection); @@ -562,7 +565,7 @@ BOOLEAN AVrfShouldFaultInject( count = RtlCaptureStackBackTrace(1, ARRAYSIZE(frames), frames, &stackHash); - if (!AVrfpShouldFaultInjectCached(FaultType, stackHash)) + if (AVrfpShouldFaultInjectCached(FaultType, stackHash, &result)) { goto Exit; }