KiUpdateVpBackingThreadPriorityFromTopLevel

NTSTATUS __stdcall KiUpdateVpBackingThreadPriorityFromTopLevel(PVOID BugCheckParameter1){
  _SINGLE_LIST_ENTRY *v1; 
  _SINGLE_LIST_ENTRY *v2; 
  volatile signed __int32 *v4; 
  int v5; 
  unsigned int v6; 
  int v7; 
  char v8; 
  char v9; 
  char v10; 
  char v11; 
  unsigned __int8 v12; 
  char v13; 
  v2 = v1;
  if( (*((_DWORD *)BugCheckParameter1 + 30) & 0x400000) != 0 )
    _InterlockedOr(*((volatile signed __int32 **)BugCheckParameter1 + 121), 0x100000u);
  LODWORD(v4) = KiReadGuestSchedulerAssistPriority((INT64)BugCheckParameter1);
  v5 = (int)v4;
  v6 = 32;
  if( (int)v4 >= 16 )
  {
    v6 = (unsigned int)v4;
    v5 = 15;
  }
  v7 = *((_DWORD *)BugCheckParameter1 + 256);
  if( v5 != v7 )
  {
    v8 = *((_BYTE *)BugCheckParameter1 + (char)v5 + 824);
    if( v8 == -1 )
      KeBugCheckEx(0x157u, (ULONG_PTR)BugCheckParameter1, (char)v5, 1ui64, 0i64);
    *((_BYTE *)BugCheckParameter1 + (char)v5 + 824) = v8 + 1;
    LODWORD(v4) = *((_DWORD *)BugCheckParameter1 + 214) | (1 << v5);
    *((_DWORD *)BugCheckParameter1 + 214) = (_DWORD)v4;
    if( *((char *)BugCheckParameter1 + 195) < (char)v5 )
      LOBYTE(v4) = KiSetPriorityThread((_KTHREAD *)BugCheckParameter1, v2, (unsigned int)(char)v5);
    if( v7 != 32 )
    {
      LODWORD(v4) = (char)v7;
      v9 = *((_BYTE *)BugCheckParameter1 + (char)v7 + 824);
      if( !v9 )
        KeBugCheckEx(0x157u, (ULONG_PTR)BugCheckParameter1, (char)v7, 2ui64, 0i64);
      v10 = v9 - 1;
      *((_BYTE *)BugCheckParameter1 + (char)v7 + 824) = v10;
      if( !v10 )
      {
        LODWORD(v4) = *((_DWORD *)BugCheckParameter1 + 214) ^ (1 << v7);
        *((_DWORD *)BugCheckParameter1 + 214) = (_DWORD)v4;
        if( (unsigned int)v4 < 1 << v7 )
        {
          v11 = *((_BYTE *)BugCheckParameter1 + 195);
          if( v11 < 16 )
          {
            v12 = *((_BYTE *)BugCheckParameter1 + 564);
            LOBYTE(v4) = v12 & 0xF;
            v13 = *((_BYTE *)BugCheckParameter1 + 563) + (v12 & 0xF) + (v12 >> 4);
            if( v13 < v11 )
              LOBYTE(v4) = KiSetPriorityThread((_KTHREAD *)BugCheckParameter1, v2, (unsigned int)v13);
          }
        }
      }
    }
    *((_DWORD *)BugCheckParameter1 + 256) = v5;
  }
  if( v6 != 32 )
  {
    LODWORD(v4) = *((char *)BugCheckParameter1 + 195);
    if( v6 != (_DWORD)v4 )
    {
      KiSetBasePriorityAndClearDecrement((_KTHREAD *)BugCheckParameter1, 0i64, 0i64);
      LOBYTE(v4) = KiSetPriorityThread((_KTHREAD *)BugCheckParameter1, v2, v6);
    }
  }
  if( (*((_DWORD *)BugCheckParameter1 + 30) & 0x400000) != 0 )
  {
    v4 = (volatile signed __int32 *)*((_QWORD *)BugCheckParameter1 + 121);
    _InterlockedAnd(v4, 0xFFEFFFFF);
  }
  return(int)v4;
}

Referenced by:

KeSetThreadSchedulerAssist
KiUpdateVpBackingThreadPriorityDpcRoutine