SL2 Analyzer
Read a FromSoftware .sl2 save and report what is in it
Loading...
Searching...
No Matches
gamefiles.py File Reference

Go to the source code of this file.

Classes

class  gamefiles.Reader
 A little-endian struct reader that exits rather than reading past its buffer. More...
 

Namespaces

namespace  gamefiles
 

Functions

dict[str, str] gamefiles.load_keys (Path path, str dict_name)
 One game's public keys out of UXM's ArchiveKeys.cs.
 
bytes gamefiles.rsa_decrypt (bytes data, str pem)
 Decrypt a .bhd with a PKCS#1 public key.
 
dict[int, dict] gamefiles.parse_bhd5 (bytes buf, str variant="ds3")
 Parse a decrypted BHD5 header into {file name hash: entry}.
 
dict gamefiles.read_aes_key (bytes buf, int off)
 The per-file AES key and the ranges it covers, or None where there is none.
 
int gamefiles.path_hash (str path, str variant="ds3")
 SFUtil.FromPathHash: the only way to find a file whose name was thrown away.
 
bytes gamefiles.read_entry (bdt, dict entry)
 Read one entry out of a .bdt, decrypting the ranges its header marks.
 
list[Path] gamefiles.ooz_paths (str|None explicit)
 Where to find the Kraken decoder.
 
 gamefiles.ooz_load (str|None explicit=None)
 Load libooz.so once, from the first candidate path that exists.
 
bytes gamefiles.ooz_decompress (bytes src, int dst_len)
 
bytes gamefiles.ooz_decompress_chunked (bytes src, int dst_len)
 Kraken decode a stream FROM's way: one 256 KiB chunk at a time.
 
bytes gamefiles.dcx_decompress (bytes data)
 Undo a DCX\0 wrapper, KRAK or DFLT.
 
int gamefiles._i32 (bytes b, int o)
 
int gamefiles._u32 (bytes b, int o)
 
int gamefiles._i64 (bytes b, int o)
 
str gamefiles._utf16 (bytes b, int off)
 A NUL-terminated UTF-16LE string at off.
 
dict[str, list[int]] gamefiles.msb_sections (bytes buf)
 Every section of an MSB as {name: [entry offsets]}.
 
int gamefiles.msb_section_pos (bytes buf, str name)
 Byte offset of one section's header, for reading its version word.
 
list[str] gamefiles.msb_models (bytes buf, list[int] offsets)
 Model names in index order, so a part's ModelIndex resolves to c1470_0000.
 
list[dict] gamefiles.msb_parts (bytes buf, list[int] offsets, list[str] models)
 Every part in one MSB as a dict, enemies carrying their param joins.
 
tuple[str, list[dict]]|None gamefiles.read_msb (Path path)
 Parse one .msb into (map name, [part rows]).
 
list[tuple[str, list[dict]]] gamefiles.read_msbs (str root)
 Every .msb under a directory, parsed, in map order; unknown layouts skipped.
 
str gamefiles.entity_map (int eid)
 The map file an entity id belongs to, by the same decomposition the flags use.
 
list|None gamefiles.unpack_args (bytes data, list[int] types)
 Unpack one instruction's argument blob against a type list.
 
list[int]|None gamefiles.common_init_args (bytes data)
 Initialize Common Event's variadic arguments: the event id, then its parameters.
 
list[tuple[int, int, int, bytes]]|None gamefiles.read_emevd (Path path)
 Every instruction in one .emevd as (event id, bank, instruction id, argdata), or None if the file is not the DS3/Sekiro shape.
 
dict[str, list] gamefiles.read_emevds (str root)
 Every .emevd under a directory, as {map name: [instructions]}.
 
list[tuple] gamefiles.roster_calls (dict[str, list] scripts)
 Every boss/miniboss call in the scripts, as (map, event, kind, entity, name id).
 
dict[int, dict] gamefiles.build_roster (dict[str, list] scripts)
 The boss/miniboss roster keyed by entity id.
 
dict[int, tuple[str, int]] gamefiles.ds3_death_flags (dict[str, list] scripts)
 Every death flag the DS3 one-time-enemy templates are initialised with.
 
dict[str, dict[int, str]] gamefiles.load_fmg_tables (str msg_dir)
 Every FMG table in the English message binders, keyed by table name.
 
tuple[str, int] gamefiles.pick_table (dict[str, dict[int, str]] tables, set[int] ids)
 The FMG table covering the most of ids, and how many it covered.
 
dict[int, str] gamefiles.npc_dev_names (str paramdex)
 Paramdex's NpcParam annotations as {row id: english text}.
 
