Example #1
0
        private async Task readExportTable(Action <DomainLoadProgress> progress)
        {
            DomainLoadProgress message = new DomainLoadProgress {
                Text = "Reading Export Table...", Current = 0, Total = ExportTableCount
            };

            reader.Seek(ExportTableOffset);

            for (int i = 0; i < ExportTableCount; ++i)
            {
                DomainExportTableEntry export = new DomainExportTableEntry {
                    TableIndex = i + 1
                };

                await export.ReadExportTableEntry(reader, this);

                ExportTable.Add(export);

                message.IncrementCurrent();

                if (ExportTableCount > 100)
                {
                    progress?.Invoke(message);
                }
            }

            message.Text    = "Expanding References...";
            message.Current = 0;
            message.Total   = 0;

            progress?.Invoke(message);

            await ExportTable.ForEachAsync(export => Task.Run(() => export.ExpandReferences(this)));
        }
Example #2
0
        public async Task ReadHeaderAsync(Action <DomainLoadProgress> progress)
        {
            DomainLoadProgress message = new DomainLoadProgress {
                Text = "Parsing Header..."
            };

            progress?.Invoke(message);

            await readUpkHeader();

            const CompressionTypes validCompression = CompressionTypes.LZO | CompressionTypes.LZO_ENC;

            if (((CompressionTypes)CompressionFlags & validCompression) > 0)
            {
                message.Text = "Decompressing...";

                progress?.Invoke(message);

                reader = await decompressChunks();
            }
            else if (CompressionFlags > 0)
            {
                throw new Exception($"Unsupported compression type 0x{CompressionFlags:X8}.");
            }

            await readNameTable(progress);

            await readImportTable(progress);

            await readExportTable(progress);

            message.Text = "Slicing and Dicing...";

            progress?.Invoke(message);

            await readDependsTable();

            await decodePointers();

            message.Text  = "Reading Objects...";
            message.Total = ExportTableCount;

            progress?.Invoke(message);

            await ExportTable.ForEachAsync(export => {
                return(export.ReadDomainObject(reader).ContinueWith(t => {
                    message.IncrementCurrent();

                    if (ExportTableCount > 100)
                    {
                        progress?.Invoke(message);
                    }
                }));
            });

            message.IsComplete = true;

            progress?.Invoke(message);
        }