PiDmObjectManagerPopulate

NTSTATUS __stdcall PiDmObjectManagerPopulate(PI_DM_OBJECT_MANAGER *ObjectManager){
  VOID **PoolWithTag; 
  __int64 v3; 
  __int64 v4; 
  __int64 v5; 
  NTSTATUS ObjectList; 
  WCHAR *i; 
  __int64 v8; 
  _PI_DM_OBJECT **v10; 
  _PI_DM_OBJECT **v11; 
  unsigned int v12; 
  _PI_DM_OBJECT *Object; 

  v12 = 0x40000;
  PoolWithTag = 0i64;
  Object = 0i64;
  while( 1 )
  {
    if( PoolWithTag )
      ExFreePoolWithTag(PoolWithTag, 0x5A706E50u);
    PoolWithTag = ExAllocatePoolWithTag(1ui64, 2i64 * v12, 1517317712i64);
    if( !PoolWithTag )
      break;
    ObjectList = PnpGetObjectList(v3, ObjectManager[52], v4, v5, (INT64)PoolWithTag, v12, (INT64)&v12, 0x10000);
    if( ObjectList != -1073741789 )
      goto LABEL_6;
  }
  ObjectList = -1073741670;
LABEL_6:
  if( ObjectList >= 0 )
  {
    if( v12 )
    {
      for( i = (WCHAR *)PoolWithTag; *i; i += v8 + 1 )
      {
        ObjectList = PiDmObjectCreate(ObjectManager[52], i, &Object);
        if( ObjectList < 0 )
          break;
        Object[8] |= 1u;
        Object[3] = 1;
        if( !RtlInsertElementGenericTableAvl((_RTL_AVL_TABLE *)ObjectManager + 1, &Object, 8ui64, 0i64) )
        {
          PiDmObjectRelease(Object);
          ObjectList = -1073741670;
          break;
        }
        v8 = -1i64;
        do
          ++v8;
        while( i[v8] );
      }
    }
  }
  if( PoolWithTag )
    ExFreePoolWithTag(PoolWithTag, 0x5A706E50u);
  if( ObjectList < 0 )
  {
    while( 1 )
    {
      v10 = (_PI_DM_OBJECT **)RtlEnumerateGenericTableAvl((_RTL_AVL_TABLE *)ObjectManager + 1, 1u);
      v11 = v10;
      if( !v10 )
        break;
      RtlDeleteElementGenericTableAvl((PRTL_AVL_TABLE)ObjectManager + 1, v10);
      PiDmObjectRelease(*v11);
    }
  }
  return ObjectList;
}

Referenced by:

PiDmInit