list[str] gamefiles.wanted (str dict_path, list[str] prefixes, list[str] paths)
 Which dictionary paths to extract, from the prefixes and exact paths given.
 
int gamefiles.cmd_unpack (args)
 
int gamefiles.cmd_msb (args)
 
int gamefiles.cmd_emevd (args)
 
 gamefiles.er_read_names (msg_dir)
 Read Elden Ring's own English item names out of an unpacked msg/engus.
 
int gamefiles.cmd_ernames (args)
 Regenerate db_er/'s item-name tables from the game's own FMGs.
 
int gamefiles.cmd_roster (args)
 Print the roster, compare it with the shipped table, optionally rewrite it.
 
int gamefiles.main ()
 

Variables

 gamefiles.BASE = Path(__file__).resolve().parent.parent
 
dict gamefiles.GAMES
 Per-game archive layout: which pairs exist, whose keys open them, which BHD5 shape.
 
dict gamefiles.HASH_PRIME = {"ds2": (37, 32), "ds3": (37, 32), "er": (0x85, 64)}
 The filename hash, per era.
 
int gamefiles.AES_BLOCK = 16
 AES block size, and so the granularity an encrypted range can be decrypted at.
 
str gamefiles.KEY_HELP
 
int gamefiles.OODLE_BLOCK = 0x40000
 Oodle's block length.
 
int gamefiles.OOZ_SLACK = 0x10000
 Slack on the Kraken output buffer.
 
 gamefiles._OOZ = None
 
 gamefiles.MODEL_SECTION
 Section names, from MSBS.cs.
 
 gamefiles.PARTS_SECTION
 Section names, from MSBS.cs.
 
 gamefiles.PART_ENEMY
 Part type ids from PartsParam.PartType.
 
 gamefiles.PART_DUMMY_ENEMY
 Part type ids from PartsParam.PartType.
 
dict gamefiles.PART_NAMES
 
 gamefiles.P_NAME_OFF
 Offsets inside a Part's base struct, and inside an enemy's type data.
 
 gamefiles.P_TYPE
 Offsets inside a Part's base struct, and inside an enemy's type data.
 
 gamefiles.P_MODEL_INDEX
 Offsets inside a Part's base struct, and inside an enemy's type data.
 
 gamefiles.P_ENTITY_DATA_OFF
 
 gamefiles.P_TYPE_DATA_OFF
 
 gamefiles.E_THINK_PARAM
 
 gamefiles.E_NPC_PARAM
 
 gamefiles.E_CHARA_INIT
 
 gamefiles.E_EVENT_FLAG
 
 gamefiles.E_EVENT_FLAG_STATE
 
dict gamefiles.MSBS_PARTS_VERSIONS = {0x21, 0x23}
 PARTS_PARAM_ST versions this reader's part struct is known to match (Sekiro).
 
 gamefiles.MINIBOSS_BAR
 The instructions that define a roster, and what each contributes.
 
 gamefiles.MINIBOSS_DEFEAT
 The instructions that define a roster, and what each contributes.
 
 gamefiles.BOSS_BAR
 
 gamefiles.BOSS_DEFEAT
 
 gamefiles.BOSS_BANNER
 
tuple gamefiles.AWARD_ITEM_LOT = (2003, 4)
 
tuple gamefiles.INIT_COMMON_EVENT = (2000, 6)
 Initialize Common Event — how a parameterised handler gets its real arguments.
 
dict gamefiles.ARG_TYPES
 EMEDF numeric type code -> (struct format, size).
 
dict gamefiles.LAYOUTS
 Argument layouts for the instructions this file reads, from the EMEDF.
 
tuple gamefiles.DS3_DEATH_TEMPLATES = (20005340, 20005341, 20005342, 20000343, 20005416, 20005061, 20005760)
 The Dark Souls III common_func templates that flag a one-time enemy death.
 
dict gamefiles.SDT_AREA_BY_MAP
 The travel-menu area a Sekiro entity id belongs to, for the shipped table's keys.
 
list gamefiles.SDT_AREA_ORDER
 The order areas are printed in: the game's own travel-menu order.
 
int gamefiles.DB_INDENT = 1
 Indent for a generated db_* table.
 
dict gamefiles.ER_NAME_FMGS
 The five item.msgbnd name tables that back a db_er/ file, and the category nibble Elden Ring's save ids carry on top of the bare param row id.
 
str gamefiles.ER_FMG_PLACEHOLDER = "[ERROR]"
 FromSoft's marker for a row that exists but carries no player-facing name.