ExReleaseRundownProtectionCacheAwareEx

NTSTATUS __fastcall ExReleaseRundownProtectionCacheAwareEx(INT64 a1, INT64 a2){
  signed __int64 *v2; 
  signed __int64 v3; 
  signed __int64 v4; 
  unsigned __int64 v5; 

  v2 = (signed __int64 *)(*(_QWORD *)a1 + *(_DWORD *)(a1 + 16) * (KeGetPcr()->Prcb.Number % *(_DWORD *)(a1 + 20)));
  _m_prefetchw(v2);
  while( 1 )
  {
    while( 1 )
    {
      v3 = *v2;
      if( (*v2 & 1) != 0 )
        break;
      v4 = _InterlockedCompareExchange64(v2, v3 - (unsigned int)(2 * a2), v3);
      if( v3 == v4 )
        return v4;
    }
    if( v3 != 1 )
      break;
    v2 = *(signed __int64 **)a1;
  }
  v5 = v3 & 0xFFFFFFFFFFFFFFFEui64;
  LODWORD(v4) = -(int)a2;
  if( _InterlockedExchangeAdd64((volatile signed __int64 *)v5, -(int)a2) == (unsigned int)a2 )
    LODWORD(v4) = KeSetEvent((PRKEVENT)(v5 + 8), 0, 0);
  return v4;
}

Referenced by:

EtwInitialize
EtwpAcquireLoggerContextByLoggerId
EtwpCancelPendingStackwalkApcs
EtwpCloseLogger
EtwpCompressionProc
EtwpEventWriteFull
EtwpFailLogging
EtwpFinalizePendingApc
EtwpFreeLoggerContext
EtwpLogKernelEvent
EtwpQueueStackWalkApc
EtwpQueueStackWalkDpc
EtwpReleaseLoggerContext
EtwpStackWalkDpc
EtwpStartLogger
EtwpStopTrace
EtwpTraceMessageVa
EtwpWriteUserEvent
RawEndOperation