CmDeleteDeviceContainerWorker

NTSTATUS __stdcall CmDeleteDeviceContainerWorker(
        HPNPCTX *hPnpCtx,
        WCHAR *DeviceContainerId,
        WCHAR *Flags,
        UINT64 a4,
        INT64 a5,
        UINT8 a6,
        INT64 a7,
        INT64 a8,
        UINT64 *a9){
  NTSTATUS v9; 
  INT64 *v12; 
  int v13; 
  NTSTATUS v14; 
  _DEVPROPKEY *v15; 
  _DEVPROPKEY *v16; 
  UINT64 *v17; 
  VOID **PoolWithTag; 
  unsigned int v19; 
  NTSTATUS DeviceContainerMappedPropertyKeys; 
  INT64 v21; 
  __int64 v22; 
  NTSTATUS v23; 
  _CM_OBJECT_TYPE v24; 
  unsigned int v26; 
  INT64 DeleteTree; 
  INT64 DeleteTreea; 
  UINT8 v29; 
  UINT8 v30; 
  INT64 v31; 
  INT64 v32; 
  UINT64 *v33; 
  INT64 v34; 

  v9 = 0;
  if( (_WORD)Flags )
    return -1073741811;
  LODWORD(v34) = 336;
  v12 = &v34;
  v13 = 0;
  while( 1 )
  {
    v14 = CmDeleteDeviceContainerRegKey(
            hPnpCtx,
            DeviceContainerId,
            (WCHAR *)*(unsigned int *)v12,
            a4,
            DeleteTree,
            v29,
            v31,
            v32,
            v33);
    if( v14 )
    {
      if( v14 != -1073741637 && v14 != -1073741772 && v14 != -1073741811 )
        break;
    }
    ++v13;
    v12 = (INT64 *)((char *)v12 + 4);
    if( v13 )
      goto LABEL_6;
  }
  v9 = v14;
  if( v14 < 0 )
    return v9;
LABEL_6:
  PoolWithTag = 0i64;
  LOBYTE(v19) = 0;
  LODWORD(v34) = 0;
  do
  {
    v30 = v19;
    DeleteTreea = (INT64)PoolWithTag;
    DeviceContainerMappedPropertyKeys = CmGetDeviceContainerMappedPropertyKeys(v16, (UINT64)v15, v17);
    v19 = v34;
    if( DeviceContainerMappedPropertyKeys != -1073741789 )
      goto LABEL_8;
    v26 = 20 * v34;
    if( 20 * (unsigned __int64)(unsigned int)v34 > 0xFFFFFFFF )
    {
      DeviceContainerMappedPropertyKeys = -1073741811;
      goto LABEL_25;
    }
    if( PoolWithTag )
      ExFreePoolWithTag(PoolWithTag, 0);
    PoolWithTag = ExAllocatePoolWithTag(1ui64, v26, 1380994640i64);
  }
  while( PoolWithTag );
  DeviceContainerMappedPropertyKeys = -1073741801;
LABEL_8:
  if( DeviceContainerMappedPropertyKeys && DeviceContainerMappedPropertyKeys != -1073741275 )
  {
LABEL_25:
    v9 = DeviceContainerMappedPropertyKeys;
    goto LABEL_16;
  }
  v22 = 0i64;
  if( v19 )
  {
    while( 1 )
    {
      DeleteTreea = (INT64)PoolWithTag + 20 * v22;
      v23 = CmSetDeviceContainerMappedProperty((WCHAR *)(5 * v22), v15);
      if( v23 )
      {
        if( v23 != -1073741790 && v23 != -1073741275 && v23 != -1073741802 && v23 != -1073741637 )
          break;
      }
      v22 = (unsigned int)(v22 + 1);
      if( (unsigned int)v22 >= v19 )
        goto LABEL_13;
    }
    v9 = v23;
  }
LABEL_13:
  if( v9 >= 0 )
  {
    DeviceContainerMappedPropertyKeys = CmDeleteDeviceContainerRegKey(
                                          hPnpCtx,
                                          DeviceContainerId,
                                          (WCHAR *)0x50,
                                          v21,
                                          DeleteTreea,
                                          v30,
                                          (INT64)&v34,
                                          v32,
                                          v33);
    if( !DeviceContainerMappedPropertyKeys
      || DeviceContainerMappedPropertyKeys == -1073741772
      || DeviceContainerMappedPropertyKeys == -1073741811 )
    {
      CmRaiseDeleteEvent(hPnpCtx, DeviceContainerId, CM_OBJECT_TYPE_DEVICE_CONTAINER, v24);
      goto LABEL_16;
    }
    goto LABEL_25;
  }
LABEL_16:
  if( PoolWithTag )
    ExFreePoolWithTag(PoolWithTag, 0);
  return v9;
}

Referenced by:

CmDeleteDeviceContainer