CmDeleteDevicePanelWorker

__int64 __fastcall CmDeleteDevicePanelWorker(__int64 a1, const wchar_t *a2, __int16 a3){
  int v3; 
  int *v6; 
  int v7; 
  int v8; 
  __int64 v9; 
  __int64 v10; 
  __int64 v11; 
  __int64 v12; 
  void *PoolWithTag; 
  unsigned int v14; 
  int DevicePanelMappedPropertyKeys; 
  unsigned int v16; 
  __int64 v17; 
  int v18; 
  unsigned int v20; 
  v3 = 0;
  if( a3 )
  {
    return(unsigned int)-1073741811;
  }
  else
  {
    v20 = 352;
    v6 = (int *)&v20;
    v7 = 0;
    while( 1 )
    {
      v8 = CmDeleteDevicePanelRegKey(a1, a2, *v6);
      if( v8 )
      {
        if( v8 != -1073741772 && v8 != -1073741811 && v8 != -1073741637 )
          break;
      }
      ++v7;
      ++v6;
      if( v7 )
        goto LABEL_11;
    }
    v3 = v8;
    if( v8 < 0 )
      return(unsigned int)v3;
LABEL_11:
    PoolWithTag = 0i64;
    v14 = 0;
    v20 = 0;
    do
    {
      DevicePanelMappedPropertyKeys = CmGetDevicePanelMappedPropertyKeys(
                                        v10,
                                        v9,
                                        v11,
                                        v12,
                                        (__int64)PoolWithTag,
                                        v14,
                                        &v20);
      v14 = v20;
      if( DevicePanelMappedPropertyKeys != -1073741789 )
        goto LABEL_18;
      v16 = 20 * v20;
      if( 20 * (unsigned __int64)v20 > 0xFFFFFFFF )
      {
        DevicePanelMappedPropertyKeys = -1073741811;
        goto LABEL_20;
      }
      if( PoolWithTag )
        ExFreePoolWithTag(PoolWithTag, 0);
      PoolWithTag = ExAllocatePoolWithTag(PagedPool, v16, 0x52504E50ui64);
    }
    while( PoolWithTag );
    DevicePanelMappedPropertyKeys = -1073741801;
LABEL_18:
    if( DevicePanelMappedPropertyKeys && DevicePanelMappedPropertyKeys != -1073741275 )
    {
LABEL_20:
      v3 = DevicePanelMappedPropertyKeys;
      goto LABEL_36;
    }
    v17 = 0i64;
    if( v14 )
    {
      while( 1 )
      {
        v18 = CmSetDevicePanelMappedProperty(5 * v17, v9, v11, 0i64, (__int64)PoolWithTag + 20 * v17);
        if( v18 )
        {
          if( v18 != -1073741275 && v18 != -1073741790 && v18 != -1073741802 && v18 != -1073741637 )
            break;
        }
        v17 = (unsigned int)(v17 + 1);
        if( (unsigned int)v17 >= v14 )
          goto LABEL_31;
      }
      v3 = v18;
    }
LABEL_31:
    if( v3 >= 0 )
    {
      DevicePanelMappedPropertyKeys = CmDeleteDevicePanelRegKey(a1, a2, 96);
      if( DevicePanelMappedPropertyKeys
        && DevicePanelMappedPropertyKeys != -1073741772
        && DevicePanelMappedPropertyKeys != -1073741811 )
      {
        goto LABEL_20;
      }
      CmRaiseDeleteEvent(a1, (__int64)a2, 6u);
    }
LABEL_36:
    if( PoolWithTag )
      ExFreePoolWithTag(PoolWithTag, 0);
  }
  return(unsigned int)v3;
}

Referenced by:

CmDeleteDevicePanel