Exemple #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.PackageRef = reader.ReadInt32();
                long object_index = reader.ReadInt32();
                import.Unk = reader.ReadInt32();

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

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

                logger.Debug("Import {0}: ClassPackage {1} Class: {2} Object: {3}", i, import.ClassPackage, import.ClassName, import.ObjectName);
                stat.progress++;
            }
        }
        public void ReadData(BinaryReader reader, GpkPackage package)
        {
            long index = reader.ReadInt32();

            value   = package.GetString(index);
            padding = reader.ReadInt32();
        }
Exemple #3
0
        public void ReadData(BinaryReader reader, GpkPackage package)
        {
            long structtype = reader.ReadInt64();

            innerType = package.GetString(structtype);
            value     = new byte[size];
            value     = reader.ReadBytes(size);
        }
Exemple #4
0
 public void ReadData(BinaryReader reader, GpkPackage package)
 {
     if (size == 8)
     {
         if (package.x64)
         {
             long structtype = reader.ReadInt64();
             enumType = package.GetString(structtype);
         }
         long byteIndex = reader.ReadInt64();
         nameValue = package.GetString(byteIndex);
     }
     else
     {
         byteValue = reader.ReadByte();
     }
 }
Exemple #5
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();
                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.Debug("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         = GenerateUID(package, export);
                }

                stat.progress++;
            }
        }
Exemple #6
0
        private Boolean ReadPropertyDetails(BinaryReader reader, GpkPackage package, GpkExport export)
        {
            GpkBaseProperty baseProp = new GpkBaseProperty();

            long nameindex = reader.ReadInt64();


            if (!package.NameList.ContainsKey(nameindex))
            {
                logger.Fatal("name not found " + nameindex);
                if (export.Properties.Count > 0)
                {
                    logger.Fatal("prev " + export.Properties[export.Properties.Count - 1]);
                }
            }

            baseProp.name = package.GetString(nameindex);
            if (baseProp.name.ToLower() == "none")
            {
                return(false);
            }

            long typeindex = reader.ReadInt64();

            if (!package.NameList.ContainsKey(typeindex))
            {
                logger.Fatal("type not found " + typeindex);
            }
            baseProp.type = package.GetString(typeindex);

            baseProp.size       = reader.ReadInt32();
            baseProp.arrayIndex = reader.ReadInt32();

            IProperty iProp;

            switch (baseProp.type)
            {
            case "StructProperty":
                iProp = new GpkStructProperty(baseProp);
                break;

            case "ArrayProperty":
                iProp = new GpkArrayProperty(baseProp);
                break;

            case "BoolProperty":
                iProp = new GpkBoolProperty(baseProp);
                break;

            case "ByteProperty":
                iProp = new GpkByteProperty(baseProp);
                break;

            case "NameProperty":
                iProp = new GpkNameProperty(baseProp);
                break;

            case "IntProperty":
                iProp = new GpkIntProperty(baseProp);
                break;

            case "FloatProperty":
                iProp = new GpkFloatProperty(baseProp);
                break;

            case "StrProperty":
                iProp = new GpkStringProperty(baseProp);
                break;

            case "ObjectProperty":
                iProp = new GpkObjectProperty(baseProp);
                break;

            default:
                throw new Exception(
                          string.Format(
                              "Unknown Property Type {0}, Position {1}, Prop_Name {2}, Export_Name {3}",
                              baseProp.type, reader.BaseStream.Position, baseProp.name, export.ObjectName));
            }

            iProp.ReadData(reader, package);
            iProp.RecalculateSize();
            export.Properties.Add(iProp);

            //logger.Trace(String.Format("Property Type {0}, Position after {1}, Prop_Name {2}, Export_Name {3}", baseProp.type, reader.BaseStream.Position, baseProp.ObjectName, export.ObjectName));

            return(true);
        }