PiPnpRtlIsDeviceValidForSession

INT64 __fastcall PiPnpRtlIsDeviceValidForSession(INT64 a1, INT64 a2, INT64 a3, INT64 a4, BYTE *a5){
  BYTE *v5; 
  void *v9; 
  NTSTATUS v10; 
  int ObjectProperty; 
  int v13; 
  UINT64 SessionId; 
  ULONG v15; 
  unsigned __int8 IsServiceSession; 
  v5 = a5;
  SessionId = 0i64;
  v15 = 0;
  v13 = 0;
  *a5 = 0;
  v9 = *(void **)a4;
  IsServiceSession = 0;
  if( !v9 )
    v9 = *(void **)(a4 + 16);
  v10 = SeQuerySessionIdTokenEx(v9, &SessionId, &IsServiceSession);
  if( v10 >= 0 )
  {
    if( IsServiceSession )
    {
LABEL_7:
      *v5 = 1;
      return(unsigned int)v10;
    }
    ObjectProperty = PnpGetObjectProperty(
                       a1,
                       a2,
                       1i64,
                       a3,
                       0i64,
                       (__int64)&DEVPKEY_Device_SessionId,
                       &v13,
                       (unsigned __int64)&SessionId + 4,
                       4,
                       &v15,
                       0);
    v10 = ObjectProperty;
    if( ObjectProperty == -1073741275 )
    {
      v10 = 0;
      goto LABEL_7;
    }
    if( ObjectProperty >= 0 && (v13 != 7 || HIDWORD(SessionId) == (_DWORD)SessionId) )
      goto LABEL_7;
  }
  return(unsigned int)v10;
}

Referenced by:

PiPnpRtlApplyMandatoryDeviceFilters