KiForceSymbolReferences

VOID __stdcall KiForceSymbolReferences(){
  _ETHREAD *CurrentThread; 
  __int64 v1; 
  __int64 v2; 
  __int64 AbOrphanedEntrySummary; 
  char v4; 
  NTSTATUS SessionId; 
  bool v6; 
  signed __int8 v7; 
  unsigned __int8 CurrentIrql; 
  UINT64 a3; 
  INT64 SpinLock; 
  __int64 Lock; 

  Lock = 0i64;
  if( KeGetPcr()->Prcb.Number )
    goto LABEL_22;
  LODWORD(a3) = 0;
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  --CurrentThread->Tcb.SpecialApcDisable;
  if( ++CurrentThread->Tcb.AbAllocationRegionCount != 1 )
  {
    v1 = 0i64;
    goto LABEL_4;
  }
  LOBYTE(v2) = CurrentThread->Tcb.AbEntrySummary;
  if( !(_BYTE)v2 )
  {
    if( !CurrentThread->Tcb.AbOrphanedEntrySummary )
    {
      v1 = 0i64;
      goto LABEL_4;
    }
    AbOrphanedEntrySummary = CurrentThread->Tcb.AbOrphanedEntrySummary;
    CurrentThread->Tcb.AbOrphanedEntrySummary = 0;
    LOBYTE(v2) = AbOrphanedEntrySummary | CurrentThread->Tcb.AbEntrySummary;
  }
  v4 = v2;
  _BitScanForward((unsigned int *)&v2, (unsigned __int8)v2);
  CurrentThread->Tcb.AbEntrySummary = v4 & ~(1 << v2);
  v1 = (__int64)&CurrentThread->Tcb.LockEntries[v2];
  if( !v1 )
  {
LABEL_4:
    _interlockedbittestandset((volatile signed __int32 *)&CurrentThread->Tcb.116 + 1, 0x10u);
    goto LABEL_15;
  }
  if( (unsigned __int64)&Lock >= 0xFFFF800000000000ui64
    && *((_BYTE *)&stru_140C4DB30 + (((unsigned __int64)&Lock >> 39) & 0x1FF) + 6872) == 1 )
  {
    SessionId = MmGetSessionIdEx(CurrentThread->Tcb.ApcState.Process);
  }
  else
  {
    SessionId = -1;
  }
  *(_DWORD *)(v1 + 40) = SessionId;
  *(_QWORD *)(v1 + 32) = &Lock;
LABEL_15:
  --CurrentThread->Tcb.AbAllocationRegionCount;
  KiAbThreadRemoveBoosts(&CurrentThread->Tcb, &Lock, &a3);
  v6 = CurrentThread->Tcb.SpecialApcDisable++ == -1;
  if( v6
    && ($F25F8C4BA33AF922A5F1AF68CD89DDDF *)CurrentThread->Tcb.ApcState.ApcListHead[0].Flink != &CurrentThread->Tcb.152 )
  {
    KiCheckForKernelApcDelivery();
  }
  v7 = _interlockedbittestandset64((volatile signed __int32 *)&Lock, 0i64);
  if( v1 )
  {
    if( v7 )
      KeAbPostReleaseEx(&Lock, (VOID *)v1);
    else
      *(_BYTE *)(v1 + 26) |= 1u;
  }
LABEL_22:
  CurrentIrql = KeGetCurrentIrql();
  __writecr8(2ui64);
  ExTryAcquireSpinLockExclusiveAtDpcLevel(&SpinLock);
  __writecr8(CurrentIrql);
}

Referenced by:

KiInitSystem