mirror of
https://github.com/SabreTools/SabreTools.Models.git
synced 2026-09-24 07:37:10 +00:00
Add PS3 SFB and SFO models
This commit is contained in:
57
PlayStation3/Constants.cs
Normal file
57
PlayStation3/Constants.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
// TODO: Add more constants from the wiki
|
||||
namespace SabreTools.Models.PlayStation3
|
||||
{
|
||||
/// <see href="https://psdevwiki.com/ps3/PS3_DISC.SFB"/>
|
||||
public static class Constants
|
||||
{
|
||||
#region Hybrid Flags
|
||||
|
||||
/// <summary>
|
||||
/// Not dependant of other disc files, enables a network connection to PSN store
|
||||
/// </summary>
|
||||
public const char FlagDiscBenefits = 'S';
|
||||
|
||||
/// <summary>
|
||||
/// dev_bdvd/PS3_CONTENT/THEMEDIR/PARAM.SFO
|
||||
/// </summary>
|
||||
public const char FlagThemes = 'T';
|
||||
|
||||
/// <summary>
|
||||
/// dev_bdvd/PS3_CONTENT/VIDEODIR/PARAM.SFO
|
||||
/// </summary>
|
||||
public const char FlagVideo = 'V';
|
||||
|
||||
/// <summary>
|
||||
/// friends? (unknown yet, usually combined with g/p?)
|
||||
/// </summary>
|
||||
public const char FlagFriends = 'f';
|
||||
|
||||
/// <summary>
|
||||
/// dev_bdvd/PS3_GAME/USRDIR/PARAM.SFO
|
||||
/// dev_bdvd/PS3_EXTRA/PARAM.SFO
|
||||
/// </summary>
|
||||
public const char FlagGameExtras = 'g';
|
||||
|
||||
/// <summary>
|
||||
/// music?
|
||||
/// </summary>
|
||||
public const char FlagMusic = 'm';
|
||||
|
||||
/// <summary>
|
||||
/// photo? (unknown yet, used with v, fv,..)
|
||||
/// </summary>
|
||||
public const char FlagPhoto = 'p';
|
||||
|
||||
/// <summary>
|
||||
/// dev_bdvd/PS3_UPDATE/PS3UPDAT.PUP
|
||||
/// </summary>
|
||||
public const char FlagFirmwareUpdate = 'u';
|
||||
|
||||
/// <summary>
|
||||
/// dev_bdvd/PS3_VPRM/PARAM.SFO
|
||||
/// </summary>
|
||||
public const char FlagMovie = 'v';
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
31
PlayStation3/Enums.cs
Normal file
31
PlayStation3/Enums.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
// TODO: Add more enumerations from the wiki
|
||||
namespace SabreTools.Models.PlayStation3
|
||||
{
|
||||
/// <see href="https://psdevwiki.com/ps3/PARAM.SFO"/>
|
||||
public enum DataFormat : ushort
|
||||
{
|
||||
/// <summary>
|
||||
/// UTF-8 Special Mode, NOT NULL terminated
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Used in SFO's generated by the system and/or linked to an user (Game Saves and Trophies).
|
||||
/// </remarks>
|
||||
UTF8SpecialMode = 0x0004,
|
||||
|
||||
/// <summary>
|
||||
/// UTF-8 character string, NULL terminated (0x00)
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Can be used any character from the system fonts. The NULL byte is counted as part of the used bytes in len
|
||||
/// </remarks>
|
||||
UTF8 = 0x0204,
|
||||
|
||||
/// <summary>
|
||||
/// Integer 32 bits unsigned
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Always has a length of 4 bytes in len and max_len (even in the case some bytes are not used, all them are marked as used)
|
||||
/// </remarks>
|
||||
Integer = 0x0404,
|
||||
}
|
||||
}
|
||||
140
PlayStation3/SFB.cs
Normal file
140
PlayStation3/SFB.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
namespace SabreTools.Models.PlayStation3
|
||||
{
|
||||
/// <see href="https://psdevwiki.com/ps3/PS3_DISC.SFB"/>
|
||||
public class SFB
|
||||
{
|
||||
/// <summary>
|
||||
/// ".SFB"
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public byte[] Magic { get; set; }
|
||||
#else
|
||||
public byte[]? Magic { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// File version(?)
|
||||
/// </summary>
|
||||
public uint FileVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Unknown (zeroes)
|
||||
/// </summary>
|
||||
/// <remarks>0x18 bytes</remarks>
|
||||
#if NET48
|
||||
public byte[] Reserved1 { get; set; }
|
||||
#else
|
||||
public byte[]? Reserved1 { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// "HYBRID_FLAG" (Flags type)
|
||||
/// </summary>
|
||||
/// <remarks>0x10 bytes</remarks>
|
||||
#if NET48
|
||||
public string FlagsType { get; set; }
|
||||
#else
|
||||
public string? FlagsType { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Disc Content Data Offset
|
||||
/// </summary>
|
||||
public uint DiscContentDataOffset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Disc Content Data Length
|
||||
/// </summary>
|
||||
public uint DiscContentDataLength { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Unknown (zeroes)
|
||||
/// </summary>
|
||||
/// <remarks>0x08 bytes</remarks>
|
||||
#if NET48
|
||||
public byte[] Reserved2 { get; set; }
|
||||
#else
|
||||
public byte[]? Reserved2 { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// "TITLE_ID" (Disc Title Name)
|
||||
/// </summary>
|
||||
/// <remarks>0x08 bytes</remarks>
|
||||
#if NET48
|
||||
public string DiscTitleName { get; set; }
|
||||
#else
|
||||
public string? DiscTitleName { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Unknown (zeroes)
|
||||
/// </summary>
|
||||
/// <remarks>0x08 bytes</remarks>
|
||||
#if NET48
|
||||
public byte[] Reserved3 { get; set; }
|
||||
#else
|
||||
public byte[]? Reserved3 { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Disc Version Data Offset
|
||||
/// </summary>
|
||||
public uint DiscVersionDataOffset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Disc Version Data Length
|
||||
/// </summary>
|
||||
public uint DiscVersionDataLength { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Unknown (zeroes)
|
||||
/// </summary>
|
||||
/// <remarks>0x188 bytes</remarks>
|
||||
#if NET48
|
||||
public byte[] Reserved4 { get; set; }
|
||||
#else
|
||||
public byte[]? Reserved4 { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Disc Content (Hybrid Flags)
|
||||
/// </summary>
|
||||
/// <remarks>0x20 bytes</remarks>
|
||||
#if NET48
|
||||
public string DiscContent { get; set; }
|
||||
#else
|
||||
public string? DiscContent { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Disc Title
|
||||
/// </summary>
|
||||
/// <remarks>0x10 bytes</remarks>
|
||||
#if NET48
|
||||
public string DiscTitle { get; set; }
|
||||
#else
|
||||
public string? DiscTitle { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Disc Version
|
||||
/// </summary>
|
||||
/// <remarks>0x10 bytes</remarks>
|
||||
#if NET48
|
||||
public string DiscVersion { get; set; }
|
||||
#else
|
||||
public string? DiscVersion { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Unknown (zeroes)
|
||||
/// </summary>
|
||||
/// <remarks>0x3C0 bytes</remarks>
|
||||
#if NET48
|
||||
public byte[] Reserved5 { get; set; }
|
||||
#else
|
||||
public byte[]? Reserved5 { get; set; }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
75
PlayStation3/SFO.cs
Normal file
75
PlayStation3/SFO.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
namespace SabreTools.Models.PlayStation3
|
||||
{
|
||||
/// <see href="https://psdevwiki.com/ps3/PARAM.SFO"/>
|
||||
public class SFO
|
||||
{
|
||||
/// <summary>
|
||||
/// SFO header
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public SFOHeader Header { get; set; }
|
||||
#else
|
||||
public SFOHeader? Header { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Index table
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public SFOIndexTableEntry[] IndexTable { get; set; }
|
||||
#else
|
||||
public SFOIndexTableEntry[]? IndexTable { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Key table
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Composed by a number of key entries defined with tables_entries in
|
||||
/// the header, are short utf8 strings in capitals, NULL terminated
|
||||
/// (0x00), and ordered alphabetically (from A to Z). This alphabetically
|
||||
/// order defines the order of the associated entries in the other
|
||||
/// two tables (index_table, and data_table)
|
||||
///
|
||||
/// The end offset of this table needs to be aligned to a multiply of
|
||||
/// 32bits (4 bytes), this is made with a padding at the end of key_table
|
||||
/// when needed (in a few SFO's the table is aligned naturally as a
|
||||
/// coincidence caused by the length of the key names used, when this
|
||||
/// happens there is no padding needed)
|
||||
/// </remarks>
|
||||
#if NET48
|
||||
public string[] KeyTable { get; set; }
|
||||
#else
|
||||
public string[]? KeyTable { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Padding
|
||||
/// </summary>
|
||||
/// <remarks>Enough bytes to align to 4 bytes</remarks>
|
||||
#if NET48
|
||||
public byte[] Padding { get; set; }
|
||||
#else
|
||||
public byte[]? Padding { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Data table
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Composed by a number of data entries defined with tables_entries in
|
||||
/// the header, every entry in this table is defined by the associated entry
|
||||
/// in the index_table by using: fmt, len, max_len, and offset. There is
|
||||
/// no padding between entries neither at the end of this table
|
||||
///
|
||||
/// Some data entries can be filled with zeroes (not used, but availables for
|
||||
/// being used). This entries can be considered reserved, and are marked with
|
||||
/// a len = 0 in the associated entry in the index_table
|
||||
/// </remarks>
|
||||
#if NET48
|
||||
public byte[][] DataTable { get; set; }
|
||||
#else
|
||||
public byte[][]? DataTable { get; set; }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
35
PlayStation3/SFOHeader.cs
Normal file
35
PlayStation3/SFOHeader.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
namespace SabreTools.Models.PlayStation3
|
||||
{
|
||||
/// <see href="https://psdevwiki.com/ps3/PARAM.SFO"/>
|
||||
public class SFOHeader
|
||||
{
|
||||
/// <summary>
|
||||
/// "\0PSF"
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public byte[] Magic { get; set; }
|
||||
#else
|
||||
public byte[]? Magic { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Version
|
||||
/// </summary>
|
||||
public uint Version { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Absolute start offset of key_table
|
||||
/// </summary>
|
||||
public uint KeyTableStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Absolute start offset of data_table
|
||||
/// </summary>
|
||||
public uint DataTableStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of entries in index_table, key_table, and data_table
|
||||
/// </summary>
|
||||
public uint TablesEntries { get; set; }
|
||||
}
|
||||
}
|
||||
33
PlayStation3/SFOIndexTableEntry.cs
Normal file
33
PlayStation3/SFOIndexTableEntry.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
namespace SabreTools.Models.PlayStation3
|
||||
{
|
||||
/// <see href="https://psdevwiki.com/ps3/PARAM.SFO"/>
|
||||
public class SFOIndexTableEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// Key relative offset.
|
||||
/// (Absolute start offset of key) - (Absolute start offset of key_table)
|
||||
/// </summary>
|
||||
public ushort KeyOffset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Data type
|
||||
/// </summary>
|
||||
public DataFormat DataFormat { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Data used length
|
||||
/// </summary>
|
||||
public uint DataLength { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Data total length. TITLE_ID is always = 16 bytes
|
||||
/// </summary>
|
||||
public uint DataMaxLength { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Data relative offset.
|
||||
/// (Absolute start offset of data_1) - (Absolute start offset of data_table)
|
||||
/// </summary>
|
||||
public uint DataOffset { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user