From f79cd759bd722e9ab1a62ab70a0e2681911fd991 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 14 Dec 2022 23:16:37 -0800 Subject: [PATCH] Add SFFS models, no encryption --- BurnOutSharp.Models/SFFS/FileEntry.cs | 20 +++++++++++ BurnOutSharp.Models/SFFS/FileHeader.cs | 20 +++++++++++ BurnOutSharp.Models/SFFS/Header.cs | 29 ++++++++++++++++ .../SFFS/StarForceFileSystem.cs | 33 +++++++++++++++++++ 4 files changed, 102 insertions(+) create mode 100644 BurnOutSharp.Models/SFFS/FileEntry.cs create mode 100644 BurnOutSharp.Models/SFFS/FileHeader.cs create mode 100644 BurnOutSharp.Models/SFFS/Header.cs create mode 100644 BurnOutSharp.Models/SFFS/StarForceFileSystem.cs diff --git a/BurnOutSharp.Models/SFFS/FileEntry.cs b/BurnOutSharp.Models/SFFS/FileEntry.cs new file mode 100644 index 00000000..3f774bc7 --- /dev/null +++ b/BurnOutSharp.Models/SFFS/FileEntry.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace BurnOutSharp.Models.SFFS +{ + /// + [StructLayout(LayoutKind.Sequential)] + public class FileEntry + { + /// + /// MD5 hash of filename (not encrypted,) + /// + /// 0x10 bytes + public byte[] FilenameMD5Hash; + + /// + /// Index of fileheader (encrypted with filename) + /// + public ulong FileHeaderIndex; + } +} diff --git a/BurnOutSharp.Models/SFFS/FileHeader.cs b/BurnOutSharp.Models/SFFS/FileHeader.cs new file mode 100644 index 00000000..5cbff9fa --- /dev/null +++ b/BurnOutSharp.Models/SFFS/FileHeader.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace BurnOutSharp.Models.SFFS +{ + /// + [StructLayout(LayoutKind.Sequential)] + public class FileHeader + { + /// + /// Start of file content (encrypted with filename) + /// + public ulong FileContentStart; + + /// + /// File info (timestamps, size, data position, encrypted) + /// + /// Unknown format + public byte[] FileInfo; + } +} diff --git a/BurnOutSharp.Models/SFFS/Header.cs b/BurnOutSharp.Models/SFFS/Header.cs new file mode 100644 index 00000000..57354bf8 --- /dev/null +++ b/BurnOutSharp.Models/SFFS/Header.cs @@ -0,0 +1,29 @@ +using System.Runtime.InteropServices; + +namespace BurnOutSharp.Models.SFFS +{ + /// + /// Header + /// + /// + [StructLayout(LayoutKind.Sequential)] + public class Header + { + /// + /// "SFFS" + /// + public uint Magic; + + /// + /// Version (0x00000001) + /// + public uint Version; + + /// + /// 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 + /// + public ulong FileCount; + } +} diff --git a/BurnOutSharp.Models/SFFS/StarForceFileSystem.cs b/BurnOutSharp.Models/SFFS/StarForceFileSystem.cs new file mode 100644 index 00000000..ec491584 --- /dev/null +++ b/BurnOutSharp.Models/SFFS/StarForceFileSystem.cs @@ -0,0 +1,33 @@ +namespace BurnOutSharp.Models.SFFS +{ + /// + /// 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. + /// + /// + public class StarForceFileSystem + { + /// + /// Header + /// + public Header Header { get; set; } + + /// + /// Files + /// + public FileEntry[] Files { get; set; } + + /// + /// File headers + /// + public FileHeader[] FileHeaders { get; set; } + } +}