KeGetCurrentUmsTeb

unsigned __int64 __fastcall KeGetCurrentUmsTeb(__int64 a1){
  _ETHREAD *CurrentThread; 
  unsigned __int64 result; 
  CurrentThread = (_ETHREAD *)a1;
  if( !a1 )
    CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  if( *((char *)CurrentThread + 3) >= 0 )
    return *(_QWORD *)(a1 + 240);
  result = __readmsr(0xC0000102);
  if( result > 0x7FFFFFFF0000i64 )
    return 0i64;
  return result;
}

Referenced by:

PspDisassociateUmsThreadFromPrimary
PspGetSetContextInternal