PiDmObjectManagerPopulate

INT64 __fastcall PiDmObjectManagerPopulate(INT64 a1){
  void *PoolWithTag; 
  __int64 v3; 
  __int64 v4; 
  __int64 v5; 
  int ObjectList; 
  const WCHAR *i; 
  __int64 v8; 
  CHAR **v10; 
  CHAR **v11; 
  unsigned int v12; 
  CHAR *Buffer; 
  v12 = 0x40000;
  PoolWithTag = 0i64;
  Buffer = 0i64;
  while( 1 )
  {
    if( PoolWithTag )
      ExFreePoolWithTag(PoolWithTag, 0x5A706E50u);
    PoolWithTag = ExAllocatePoolWithTag(PagedPool, 2i64 * v12, 0x5A706E50ui64);
    if( !PoolWithTag )
      break;
    ObjectList = PnpGetObjectList(v3, *(_DWORD *)(a1 + 208), 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 = (const WCHAR *)PoolWithTag; *i; i += v8 + 1 )
      {
        ObjectList = PiDmObjectCreate(*(unsigned int *)(a1 + 208), i, &Buffer);
        if( ObjectList < 0 )
          break;
        *((_DWORD *)Buffer + 8) |= 1u;
        *((_DWORD *)Buffer + 3) = 1;
        if( !RtlInsertElementGenericTableAvl((RTL_AVL_TABLE *)(a1 + 104), &Buffer, 8ui64, 0i64) )
        {
          PiDmObjectRelease(Buffer);
          ObjectList = -1073741670;
          break;
        }
        v8 = -1i64;
        do
          ++v8;
        while( i[v8] );
      }
    }
  }
  if( PoolWithTag )
    ExFreePoolWithTag(PoolWithTag, 0x5A706E50u);
  if( ObjectList < 0 )
  {
    while( 1 )
    {
      LODWORD(v10) = RtlEnumerateGenericTableAvl((RTL_AVL_TABLE *)(a1 + 104), 1u);
      v11 = v10;
      if( !v10 )
        break;
      RtlDeleteElementGenericTableAvl((RTL_AVL_TABLE *)(a1 + 104), v10);
      PiDmObjectRelease(*v11);
    }
  }
  return(unsigned int)ObjectList;
}

Referenced by:

PiDmInit