Add SFFS models, no encryption

This commit is contained in:
Matt Nadareski
2022-12-14 23:16:37 -08:00
parent 1b232e4405
commit f79cd759bd
4 changed files with 102 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
using System.Runtime.InteropServices;
namespace BurnOutSharp.Models.SFFS
{
/// <see cref="https://forum.xentax.com/viewtopic.php?f=21&t=2084"/>
[StructLayout(LayoutKind.Sequential)]
public class FileEntry
{
/// <summary>
/// MD5 hash of filename (not encrypted,)
/// </summary>
/// <remarks>0x10 bytes</remarks>
public byte[] FilenameMD5Hash;
/// <summary>
/// Index of fileheader (encrypted with filename)
/// </summary>
public ulong FileHeaderIndex;
}
}

View File

@@ -0,0 +1,20 @@
using System.Runtime.InteropServices;
namespace BurnOutSharp.Models.SFFS
{
/// <see cref="https://forum.xentax.com/viewtopic.php?f=21&t=2084"/>
[StructLayout(LayoutKind.Sequential)]
public class FileHeader
{
/// <summary>
/// Start of file content (encrypted with filename)
/// </summary>
public ulong FileContentStart;
/// <summary>
/// File info (timestamps, size, data position, encrypted)
/// </summary>
/// <remarks>Unknown format</remarks>
public byte[] FileInfo;
}
}

View File

@@ -0,0 +1,29 @@
using System.Runtime.InteropServices;
namespace BurnOutSharp.Models.SFFS
{
/// <summary>
/// Header
/// </summary>
/// <see cref="https://forum.xentax.com/viewtopic.php?f=21&t=2084"/>
[StructLayout(LayoutKind.Sequential)]
public class Header
{
/// <summary>
/// "SFFS"
/// </summary>
public uint Magic;
/// <summary>
/// Version (0x00000001)
/// </summary>
public uint Version;
/// <summary>
/// Number of files in the container (encrypted with application key).
/// Minimal number here is usually 65h, so its not real file count
/// in some cases, more like index size
/// </summary>
public ulong FileCount;
}
}

View File

@@ -0,0 +1,33 @@
namespace BurnOutSharp.Models.SFFS
{
/// <summary>
/// SFFS consists of 2 major parts: the container files that contain the game
/// content and a filesystem filter driver (sfvfs02.sys) that handles all file-io.
/// When a game has SFFS'ed files and uses some file-io api like CreateFile, the
/// SFFS filterdriver sees this request and handles it if needed.that way, SFFS is
/// totally transparent to the game, since it never knows if the data is coming from
/// real file API or from the SFFS filterdriver. during SF initialization, the
/// SF-process registers itself as a SFFS process in a processid list, maintained
/// from the filterdriver. Part of that registration are the names of the
/// containerfiles, the process uses and an application key, that is needed to
/// decrypt headerinfos. Note that SFFS itself is completly vm-free.
/// </summary>
/// <see cref="https://forum.xentax.com/viewtopic.php?f=21&t=2084"/>
public class StarForceFileSystem
{
/// <summary>
/// Header
/// </summary>
public Header Header { get; set; }
/// <summary>
/// Files
/// </summary>
public FileEntry[] Files { get; set; }
/// <summary>
/// File headers
/// </summary>
public FileHeader[] FileHeaders { get; set; }
}
}