CmGetInstallerClassCompoundFiltersWorker

__int64 __fastcall CmGetInstallerClassCompoundFiltersWorker(
        __int64 a1,
        __int64 a2,
        __int64 a3,
        void *a4,
        __int64 a5,
        __int64 a6,
        __int64 a7,
        __int64 a8,
        int a9,
        __int64 a10){
  wchar_t *v10; 
  __int64 v14; 
  __int64 *v15; 
  __int64 *v16; 
  wchar_t *PoolWithTag; 
  int ObjectProperty; 
  __int64 v19; 
  int InstallerClassMappedPropertyFromRegProp; 
  int v21; 
  __int64 v22; 
  void *v23; 
  __int64 v25; 
  SIZE_T NumberOfBytes; 
  int v27[2]; 
  PVOID P; 
  PVOID v29; 
  __int64 *v30; 
  PVOID v31; 
  __int64 v32; 
  v10 = 0i64;
  v27[0] = 0;
  P = 0i64;
  NumberOfBytes = 0i64;
  v31 = 0i64;
  v29 = 0i64;
  if( (int)PnpCtxRegQueryInfoKey(a1, a4, v27, 0i64, 0i64, 0i64, 0i64) < 0 || !v27[0] )
    goto LABEL_44;
  if( *(_DWORD *)(a5 + 16) != 20 )
    goto LABEL_8;
  v14 = *(_QWORD *)a5 - DEVPKEY_DeviceClass_CompoundUpperFilters;
  if( *(_QWORD *)a5 == DEVPKEY_DeviceClass_CompoundUpperFilters )
    v14 = *(_QWORD *)(a5 + 8) - 0x4B88D2ECD9DBB9A9i64;
  if( v14 )
  {
LABEL_8:
    v32 = (__int64)DEVPKEY_DeviceClass_LowerFilterLevels;
    v15 = DEVPKEY_DeviceClass_LowerFilterCache;
    *(_QWORD *)v27 = L"*Lower";
    v16 = DEVPKEY_DeviceClass_LowerFilterDefaultLevel;
  }
  else
  {
    v32 = (__int64)DEVPKEY_DeviceClass_UpperFilterLevels;
    v15 = DEVPKEY_DeviceClass_UpperFilterCache;
    *(_QWORD *)v27 = L"*Upper";
    v16 = DEVPKEY_DeviceClass_UpperFilterDefaultLevel;
  }
  v30 = v15;
  if( (unsigned int)PnpGetObjectProperty(
                       a1,
                       a2,
                       2i64,
                       a3,
                       0i64,
                       (__int64)v15,
                       (int *)&NumberOfBytes + 1,
                       0i64,
                       0,
                       (ULONG *)&NumberOfBytes,
                       0) == -1073741789
    && HIDWORD(NumberOfBytes) == 8210 )
  {
    PoolWithTag = (wchar_t *)ExAllocatePoolWithTag(PagedPool, (unsigned int)NumberOfBytes, 0x52504E50ui64);
    v10 = PoolWithTag;
    if( !PoolWithTag )
      return(unsigned int)-1073741801;
    ObjectProperty = PnpGetObjectProperty(
                       a1,
                       a2,
                       2i64,
                       a3,
                       0i64,
                       (__int64)v30,
                       (int *)&NumberOfBytes + 1,
                       (unsigned __int64)PoolWithTag,
                       NumberOfBytes,
                       (ULONG *)&NumberOfBytes,
                       0);
    if( ObjectProperty < 0 )
      goto LABEL_47;
    v19 = a2;
    goto LABEL_15;
  }
  v21 = PnpGetObjectProperty(
          a1,
          a2,
          2i64,
          a3,
          0i64,
          (__int64)v16,
          (int *)&NumberOfBytes + 1,
          0i64,
          0,
          (ULONG *)&NumberOfBytes,
          0);
  ObjectProperty = v21;
  if( v21 == -1073741789 && HIDWORD(NumberOfBytes) == 18 )
  {
    P = ExAllocatePoolWithTag(PagedPool, (unsigned int)NumberOfBytes, 0x52504E50ui64);
    if( !P )
      return(unsigned int)-1073741801;
    v25 = (__int64)v16;
    v19 = a2;
    ObjectProperty = PnpGetObjectProperty(
                       a1,
                       a2,
                       2i64,
                       a3,
                       0i64,
                       v25,
                       (int *)&NumberOfBytes + 1,
                       (unsigned __int64)P,
                       NumberOfBytes,
                       (ULONG *)&NumberOfBytes,
                       0);
    if( ObjectProperty < 0 )
      goto LABEL_45;
    v22 = v32;
    if( (unsigned int)PnpGetObjectProperty(
                         a1,
                         a2,
                         2i64,
                         a3,
                         0i64,
                         v32,
                         (int *)&NumberOfBytes + 1,
                         0i64,
                         0,
                         (ULONG *)&NumberOfBytes,
                         0) == -1073741789 )
    {
      v23 = ExAllocatePoolWithTag(PagedPool, (unsigned int)NumberOfBytes, 0x52504E50ui64);
      v29 = v23;
      if( !v23 )
        goto LABEL_23;
      ObjectProperty = PnpGetObjectProperty(
                         a1,
                         a2,
                         2i64,
                         a3,
                         0i64,
                         v22,
                         (int *)&NumberOfBytes + 1,
                         (unsigned __int64)v23,
                         NumberOfBytes,
                         (ULONG *)&NumberOfBytes,
                         0);
      if( ObjectProperty < 0 )
        goto LABEL_45;
      ObjectProperty = CmGetDeclarativeFilterList(
                         a1,
                         (char *)a4,
                         (wchar_t *)v29,
                         (wchar_t *)P,
                         *(const wchar_t **)v27,
                         0i64,
                         0,
                         (__int64)&NumberOfBytes);
      if( !ObjectProperty )
        ObjectProperty = -1073741762;
      if( ObjectProperty != -1073741789 )
        goto LABEL_45;
      v10 = (wchar_t *)ExAllocatePoolWithTag(PagedPool, (unsigned int)NumberOfBytes, 0x52504E50ui64);
      if( !v10 )
        goto LABEL_23;
      ObjectProperty = CmGetDeclarativeFilterList(
                         a1,
                         (char *)a4,
                         (wchar_t *)v29,
                         (wchar_t *)P,
                         *(const wchar_t **)v27,
                         (__int64)v10,
                         NumberOfBytes,
                         (__int64)&NumberOfBytes);
      if( ObjectProperty < 0 )
        goto LABEL_45;
      PnpSetObjectProperty(a1, a2, 2u, a3, 0i64, (__int64)v30, 8210, (__int64)v10, NumberOfBytes, 0);
LABEL_15:
      InstallerClassMappedPropertyFromRegProp = CmGetInstallerClassMappedPropertyFromRegProp(
                                                  a1,
                                                  v19,
                                                  a3,
                                                  a6,
                                                  (_DWORD *)&NumberOfBytes + 1,
                                                  0i64,
                                                  0,
                                                  (unsigned int *)&NumberOfBytes);
      if( InstallerClassMappedPropertyFromRegProp == -1073741275 )
      {
        LODWORD(NumberOfBytes) = 0;
        goto LABEL_37;
      }
      if( InstallerClassMappedPropertyFromRegProp != -1073741789 )
      {
        ObjectProperty = InstallerClassMappedPropertyFromRegProp;
        goto LABEL_45;
      }
      if( !(_DWORD)NumberOfBytes || !a9 )
      {
LABEL_37:
        ObjectProperty = CmMergeFilterLists(v10, (wchar_t *)v31, *(wchar_t **)v27, (wchar_t *)a8, a9, a10);
        if( (int)(ObjectProperty + 0x80000000) < 0 || ObjectProperty == -1073741789 )
          *(_DWORD *)a7 = 8210;
        goto LABEL_45;
      }
      v31 = ExAllocatePoolWithTag(PagedPool, (unsigned int)NumberOfBytes, 0x52504E50ui64);
      if( v31 )
      {
        ObjectProperty = CmGetInstallerClassMappedPropertyFromRegProp(
                           a1,
                           v19,
                           a3,
                           a6,
                           (_DWORD *)&NumberOfBytes + 1,
                           (wchar_t *)v31,
                           NumberOfBytes,
                           (unsigned int *)&NumberOfBytes);
        if( ObjectProperty >= 0 )
          goto LABEL_37;
LABEL_45:
        if( P )
          ExFreePoolWithTag(P, 0);
LABEL_47:
        if( v10 )
          ExFreePoolWithTag(v10, 0);
        if( v31 )
          ExFreePoolWithTag(v31, 0);
        if( v29 )
          ExFreePoolWithTag(v29, 0);
        return(unsigned int)ObjectProperty;
      }
LABEL_23:
      ObjectProperty = -1073741801;
      goto LABEL_45;
    }
LABEL_44:
    ObjectProperty = -1073741275;
    goto LABEL_45;
  }
  if( HIDWORD(NumberOfBytes) != 8210 || v21 == -1073739509 || !v21 )
    return(unsigned int)-1073741275;
  return(unsigned int)ObjectProperty;
}

Referenced by:

CmGetInstallerClassCompoundFilters