KeClearSystemPriority

NTSTATUS __stdcall KeClearSystemPriority(PVOID BugCheckParameter1){
  unsigned __int8 CurrentIrql; 
  struct _KPRCB *CurrentPrcb; 
  __int64 v4; 
  char v5; 
  char v6; 
  unsigned int v7; 
  char v8; 
  char v9; 
  __int64 v11; 
  UINT64 SpinCount; 
  _SINGLE_LIST_ENTRY ReadyList; 
  ReadyList.Next = 0i64;
  CurrentIrql = KeGetCurrentIrql();
  __writecr8(2ui64);
  CurrentPrcb = KeGetCurrentPrcb();
  LODWORD(SpinCount) = 0;
  while( _interlockedbittestandset64((volatile signed __int32 *)BugCheckParameter1 + 16, 0i64) )
  {
    do
      KeYieldProcessorEx(&SpinCount);
    while( *((_QWORD *)BugCheckParameter1 + 8) );
    v11 = *((_QWORD *)CurrentPrcb + 4247);
    if( v11 && *((_BYTE *)CurrentPrcb + 32) <= 1u )
      ++*(_DWORD *)(v11 + 24);
  }
  v4 = *((char *)BugCheckParameter1 + 795);
  v5 = *((_BYTE *)BugCheckParameter1 + v4 + 824);
  if( !v5 )
    KeBugCheckEx(0x157u, (ULONG_PTR)BugCheckParameter1, *((char *)BugCheckParameter1 + 795), 2ui64, 0i64);
  v6 = v5 - 1;
  *((_BYTE *)BugCheckParameter1 + v4 + 824) = v6;
  if( !v6 )
  {
    v7 = *((_DWORD *)BugCheckParameter1 + 214) ^ (1 << v4);
    *((_DWORD *)BugCheckParameter1 + 214) = v7;
    if( v7 < 1 << v4 )
    {
      v8 = *((_BYTE *)BugCheckParameter1 + 195);
      if( v8 < 16 )
      {
        v9 = *((_BYTE *)BugCheckParameter1 + 563)
           + (*((_BYTE *)BugCheckParameter1 + 564) & 0xF)
           + (*((_BYTE *)BugCheckParameter1 + 564) >> 4);
        if( v9 < v8 )
          KiSetPriorityThread((_KTHREAD *)BugCheckParameter1, &ReadyList, (unsigned int)v9);
      }
    }
  }
  *((_BYTE *)BugCheckParameter1 + 795) = 0;
  *((_QWORD *)BugCheckParameter1 + 8) = 0i64;
  return KiProcessDeferredReadyList((__int64)KeGetCurrentPrcb(), &ReadyList, CurrentIrql);
}

Referenced by:

PspRevertContainerImpersonation