Esempio n. 1
0
        private void ReadImports(BinaryReader reader, GpkPackage package)
        {
            logger.Debug("Reading Imports at {0}....", package.Header.ImportOffset);
            reader.BaseStream.Seek(package.Header.ImportOffset, SeekOrigin.Begin);

            for (int i = 0; i < package.Header.ImportCount; i++)
            {
                GpkImport import = new GpkImport();
                long      package_class_index = reader.ReadInt64();
                long      class_index         = reader.ReadInt64();

                import.OwnerIndex = reader.ReadInt32();
                long object_index = reader.ReadInt64();

                import.ClassPackage = package.GetString(package_class_index);
                import.ClassName    = package.GetString(class_index);
                import.ObjectName   = package.GetString(object_index);

                import.UID = package.GenerateUID(import);
                package.ImportList.Add(i, import);

                logger.Trace("Import {0}: ClassPackage {1} Class: {2} Object: {3}", i, import.ClassPackage, import.ClassName, import.ObjectName);
                stat.progress++;
            }


            foreach (KeyValuePair <long, GpkImport> pair in package.ImportList)
            {
                pair.Value.OwnerObject = package.GetObjectName(pair.Value.OwnerIndex);
            }
        }
Esempio n. 2
0
        private void ReadExports(BinaryReader reader, GpkPackage package)
        {
            logger.Debug("Reading Exports at {0}....", package.Header.ExportOffset);
            reader.BaseStream.Seek(package.Header.ExportOffset, SeekOrigin.Begin);

            for (int i = 0; i < package.Header.ExportCount; i++)
            {
                GpkExport export = new GpkExport(package);
                export.ClassIndex   = reader.ReadInt32();
                export.SuperIndex   = reader.ReadInt32();
                export.PackageIndex = reader.ReadInt32();

                long nameIndex = reader.ReadInt32();
                export.ObjectName = package.GetString(nameIndex);

                export.Unk1 = reader.ReadInt64();
                export.Unk2 = reader.ReadInt64();

                export.SerialSize = reader.ReadInt32();

                if (export.SerialSize > 0)
                {
                    export.SerialOffset = reader.ReadInt32();
                }

                export.Unk3           = reader.ReadInt32(); //ExportFlags
                export.UnkHeaderCount = reader.ReadInt32();
                export.Unk4           = reader.ReadInt32();
                export.Guid           = reader.ReadBytes(16);
                export.UnkExtraInts   = reader.ReadBytes(export.UnkHeaderCount * 4);

                package.ExportList.Add(i, export);

                logger.Trace("Export {0}: ObjectName: {1}, Data_Size: {2}, Data_Offset {3}, Export_offset {4}", i, export.ObjectName, export.SerialSize, export.SerialOffset, reader.BaseStream.Position);
                stat.progress++;
            }

            //post-processing. needed if a object points to another export.
            logger.Debug("Linking Exports..");
            foreach (KeyValuePair <long, GpkExport> pair in package.ExportList)
            {
                GpkExport export = pair.Value;
                if (export.ClassName == null || export.SuperName == null || export.PackageName == null || export.UID == null)
                {
                    export.ClassName   = package.GetObjectName(export.ClassIndex);
                    export.SuperName   = package.GetObjectName(export.SuperIndex);
                    export.PackageName = package.GetObjectName(export.PackageIndex);
                    export.UID         = package.GenerateUID(export);
                }

                stat.progress++;
            }
        }
Esempio n. 3
0
        public static void ReplaceAll(GpkExport source, GpkExport destination)
        {
            GpkPackage sourcePackage       = source.motherPackage;
            GpkPackage destinantionPackage = destination.motherPackage;

            //exclude: motherPackage, guid, uid, SerialOffset, SerialOffsetPosition, ObjectName, PackageName
            destination.ClassName = source.ClassName;
            destination.SuperName = source.SuperName;
            //destination.PackageName = source.PackageName;
            //destination.ObjectName = source.ObjectName;

            destination.Unk1 = source.Unk1;
            destination.Unk2 = source.Unk2;

            destination.SerialSize = source.SerialSize;

            destination.NetIndex     = source.NetIndex;
            destination.NetIndexName = source.NetIndexName;

            destination.Unk3           = source.Unk3;
            destination.UnkHeaderCount = source.UnkHeaderCount;
            destination.Unk4           = source.Unk4;
            destination.UnkExtraInts   = source.UnkExtraInts;

            destination.DependsTableData = source.DependsTableData;

            ReplaceProperties(source, destination);
            ReplaceData(source, destination);

            //regenerate uid
            destinantionPackage.GenerateUID(destination);

            //copy deps
            destinantionPackage.CopyObjectFromPackage(source.ClassName, sourcePackage, false);
            destinantionPackage.CopyObjectFromPackage(source.PackageName, sourcePackage, false);
            destinantionPackage.CopyObjectFromPackage(source.SuperName, sourcePackage, false);
            destinantionPackage.CopyObjectFromPackage(source.NetIndexName, sourcePackage, false);
        }