Skip to main content

Overview

The ResourceManager class handles low-level access to game resource data stored in CAS (Content Addressable Storage) archives. It manages catalog loading, encryption, and data decompression.
using FrostySdk.Managers;

ResourceManager rm = new ResourceManager(fileSystem);
rm.Initialize();

Constructor

ResourceManager
constructor
Creates a new ResourceManager instance
ResourceManager rm = new ResourceManager(FileSystem fs);
fs
FileSystem
required
Initialized FileSystem instance

Initialization

Initialize
void
Initializes the resource manager and loads all catalogs
rm.Initialize();
This method:
  • Binds compression libraries (ZStd, Oodle)
  • Loads all CAS catalogs from native_data and native_patch
  • Loads encryption keys if required
  • Sets up decompression dictionaries for specific games

Resource Data Access

Get Resource Data (Unpatched)

GetResourceData
Stream
Loads resource data from CAS using SHA1 hash
// Load by SHA1
Stream data = rm.GetResourceData(sha1);
if (data != null)
{
    // Process decompressed data
    byte[] buffer = new byte[data.Length];
    data.Read(buffer, 0, buffer.Length);
}
sha1
Sha1
required
SHA1 hash of the resource
Returns: Decompressed and decrypted resource data stream, or null if not found or encrypted without key

Get Resource Data (Patched)

GetResourceData
Stream
Loads patched resource data using base and delta SHA1
Stream data = rm.GetResourceData(baseSha1, deltaSha1);
baseSha1
Sha1
required
SHA1 of base resource
deltaSha1
Sha1
required
SHA1 of delta/patch data
Returns: Merged and decompressed resource data

Get Resource Data (SuperBundle)

GetResourceData
Stream
Loads resource data from a binary superbundle file
Stream data = rm.GetResourceData(
    "win32/levels/mp_001",
    offset: 12345,
    size: 8192
);
superBundleName
string
required
Name of the superbundle file
offset
long
required
Offset within the superbundle
size
long
required
Size of the resource data

Get Resource Data (Cache)

GetResourceData
Stream
Loads resource data from the cache file
Stream data = rm.GetResourceData(offset, size);
offset
long
required
Offset in cache file
size
long
required
Size of data

Get Resource Data (Buffer)

GetResourceData
Stream
Decompresses resource data from a byte buffer
byte[] compressedData = GetCompressedData();
Stream data = rm.GetResourceData(compressedData);
buffer
byte[]
required
Compressed resource data buffer

Raw Data Access

The following methods return compressed/encrypted data without decompression:
GetRawResourceData
Stream
Gets raw (compressed/encrypted) resource data
// From CAS
Stream raw = rm.GetRawResourceData(sha1);

// From superbundle
Stream raw = rm.GetRawResourceData("win32/levels/mp_001", offset, size);

// From cache
Stream raw = rm.GetRawResourceData(offset, size);
Useful for:
  • Extracting exact data as stored
  • Custom decompression logic
  • Data analysis

Utility Methods

GetBaseSha1
Sha1
Gets the base SHA1 for a patched resource
Sha1 baseSha1 = rm.GetBaseSha1(patchedSha1);
// Returns the same SHA1 if not patched
sha1
Sha1
required
Potentially patched resource SHA1
Returns: Base SHA1, or the input SHA1 if not patched
IsEncrypted
bool
Checks if a resource is encrypted
if (rm.IsEncrypted(sha1))
{
    Console.WriteLine("Resource is encrypted");
    // May need encryption key to load
}
sha1
Sha1
required
Resource SHA1 to check

Logging

SetLogger
void
Sets the logger for diagnostic output
rm.SetLogger(logger);
logger
ILogger
required
Logger implementation
ClearLogger
void
Clears the current logger
rm.ClearLogger();

Usage Examples

using FrostySdk;
using FrostySdk.Managers;
using System.IO;

// Initialize
FileSystem fs = new FileSystem(@"C:\Games\FIFA20");
fs.Initialize();

ResourceManager rm = new ResourceManager(fs);
rm.Initialize();

// Load resource by SHA1
Sha1 resourceHash = new Sha1("abc123...");
Stream data = rm.GetResourceData(resourceHash);

if (data != null)
{
    using (BinaryReader reader = new BinaryReader(data))
    {
        // Read and process resource data
        byte[] buffer = reader.ReadBytes((int)data.Length);
        ProcessResourceData(buffer);
    }
}
else
{
    Console.WriteLine("Resource not found or encrypted");
}

Resource Types

The ResourceManager handles various resource types defined in ResourceType enum:
public enum ResourceType : uint
{
    Texture = 0x6BDE20BA,
    MeshSet = 0x49B156D4,
    CompiledLuaResource = 0xAFECB022,
    SwfMovie = 0x2D47A5FF,
    // ... and many more
}
Common resource types:
  • Texture - Image/texture data
  • MeshSet - 3D mesh geometry
  • IShaderDatabase - Compiled shaders
  • LocalizedStringResource - Localized text
  • CompiledLuaResource - Lua scripts
  • SwfMovie - UI Flash files

Data Locations

Resources can be stored in different locations:
public enum AssetDataLocation
{
    Cas,              // Standard CAS archive
    SuperBundle,      // Binary superbundle file
    Cache,            // Local cache file
    CasNonIndexed     // CAS without catalog index
}

Performance Notes

Caching: The ResourceManager doesn’t cache decompressed data. For frequently accessed resources, cache the decompressed streams in your code.
Large Resources: Some resources (like high-res textures) can be very large. Use streaming where possible and dispose of streams when done.

See Also

Build docs developers (and LLMs) love