PnpCallDriverQueryServiceHelper

INT64 __fastcall PnpCallDriverQueryServiceHelper(
        VOID **a1,
        ULONG *a2,
        INT64 a3,
        INT64 a4,
        WCHAR *a5,
        INT64 a6,
        CHAR a7,
        INT64 a8,
        CHAR a9,
        INT64 *a10){
  CHAR v10; 
  __int64 v11; 
  WCHAR *v12; 
  int v14; 
  int v15; 
  unsigned int v17; 
  VOID *v18; 
  int ObjectProperty; 
  int v20; 
  int v21; 
  unsigned int v23; 
  const WCHAR *v24; 
  char v25; 
  int v26; 
  __int64 v27; 
  unsigned int v28; 
  unsigned int v29; 
  UINT64 v30; 
  VOID *PoolWithTag; 
  int InstallerClassRegProp; 
  int v33; 
  int v34[3]; 
  UINT64 ulMinuend; 
  v10 = a7;
  v11 = a6;
  v12 = a5;
  v33 = 0;
  v14 = a3;
  v15 = *a2;
  LODWORD(ulMinuend) = *a2;
  v17 = 0;
  v18 = *a1;
  v34[0] = 0;
  if( a4 )
  {
    v17 = (a7 != 0) + 1;
    ObjectProperty = PnpGetObjectProperty(
                       PiPnpRtlCtx,
                       (__int64)a5,
                       v17,
                       a6,
                       0i64,
                       a4,
                       v34,
                       (unsigned __int64)v18,
                       v15,
                       (ULONG *)&ulMinuend,
                       0);
  }
  else if( a7 )
  {
    ObjectProperty = CmGetInstallerClassRegProp(
                       PiPnpRtlCtx,
                       (__int64)a5,
                       a6,
                       v14,
                       (__int64)&v33,
                       (__int64)v18,
                       (__int64)&ulMinuend);
  }
  else
  {
    ObjectProperty = CmGetDeviceRegProp(PiPnpRtlCtx, a5, a6, v14, (__int64)&v33, (__int64)v18, (__int64)&ulMinuend, 0);
  }
  v20 = ObjectProperty;
  if( ObjectProperty == -1073741789 )
  {
    ExFreePoolWithTag(*a1, 0);
    v30 = (unsigned int)ulMinuend;
    *a2 = ulMinuend;
    PoolWithTag = ExAllocatePoolWithTag(PagedPool, v30, 0x6E657050ui64);
    *a1 = PoolWithTag;
    if( !PoolWithTag )
      return(unsigned int)-1073741670;
    if( a4 )
    {
      v20 = PnpGetObjectProperty(
              PiPnpRtlCtx,
              (__int64)v12,
              v17,
              v11,
              0i64,
              a4,
              v34,
              (unsigned __int64)PoolWithTag,
              ulMinuend,
              (ULONG *)&ulMinuend,
              0);
    }
    else
    {
      if( v10 )
        InstallerClassRegProp = CmGetInstallerClassRegProp(
                                  PiPnpRtlCtx,
                                  (__int64)v12,
                                  v11,
                                  v14,
                                  (__int64)&v33,
                                  (__int64)PoolWithTag,
                                  (__int64)&ulMinuend);
      else
        InstallerClassRegProp = CmGetDeviceRegProp(
                                  PiPnpRtlCtx,
                                  v12,
                                  v11,
                                  v14,
                                  (__int64)&v33,
                                  (__int64)PoolWithTag,
                                  (__int64)&ulMinuend,
                                  0);
      v20 = InstallerClassRegProp;
    }
  }
  if( v20 >= 0 )
  {
    if( a4 )
    {
      if( v34[0] == 8210 )
      {
        v33 = 7;
LABEL_14:
        if( *a2 < 2 )
          return(unsigned int)-1073741823;
        v23 = ulMinuend;
        if( (unsigned int)ulMinuend < 2 )
        {
          return(unsigned int)-1073741823;
        }
        else
        {
          v24 = (const WCHAR *)*a1;
          if( *(_WORD *)*a1 )
          {
            v25 = a9;
            v26 = a8;
            while( 1 )
            {
              v27 = -1i64;
              do
                ++v27;
              while( v24[v27] );
              v28 = v27 + 1;
              if( RtlULongSub(v23, 2 * v28, &ulMinuend) < 0 )
                break;
              v20 = PipCallDriverAddDeviceQueryRoutine(1, v24, v29, a10, v26, v25);
              if( v20 >= 0 )
              {
                v23 = ulMinuend;
                if( (unsigned int)ulMinuend >= 2 )
                {
                  v24 += v28;
                  if( *v24 )
                    continue;
                }
              }
              return(unsigned int)v20;
            }
            return 0;
          }
        }
        return(unsigned int)v20;
      }
      if( v34[0] != 18 )
      {
        v21 = 0;
        v33 = 0;
        return(unsigned int)PipCallDriverAddDeviceQueryRoutine(v21, (const WCHAR *)*a1, ulMinuend, a10, a8, a9);
      }
      v21 = 1;
      v33 = 1;
    }
    else
    {
      v21 = v33;
    }
    if( v21 != 7 )
      return(unsigned int)PipCallDriverAddDeviceQueryRoutine(v21, (const WCHAR *)*a1, ulMinuend, a10, a8, a9);
    goto LABEL_14;
  }
  return(unsigned int)v20;
}

Referenced by:

PipCallDriverAddDevice