XML title launching in gridlauncher

Discussion in '3DS - Homebrew Development and Emulators' started by mashers, Oct 27, 2015.

  1. mashers
    OP

    mashers Stubborn ape

    Member
    3,837
    5,153
    Jun 10, 2015
    Kongo Jungle
    Just tagging @suloku and @smealum in this thread.

    I don't use XML titles myself but am trying to get them working in gridlauncher as it's a frequently requested feature. I'm having a really difficult time working out what is actually different between gridlauncher and suloku's changes. The handling of title selection in the menu is completely different, so I added some logging just before the titles get booted at the end of main():

    Code:
    //Gridlauncher main.c
    
    int main() {
    
        // ...
    
        if(!strcmp(me->executablePath, REGIONFREE_PATH) && regionFreeAvailable && !netloader_boot) {
                logText("Region free boot");
            }
            else {
                logText(me->executablePath);
            }
       
            exitServices();
       
            if(!strcmp(me->executablePath, REGIONFREE_PATH) && regionFreeAvailable && !netloader_boot) {
                return regionFreeRun2(target_title.title_id & 0xffffffff, (target_title.title_id >> 32) & 0xffffffff, target_title.mediatype, 0x1);
            }
       
            regionFreeExit();
       
            return bootApp(me->executablePath, &me->descriptor.executableMetadata, NULL);
    }
    Code:
    //Suloku's launcher main.c
    
    int main() {
    
        // ...
    
        if(!strcmp(me->executablePath, REGIONFREE_PATH) && regionFreeAvailable && !netloader_boot){
                logText("Title boot");
            }
            else {
                logText(me->executablePath);
            }
    
        // cleanup whatever we have to cleanup
        netloader_exit();
        titlesExit();
        ptmExit();
        acExit();
        hidExit();
        gfxExit();
        closeSDArchive();
        exitFilesystem();
        aptExit();
        srvExit();
    
        //Title launching
        if(!strcmp(me->executablePath, REGIONFREE_PATH) && regionFreeAvailable && !netloader_boot){
            if (strlen(HansPath) > 0){
                regionFreeExit();
                return bootApp(HansPath, NULL, HansArg);
            }else{
                return regionFreeRun2(target_title.title_id & 0xffffffff, (target_title.title_id >> 32) & 0xffffffff, target_title.mediatype, 0x1);
            }
        }
       
        regionFreeExit();
       
        return bootApp(me->executablePath, &me->descriptor.executableMetadata, me->arg);
    }

    In both cases (with both launchers), if I run the Ironhax installer then I get the path to the Ironhax installer 3dsx show in the log. This means that bootApp is being called with the path to the 3dsx executable as its first parameter. I am using bootApp() from suloku's launcher boot.c as well (but passing NULL as the arg parameter as I haven't implemented HANS launching yet), so I can't see any difference between what the gridlauncher is doing and what Suloku's launcher is doing.

    Any help would be much appreciated!
     
    fiese_nase and nallar like this.
  2. suloku

    suloku GBAtemp Advanced Fan

    Member
    862
    491
    Apr 28, 2008
    I think the problem lies with the changes you made here (main.c):
    Code:
    else if(updateMenu(&menu))
    {
    menuEntry_s* me = getMenuEntry(&menu, menu.selectedEntry);
    if(me && !strcmp(me->executablePath, REGIONFREE_PATH) && regionFreeAvailable && !netloader_boot)
    {
    regionFreeUpdate();
    if (regionFreeGamecardIn) {
    break;
    }
    }else
    {
    // if appropriate, look for specified titles in list
    if(me->descriptor.numTargetTitles)
    {
    // go through target title list in order so that first ones on list have priority
    int i;
    titleInfo_s* ret = NULL;
    for(i=0; i<me->descriptor.numTargetTitles; i++)
    {
    launchSVDTFromTitleMenu();
    }
    if(ret)
    {
    targetProcessId = -2;
    target_title = *ret;
    break;
    }
    // if we get here, we aint found shit
    // if appropriate, let user select target title
    if(me->descriptor.selectTargetProcess){
    showSVDTTitleSelect();
    }
    else {
    /*
    XML titles
    */
    //If the title menu has not been loaded yet
    if (!titleMenuInitialLoadDone && !titlemenuIsUpdating) {
    //Force an updatae to the title menu and then break out of the main loop to boot the title
    updateTitleMenu(&titleBrowser, &titleMenu, "Preparing title", true, false);
    titleMenuInitialLoadDone = true;
    menuForceReturnTrue = true;
    // break;
    }
    //The title menu has been populated but there is still no matching title
    //Show an error
    else {
    hbmenu_state = HBMENU_TITLETARGET_ERROR;
    }
    }
    }else
    {
    if(me->descriptor.selectTargetProcess) {
    showSVDTTitleSelect();
    }
    else {
    break;
    }
    }
    }
    }
    
    You should revert to what smea's HBL does, adapting it to your new title structures.
     
    fiese_nase, kiwiis and VaiCorunthians like this.
  3. mashers
    OP

    mashers Stubborn ape

    Member
    3,837
    5,153
    Jun 10, 2015
    Kongo Jungle
    Thanks buddy! I'll take a look at what smea's launcher does as I can no longer remember. I'll give it a try and report back :)
     
    fiese_nase likes this.
  4. mashers
    OP

    mashers Stubborn ape

    Member
    3,837
    5,153
    Jun 10, 2015
    Kongo Jungle
    It works! Thank you my friend! I'm not entirely sure *why* it works, since the whole point of the code I added here was that loading the XML titles didn't work if the title list hadn't been opened at least once. But now it seems to work fine. Perhaps something to do with subsequent changes to the grid loading code. In any case, it seems to be working now as the Ironhax installer successfully completes. Thanks again pal! :)
     
    fiese_nase likes this.