KiAbCleanupThreadState

NTSTATUS __stdcall KiAbCleanupThreadState(PVOID BugCheckParameter1){
  PVOID v1; 
  __int64 v2; 
  void *BugCheckParameter4; 
  int v4; 
  __int64 i; 
  __int64 v6; 

  LODWORD(v1) = *((_DWORD *)BugCheckParameter1 + 29);
  v2 = 1i64;
  if( ((unsigned __int8)v1 & 1) != 0 )
  {
    BugCheckParameter4 = 0i64;
    v4 = 0;
    for( i = 0i64; ; i += 96i64 )
    {
      v6 = i + *((_QWORD *)BugCheckParameter1 + 100);
      if( *(_QWORD *)(v6 + 32) )
        break;
      if( *(_DWORD *)(v6 + 24) >= 0x100u )
      {
        v2 = 2i64;
        goto LABEL_13;
      }
      v1 = (PVOID)(v6 - 16i64 * *(unsigned __int8 *)(v6 + 24));
      if( BugCheckParameter1 != v1 )
      {
        v2 = 3i64;
        goto LABEL_13;
      }
      if( (*(_DWORD *)(v6 + 88) & 0x1FFFF) != 0 )
      {
        v2 = 4i64;
        goto LABEL_13;
      }
      if( (unsigned int)++v4 >= 6 )
        return(int)v1;
    }
    BugCheckParameter4 = (void *)(*(_QWORD *)(v6 + 32) & 0x7FFFFFFFFFFFFFFCi64 | 0x8000000000000000ui64);
LABEL_13:
    KeBugCheckEx(0x153u, BugCheckParameter1, (PVOID)v6, (PVOID)v2, BugCheckParameter4);
  }
  return(int)v1;
}

Referenced by:

KeCleanupThreadState