Repository navigation
Protocol CEC Message Boxes
A console keeps its StreetPass data in a CEC folder. Each title has a folder with an inbox and an outbox. ctrpass's own store uses the same layout, and ctrpass can copy messages into an emulator's copy of this folder. This page covers the files that make up the folder.
All integers are little-endian.
Implemented in: store, export::folder.
flowchart TD
cec["CEC/"] --> list["MBoxList____"]
cec --> t["00020800/ (title ID, 8 hex digits)"]
t --> info["MBoxInfo____"]
t --> name["MBoxData.010"]
t --> inbox["InBox___/"]
t --> outbox["OutBox__/"]
inbox --> ib["BoxInfo_____"]
inbox --> im["_xxxxxxxxxxx (one file per message)"]
outbox --> ob["BoxInfo_____"]
outbox --> om["_xxxxxxxxxxx"]
In an emulator's data folder the CEC folder sits at nand/data/<id>/sysdata/00010026/00000000/CEC.
The list of titles that have a box.
| Offset | Size | Field |
|---|---|---|
0x00 |
2 | Magic 0x6868 (hh) |
0x04 |
4 | 1 |
0x08 |
4 | Number of titles, at most 24 |
0x0c |
16 × 24 | Entries: the title ID as 8 ASCII hex digits, zero-padded to 16 bytes |
ctrpass writes lowercase hex digits and reads either case.
Per-title information.
| Offset | Size | Field |
|---|---|---|
0x00 |
2 | Magic 0x6363 (cc) |
0x04 |
4 | Title ID |
0x10 |
32 | Title signing key (HMAC-SHA256 key for the trailer), all zero when unset |
0x40 |
1 | Arrival flag, set to 1 when messages are delivered |
0x41 |
1 | Arrival flag, set to 1 when messages are delivered |
0x44 |
12 | Time of the last arrival, CEC timestamp |
The file is at least 0x60 bytes. ctrpass keeps any bytes it does not know. The two arrival flags make the game notice new messages; their separate meanings are not known.
The title's name, in UTF-16LE ending in a zero unit.
One per box. The header is 0x20 bytes:
| Offset | Size | Field |
|---|---|---|
0x00 |
2 | Magic 0x6262 (bb) |
0x04 |
4 | File size: 0x20 + 0x70 × count
|
0x08 |
4 | Largest total bytes the box holds |
0x0c |
4 | Bytes in use |
0x10 |
4 | Largest number of messages |
0x14 |
4 | Number of messages |
0x18 |
4 | Unknown |
0x1c |
4 | Largest size of one message, 0 for no limit |
On a console, the header is followed by the 0x70-byte container header of each message in the box, newest first.
ctrpass's own store writes a 0x20-byte BoxInfo with limits of 1 MiB and 24 messages and does not list the message headers. When delivering into another CEC folder, ctrpass reads the box's own limits and adds the new message's header at the front of the list.
Each message is stored whole, as its container bytes, in a file named after its message ID:
- Take the 8 message ID bytes in little-endian order.
- Encode them with base64, alphabet
A-Z a-z 0-9 + -, without padding. - Put
_in front.
The result is 12 characters: _ and 11 base64 characters.
When ctrpass delivers a message into a CEC folder as if it had arrived, it does what a receiving console does:
| Where | Change |
|---|---|
Container 0x36
|
Set to 1 (unopened) |
Container 0x37
|
Set to 1 (new) |
Container 0x48, 0x54
|
Set to the arrival time if all zero |
| BoxInfo | Header added at the front of the list; size, bytes in use and count updated |
| MBoxInfo | Bytes 0x40 and 0x41 set to 1, 0x44 set to the arrival time |
Before delivering, ctrpass checks that the title is in the folder's MBoxList____ and has an inbox, that the message is not already there, that it fits the box's limits, and that its trailer matches the folder's key for the title when there is one.
How to set up
- Overview and requirements
- Choosing a Wi-Fi adapter
- Building and installing
- Making the key file
- Desktop app
- Command line
- Messages and emulators
- Troubleshooting
Plugins
Protocol
- Overview
- Discovery
- Link setup
- Frames and CCMP
- YY transport
- Exchange flow
- Exchange objects
- CEC messages
- CEC message boxes
- Mii records
- Mii Plaza
- Keys
ctrpass library
Linux