QUOTE said:
All handles or just the official ones? I mean would it not be possible to get IOS reload to just shut down the offical subsystems and the IOS init code to not touch anything to do with the dip module?
to load second dol, multidol game does:
1) loads some part of apploader into himem
2) apploader loads some other part of applader into lowmem
3) apploader in lowmem loads another apploader part into himem
4) apploader in himem loads target dol and run it.
5) loaded dol reinit whole system (IOS reload, IOS init)
I'm not sure why need so many reloads of apploader, but the game i've tried (Mortal Kombat, because its first dol is very simple to analyze) did this.
I think IOS init function doesn't provide full reinitializaiton and probably it can be called only ONCE, stright after IOS loading. Since second dol doesn't know anything about first one, it's impossible to re-use memory from first dol. So, all buffers and handles should be reinited.
I'm not sure if it's possible to full reinit in cIOS without reloading. Probably, no. Because IOS designed for "short" lifetime. System loads IOS with every new dol. Next dol can load the same IOS or another. So, IOS doesn't need to re-use itself. I will be not surprised if IOS removes some its code from memory after load (just to free more memory for application) and thus simple unable to do full reinitialization without reloading.
So, most correct way is to let cIOS reload itself and then re-open selected earlier ISO.
I think, cIOS can find several bytes (8-12 bytes are enough) in memory which is not touched by IOS loading procedure and any (ok, "any of multidol" is enough) game, put gameID and USB/SD flag there along with checksumm. After that reloads itself. In IOS init (or more suitable) function add code which will check this memory against checksumm and if it ok, grab gameID and USB/SD flag and then re-open selected game.
That's my idea. It's simple and should work in theory at 100%.
Implementation probably will not be so easy, but i'm sure it's possible.