ExfReleaseRundownProtection

VOID __stdcall ExfReleaseRundownProtection(_EX_RUNDOWN_REF *RunRef){
  signed __int64 Count; 
  bool v2; 
  signed __int64 v3; 
  unsigned __int64 v4; 

  _m_prefetchw(RunRef);
  Count = RunRef->Count;
  if( (RunRef->Count & 1) != 0 )
  {
LABEL_4:
    v4 = Count & 0xFFFFFFFFFFFFFFFEui64;
    if( _InterlockedExchangeAdd64((volatile signed __int64 *)v4, 0xFFFFFFFFFFFFFFFFui64) == 1
      && !_interlockedbittestandreset((volatile signed __int32 *)(v4 + 32), 0) )
    {
      KeSetEvent((PRKEVENT)(v4 + 8), 0, 0);
    }
  }
  else
  {
    while( 1 )
    {
      v3 = _InterlockedCompareExchange64((volatile signed __int64 *)RunRef, Count - 2, Count);
      v2 = Count == v3;
      Count = v3;
      if( v2 )
        break;
      if( (v3 & 1) != 0 )
        goto LABEL_4;
    }
  }
}

Referenced by:

ExReleaseRundownProtection