CmDeleteInstallerClassWorker

__int64 __fastcall CmDeleteInstallerClassWorker(__int64 a1, const WCHAR *a2, __int16 a3){
  int v3; 
  unsigned int MatchingFilteredDeviceList; 
  int *v7; 
  unsigned int v8; 
  int v9; 
  int v10; 
  void *PoolWithTag; 
  int InstallerClassMappedPropertyKeys; 
  unsigned int v13; 
  unsigned __int64 v14; 
  __int64 v15; 
  int v16; 
  unsigned int v18; 
  int v19; 
  int v20[4]; 
  v3 = 0;
  v19 = 0;
  if( a3 )
    return(unsigned int)-1073741811;
  MatchingFilteredDeviceList = CmGetMatchingFilteredDeviceList(a1, (__int64)a2, 128, 0i64, 0i64, 0i64, 0, (__int64)&v19);
  if( MatchingFilteredDeviceList == -1073741789 )
    return(unsigned int)-1073741535;
  if( MatchingFilteredDeviceList )
    return MatchingFilteredDeviceList;
  v20[0] = 800;
  v7 = v20;
  v20[1] = 544;
  v8 = 0;
  v20[2] = 288;
  while( 1 )
  {
    v9 = *v7;
    if( !*v7 || (v9 & 0xFFFFFCDF) != 0 )
      v10 = -1073741811;
    else
      v10 = CmDeleteCommonClassRegKey(a1, a2, v9);
    if( v10 && v10 != -1073741772 && v10 != -1073741811 && v10 != -1073741637 )
      break;
    ++v8;
    ++v7;
    if( v8 >= 3 )
      goto LABEL_19;
  }
  v3 = v10;
  if( v10 < 0 )
    return(unsigned int)v3;
LABEL_19:
  PoolWithTag = 0i64;
  v18 = 0;
  InstallerClassMappedPropertyKeys = CmGetInstallerClassMappedPropertyKeys(a1, a2, 0i64, 1, 0i64, 0, &v18);
  if( InstallerClassMappedPropertyKeys == -1073741789 )
  {
    while( 1 )
    {
      v13 = v18;
      v14 = 20i64 * v18;
      if( v14 > 0xFFFFFFFF )
        break;
      if( PoolWithTag )
        ExFreePoolWithTag(PoolWithTag, 0);
      PoolWithTag = ExAllocatePoolWithTag(PagedPool, (unsigned int)v14, 0x52504E50ui64);
      if( !PoolWithTag )
      {
        InstallerClassMappedPropertyKeys = -1073741801;
        goto LABEL_26;
      }
      InstallerClassMappedPropertyKeys = CmGetInstallerClassMappedPropertyKeys(
                                           a1,
                                           a2,
                                           0i64,
                                           1,
                                           (__int64)PoolWithTag,
                                           v13,
                                           &v18);
      if( InstallerClassMappedPropertyKeys != -1073741789 )
        goto LABEL_25;
    }
    InstallerClassMappedPropertyKeys = -1073741811;
LABEL_28:
    v3 = InstallerClassMappedPropertyKeys;
    goto LABEL_45;
  }
LABEL_25:
  v13 = v18;
LABEL_26:
  if( InstallerClassMappedPropertyKeys && InstallerClassMappedPropertyKeys != -1073741275 )
    goto LABEL_28;
  v15 = 0i64;
  if( v13 )
  {
    while( 1 )
    {
      v16 = CmSetInstallerClassMappedProperty(a1, a2, 0i64, 0i64, (__int64)PoolWithTag + 20 * v15, 0, 0i64, 0);
      if( v16 )
      {
        if( v16 != -1073741275 && v16 != -1073741790 && v16 != -1073741802 && v16 != -1073741637 )
          break;
      }
      v15 = (unsigned int)(v15 + 1);
      if( (unsigned int)v15 >= v13 )
        goto LABEL_40;
    }
    v3 = v16;
  }
LABEL_40:
  if( v3 < 0 )
    goto LABEL_45;
  InstallerClassMappedPropertyKeys = CmDeleteCommonClassRegKey(a1, a2, 32);
  if( InstallerClassMappedPropertyKeys )
  {
    if( InstallerClassMappedPropertyKeys != -1073741772 && InstallerClassMappedPropertyKeys != -1073741811 )
      goto LABEL_28;
  }
  CmRaiseDeleteEvent(a1, (__int64)a2, 2u);
LABEL_45:
  if( PoolWithTag )
    ExFreePoolWithTag(PoolWithTag, 0);
  return(unsigned int)v3;
}

Referenced by:

CmDeleteInstallerClass