PsGetCurrentProcessSessionId

__int64 PsGetCurrentProcessSessionId(){
  __int64 v0; 
  __int64 v1; 
  unsigned int v2; 
  unsigned int v3; 
  v0 = *((_QWORD *)KeGetCurrentThread() + 23);
  v1 = *(_QWORD *)(v0 + 1368);
  if( !v1 || (*(_DWORD *)(v0 + 2172) & 0x1000) != 0 )
    v2 = -1;
  else
    v2 = *(_DWORD *)(v1 + 8);
  v3 = 0;
  if( v2 != -1 )
    return v2;
  return v3;
}

Referenced by:

EtwpWriteUserEvent
IopParseDevice
NtSetInformationObject
ObpLookupObjectName
PfpProcessScenarioPhase
PnpNotifyDriverCallback
PopCreatePowerRequestObject