ExTryAcquirePushLockExclusiveEx

NTSTATUS __fastcall ExTryAcquirePushLockExclusiveEx(_EX_PUSH_LOCK *PushLock, UINT64 Flags){
  NTSTATUS result; 
  __int64 v3; 
  _ETHREAD *CurrentThread; 
  bool v6; 
  __int64 AbOrphanedEntrySummary; 
  char v8; 
  NTSTATUS SessionId; 
  UINT64 a3; 

  v3 = 0i64;
  if( (Flags & 0xFFFFFFFC) != 0 )
    KeBugCheckEx(0x152u, (PVOID)(unsigned int)Flags, PushLock, 0i64, 0i64);
  if( (Flags & 2) == 0 )
  {
    LODWORD(a3) = 0;
    CurrentThread = (_ETHREAD *)KeGetCurrentThread();
    --CurrentThread->Tcb.SpecialApcDisable;
    if( ++CurrentThread->Tcb.AbAllocationRegionCount != 1 )
      goto LABEL_4;
    LOBYTE(AbOrphanedEntrySummary) = CurrentThread->Tcb.AbEntrySummary;
    if( !(_BYTE)AbOrphanedEntrySummary )
    {
      if( !CurrentThread->Tcb.AbOrphanedEntrySummary )
      {
LABEL_14:
        if( v3 )
        {
          if( (unsigned __int64)PushLock >= 0xFFFF800000000000ui64
            && *((_BYTE *)&stru_140C4DB30 + (((unsigned __int64)PushLock >> 39) & 0x1FF) + 6872) == 1 )
          {
            SessionId = MmGetSessionIdEx(CurrentThread->Tcb.ApcState.Process);
          }
          else
          {
            SessionId = -1;
          }
          *(_DWORD *)(v3 + 40) = SessionId;
          *(_QWORD *)(v3 + 32) = (unsigned __int64)PushLock & 0x7FFFFFFFFFFFFFFCi64;
LABEL_5:
          --CurrentThread->Tcb.AbAllocationRegionCount;
          KiAbThreadRemoveBoosts(&CurrentThread->Tcb, PushLock, &a3);
          v6 = CurrentThread->Tcb.SpecialApcDisable++ == -1;
          if( v6
            && ($F25F8C4BA33AF922A5F1AF68CD89DDDF *)CurrentThread->Tcb.ApcState.ApcListHead[0].Flink != &CurrentThread->Tcb.152 )
          {
            KiCheckForKernelApcDelivery();
          }
          goto LABEL_8;
        }
LABEL_4:
        _interlockedbittestandset((volatile signed __int32 *)&CurrentThread->Tcb.116 + 1, 0x10u);
        goto LABEL_5;
      }
      AbOrphanedEntrySummary = CurrentThread->Tcb.AbOrphanedEntrySummary;
      CurrentThread->Tcb.AbOrphanedEntrySummary = 0;
      LOBYTE(AbOrphanedEntrySummary) = CurrentThread->Tcb.AbEntrySummary | AbOrphanedEntrySummary;
    }
    v8 = AbOrphanedEntrySummary;
    _BitScanForward((unsigned int *)&AbOrphanedEntrySummary, (unsigned __int8)AbOrphanedEntrySummary);
    CurrentThread->Tcb.AbEntrySummary = v8 & ~(1 << AbOrphanedEntrySummary);
    v3 = (__int64)&CurrentThread->Tcb.LockEntries[AbOrphanedEntrySummary];
    goto LABEL_14;
  }
LABEL_8:
  if( _interlockedbittestandset64((volatile signed __int32 *)PushLock, 0i64) )
  {
    if( v3 )
      KeAbPostReleaseEx(PushLock, (VOID *)v3);
    LOBYTE(result) = 0;
  }
  else
  {
    if( v3 )
      *(_BYTE *)(v3 + 26) |= 1u;
    LOBYTE(result) = 1;
  }
  return result;
}

Referenced by:

No references.