DrvDbGetDeviceIdDriverInfMatches

__int64 __fastcall DrvDbGetDeviceIdDriverInfMatches(
        __int64 a1,
        void *a2,
        __int64 a3,
        unsigned int a4,
        unsigned int *a5,
        char a6){
  unsigned int *v6; 
  ULONG v7; 
  __int64 v8; 
  int v9; 
  unsigned int v10; 
  unsigned int v11; 
  unsigned int v12; 
  __int64 v13; 
  void *PoolWithTag; 
  int v15; 
  __int64 v16; 
  int v17; 
  __int64 v18; 
  int v19; 
  unsigned int v20; 
  unsigned int v21; 
  UINT64 dwFlags; 
  int v24; 
  int v25; 
  unsigned int v26; 
  unsigned int v27; 
  unsigned int v28; 
  int v29; 
  void *v30; 
  __int64 v31; 
  unsigned int v32; 
  v32 = a4;
  v31 = a3;
  v30 = a2;
  v29 = HIDWORD(a1);
  v6 = a5;
  v7 = 0;
  v8 = a3;
  v26 = 0;
  v28 = 0;
  v25 = 0;
  v24 = 0;
  v27 = 0;
  *a5 = 0;
  v9 = PnpCtxRegQueryInfoKey((__int64)&v26, a2, 0i64, 0i64, &v26, &v28, 0i64);
  if( v9 >= 0 )
  {
    v10 = v26;
    v11 = v28 + 1;
    if( v26 )
    {
      v12 = v28 + 1;
      if( a6 )
      {
        v12 = v28 + 17;
        v11 = v28 + 17;
      }
      PoolWithTag = ExAllocatePoolWithTag(PagedPool, 2i64 * v12, 0x42444450ui64);
      if( PoolWithTag )
      {
        if( v10 )
        {
          do
          {
            v28 = v11;
            if( a6 )
            {
              LODWORD(a5) = 4;
              v15 = PnpCtxRegEnumValue(v13, v30, v7, PoolWithTag, &v28, (__int64)&v25, &v24, (__int64)&a5);
              v9 = v15;
              if( v15 < 0 )
                goto LABEL_37;
              if( !v28 )
              {
LABEL_35:
                v9 = -1073741595;
                goto LABEL_26;
              }
              if( v25 == 3 )
              {
                if( (_DWORD)a5 != 4 )
                  goto LABEL_35;
              }
              else
              {
                v24 = 0;
              }
              DrvDbBuildDeviceIdDriverInfMatch(v16, (unsigned __int8 *)&v24, (wchar_t *)PoolWithTag + v28, v11 - v28);
              v9 = v17;
              if( v17 < 0 )
                goto LABEL_26;
              v18 = -1i64;
              do
                ++v18;
              while( *((_WORD *)PoolWithTag + v18) );
              v19 = v18 + 1;
            }
            else
            {
              v15 = PnpCtxRegEnumValue(v13, v30, v7, PoolWithTag, &v28, (__int64)&v25, 0i64, 0i64);
              v9 = v15;
              if( v15 < 0 )
              {
LABEL_37:
                if( v15 == -2147483622 )
                  v9 = 0;
                break;
              }
              v13 = v28;
              if( !v28 )
              {
                v9 = -1073741595;
                break;
              }
              *((_WORD *)PoolWithTag + v28) = 0;
              v19 = v13 + 1;
            }
            if( v8 )
            {
              v13 = v27;
              v20 = v19 + v27;
              if( v19 + v27 < v32 )
              {
                LODWORD(dwFlags) = 2304;
                RtlStringCchCopyExW((WCHAR *)(v31 + 2i64 * v27), v32 - v27, (WCHAR *)PoolWithTag, 0i64, 0i64, dwFlags);
                v27 = v20;
              }
              v8 = v31;
            }
            *v6 += v19;
            ++v7;
          }
          while( v7 < v26 );
        }
        if( v9 >= 0 )
        {
          if( *v6 )
          {
            v21 = *v6 + 1;
            *v6 = v21;
            if( v8 && v21 <= v32 )
              *(_WORD *)(v8 + 2i64 * (v21 - 1)) = 0;
            else
              v9 = -1073741789;
          }
          else
          {
            v9 = -1073741275;
          }
        }
LABEL_26:
        ExFreePoolWithTag(PoolWithTag, 0);
      }
      else
      {
        return(unsigned int)-1073741801;
      }
    }
    else
    {
      return(unsigned int)-1073741275;
    }
  }
  return(unsigned int)v9;
}

Referenced by:

DrvDbGetDeviceIdMappedProperty