exefs - ExeFS reader

The exefs module enables reading application executable filesystems.

ExeFSReader objects

class pyctr.type.exefs.ExeFSReader(fp, *, fs=None, closefd=True, _load_icon=True)[source]

Bases: TypeReaderBase

Reads the contents of the ExeFS, found inside NCCH containers.

The contents typically include .code, icon, and banner. For titles released before System Menu 5.0.0-11, logo can also one of the contents, otherwise logo has a dedicated NCCH section.

The other notable use of an ExeFS is GodMode9’s essentials backup, which can include the files frndseed, hwcal0, hwcal1, movable, nand_cid, nand_hdr, otp, and secinfo.

.code can sometimes be compressed which is indicated in the NCCH Extended Header. When decompressed, a new entry called .code-decompressed is added.

If icon is found, it is loaded into an SMDH object.

Parameters:
  • fp (FilePathOrObject) – A file path or a file-like object with the CCI data.

  • closefd (bool) – Close the underlying file object when closed. Defaults to True for file paths, and False for file-like objects.

  • fs (Optional[FS]) –

  • _load_icon (bool) –

icon: SMDH | None

The icon info, if one is in the ExeFS.

entries: Dict[str, ExeFSEntry]

Entries in the ExeFS.

open(path, *, normalize=True)[source]

Open an entry in the ExeFS for reading.

Parameters:
  • path (str) – Name of the entry. Can start with / or end in .bin.

  • normalize (bool) – Remove / and .bin from the path.

Returns:

A file-like object that reads from the entry.

decompress_code()[source]

Decompress ‘.code’ in the container. The result will be available as ‘.code-decompressed’.

Returns:

If ‘.code’ was actually decompressed.

Return type:

bool

Data classes

class pyctr.type.exefs.ExeFSEntry(name, offset, size, hash)[source]
Parameters:

Functions

pyctr.type.exefs.decompress_code(code)[source]

Decompress the given code. This is called by ExeFSReader.decompress_code(), and you should probably use that instead if you are loading the code from an ExeFS.

Parameters:

code (bytes) –

Return type:

bytes

Exceptions

exception pyctr.type.exefs.ExeFSError[source]

Generic exception for ExeFS operations.

exception pyctr.type.exefs.ExeFSFileNotFoundError[source]

File not found in the ExeFS.

exception pyctr.type.exefs.InvalidExeFSError[source]

Invalid ExeFS header.

exception pyctr.type.exefs.ExeFSNameError[source]

Name could not be decoded, likely making the file not a valid ExeFS.

exception pyctr.type.exefs.BadOffsetError[source]

Offset is not a multiple of 0x200. This kind of ExeFS will not work on a 3DS.

exception pyctr.type.exefs.CodeDecompressionError[source]

Exception when attempting to decompress ExeFS .code.