Skip to content

Commit

Permalink
Update AppInfoReader to reflect appinfo.vdf 28
Browse files Browse the repository at this point in the history
  • Loading branch information
mvegter committed Mar 19, 2023
1 parent 3b7f428 commit 988cf7e
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/Depressurizer.Core/Helpers/AppInfoReader.cs
Expand Up @@ -18,6 +18,9 @@ public class AppInfoReader

private static FileStream _fileStream;

private const uint Magic27 = 0x07_56_44_27;
private const uint Magic28 = 0x07_56_44_28;

#endregion

#region Constructors and Destructors
Expand All @@ -34,25 +37,37 @@ public AppInfoReader(string path)
_binaryReader = new BinaryReader(_fileStream);

// Read some header fields
_binaryReader.ReadByte();
if (_binaryReader.ReadByte() != 0x44 || _binaryReader.ReadByte() != 0x56)
var magic = _binaryReader.ReadUInt32();
if (magic != Magic27 && magic != Magic28)
{
throw new InvalidDataException("Invalid VDF format");
}

// Skip more header fields
_binaryReader.ReadBytes(5);
_binaryReader.ReadUInt32();

while (true)
{
// uint32 - AppID
uint id = _binaryReader.ReadUInt32();
if (id == 0)
{
break;
}

// Skip unused fields
// uint32 - size
// uint32 - infoState
// uint32 - lastUpdated
// uint64 - picsToken
// 20bytes - SHA1 of text appinfo vdf
// uint32 - changeNumber
_binaryReader.ReadBytes(44);
if (magic == Magic28)
{
// 20bytes - SHA1 of binary_vdf
_binaryReader.ReadBytes(20);
}

// Load details
Items[id] = ReadEntries();
Expand Down

0 comments on commit 988cf7e

Please sign in to comment.