Пример #1
0
        public static SteamAppInfoDataFile Read(string steamShortcutFilePath)
        {
            using (FileStream stream = File.OpenRead(steamShortcutFilePath))
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    List <SteamAppInfoDataFileChunk> Chunks = new List <SteamAppInfoDataFileChunk>();
                    byte   Version1 = reader.ReadByte();
                    UInt16 Type     = reader.ReadUInt16();
                    byte   Version2 = reader.ReadByte();
                    UInt32 Version3 = reader.ReadUInt32();
                    //while(reader.BaseStream.Position < reader.BaseStream.Length)
                    for (; ;)
                    {
                        UInt32 AppID = reader.ReadUInt32();
                        if (AppID == 0)
                        {
                            break;
                        }
                        UInt32 DataSize = reader.ReadUInt32();
                        long   startPos = reader.BaseStream.Position;
                        //Console.WriteLine($"Expected End Position: {(startPos + DataSize):X8}");

                        UInt32 State            = reader.ReadUInt32();
                        UInt32 LastUpdate       = reader.ReadUInt32();
                        UInt64 AccessToken      = reader.ReadUInt64();
                        byte[] Checksum         = reader.ReadBytes(20);
                        UInt32 LastChangeNumber = reader.ReadUInt32();

                        BVPropertyCollection Data = BVdfFile.ReadPropertyArray(reader);
                        //long endPos = reader.BaseStream.Position;
                        if (reader.BaseStream.Position != (startPos + DataSize))
                        {
                            Console.WriteLine("appinfo.vdf chunk data size wrong, adjusting stream position");
                            reader.BaseStream.Seek(startPos + DataSize, SeekOrigin.Begin);
                        }
                        //Console.WriteLine($"*Expected End Position: {(startPos + DataSize):X8}");
                        //Console.WriteLine($"End Position: {(endPos):X8}");

                        SteamAppInfoDataFileChunk Chunk = new SteamAppInfoDataFileChunk(AppID, State, LastUpdate, AccessToken, Checksum, LastChangeNumber, Data);
                        Chunks.Add(Chunk);
                    }
                    return(new SteamAppInfoDataFile(Version1, Type, Version2, Version3, Chunks));
                }
        }
Пример #2
0
        public static SteamPackageInfoDataFile Read(string steamShortcutFilePath)
        {
            using (FileStream stream = File.OpenRead(steamShortcutFilePath))
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    List <SteamPackageInfoDataFileChunk> Chunks = new List <SteamPackageInfoDataFileChunk>();
                    byte   Version1 = reader.ReadByte();
                    UInt16 Type     = reader.ReadUInt16();
                    byte   Version2 = reader.ReadByte();
                    UInt32 Version3 = reader.ReadUInt32();
                    //while(reader.BaseStream.Position < reader.BaseStream.Length)
                    for (; ;)
                    {
                        UInt32 SubID = reader.ReadUInt32();
                        if (SubID == 0xffffffff)
                        {
                            break;
                        }
                        //UInt32 DataSize = reader.ReadUInt32();
                        long startPos = reader.BaseStream.Position;
                        //Console.WriteLine($"Expected End Position: {(startPos + DataSize):X8}");

                        //UInt32 State = reader.ReadUInt32();
                        //UInt32 LastUpdate = reader.ReadUInt32();
                        //UInt64 AccessToken = reader.ReadUInt64();
                        byte[] Checksum         = reader.ReadBytes(20);
                        UInt32 LastChangeNumber = reader.ReadUInt32();

                        BVPropertyCollection Data = BVdfFile.ReadPropertyArray(reader);
                        //long endPos = reader.BaseStream.Position;
                        //if (reader.BaseStream.Position != (startPos + DataSize))
                        //{
                        //    Console.WriteLine("appinfo.vdf chunk data size wrong, adjusting stream position");
                        //    reader.BaseStream.Seek(startPos + DataSize, SeekOrigin.Begin);
                        //}
                        //Console.WriteLine($"*Expected End Position: {(startPos + DataSize):X8}");
                        //Console.WriteLine($"End Position: {(endPos):X8}");

                        Data.ForceObjectWhenUnsure = true;
                        Data.Children()?.ForEach(node =>
                        {
                            BVPropertyCollection appids = ((node.Value as BVPropertyCollection)?["appids"] as BVPropertyCollection);
                            if (appids != null)
                            {
                                appids.ForceNumericWhenUnsure = true;
                            }

                            BVPropertyCollection depotids = ((node.Value as BVPropertyCollection)?["depotids"] as BVPropertyCollection);
                            if (depotids != null)
                            {
                                depotids.ForceNumericWhenUnsure = true;
                            }

                            BVPropertyCollection appitems = ((node.Value as BVPropertyCollection)?["appitems"] as BVPropertyCollection);
                            if (appitems != null)
                            {
                                appitems.ForceNumericWhenUnsure = true;
                            }
                        });

                        SteamPackageInfoDataFileChunk Chunk = new SteamPackageInfoDataFileChunk(SubID, /*State, LastUpdate, AccessToken,*/ Checksum, LastChangeNumber, Data);
                        Chunks.Add(Chunk);
                    }
                    return(new SteamPackageInfoDataFile(Version1, Type, Version2, Version3, Chunks));
                }
        }