- Joined
- Mar 26, 2016
- Messages
- 1,365
- Trophies
- 1
- Location
- ↑↑↓↓←→←→BA
- Website
- github.com
- XP
- 2,287
- Country
Sort of a suggestion to homebrew devs, and I also want to pick some other developers' brains on standards.
Right now, many A9LH-based CFWs need to know their location via a path changer and a static string within the program itself. Mostly for re-calling the payload via reboot patches.
Using a path changer is messy for multiple reasons, including:
* Not user friendly when using a boot manager.
* Requires a string search which is a heuristic and can't necessarily be relied upon to be found in every program, and not always stored the same in it (char -> wchar_t conversion, arm9loaderhax.bin / arm9loaderhax_si.bin) as well as the possibility of overwriting an unrelated string.
I propose that we switch over to using argc/argv passing, ideally stored after the arm9loaderhax payload somewhere in FCRAM. Then, payloads could simply use argv[0] to get their own path.
I'm aware that I'm asking a lot. I don't expect anyone to do anything really, so this is more a suggestion. I just feel that it would be a much cleaner solution.
It would allow not only argument passing but would obsolete path changers entirely, provide saner ways to enable and disable features...because it would allow calling programs like any other program on Linux, Windows, etc.
I've personally implemented this into my CFW's chainloader. Take that as you will. Trashing r0 and r1 will work the same as before, regardless, because a no-argument main function doesn't check the arguments.
EDIT: For a summary of what is involved in this, see my start.s file here: https://raw.githubusercontent.com/chaoskagami/corbenik/master/source/start.s
It only requires saving r0 and r1 not to be trashed by the MPU setup, and reloading the registers prior to main.
Right now, many A9LH-based CFWs need to know their location via a path changer and a static string within the program itself. Mostly for re-calling the payload via reboot patches.
Using a path changer is messy for multiple reasons, including:
* Not user friendly when using a boot manager.
* Requires a string search which is a heuristic and can't necessarily be relied upon to be found in every program, and not always stored the same in it (char -> wchar_t conversion, arm9loaderhax.bin / arm9loaderhax_si.bin) as well as the possibility of overwriting an unrelated string.
I propose that we switch over to using argc/argv passing, ideally stored after the arm9loaderhax payload somewhere in FCRAM. Then, payloads could simply use argv[0] to get their own path.
I'm aware that I'm asking a lot. I don't expect anyone to do anything really, so this is more a suggestion. I just feel that it would be a much cleaner solution.
It would allow not only argument passing but would obsolete path changers entirely, provide saner ways to enable and disable features...because it would allow calling programs like any other program on Linux, Windows, etc.
I've personally implemented this into my CFW's chainloader. Take that as you will. Trashing r0 and r1 will work the same as before, regardless, because a no-argument main function doesn't check the arguments.
EDIT: For a summary of what is involved in this, see my start.s file here: https://raw.githubusercontent.com/chaoskagami/corbenik/master/source/start.s
It only requires saving r0 and r1 not to be trashed by the MPU setup, and reloading the registers prior to main.
Last edited by chaoskagami,