PiControlQueryAndRemoveDevice

__int64 __fastcall PiControlQueryAndRemoveDevice(__int64 a1, __int16 *a2, INT64 a3, INT8 a4){
  __int16 v4; 
  int v7; 
  VOID *v8; 
  UINT64 v9; 
  int UserModeCallersCopy; 
  NTSTATUS v11; 
  UINT64 AllocateDestination; 
  UINT64 AllocateDestinationa; 
  VOID *Dest; 
  VOID *Destination[2]; 
  unsigned int v17; 

  v4 = *a2;
  *(_OWORD *)Destination = 0i64;
  WORD1(Destination[0]) = v4;
  LOWORD(Destination[0]) = v4;
  if( (unsigned __int16)(v4 - 1) > 0x18Fu || (v4 & 1) != 0 )
    return 3221225485i64;
  Dest = 0i64;
  Destination[1] = 0i64;
  v7 = *((_DWORD *)a2 + 8);
  v8 = (VOID *)*((_QWORD *)a2 + 3);
  if( v7 && v8 )
  {
    v9 = (unsigned int)(2 * v7);
  }
  else
  {
    *((_DWORD *)a2 + 8) = 0;
    v9 = 0i64;
  }
  v17 = v9;
  UserModeCallersCopy = PiControlAllocateBufferForUserModeCaller(&Dest, v9, a4, v8);
  if( UserModeCallersCopy >= 0 )
  {
    LODWORD(AllocateDestination) = 1;
    UserModeCallersCopy = PiControlMakeUserModeCallersCopy(
                            &Destination[1],
                            *((VOID **)a2 + 1),
                            LOWORD(Destination[0]),
                            2ui64,
                            a4,
                            AllocateDestination);
    if( UserModeCallersCopy >= 0 )
    {
      UserModeCallersCopy = PnpQueueQueryAndRemoveEvent(
                              (unsigned __int16 *)Destination,
                              (char *)a2 + 20,
                              Dest,
                              &v17,
                              *((_DWORD *)a2 + 4),
                              0);
      if( Dest )
      {
        LODWORD(AllocateDestinationa) = 0;
        v11 = PiControlMakeUserModeCallersCopy(
                (VOID **)a2 + 3,
                Dest,
                (unsigned int)(2 * *((_DWORD *)a2 + 8)),
                2ui64,
                a4,
                AllocateDestinationa);
        if( v11 < 0 )
          UserModeCallersCopy = v11;
      }
      *((_DWORD *)a2 + 8) = v17 >> 1;
    }
  }
  PiControlFreeUserModeCallersBuffer(a4, Destination[1]);
  PiControlFreeUserModeCallersBuffer(a4, Dest);
  return(unsigned int)UserModeCallersCopy;
}

Referenced by:

No references.