private void FixObjectReferencesInFilteredExports(DummyExportTableItem export, List <DummyExportTableItem> exportsToSerialize, List <UExportTableItem> exports)
 {
     export.newClassIndex     = FindNewExportReference(export.original.ClassIndex, exportsToSerialize, exports);
     export.newSuperIndex     = FindNewExportReference(export.original.SuperIndex, exportsToSerialize, exports);
     export.newOuterIndex     = FindNewExportReference(export.original.OuterIndex, exportsToSerialize, exports);
     export.newArchetypeIndex = FindNewExportReference(export.original.ArchetypeIndex, exportsToSerialize, exports);
 }
        private void DummyExportTableSerialize(DummyExportTableItem tableItem, int serialOffset, int serialSize)
        {
            this.Write(tableItem.newClassIndex);
            this.Write(tableItem.newSuperIndex);
            this.Write(tableItem.newOuterIndex);
            this.Write(tableItem.original.ObjectName);
            this.Write(tableItem.newArchetypeIndex);
            //this.Write(tableItem.ObjectFlags);
            if (tableItem.original.ClassName == "Package")
            {
                this.Write(1970342016843776);
            }
            else
            {
                this.Write(4222141830530048);
            }

            this.Write(serialSize);

            //this.Write(tableItem.SerialOffset);
            this.Write(serialOffset);
            //this.Write(tableItem.ExportFlags);
            this.Write(0);
            //Net objects count
            this.Write(0);

            //PackageGUID
            this.Write(0);
            this.Write(0);
            this.Write(0);
            this.Write(0);

            //Package flags
            if (tableItem.original.ClassName == "Package")
            {
                this.Write(1);
            }
            else
            {
                this.Write(0);
            }
        }
        private int AddToImportTable(List <DummyImportTableItem> newImportTable, DummyExportTableItem export, int importIndex)
        {
            if (importIndex < 0) //import
            {
                var import   = package.Imports[-importIndex - 1];
                var newIndex = newImportTable.FindIndex((i) => i.original == import);
                if (newIndex == -1)
                {
                    newImportTable.Add(new DummyImportTableItem(import));
                    newIndex = newImportTable.Count - 1;
                }

                //Process the outer\parent object(s) of the import
                var dummyImport = newImportTable[newIndex];
                while (dummyImport.newOuterIndex < 0)
                {
                    var parentImport   = package.Imports[-dummyImport.original.OuterIndex - 1];
                    var newParentIndex = newImportTable.FindIndex((i) => i.original == parentImport);
                    if (newParentIndex == -1)
                    {
                        newImportTable.Add(new DummyImportTableItem(parentImport));
                        newParentIndex            = newImportTable.Count - 1;
                        dummyImport.newOuterIndex = FromListIndexToImportTableIndex(newParentIndex);
                        dummyImport = newImportTable[newParentIndex];
                    }
                    else
                    {
                        dummyImport.newOuterIndex = FromListIndexToImportTableIndex(newParentIndex);
                        //We've already added this to the table. And we assume we can break the "recursion" here..
                        break;
                    }
                }
                return(FromListIndexToImportTableIndex(newIndex));
            }
            //if export, just return the old one.
            return(importIndex);
        }