KiUpdateVPBackingThreadPriority

NTSTATUS __stdcall KiUpdateVPBackingThreadPriority(PVOID BugCheckParameter1){
  volatile signed __int32 *v1; 
  _KPRCB *v2; 
  char v3; 
  char v4; 
  _KPRCB *v5; 
  NTSTATUS GuestSchedulerAssistPriority; 
  int v8; 
  int v9; 
  int v10; 
  char v11; 
  char v12; 
  char v13; 
  UINT8 v14; 
  int v15; 

  v4 = v3;
  v5 = v2;
  if( (*((_DWORD *)BugCheckParameter1 + 30) & 0x400000) == 0 )
  {
    LOBYTE(v1) = 0;
    return(int)v1;
  }
  _InterlockedOr(*((volatile signed __int32 **)BugCheckParameter1 + 121), 0x100000u);
  GuestSchedulerAssistPriority = KiReadGuestSchedulerAssistPriority((INT64)BugCheckParameter1);
  v8 = GuestSchedulerAssistPriority;
  v9 = 32;
  if( GuestSchedulerAssistPriority >= 16 )
  {
    v9 = GuestSchedulerAssistPriority;
    v8 = 15;
  }
  v10 = *((_DWORD *)BugCheckParameter1 + 256);
  if( v8 != v10 )
  {
    v11 = *((_BYTE *)BugCheckParameter1 + (char)v8 + 824);
    if( v11 == -1 )
      KeBugCheckEx(0x157u, BugCheckParameter1, (PVOID)(char)v8, (PVOID)1, 0i64);
    *((_BYTE *)BugCheckParameter1 + (char)v8 + 824) = v11 + 1;
    *((_DWORD *)BugCheckParameter1 + 214) |= 1 << v8;
    if( v10 != 32 )
    {
      v12 = *((_BYTE *)BugCheckParameter1 + (char)v10 + 824);
      if( !v12 )
        KeBugCheckEx(0x157u, BugCheckParameter1, (PVOID)(char)v10, (PVOID)2, 0i64);
      v13 = v12 - 1;
      *((_BYTE *)BugCheckParameter1 + (char)v10 + 824) = v13;
      if( !v13 )
        *((_DWORD *)BugCheckParameter1 + 214) ^= 1 << v10;
    }
    *((_DWORD *)BugCheckParameter1 + 256) = v8;
  }
  v14 = v9;
  if( v9 == 32 )
    v14 = v8;
  v15 = KiComputePriorityFloor((_KTHREAD *)BugCheckParameter1, v14);
  if( v4 && (*((_BYTE *)BugCheckParameter1 + 564) & 0xF0) != 0 )
  {
    LODWORD(v1) = *((char *)BugCheckParameter1 + 195);
    if( v15 <= (int)v1 )
      goto LABEL_22;
    goto LABEL_21;
  }
  LODWORD(v1) = *((char *)BugCheckParameter1 + 195);
  if( v15 != (_DWORD)v1 )
  {
LABEL_21:
    KiSetBasePriorityAndClearDecrement((_KTHREAD *)BugCheckParameter1, 0i64, 0i64);
    KiUpdateThreadPriority(v5, (_KTHREAD *)BugCheckParameter1, (unsigned int)v15, v5 != 0i64);
  }
LABEL_22:
  if( (*((_DWORD *)BugCheckParameter1 + 30) & 0x400000) != 0 )
  {
    v1 = (volatile signed __int32 *)*((_QWORD *)BugCheckParameter1 + 121);
    _InterlockedAnd(v1, 0xFFEFFFFF);
  }
  LOBYTE(v1) = 1;
  return(int)v1;
}

Referenced by:

KeDelayExecutionThread
KeYieldExecution
KiDeferredReadySingleThread
KiQuantumEnd
KiQueueReadyThread
KiSwapThread
KiTryToUpdateVPBackingThreadPriority