Skip to content

3DS Link 1.0.12

Choose a tag to compare

@gionko gionko released this 01 Nov 10:47
· 14 commits to main since this release

Mario Tennis Open is played between consoles. A fix for HOME on the Old 3DS (not tried on one). A change so that LEGO Batman 2 also starts with 3DS Link switched off (not tried).

Tried on the owner's consoles: Mario Tennis Open (Europe copy, two New Nintendo 2DS XL, several modes and several matches, no problems: 9/10) and SEGA 3D Classics Collection (Altered Beast, 2 consoles, 10/10). Not tried on any Old 3DS or Old 2DS: the fix for HOME was written from Luma3DS's source and tested on a PC only. The change for LEGO Batman 2 with the main switch off was not tried either. Scores and setups: Tested games.

At a glance

Game or area Before Now Since
Mario Tennis Open, local wireless the game said the Wi-Fi switch was off the plugin provides the Download Play lobby inside the room, as for the Kirby games, with the console's own friend code seed in it; played between two consoles 1.0.12
Old 3DS: pressing HOME with the plugin enabled closed the game a fix, not tried on an Old 3DS 1.0.12
LEGO Batman 2 with the main switch off by reading the code, the framework still stopped the game at launch (never seen on a console) the plugin rewrites the stub whatever the switch 1.0.12 (not tried)

Install

Put 3DSLink.cia on your console and install it with FBI (or 3DSLink.3dsx in /3ds/ for the Homebrew Launcher). Needs Luma3DS; for the Azahar room, Luma3DS 13.3 or newer with the Plugin Loader enabled (see the README). Then open 3DS Link once and wait for "You can close 3DS Link.": the app puts the plugin in the folders of the games you switched on.

File Size SHA-256
3DSLink.cia 1748416 bytes 6e4bb2db7412300a9465f96c0da9547937fc5109c2a4295bf1fcef55536b22a6
3DSLink.3dsx 2429052 bytes 3713324b5e96598da6f0dc26dbc8272d645c3074faaf5e8bbc09b8f4c1e4d200

Not fixed

What Notes
Monster Hunter XX closes when a multiplayer match starts (Old 3DS) reported by users: issue 3, issue 2
Mario Tennis Open, USA copy on an Old 3DS: "the Wi-Fi switch is off" after the online option issue 2: not confirmed fixed, not tried on an Old 3DS (the Europe copy plays between two New 2DS XL)
The power button closes the game on an Old 3DS reported in issue 2; it is not known whether the fix for HOME covers it
Pac-Man & Galaga Dimensions, Ridge Racer 3D, Ocarina of Time 3D close at launch (0xE0A01839) on one console (a New 3DS XL): Known limits
Balloon Fight (Virtual Console) closes at startup the plugin framework aborts in Virtual Console games: a known limit

Technical notes

Mario Tennis Open: why it needed the lobby, and the friend code seed

The lobby. The game's local multiplayer scene starts the Download Play client at once (Initialize, GetMyStatus every 5 ms, GetChannels, a scan, a join) and, for the player who hosts, the Download Play server. 3DS Link replaces the wireless services, so the real service answered "wireless off" and the game showed its message about the Wi-Fi switch. The game is now one of the titles of kDlpGames that get the Download Play lobby inside the room (the one made for the Kirby games).

What the first try showed. With the lobby alone, the match was found and the match type could be chosen, but at the character selection nothing loaded on either console. Reading the game's memory with Luma's debugger showed both consoles inside the game's own synchronisation: the host waits until the number of players with a valid id, minus one, equals the number of "ready" messages it received. Its table of players held the guest with the right name and id 0. The game keeps the players of the lobby in a table and, when its own network starts, zeroes their ids and gives each one back by comparing the friend code seed of the lobby with the seed of the player's nwm::UDS node. The lobby used a seed made by the plugin (a hash of the console's MAC), while the game gives nwm::UDS the console's real seed (it reads it from config block 0x00090000, 8 bytes, just before Initialize), so the comparison never matched.

What the plugin does now. For this game only, it reads that config block at start and announces it as the lobby's seed. The table is kDlpGames in AzaharLink/Sources/ctr/plugin.cpp: the Europe copy 000400000007C800 was tried; the USA 000400000007C700, Japan 0004000000064D00 and Taiwan 00040000000B9100 ids come from catalogues and were never seen on a console. The Kirby games, which work with the hash, are unchanged. With the debug log on, the line dlp: the lobby's friend code seed is the console's own tells that it happened (it prints the console's friend code seed: do not post it); WARNING: cannot read the console's friend code seed says the block could not be read.

Old 3DS: the fix for HOME (not tried on an Old 3DS)

Why the game fell. On an Old 3DS, Luma saves the plugin's memory to a file and frees its 5 MiB when the game goes to the HOME menu. The kernel raises that event on the game's own thread, at the end of its APT:ReceiveParameter, and that thread sleeps in the kernel until the swap is finished. If the system call was made by the plugin's hook, the thread wakes up in memory that is no longer there (the crash of the report: PC in svcSendSyncRequest, LR in the plugin's hook).

What the plugin does. On an Old 3DS only, and right after a HOME seen (10 s window), that one call returns to its call site and the game makes the system call from its own code. At the start of the swap all the call sites go back to the game and the threads already inside the hook are waited for (up to 1.5 s; Luma gives 10). At its end the sites re-enter the hook. On a New 3DS nothing of this happens (there is no swap event). The cost for every call of the game is a counter and a comparison.

What was checked, and what was not. The logic of the sites, the real entry assembly in an ARM11 emulator and the compiled plugin were tested on a PC, with ThreadSanitizer and mutants. Not checked: that Luma behaves on a real console as its source says (read, not run), what the other threads of the game do in the short time between the start of the swap and the suspension, and that the game's APT session is always the one the plugin tracks. If it does not hold, the behaviour stays the one of before (the game closes). With the debug log on, a successful HOME shows hook swap: ... call sites given back, then SWAP_EXIT.

LEGO Batman 2 with the main switch off, and the bound test

With the main switch off, Luma still loads the plugin, the framework ran and stopped the game. The rewrite of the stub (see 1.0.11) now runs before the hooks whatever the switch; it reads the game's .text and writes one word. In the search, stub + 8 > end could overflow for a bl aimed at 0xFFFFFFFC (never seen in a game); the test is now stub > end - 8 and AzaharLink/Tests/gsp_wrapper_test.cpp tries six targets around the top of the address space.

About the files of this release

3DSLink.cia is the very file that was tried on the consoles (same bytes); 3DSLink.3dsx was built in the same run, from the same plugin, and was not installed on its own. SEGA 3D Classics Collection was tried on an earlier build of 1.0.12, before the Mario Tennis Open change, which only touches that game's four title ids.