KeAbPreAcquire

VOID *__stdcall KeAbPreAcquire(VOID *Lock, VOID *LockHandle, UINT64 Flags){
  _KLOCK_ENTRY *v3; 
  _ETHREAD *CurrentThread; 
  __int64 AbOrphanedEntrySummary; 
  char v7; 
  NTSTATUS SessionId; 
  bool v9; 
  int v11; 
  unsigned int v12; 
  UINT64 a3; 

  v3 = (_KLOCK_ENTRY *)LockHandle;
  LODWORD(a3) = 0;
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  --CurrentThread->Tcb.SpecialApcDisable;
  if( ++CurrentThread->Tcb.AbAllocationRegionCount == 1 )
  {
    if( LockHandle )
    {
      *((_BYTE *)LockHandle + 32) |= 2u;
      if( *((__int64 *)LockHandle + 4) < 0 )
        KiAbEntryRemoveFromTree((_KLOCK_ENTRY *)LockHandle);
      v11 = v3->BoostBitmap.AllFields & 0x1FFFF;
      v12 = v3->BoostBitmap.AllFields & 0xFFFE0000;
      v3->ThreadLocalFlags &= ~1u;
      LODWORD(a3) = v11;
      v3->BoostBitmap.AllFields = v12;
      v3->LockState.$E8276A2CF8B819ED32D1B6FEB35D730A::_bf_0 = 0i64;
LABEL_6:
      if( (unsigned __int64)Lock >= 0xFFFF800000000000ui64
        && *((_BYTE *)&stru_140C4DB30 + (((unsigned __int64)Lock >> 39) & 0x1FF) + 6872) == 1 )
      {
        SessionId = MmGetSessionIdEx(CurrentThread->Tcb.ApcState.Process);
      }
      else
      {
        SessionId = -1;
      }
      v3->LockState.SessionId = SessionId;
      v3->LockState.$E8276A2CF8B819ED32D1B6FEB35D730A::_bf_0 = (unsigned __int64)Lock & 0x7FFFFFFFFFFFFFFCi64;
      goto LABEL_10;
    }
    LOBYTE(AbOrphanedEntrySummary) = CurrentThread->Tcb.AbEntrySummary;
    if( !(_BYTE)AbOrphanedEntrySummary )
    {
      if( !CurrentThread->Tcb.AbOrphanedEntrySummary )
      {
        v3 = 0i64;
LABEL_5:
        if( !v3 )
        {
          _interlockedbittestandset((volatile signed __int32 *)&CurrentThread->Tcb.116 + 1, 0x10u);
          goto LABEL_10;
        }
        goto LABEL_6;
      }
      AbOrphanedEntrySummary = CurrentThread->Tcb.AbOrphanedEntrySummary;
      CurrentThread->Tcb.AbOrphanedEntrySummary = 0;
      LOBYTE(AbOrphanedEntrySummary) = CurrentThread->Tcb.AbEntrySummary | AbOrphanedEntrySummary;
    }
    v7 = AbOrphanedEntrySummary;
    _BitScanForward((unsigned int *)&AbOrphanedEntrySummary, (unsigned __int8)AbOrphanedEntrySummary);
    CurrentThread->Tcb.AbEntrySummary = v7 & ~(1 << AbOrphanedEntrySummary);
    v3 = &CurrentThread->Tcb.LockEntries[AbOrphanedEntrySummary];
    goto LABEL_5;
  }
  if( (Flags & 1) == 0 )
    KeBugCheckEx(0x192u, CurrentThread, Lock, (PVOID)KeGetCurrentIrql(), 0i64);
  _interlockedbittestandset((volatile signed __int32 *)&CurrentThread->Tcb.116 + 1, 0x10u);
  v3 = 0i64;
LABEL_10:
  --CurrentThread->Tcb.AbAllocationRegionCount;
  KiAbThreadRemoveBoosts(&CurrentThread->Tcb, Lock, &a3);
  v9 = CurrentThread->Tcb.SpecialApcDisable++ == -1;
  if( v9
    && ($F25F8C4BA33AF922A5F1AF68CD89DDDF *)CurrentThread->Tcb.ApcState.ApcListHead[0].Flink != &CurrentThread->Tcb.152 )
  {
    KiCheckForKernelApcDelivery();
  }
  return v3;
}

Referenced by:

