PopPlInitDevices

INT64 __fastcall PopPlInitDevices(INT64 a1, UINT64 *a2, UINT64 a3, INT64 a4, UINT64 a5, UINT64 *a6, CHAR **a7){
  _QWORD *PoolWithTag; 
  UINT64 v8; 
  UINT64 *v11; 
  int inited; 
  UINT64 v14; 
  UINT64 i; 
  __int64 v16; 
  unsigned __int64 v17; 
  unsigned __int64 v18; 
  INT64 v20; 
  v20 = 0i64;
  PoolWithTag = 0i64;
  v8 = 0i64;
  v11 = a2;
  if( a3 )
  {
    if( (unsigned __int64)a2 + 44 * a3 <= a5 )
    {
      PoolWithTag = ExAllocatePoolWithTag(NonPagedPoolNx, 8 * a3, 0x6C506F50ui64);
      if( PoolWithTag )
      {
        inited = 0;
        v14 = 0i64;
        if( a3 )
        {
          while( 1 )
          {
            inited = PopPlInitDevice(a1, v11, a4, a5, &v20);
            if( inited < 0 )
              break;
            ++v14;
            PoolWithTag[v8] = v20;
            v11 = (UINT64 *)((char *)v11 + 44);
            ++v8;
            if( v14 >= a3 )
              goto LABEL_18;
          }
          for( i = 0i64; i < v8; ++i )
          {
            v16 = PoolWithTag[i];
            v17 = 0i64;
            if( *(_QWORD *)(v16 + 72) )
            {
              do
              {
                ExFreePoolWithTag(*(PVOID *)(*(_QWORD *)(v16 + 80) + 8 * v17), 0x6C506F50u);
                v18 = *(_QWORD *)(v16 + 72);
                ++v17;
              }
              while( v17 < v18 );
              if( v18 )
                ExFreePoolWithTag(*(PVOID *)(v16 + 80), 0x6C506F50u);
            }
            ExFreePoolWithTag((PVOID)v16, 0x6C506F50u);
          }
          ExFreePoolWithTag(PoolWithTag, 0x6C506F50u);
          PoolWithTag = 0i64;
          v8 = 0i64;
        }
      }
      else
      {
        inited = -1073741670;
      }
    }
    else
    {
      inited = -1073741306;
    }
  }
  else
  {
    inited = -1073741811;
  }
LABEL_18:
  *a7 = (CHAR *)PoolWithTag;
  *a6 = v8;
  return(unsigned int)inited;
}

Referenced by:

PopPlInitPowerPlane