RtlGetCurrentServiceSessionId

UINT64 __stdcall RtlGetCurrentServiceSessionId(){
  int v0; 
  __int64 v1; 
  INT64 *v2; 

  LOBYTE(v0) = KeIsExecutingInArbitraryThreadContext();
  if( v0 || (LODWORD(v1) = PsGetThreadServerSilo((INT64)KeGetCurrentThread()), !v1) )
    v2 = &PspHostSiloGlobals;
  else
    v2 = *(INT64 **)(v1 + 1272);
  return *(unsigned int *)v2[141];
}

Referenced by:

RtlpGetTokenNamedObjectPath
SepValidateReferencedCachedHandles