AlpcpTryLockForCachedReferenceBlob
BuildQueryDirectoryIrp
CmpAcquireWriteQueue
CmpCreateKeyControlBlock
CmpDereferenceKeyControlBlock
CmpPerformSingleKcbCacheLookup
CmpTryToLockHashEntryExclusive
CmpTryToLockKcbExclusive
CmpWaitOnHiveWriteQueue
ExAcquireCacheAwarePushLockExclusive
ExAcquireCacheAwarePushLockExclusiveEx
ExAcquireFastResourceExclusive
ExAcquireFastResourceShared
ExAcquireFastResourceSharedStarveExclusive
ExEnterCriticalRegionAndAcquireFastMutexUnsafe
ExRegisterExtension
ExRegisterHost
ExTryAcquireAutoExpandPushLockExclusive
ExTryAcquireAutoExpandPushLockShared
ExTryAcquireCacheAwarePushLockExclusiveEx
ExTryAcquireCacheAwarePushLockSharedEx
ExTryToAcquireFastMutex
ExUnregisterExtension
ExUuidCreate
ExfAcquirePushLockExclusiveEx
ExfAcquirePushLockSharedEx
ExfAcquireReleasePushLockExclusive
ExpAcquireFastMutexContended
ExpKdPullRemoteFileForUser
ExpNtUpdateWnfStateData
ExpWnfAcquireSubscriptionByName
ExpWnfAcquireSubscriptionNameInstance
ExpWnfAllocateNextPersistentNameSequence
ExpWnfCompleteThreadSubscriptions
ExpWnfCreateNameInstance
ExpWnfCreateProcessContext
ExpWnfDeleteNameInstance
ExpWnfDeleteProcessContext
ExpWnfDeleteScopeById
ExpWnfDeleteScopeInstances
ExpWnfDeleteStateData
ExpWnfDeleteSubscription
ExpWnfDeliverThreadNotifications
ExpWnfDispatchKernelSubscription
ExpWnfEnumerateScopeInstances
ExpWnfLookupNameInstance
ExpWnfNotifyNameSubscribers
ExpWnfNotifySubscription
ExpWnfReadStateData
ExpWnfResolveScopeInstance
ExpWnfSubscribeNameInstance
ExpWnfUpdateSubscription
ExpWnfWriteStateData
FsRtlAcquireHeaderMutex
IoSetInformation
IopCloseFile
IopGetSetSecurityObject
IopQueryXxxInformation
IopSetEaOrQuotaInformationFile
IopWaitAndAcquireFileObjectLock
IopXxxControlFile
KeAcquireGuardedMutex
KeWaitForMultipleObjects
KeWaitForSingleObject
KiInitializeMutant
KiSatisfyThreadWait
KiWaitForAllObjects
KiWaitSatisfyAny
MiChangingSubsectionProtos
MiCoalesceFreePages
MiDeleteExtentPfns
MiInitializeInPageSupport
MiLockControlAreaSectionExtend
MiRebuildLargePages
MiReferenceControlArea
MiWaitForCollidedFaultComplete
MiWaitForExtentDeletions
NtAllocateUuids
NtFlushBuffersFileEx
NtLockFile
NtNotifyChangeDirectoryFileEx
NtQueryEaFile
NtQueryInformationFile
NtQueryQuotaInformationFile
NtQueryVolumeInformationFile
NtReadFile
NtReadFileScatter
NtReleaseKeyedEvent
NtSetEaFile
NtSetInformationFile
NtSetUuidSeed
NtSetVolumeInformationFile
NtUnlockFile
NtWaitForKeyedEvent
NtWriteFile
NtWriteFileGather
PdcAcquireRwLockExclusive
PfpPrefetchSharedConflictNotifyEnd
PfpPrefetchSharedConflictNotifyStart
TlgAggregateInternalProviderCallback
TlgRegisterAggregateProviderEx
TryLockShutdownShared
VrpBecomeDiffHiveEntryTransitionOwner
VrpWaitForDiffHiveEntryTransitionOwnerToLeave
WbAddHeapExecutedBlockToCache
WbAddHeapExecutedBlockToLRU
WbAddWarbirdEncryptionSegment
WbAllocateSlots
WbAllocateUserMemory
WbDecryptEncryptionSegment
WbFreeMemoryBlockRegion
WbGetHeapExecutedBlock
WbGetInitializedEncryptionSegment
WbGetWarbirdEncryptionSegment
WbGetWarbirdProcess
WbGetWarbirdThread
WbHeapExecutionUnloadModule
WbInPlaceEncryptionUnloadModule
WbMoveHeapExecutedBlockToBackOfLRU
WbReEncryptEncryptionSegment
WbReleaseLeastRecentlyUsedHeapExecutedBlocks
WbRemoveWarbirdProcess
WheaConfigureErrorSource
WheaRegisterInUsePageOfflineNotification
WheaUnconfigureErrorSource
WheaUnregisterInUsePageOfflineNotification
WheapCallInUsePageNotificationCallbacks
WheapPfaReset
WheapPredictiveFailureAnalysis
sub_14065DA88