Esempio n. 1
0
        internal Steam2Ticket(byte[] blob)
        {
            Entries = new List <Entry>();

            using (var ds = new DataStream(blob))
            {
                Magic = ds.ReadUInt16();

                Length   = ds.ReadUInt32();
                unknown1 = ds.ReadUInt32();

                while (ds.SizeRemaining() > 0)
                {
                    var entry = new Entry();
                    entry.Deserialize(ds);

                    Entries.Add(entry);
                }
            }
        }
Esempio n. 2
0
            internal void Deserialize(DataStream ds)
            {
                FileName = ds.ReadNullTermString(Encoding.ASCII);

                TotalSize = ds.ReadUInt64();

                Flags = (EDepotFileFlag)ds.ReadUInt32();

                HashFileName = ds.ReadBytes(20);
                HashContent  = ds.ReadBytes(20);

                NumChunks = ds.ReadUInt32();

                Chunks = new Chunk[NumChunks];

                for (int x = 0; x < Chunks.Length; ++x)
                {
                    Chunks[x] = new Chunk();
                    Chunks[x].Deserialize(ds);
                }
            }
Esempio n. 3
0
            internal VACStatusCallback(MsgClientVACBanStatus msg, byte[] payload)
            {
                var tempList = new List <uint>();

                using (DataStream ds = new DataStream(payload))
                {
                    for (int x = 0; x < msg.NumBans; x++)
                    {
                        tempList.Add(ds.ReadUInt32());
                    }

                    BannedApps = new ReadOnlyCollection <uint>(tempList);
                }
            }
Esempio n. 4
0
            /// <summary>
            /// Downloads a list of updated FileIDs since the given version.
            /// </summary>
            /// <param name="oldVersion">The old version to compare to.</param>
            /// <returns>A list of FileIDs that have been updated.</returns>
            public uint[] DownloadUpdates(uint oldVersion)
            {
                bool bRet = this.SendCommand(
                    5, // download updates
                    this.StorageID,
                    this.MessageID,
                    oldVersion
                    );

                uint storId = NetHelpers.EndianSwap(this.Socket.Reader.ReadUInt32());
                uint msgId  = NetHelpers.EndianSwap(this.Socket.Reader.ReadUInt32());

                byte updateState = this.Socket.Reader.ReadByte();

                uint numUpdates = NetHelpers.EndianSwap(this.Socket.Reader.ReadUInt32());

                if (numUpdates == 0)
                {
                    return(null);
                }

                uint storId2 = NetHelpers.EndianSwap(this.Socket.Reader.ReadUInt32());
                uint msgId2  = NetHelpers.EndianSwap(this.Socket.Reader.ReadUInt32());

                TcpPacket  packet = this.Socket.ReceivePacket();
                DataStream ds     = new DataStream(packet.GetPayload());

                uint[] fileIdList = new uint[numUpdates];
                for (int x = 0; x < numUpdates; ++x)
                {
                    fileIdList[x] = ds.ReadUInt32();
                }

                this.MessageID++;

                return(fileIdList);
            }
        static ContentServer[] GetServersFromPacket(TcpPacket packet)
        {
            DataStream ds = new DataStream(packet.GetPayload(), true);

            ushort numAddrs = ds.ReadUInt16();

            ContentServer[] serverList = new ContentServer[numAddrs];
            for (int x = 0; x < numAddrs; ++x)
            {
                uint weighedLoad = ds.ReadUInt32();

                IPAddrPort ipAddr  = IPAddrPort.Deserialize(ds.ReadBytes(6));
                IPAddrPort ipAddr2 = IPAddrPort.Deserialize(ds.ReadBytes(6));

                serverList[x] = new ContentServer()
                {
                    Load          = weighedLoad,
                    PackageServer = ipAddr,
                    StorageServer = ipAddr2,
                };
            }

            return(serverList);
        }
Esempio n. 6
0
        const uint ENTRY_SIZE  = 28; // the size of a single node


        internal Steam2Manifest(byte[] manifestBlob)
        {
            this.Nodes = new List <Node>();

            using (DataStream ds = new DataStream(manifestBlob))
            {
                uint headerVersion = ds.ReadUInt32();

                this.DepotID      = ds.ReadUInt32();
                this.DepotVersion = ds.ReadUInt32();

                this.NodeCount = ds.ReadUInt32();
                this.FileCount = ds.ReadUInt32();

                this.BlockSize = ds.ReadUInt32();

                // checksum is the last field in the header
                ds.Seek(HEADER_SIZE - 4, SeekOrigin.Begin);

                this.DepotChecksum = ds.ReadUInt32();

                // the start of the names section is after the header and every node
                uint namesStart = HEADER_SIZE + (this.NodeCount * ENTRY_SIZE);

                for (int x = 0; x < this.NodeCount; ++x)
                {
                    ds.Seek(HEADER_SIZE + (x * ENTRY_SIZE), SeekOrigin.Begin);

                    // the first value within a node is the offset from the start of the names section
                    uint nameOffset = namesStart + ds.ReadUInt32();

                    Node entry = new Node
                    {
                        SizeOrCount = ds.ReadUInt32(),
                        FileID      = ds.ReadInt32(),
                        Attributes  = (Node.Attribs)ds.ReadUInt32(),
                        ParentIndex = ds.ReadInt32(),

                        Parent = this,
                    };

                    ds.Seek(nameOffset, SeekOrigin.Begin);

                    entry.Name = ds.ReadNullTermString(Encoding.ASCII);

                    this.Nodes.Add(entry);
                }
            }

            // now build full names
            for (int x = 0; x < this.NodeCount; ++x)
            {
                Node   entry    = this.Nodes[x];
                string fullName = entry.Name;

                while (entry.ParentIndex != -1)
                {
                    entry    = this.Nodes[entry.ParentIndex];
                    fullName = Path.Combine(entry.Name, fullName);
                }

                entry          = this.Nodes[x];
                entry.FullName = fullName;
            }
        }
Esempio n. 7
0
        void Deserialize(DataStream ds)
        {
            Mapping = new List <FileMapping>();

            Magic = ds.ReadUInt32();

            if (Magic != MAGIC)
            {
                throw new InvalidDataException("data is not a valid steam3 manifest: incorrect magic.");
            }

            Version = ds.ReadUInt32();

            DepotID = ds.ReadUInt32();

            ManifestGID  = ds.ReadUInt64();
            CreationTime = Utils.DateTimeFromUnixTime(ds.ReadUInt32());

            AreFileNamesEncrypted = ds.ReadUInt32() != 0;

            TotalUncompressedSize = ds.ReadUInt64();
            TotalCompressedSize   = ds.ReadUInt64();

            ChunkCount = ds.ReadUInt32();

            FileEntryCount  = ds.ReadUInt32();
            FileMappingSize = ds.ReadUInt32();

            EncryptedCRC = ds.ReadUInt32();
            DecryptedCRC = ds.ReadUInt32();

            Flags = ds.ReadUInt32();

            for (uint i = FileMappingSize; i > 0;)
            {
                long start = ds.Position;

                FileMapping mapping = new FileMapping();
                mapping.Deserialize(ds);
                Mapping.Add(mapping);

                i -= (uint)(ds.Position - start);
            }
        }