PiPnpRtlIsDeviceValidForSession

NTSTATUS __stdcall PiPnpRtlIsDeviceValidForSession(
        HPNPCTX *hPnpCtx,
        WCHAR *DeviceIntanceId,
        VOID *ObjectBaseKey,
        _SECURITY_SUBJECT_CONTEXT *SecuritySubjectContext,
        UINT8 *ObjectValidForSession){
  UINT8 *v5; 
  ULONG v6; 
  void *ClientToken; 
  int v10; 
  NTSTATUS ObjectProperty; 
  INT64 v13; 
  INT64 v14; 
  UINT8 IsServiceSession; 

  v5 = ObjectValidForSession;
  v6 = (unsigned int)hPnpCtx;
  v14 = 0i64;
  v13 = 0i64;
  *ObjectValidForSession = 0;
  ClientToken = SecuritySubjectContext->ClientToken;
  IsServiceSession = 0;
  if( !ClientToken )
    ClientToken = SecuritySubjectContext->PrimaryToken;
  v10 = SeQuerySessionIdTokenEx(ClientToken, (UINT64 *)((char *)&v13 + 4), &IsServiceSession);
  if( v10 >= 0 )
  {
    if( IsServiceSession )
    {
LABEL_7:
      *v5 = 1;
      return v10;
    }
    ObjectProperty = PnpGetObjectProperty(
                       v6,
                       (INT64)DeviceIntanceId,
                       1i64,
                       (INT64)ObjectBaseKey,
                       0i64,
                       (INT64)&DEVPKEY_Device_SessionId,
                       (INT64)&v13,
                       (INT64)&v14);
    v10 = ObjectProperty;
    if( ObjectProperty == -1073741275 )
    {
      v10 = 0;
      goto LABEL_7;
    }
    if( ObjectProperty >= 0 && ((_DWORD)v13 != 7 || (_DWORD)v14 == HIDWORD(v13)) )
      goto LABEL_7;
  }
  return v10;
}

Referenced by:

PiPnpRtlApplyMandatoryDeviceFilters