FMT.Core
Central core library for the Frostbite Modding Tool (FMT) — asset ingestion, serialization, caching and utility infrastructure for Frostbite engine titles (FIFA / FC, Madden, Need for Speed, Dead Space, Skate, …).
FMT.Core is the catch-all shared library that houses every asset-level primitive that does not belong in a more specific package such as FMT.Ebx, FMT.FileTools, FMT.Resources or FMT.Sound. If your code needs to read a TOC/CAS/SB layout, decode an EBX, touch the cache, compress a bundle name with Huffman, or write a signed TOC back to disk, it goes through FMT.Core.
Table of Contents
Features
- Frostbite container I/O —
TOC (TocFile), SB (SBFile), CAS/CAT (CASDataReader, CasReader, CatReader) and raw bundle parsing (BundleReader) with parallel CAS loading and SHA-1 table handling.
- Versioned EBX codecs — reader/writer families (
EbxReader, EbxReaderV2/Riff/2021/22A/22B, EbxBaseWriter, EbxWriter, EbxWriter2022/2023/Riff) dispatched via ProfileManager + TypeLibrary.
- TOC writing & layout preservation —
TOCFileWriter / ITOCFileWriter with deterministic rebuild, perfect-hash bundle indexing (BundleHashing<TKey,TValue>), add/remove bundle & chunk, old-layout-preserving write.
- Cryptographic TOC signing — RSA
RSAPRIVATEBLOB + BCryptSignHash(HMACSHA1("Powered by Frostbite")) in Utilities / TOCFileSignatureWriter.
- Deflate cache layer —
CacheManager + BaseCacheReader/BaseCacheWriter (v3, 5 header offsets) for fast EnumerateEbx/Res/Chunks without re-scanning CAS.
- Chunk file collections — legacy and 2022+ managers (
ChunkFileManager, ChunkFileManager2022, ChunkFileService, ChunkFileCollectionWriter) with Oodle/ZStd/LZ4 compression.
- Resource system —
Texture (per-title ReadInStream* branches, mip/pool/slice handling), AtlasTexture, LocalizedString, and full AssetBank / Ant / GenericData stack with VbrEncoder/VbrDecoder and FBX export.
- Mesh pipeline —
MeshSet / MeshSetLod / MeshSetSection / MeshContainer with relocation-table I/O and FC26/Madden26 quirks.
- Mod archives —
FrostbiteMod (.fbmod / FMT magic Fnv1a), FrostbiteModReader/FrostbiteModWriter, FET manifests.
- Huffman TOC string table —
HuffmanTree / HuffmanEncoder / HuffmanDecoder / HuffmanCode for compressed bundle names.
- Utilities —
PooledMemoryStream (ArrayPool<byte>-backed), FrostbiteInjection (remote DLL injection via Win32 P/Invoke), HalfUtils (float↔half tables), TextureSwizzle (BCn/RGBA swizzling, PS5 variants).
Requirements
- .NET 10.0 (
<TargetFramework>net10.0</TargetFramework> in FMT.Core.csproj:4)
- OS: Windows (
_WINDOWS define on Windows_NT — FMT.Core.csproj:51) — required for FrostbiteInjection.cs:12 and BCrypt signing.
- Unsafe blocks allowed (
AllowUnsafeBlocks: true — FMT.Core.csproj:7).
Installation
As a NuGet package
<PackageReference Include="FMT.Core" Version="2026.13.1.0" />
As a project reference
<ProjectReference Include="..\FMT.Core\FMT.Core.csproj" />
Build with Debug, Release or FMT_PRO (FMT.Core.csproj:38).
Project Structure
FMT.Core/
├── Attributes/ # UI attributes (BrowseFileAttribute)
├── Cache/ # CacheManager, BaseCacheReader/Writer, CacheLoadResult
├── ChunkFileCollection/ # ChunkFileManager (+2022), ChunkFileService, Writer
├── CustomExceptions/ # RequiresFMTProException, UnableToDetermineCasPath..., etc.
├── Enums/ # TocFlags
├── GameSingleton/ # GameSingletonResult / ResultType
├── Huffman/ # HuffmanTree, Encoder, Decoder, Code, Utils
├── Meshes/ # MeshSet, MeshSetLod, MeshSetSection, MeshContainer
├── Models/
│ ├── TOC/ # CASBundle, CasBundleEntry, BundleReferenceTableItem
│ └── Modding/ (+FET) # FrostbiteModDetails, ModdedFile, AddedBundle, Ebx/Res/Chunk index entries
├── Mods/ # FrostbiteMod, FrostbiteModReader/Writer
├── Projects/ # FolderProject (IProject, .fmtfolderproj)
├── Readers/
│ ├── CasReader, CatReader, BinaryReaderFIFA21
│ └── Ebx/ # EbxReader, EbxReaderV2/Riff/2021/22A/22B
├── Resources/
│ ├── Texture, AtlasTexture, LocalizedString, Resource, ModifiedResource
│ ├── Textures/TextureSwizzle (+ PS5 variants)
│ └── AssetBank/ # AssetBankCache, VbrEncoder/Decoder, GenericData/Bank/Section,
│ # Ant/*AnimationAsset, Export/SkeletonAsset & FbxWriter
├── SDK/ # GeneralSDKKnownHashToNames / GuidTypesToNames
├── Services/
│ └── DuplicationServicing/# IAssetEntryDuplicationService, EbxTexture dupl., DuplicationServicingUtils
├── ThirdParty/Fbx/ # HalfUtils (float↔half LUTs)
├── Utils/ # PooledMemoryStream
├── Writers/
│ ├── BundleWriter, TOCFileWriter, ITOCFileWriter
│ └── Ebx/ # EbxBaseWriter, EbxWriter, EbxWriter2022/2023/Riff, EbxWriteFlags
├── BundleReader.cs # SB bundle blob parser
├── CASDataReader.cs # CAS → DbObject / IAssetEntry bridge
├── TOCFile.cs # TOC container (CompressedStringHandler, ContainerMetaData)
├── SBFile.cs # .sb companion reader (BundleHeader)
├── SBHeaderInformation.cs # SB header struct (magic 0xD68E799D)
├── FrostbiteInjection.cs # Win32 remote DLL injection
├── Utilities.cs # TOC RSA signing, reflection helpers, CloneJson
├── FMTAppSettings.cs # Persisted singleton settings (FMTAppSettings.dat v4)
├── GameSpecificAppSettings.cs
├── EbxxWritingFormat.cs # None / UseVanillaIfAvailable / GenerateNew
├── CachingSBData.cs
└── T3DBManager.cs
ServicesAndManagers/ is currently empty and reserved for future service registrations.
Dependencies
NuGet
| Package |
Version |
Purpose |
FMT.Hash |
2026.3.28.12001 |
FNV/Murmur hashing for bundle & asset names |
FMT.Logging |
2026.11.0 |
Structured logging |
Newtonsoft.Json |
13.0.* |
JSON (mod manifests, settings, CloneJson) |
PInvoke.BCrypt |
0.7.124 |
BCryptSignHash for TOC RSA signing (Utilities.cs:15) |
System.IO.Hashing |
10.0.5 |
XxHash / non-cryptographic hashes |
Project references (FMT.Core.csproj:69-78)
FMT.Ebx · FMT.FileTools (NativeReader/NativeWriter) · FMT.InitfsSupport · FMT.Models.Assets (EbxAssetEntry/ResAssetEntry/ChunkAssetEntry) · FMT.PluginInterfaces · FMT.ProfileSystem (ProfileManager, TypeLibrary) · FMT.Resources · FMT.ServicesManagers · FMT.Sound
API Reference
Root — bundle / TOC / CAS / SB / injection
| Type |
File |
Description |
BundleReader |
BundleReader.cs:10 |
Parses a raw SB bundle blob: SHA-1 table + EBX/RES/Chunk sections into a DbObject or IAssetEntry[]. Dual-mode via readAsAssetEntries; uses ArrayPool fast paths and SBHeaderInformation (magic 0xD68E799D). |
CASDataReader |
CASDataReader.cs:13 |
Resolves a CAS path via IFileSystemService, iterates CASBundle offsets, calls BundleReader.Read, enriches DbObject and optionally converts to Ebx/Res/ChunkAssetEntry through DboToAssetConversionService and IAssetManager.Add*. Read(path, List<CASBundle>) → (Dictionary<CASBundle,DbObject>, List<IAssetEntry>). |
TOCFile : IDisposable |
TOCFile.cs:21 |
Central TOC container. Reads 556-byte header (sig + XOR + meta), ContainerMetaData (12 ints + TocFlags), BundleReferenceTableItem[], CasBundle[], chunk GUIDs/flags/entries and compressed string table. Read(NativeReader), ReadCasBundles, ReadCasBundlesFromCasFiles (parallel CASDataReader), RebuildTOCSignatureOnly. Nested ContainerMetaData (TOCFile.cs:134) and CompressedStringHandler (TOCFile.cs:972). |
SBFile : IDisposable |
SBFile.cs:12 |
Reads the .sb companion to a TOC. Iterates AssociatedTOCFile.Bundles via CreateViewStream(BaseBundle.Offset, Size) → ReadInternalBundle. Parses 8-int bundle header (CatalogOffset/EndOfMeta/casFileForGroupOffset/totalCount/...), delegates payload to BinaryReaderFIFA21, handles boolChangeOfCas mask and per-asset catalog/CAS routing. Nested BundleHeader (SBFile.cs:252). |
SBHeaderInformation |
SBHeaderInformation.cs:5 |
Value type for the SB bundle header: size, magic 0xD68E799D, totalCount, ebxCount/resCount/chunkCount, stringOffset/metaOffset/metaSize, Write(). |
TOCFileSignatureWriter |
TOCFileSignatureWriter.cs:7 |
Extension helper ToTOCSignature() that delegates to Utilities.CreateTOCSignature. |
FrostbiteInjection |
FrostbiteInjection.cs:12 |
Win32 P/Invoke wrapper (OpenProcess, VirtualAllocEx, WriteProcessMemory, GetProcAddress, CreateRemoteThread). InjectDLLFromPath(procId, dllPath) (LoadLibraryA remote thread) and InjectDLLIntoProcessName(dllPath, processName, maxProcesses:2, attemptTime:2min) with polling. Nested enums ProcessAccessFlags (FrostbiteInjection.cs:25), AllocationType (:54), MemoryProtection (:73). |
Utilities |
Utilities.cs:15 |
DefaultTOCHeaderSize = 556, RSA key parts TOCKeyPart1/2, CreateTOCSignature(input) / RebuildTOCSignature(tocBytes) via BCrypt.BCryptSignHash over HMACSHA1("Powered by Frostbite"), reflection helpers, CloneJson<T>. |
CachingSBData / CachingSB |
CachingSBData.cs:8,33 |
Caches SB bundle header + bundle list for SBFile.ReadInternalBundle; nested Bundle DTO. |
T3DBManager |
T3DBManager.cs:5 |
Stub manager for legacy T3DB assets. |
Cache
| Type |
File |
Description |
CacheManager |
Cache/CacheManager.cs:28 |
Singleton that owns the "_GameCaches/{ProfileManager.CacheName}.cache" lifecycle. LoadData() / LoadDataAsync(), CacheRead/CacheWrite, CacheDecompress/CacheCompress (Deflate), EnumerateEbx/Res/Chunks, name→position indexes, added/modified diff summary. |
BaseCacheReader : ICacheReader |
Cache/BaseCacheReader.cs:13 |
Reads cache v3: 5 header offsets (ebx/res/chunk/nameToPosition/sbChunk), ReadEbx/Res/ChunkAssetEntry, DoesCacheNeedRebuilding, ReadIntoLists. Namespace FMT.Cache. |
BaseCacheWriter : ICacheWriter |
Cache/BaseCacheWriter.cs:13 |
Writes cache v3 with the same 5-offset header. WriteEbx/Res/ChunkEntry. Namespace FMT.Cache. |
CacheLoadResult / CacheLoadResultType |
Cache/CacheLoadResult.cs:9, CacheLoadResultType.cs:9 |
Result wrapper; enum { CreatedNew, Loaded, Failed }. |
ChunkFileCollection
| Type |
File |
Description |
ChunkFileManager : IChunkFileAssetManager, ICustomAssetManager<IAssetEntry> |
ChunkFileCollection/ChunkFileManager.cs:22 |
Legacy (pre-2022) collector. Parses EBX ChunkId manifest → LegacyFileEntry, tracks bootables/cacheRecords, EnumerateAssets, GetAsset/AsSpan, ModifyAsset, DuplicateAsset, Write() rebuild with Oodle/compression, RebuildEntireChunkCollection / CompressChunkGroup. |
ChunkFileManager2022 : IChunkFileAssetManager, ICustomAssetManager<IAssetEntry> |
ChunkFileCollection/ChunkFileManager2022.cs:29 |
Post-2022 layout variant. Nested ChunkBatch (:53), BootableItem (:156), UnknownItem (:164). |
ChunkFileService : IChunkFileService |
ChunkFileCollection/ChunkFileService.cs:23 |
Locator for collector EBX entries (GetChunkFileCollectors). |
ChunkFileCollectionWriter |
ChunkFileCollection/ChunkFileCollectionWriter.cs:9 |
Writes modified legacy collections (internal). |
Readers
| Type |
File |
Description |
CasReader : NativeReader |
Readers/CasReader.cs:15 |
CAS block decompression: reads originalSize/compressType/LastCompressedBufferSize; handles 0 (uncompressed), 2 (ZLib), 9 (LZ4), 15 (ZStd+dict), 17/21/25 (Oodle), patched deltaStream cases 0–4, optional AES DecryptStream. |
CatReader : NativeReader |
Readers/CatReader.cs:7 |
CAT parsing: magic NyanNyan…, ResourceCount/PatchCount/EncryptedCount, ReadResourceEntry/EncryptedEntry/PatchEntry. |
BinaryReaderFIFA21 |
Readers/BinaryReaderFIFA21.cs:9 |
BinaryRead_FIFA21() → SBHeaderInformation + Ebx/Res/Chunk DbObject lists; consumed by SBFile. |
EbxReader : NativeReader |
Readers/Ebx/EbxReader.cs:17 |
Base EBX reader. Header EbxVersion V2(263377358)/V4(263508430), stringsOffset, guidCount, instanceCount; resolves types via TypeLibrary.CreateObject, ReadAsset/ReadObject, boxed values/arrays, pointer/array/struct handling. |
EbxReaderV2 |
Readers/Ebx/EbxReaderV2.cs:15 |
V2-specific field-type handling. |
EbxReaderRiff : EbxReader22B |
Readers/Ebx/EbxReaderRiff.cs:3 |
RIFF EBX variant. |
EbxReader2021 |
Readers/Ebx/EbxReader2021.cs:15 |
2021 layout. |
EbxReader22A / EbxReader22B |
Readers/Ebx/EbxReader22A.cs:19, EbxReader22B.cs:11 |
2022 layouts (field-type flag shifting type<<1, boxed values). |
Selection is via ProfileManager.EBXReader + TypeLibrary.LoadTypeByName; see EBX Versioning.
Writers
| Type |
File |
Description |
BundleWriter |
Writers/BundleWriter.cs:9 |
Write(Stream, DbObject) — writes SB bundle: header (size/magic/total/ebx/res/chunk counts/string/meta offsets), SHA-1 table, EBX name offsets+sizes, RES name+type+meta+Rid, Chunk GUIDs, strings, chunkMeta via DbWriter; fixes up header size. |
ITOCFileWriter |
Writers/ITOCFileWriter.cs:6 |
Contract: WriteCasBundles, Add/RemoveBundle(Bundle), Add/RemoveChunk, GenerateBundleNames(), WriteOld(preserveLayout) vs Write(preserveLayout:false). |
TOCFileWriter : ITOCFileWriter |
Writers/TOCFileWriter.cs:16 |
Full TOC writer. Deterministic rebuild with perfect-hash (BundleHashing<TKey,TValue> FNV seed 2166136261 — Writers/TOCFileWriter.cs:888, BundleHashingByString<T> :1142), Huffman GenerateBundleNames(), WriteChunkData, WriteOld (layout-preserving) vs Write. |
EbxBaseWriter : NativeWriter |
Writers/Ebx/EbxBaseWriter.cs |
Base: strings/boxedValues, AddString, WriteBoxedValueRef, GetEbxByteArrayDecompressed, GetEbxWriter() via ProfileManager.EBXWriter. |
EbxWriter : EbxBaseWriter |
Writers/Ebx/EbxWriter.cs:19 |
Standard writer: ExtractClass, ProcessClass/Type/Data, WriteEbx, WriteClass/Field (Pointer/Array/Struct/BoxedValueRef), object sorting. |
EbxWriter2022 : EbxBaseWriter |
Writers/Ebx/EbxWriter2022.cs:19 |
2022 layout (hierarchy walking, EFIX class table). |
EbxWriter2023 : EbxWriter2022 |
Writers/Ebx/EbxWriter2023.cs:7 |
2023 layout. |
EbxWriterRiff : EbxWriter2023 |
Writers/Ebx/EbxWriterRiff.cs:12 |
RIFF layout. |
EbxWriteFlags |
Writers/Ebx/EbxWriteFlags.cs:4 |
[Flags] { None, DoNotSort, IncludeTransient }. |
Resources & AssetBank
| Type |
File |
Description |
Texture : ITexture, IDisposable |
Resources/Texture.cs:13 |
MipOffsets[3], TextureType, pixelFormat, poolId, flags, width/height/depth/sliceCount, MipCount/firstMip, chunkId/MipSizes[15]/chunkSize, assetNameHash/textureGroup; per-title branches (ReadInStreamFIFA23, NHL_PS4, Madden23, NFSU, DeadSpace), ToBytes* writers, CalculateMipData, SetData. |
AtlasTexture |
Resources/AtlasTexture.cs:5 |
Atlas entry wrapper. |
Resource / ModifiedResource |
Resources/Resource.cs:6, ModifiedResource.cs:5 |
Generic resource DTOs. |
LocalizedString |
Resources/LocalizedString.cs:3 |
Localized string entry. |
TextureSwizzle / FrostbiteTextureSwizzle / TextureSwizzlePS5 / FrostbiteTextureSwizzlePS5 |
Resources/Textures/TextureSwizzle.cs:12,292,405,673 |
BC1/BC3/BC5/BC7/RGBA swizzle/unswizzle; ConsoleTarget (:276), PS5 Format { BC1, BC3, BC5, BC7, RGBA8, RG16, RGBA16 } (:675). |
AssetBankCache |
Resources/AssetBank/AssetBankCache.cs |
In-memory bank index. |
VbrEncoder / VbrDecoder |
Resources/AssetBank/VbrEncoder.cs, VbrDecoder.cs |
Variable-bit-rate codec for animation banks. |
GenericData/Bank / Section / GenericClass / GenericField / SectionStrm/Refl/Ref2/Data |
Resources/AssetBank/GenericData/* |
Generic bank data model (sections, classes, fields, stream/ref tables). |
Ant/* — VbrAnimationAsset, RawAnimationAsset, DctAnimationAsset, FrameAnimationAsset, LayoutAsset, ChannelToDofAsset, etc. |
Resources/AssetBank/Ant/* |
ANT animation assets (VBR/DCT/raw/curve/clip-controller). |
Export/SkeletonAsset, SEAnim, Transform, FbxWriter |
Resources/AssetBank/Export/* |
Skeleton → SEAnim → FBX export pipeline. |
Meshes
| Type |
File |
Description |
MeshSet : IMeshSet |
Meshes/MeshSet.cs |
Reads ResAssetEntry.ResMeta[16] + stream via IMeshSetReader plugin; BoundingBox, Lods, boneIndices/partTransforms, TangentSpaceCompressionType; ToBytes() / ToBytes_FC26() with MeshContainer reloc-ptr handling and FC26/Madden26 hacks. |
MeshSetLod |
Meshes/MeshSetLod.cs |
LOD container. |
MeshSetSection / MeshSetSectionWithSmoothing |
Meshes/MeshSetSection.cs, MeshSetSectionWithSmoothing.cs |
Per-section vertex/index data + smoothing. |
MeshContainer : IMeshContainer |
Meshes/MeshContainer.cs |
Relocation table: RelocPtr/RelocArray, AddString/RelocPtr/Offset, WriteRelocPtrs/Strings/Table, partial-reloc handling. |
MeshLimits |
Meshes/MeshLimits.cs |
Constants (MaxMeshLodCount = 6). |
Huffman
| Type |
File |
Description |
HuffmanTree (nested Node, HuffmanNodeComparer) |
Huffman/HuffmanTree.cs:6,8,54 |
Symbol counting (SetMaxSymbol(128)), BuildTree, BuildDecodingTable, GenerateHuffmanEncodedNames(bundleNames). |
HuffmanCode |
Huffman/HuffmanCode.cs:9 |
Bit-vector AddBit/RemoveBit/SetBit. |
HuffmanEncoder (+ EncodeResult { BitIndex }) |
Huffman/HuffmanEncoder.cs:9,11 |
EncodeData(string) → (Data: uint[], Length). |
HuffmanDecoder (+ HuffmanNode) |
Huffman/HuffmanDecoder.cs:6,30 |
ReadHuffmanTable(count), ReadEncodedData, ReadHuffmanEncodedString(bitIndex). |
HuffmanUtils |
Huffman/HuffmanUtils.cs:9 |
Glue GenerateHuffmanEncodedNames (internal). |
Used for TOC CompressedStrings bundle names; decoded via TOCFile.CompressedStringHandler.
Mods
| Type |
File |
Description |
FrostbiteMod : IFrostbiteMod |
Mods/FrostbiteMod.cs |
Mod archive: MagicFrosty 72155812747760198, MagicFMT (Fnv1a), decompresses CAS CompressType 2 via CasReader, reads ModDetails/Resources via FrostbiteModReader, GetResourceData. |
FrostbiteModReader / FrostbiteModWriter |
Mods/FrostbiteModReader.cs, FrostbiteModWriter.cs |
Binary (de)serialization of the mod format. |
Models
| Type |
File |
Description |
CASBundle |
Models/TOC/CASBundle.cs |
In-memory CAS bundle: unk1/2/HeaderSize/unk4/5, Catalog/Cas/Patch, FlagsOffset, BundleOffset/Size, Sizes/Offsets/Entries, TOCOffsets/Sizes/Cas/Catalog/Patch, BaseEntry/BaseBundle, Flags: byte[]. |
CASBundleEntry / BundleReferenceTableItem (ModifiedBundleReferenceTableItem) |
Models/TOC/CasBundleEntry.cs, BundleReferenceTableItem.cs |
TOC bundle-table rows. |
Modding/* — BaseModResource, BaseModReader, IModReader, FrostbiteModDetails, FrostbiteModWriterManifest, ModdedFile, EditorModResource |
Models/Modding/* |
Frosty .fbmod / FMT manifest structures. |
Modding/FET/* — AddedBundle, BrtAddition, ChunkFlags/ChunkIndexEntry, CollectorTarget, CommonIndex, EbxFlags/EbxIndexEntry, ResFlags/ResIndexEntry, FIFAModWriterManifest |
Models/Modding/FET/* |
FET-specific manifest extensions. |
StronglyTypedTransform |
Models/StronglyTypedTransform.cs:9 |
Typed transform DTO. |
Services — Duplication
| Type |
File |
Description |
IAssetEntryDuplicationService |
Services/DuplicationServicing/IAssetEntryDuplicationService.cs:8 |
DuplicationType Type; IAssetEntry DuplicateAsset(...). |
EbxTextureAssetEntryDuplicationService : IAssetEntryDuplicationService |
Services/DuplicationServicing/EbxTextureAssetEntryDuplicationService.cs:18 |
Duplicates EbxTexture assets with hash remapping. |
DuplicationServicingUtils (+ enums CodecMethod, ChunkStorageMode, DuplicationType) |
Services/DuplicationServicing/DuplicationServicingUtils.cs:8,39,47,55 |
Helpers for codec/storage/mode selection during duplication. |
Utils / Attributes / Enums / SDK / Projects
| Type |
File |
Description |
PooledMemoryStream : Stream |
Utils/PooledMemoryStream.cs |
ArrayPool<byte>-backed stream; Create(capacity), CreateFromOwnedBuffer(buffer,length), GetBufferMemory(), returns buffer on Dispose. Avoids LOH pressure for CAS blocks. |
BrowseFileAttribute : Attribute |
Attributes/BrowseFileAttribute.cs:4 |
Property attribute for file/folder picker UI (Filter, IsFolder). |
TocFlags : byte |
Enums/TocFlags.cs:10 |
[Flags] { HasBaseBundles=1, HasBaseChunks=2, CompressedStrings=4 }. |
EbxxWritingFormat : byte |
EbxxWritingFormat.cs:11 |
{ None, UseVanillaIfAvailable, GenerateNew } — controls EBX RIFF writing strategy. |
GameSingletonResult / GameSingletonResultType |
GameSingleton/GameSingletonResult.cs:10, GameSingletonResultType.cs:9 |
enum { Loaded, Failed, AlreadyLoaded } + wrapper with CacheLoadResult. |
GeneralSDKKnownHashToNames : ISDKKnownHashesToNames |
SDK/GeneralSDKKnownHashToNames.cs:8 |
e.g. { 807239646: "RenderFormat" }. |
GeneralSDKKnownGuidTypesToNames : ISDKKnownGuidTypesToNames |
SDK/GeneralSDKKnownGuidTypesToNames.cs:8 |
GUID→name map. |
HalfUtils |
ThirdParty/Fbx/HalfUtils.cs |
Static float↔half(ushort) pack/unpack with precomputed HalfToFloat*/FloatToHalf* tables. |
FolderProject : IProject |
Projects/FolderProject.cs:11 |
#if DEBUG||FMT_PRO — FileExtension .fmtfolderproj, IsDirty via EnumerateEbx/Res/Chunks(modifiedOnly), Folder, ModSettings, Load(Stream) reads ProjectVersion/GameDataVersion/Folder. |
| Custom exceptions |
CustomExceptions/* |
RequiresFMTProException (:3, gates PRO features), UnableToDetermineCasPathException (:7), CatalogNotFoundByIndexException : Exception (:6), MissingRequiredExtraDataException (:7, ExtraData==null guard). |
Configuration
| Type |
File |
Description |
FMTAppSettings : INotifyPropertyChanged |
FMTAppSettings.cs:9 |
Singleton persisted to FMTAppSettings.dat (v4): DoNotUseRegistry, SelectedEbxxWritingFormat, UseVisualStudioFont, DebugLogModifiedEbx, EnableEbxVanillaObjectComparison, etc. |
GameSpecificAppSettings : IGameSpecificAppSettings |
GameSpecificAppSettings.cs:11 |
Abstract base for per-game settings (profile-system extensibility). |
EBX Versioning
EBX I/O is version-dispatched via ProfileManager.EBXReader / ProfileManager.EBXWriter and TypeLibrary.LoadTypeByName:
EbxReader (base, V2 vs V4 magic 0x0FB2D1CE / 0x0FB4D1CE)
├── EbxReaderV2
├── EbxReader2021
└── EbxReader22A
└── EbxReader22B
└── EbxReaderRiff (RIFF container)
EbxBaseWriter
├── EbxWriter (standard)
├── EbxWriter2022
│ └── EbxWriter2023
│ └── EbxWriterRiff
V2 vs V4 splits header fields and field-type flag shifting (type << 1). Writers mirror readers; second-offsets can be resolved from vanilla EBX for bit-perfect output. Select with EbxBaseWriter.GetEbxWriter() / EbxReader.GetEbxReader(stream).
TOC Signing & Huffman
- Huffman — when
TocFlags.CompressedStrings is set, bundle names are encoded with HuffmanTree/HuffmanEncoder and stored as CompressedStringNames uint[] + CompressedStringTable int[]; decoded at read time by TOCFile.CompressedStringHandler via HuffmanDecoder.
- RSA signature —
Utilities.CreateTOCSignature (Utilities.cs:15) builds an RSAPRIVATEBLOB from TOCKeyPart1 (283 B) + TOCKeyPart2 (256 B) or a plugin-supplied toc.key, then signs HMACSHA1("Powered by Frostbite \\o/…", input) with BCryptSignHash(PKCS1 SHA1). Signature size equals modulus size. TOCFileSignatureWriter.ToTOCSignature() is a thin wrapper.
Cache System
Deflate-compressed cache at _GameCaches/{ProfileManager.CacheName}.cache (v3, 5 header offsets: ebx/res/chunk/nameToPosition/sbChunk):
CacheManager.LoadData() ──┐
├─ delete stale cache (Head check)
├─ IAssetLoader.Load(SuperBundles) ← profile
└─ BaseCacheWriter.Write* → Deflate
CacheManager.EnumerateEbx(name) → name→position dict → BaseCacheReader.ReadEbx*
CacheLoadResultType is CreatedNew / Loaded / Failed. BaseCacheReader.DoesCacheNeedRebuilding gates invalidation.
Usage Examples
Read a TOC + CAS
using FMT.Core;
using FMT.FileTools;
using var tocReader = new NativeReader(File.OpenRead("path/to/game.toc"));
var toc = new TOCFile("path/to/game.toc");
toc.Read(tocReader);
// Pull CAS bundles in parallel and build asset entries
toc.ReadCasBundlesFromCasFiles();
// Or manually:
var casReader = new CASDataReader { AssociatedTOCFile = toc };
var (dbObjects, assetEntries) = casReader.Read("path/to/cas_01.cas", toc.CasBundles);
Read an SB companion
using var sbReader = new NativeReader(File.OpenRead("path/to/game.sb"));
var sb = new SBFile { AssociatedTOCFile = toc };
sb.Read(sbReader);
foreach (var bundle in sb.Bundles)
{
// bundle.Ebx / bundle.Res / bundle.Chunks
}
Read / write EBX
using FMT.Core.Readers.Ebx;
using FMT.Core.Writers.Ebx;
// Reader is dispatched by ProfileManager.EBXReader
using var ebxStream = File.OpenRead("asset.ebx");
var reader = EbxReader.GetEbxReader(ebxStream); // or new EbxReader2021(...)
var dbObject = reader.ReadAsset(ebxStream);
// Writer is dispatched by ProfileManager.EBXWriter
var writer = EbxBaseWriter.GetEbxWriter();
byte[] bytes = writer.WriteEbx(dbObject, EbxWriteFlags.None);
Work with the cache
using FMT.Core.Cache;
var mgr = CacheManager.Instance;
CacheLoadResult result = await mgr.LoadDataAsync();
if (result.ResultType == CacheLoadResultType.Loaded)
{
foreach (var ebx in mgr.EnumerateEbx("characters/player"))
Console.WriteLine(ebx.Name);
}
Sign a modified TOC
using FMT.Core;
// After modifying TOCFileWriter and writing bytes:
byte[] tocBytes = tocWriter.Write(preserveLayout: false);
byte[] signature = Utilities.CreateTOCSignature(tocBytes);
// or
byte[] sig2 = tocBytes.ToTOCSignature();
Texture swizzling
using FMT.Core.Resources.Textures;
byte[] swizzled = TextureSwizzle.Swizzle(...);
byte[] deswizzled = FrostbiteTextureSwizzlePS5.Deswizzle(data, width, height, Format.BC7);
Build Configurations
| Configuration |
Symbols |
DebugType |
Notes |
Debug |
— |
Full |
Default development build |
Release |
— |
None |
Shipping build (FMT.Core.csproj:41) |
FMT_PRO |
— |
None |
Enables PRO-only paths (RequiresFMTProException, FolderProject) — FMT.Core.csproj:46 |
License
Licensed under CC BY-NC-ND 4.0 — see LICENSE.md.
Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International. You may share the material for non-commercial purposes only, without adaptation, with attribution to Paulov / FMTDev.