LumaTeam / Luma3DS

Nintendo 3DS "Custom Firmware"
GNU General Public License v3.0
5.35k stars 559 forks source link

Adding ext: to layeredfs will also cause extdata to be redirected. #433

Closed PabloMK7 closed 7 years ago

PabloMK7 commented 7 years ago

Many games mount the extdata archive as extdata: Allowing ext: to be redirected (only checking the e) will also cause the extdata files to be redirected. This may cause problems in the case where some extdata and romfs files have the same name (extdata:/data.dat and rom:/data.dat for example). I'm researching the archive type, and it looks like *(archiveptr + 0x18) always is a pointer to the stack if the archive is a romfs archive. I'll need some help to fully understand how the archive type works, it's only a theory for now.

AuroraWright commented 7 years ago

The problem is that we are space constrained in the payload. The code and the folder path (currently lf:/luma/titles/0000000000000000/romfs where the titleid is inserted) currently are at 275 out of 284 max.

AuroraWright commented 7 years ago

I had an idea, I'll try implementing it

AuroraWright commented 7 years ago

https://github.com/AuroraWright/Luma3DS/commit/db33c315f2fc65938ed4ea53a630355076b64e27

AuroraWright commented 7 years ago

I had to revert in https://github.com/AuroraWright/Luma3DS/commit/1887c6fae3539200854b8c615932a1916d8fb591 because it broke animal crossing and possibly other games, so the issue is still open. Did you discover an easy way to detect RomFSes from fsTryOpenFile @mariohackandglitch?

PabloMK7 commented 7 years ago

That's the only pattern that I've seen all romfs archives follow (for now). You could also hook to the function that mounts romfs (as it's different than RegisterArchive but I guess that function calls it), but it's asm pattern is unknown. It's also unknown if that function is used by all games.

TuxSH commented 7 years ago

Could you provide the disasm of the function as well as the dump of the object, please?

PabloMK7 commented 7 years ago

I only know that function exists. Never had the opportunity to search it nor I have much asm knowledge. Here are some archive dumps for some games.

AuroraWright commented 7 years ago

I think the bug has finally been fixed (and any other conflicts that may arise) in https://github.com/AuroraWright/Luma3DS/commit/e231275cbe304b546d7793283a6738f3fe6ed1ca

PabloMK7 commented 7 years ago

How was it fixed? Also, from what I can see you should also add pat1:/ as MK7 uses that for the update romfs