mirror of
https://github.com/SabreTools/SabreTools.Models.git
synced 2026-09-23 07:06:17 +00:00
Update VPK models
This commit is contained in:
27
SabreTools.Models/VPK/ArchiveMD5SectionEntry.cs
Normal file
27
SabreTools.Models/VPK/ArchiveMD5SectionEntry.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SabreTools.Models.VPK
|
||||
{
|
||||
/// <see href="https://developer.valvesoftware.com/wiki/VPK_(file_format)"/>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public sealed class ArchiveMD5SectionEntry
|
||||
{
|
||||
public uint ArchiveIndex;
|
||||
|
||||
/// <summary>
|
||||
/// Where to start reading bytes
|
||||
/// </summary>
|
||||
public uint StartingOffset;
|
||||
|
||||
/// <summary>
|
||||
/// How many bytes to check
|
||||
/// </summary>
|
||||
public uint Count;
|
||||
|
||||
/// <summary>
|
||||
/// Expected checksum
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
||||
public byte[]? MD5Checksum = new byte[16];
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,37 @@ using System.Runtime.InteropServices;
|
||||
namespace SabreTools.Models.VPK
|
||||
{
|
||||
/// <see href="https://github.com/RavuAlHemio/hllib/blob/master/HLLib/VPKFile.h"/>
|
||||
/// <see href="https://developer.valvesoftware.com/wiki/VPK_(file_format)"/>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public sealed class DirectoryEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// A 32bit CRC of the file's data.
|
||||
/// </summary>
|
||||
public uint CRC;
|
||||
|
||||
/// <summary>
|
||||
/// The number of bytes contained in the index file.
|
||||
/// </summary>
|
||||
public ushort PreloadBytes;
|
||||
|
||||
/// <summary>
|
||||
/// A zero based index of the archive this file's data is contained in.
|
||||
/// If 0x7fff, the data follows the directory.
|
||||
/// </summary>
|
||||
public ushort ArchiveIndex;
|
||||
|
||||
/// <summary>
|
||||
/// If ArchiveIndex is 0x7fff, the offset of the file data relative to the
|
||||
/// end of the directory (see the header for more details).
|
||||
/// Otherwise, the offset of the data from the start of the specified archive.
|
||||
/// </summary>
|
||||
public uint EntryOffset;
|
||||
|
||||
/// <summary>
|
||||
/// If zero, the entire file is stored in the preload data.
|
||||
/// Otherwise, the number of bytes stored starting at EntryOffset.
|
||||
/// </summary>
|
||||
public uint EntryLength;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
namespace SabreTools.Models.VPK
|
||||
{
|
||||
/// <see href="https://github.com/RavuAlHemio/hllib/blob/master/HLLib/VPKFile.h"/>
|
||||
/// <see href="https://developer.valvesoftware.com/wiki/VPK_(file_format)"/>
|
||||
public sealed class DirectoryItem
|
||||
{
|
||||
public string? Extension { get; set; }
|
||||
|
||||
@@ -6,27 +6,33 @@ namespace SabreTools.Models.VPK
|
||||
/// Added in version 2.
|
||||
/// </summary>
|
||||
/// <see href="https://github.com/RavuAlHemio/hllib/blob/master/HLLib/VPKFile.h"/>
|
||||
/// <see href="https://developer.valvesoftware.com/wiki/VPK_(file_format)"/>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public sealed class ExtendedHeader
|
||||
{
|
||||
/// <summary>
|
||||
/// Reserved
|
||||
/// How many bytes of file content are stored in this
|
||||
/// VPK file (0 in CSGO)
|
||||
/// </summary>
|
||||
public uint Dummy0;
|
||||
public uint FileDataSectionSize;
|
||||
|
||||
/// <summary>
|
||||
/// Archive hash length
|
||||
/// The size, in bytes, of the section containing MD5
|
||||
/// checksums for external archive content
|
||||
/// </summary>
|
||||
public uint ArchiveHashLength;
|
||||
public uint ArchiveMD5SectionSize;
|
||||
|
||||
/// <summary>
|
||||
/// Looks like some more MD5 hashes.
|
||||
/// The size, in bytes, of the section containing MD5
|
||||
/// checksums for content in this file (should always be 48)
|
||||
/// </summary>
|
||||
public uint ExtraLength;
|
||||
public uint OtherMD5SectionSize;
|
||||
|
||||
/// <summary>
|
||||
/// Reserved
|
||||
/// The size, in bytes, of the section containing the public
|
||||
/// key and signature. This is either 0 (CSGO & The Ship) or
|
||||
/// 296 (HL2, HL2:DM, HL2:EP1, HL2:EP2, HL2:LC, TF2, DOD:S & CS:S)
|
||||
/// </summary>
|
||||
public uint Dummy1;
|
||||
public uint SignatureSectionSize;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Runtime.InteropServices;
|
||||
namespace SabreTools.Models.VPK
|
||||
{
|
||||
/// <see href="https://github.com/RavuAlHemio/hllib/blob/master/HLLib/VPKFile.h"/>
|
||||
/// <see href="https://developer.valvesoftware.com/wiki/VPK_(file_format)"/>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public sealed class Header
|
||||
{
|
||||
@@ -13,6 +14,9 @@ namespace SabreTools.Models.VPK
|
||||
|
||||
public uint Version;
|
||||
|
||||
public uint DirectoryLength;
|
||||
/// <summary>
|
||||
/// The size, in bytes, of the directory tree
|
||||
/// </summary>
|
||||
public uint TreeSize;
|
||||
}
|
||||
}
|
||||
|
||||
18
SabreTools.Models/VPK/OtherMD5Section.cs
Normal file
18
SabreTools.Models/VPK/OtherMD5Section.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SabreTools.Models.VPK
|
||||
{
|
||||
/// <see href="https://developer.valvesoftware.com/wiki/VPK_(file_format)"/>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public sealed class OtherMD5Section
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
||||
public byte[]? TreeChecksum = new byte[16];
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
||||
public byte[]? ArchiveMD5SectionChecksum = new byte[16];
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
||||
public byte[]? WholeFileChecksum = new byte[16];
|
||||
}
|
||||
}
|
||||
29
SabreTools.Models/VPK/SignatureSection.cs
Normal file
29
SabreTools.Models/VPK/SignatureSection.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SabreTools.Models.VPK
|
||||
{
|
||||
/// <see href="https://developer.valvesoftware.com/wiki/VPK_(file_format)"/>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public sealed class SignatureSection
|
||||
{
|
||||
/// <summary>
|
||||
/// Always seen as 160 (0xA0) bytes
|
||||
/// </summary>
|
||||
public uint PublicKeySize;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="PublicKeySize"/>
|
||||
/// </summary>
|
||||
public byte[]? PublicKey;
|
||||
|
||||
/// <summary>
|
||||
/// Always seen as 128 (0x80) bytes
|
||||
/// </summary>
|
||||
public uint SignatureSize;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="SignatureSize"/>
|
||||
/// </summary>
|
||||
public byte[]? Signature;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user