Welcome! Log In Create A New Profile

Advanced

Check If Channel

Posted by shardrillMorden 
Check If Channel
May 18, 2009 05:33PM
How can I make an application check if it's been installed as a channel.

I have two projects I'm working on, one of which I want to abort if it has been installed as a channel, and another that if it is installed as a channel should load a static configuration file that is installed as part of the channel.

How would I go about doing these two tasks? Is it as simple as using the ISFS_ function calls?

Also, for the channel, is there a way to retrieve that channels TitleID via code?

If this post violates a forum rule, I apologize and feel free to delete it.
Re: Check If Channel
July 03, 2009 01:53AM
I've been using this little snippet from snes9x to check it. Just have int HBC=0; then this and HBC will be 1 if this app was launched from there.
	#ifdef HW_RVL

    char * sig = (char *)0x80001804;
    if(
        sig[0] == 'S' &&
        sig[1] == 'T' &&
        sig[2] == 'U' &&
        sig[3] == 'B' &&
        sig[4] == 'H' &&
        sig[5] == 'A' &&
        sig[6] == 'X' &&
        sig[7] == 'X')
        HBC=1; // Exit to HBC
    #endif
It loadmii also makes HBC=1. Launching this app via forwarder channel or installed channel both leave HBC=0;. I haven't tested out any other methods so I can't say how it will respond, but it works well enough for me. Check the snes9x or usbloader gx code because we also have a check that isn't just for this stub if you want to go that way.
Re: Check If Channel
July 03, 2009 08:40AM
One could use the channles loader stub to leave a hint in memory.
Re: Check If Channel
July 04, 2009 09:01AM
Another idea: if you don't have a fake SuperUser status for your app, it should only be able to enter the title directory of your channel.
One might probe all title directories.

Granted, that's more like a hack....
Re: Check If Channel
July 04, 2009 10:52AM
If you just want to distinguish between being started from HBC or being started from HBC, and don't care about other booting methods, then just look if the app was started with a loader you can return to. That can be checked with one easy if.

I use this code very often:
if (*(u32*)0x80001800) exit(0);
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);

This returns to loader if possible and reboots the Wii else. Hope this helps.
Re: Check If Channel
July 04, 2009 03:19PM
Because it's guaranteed that the memory address will be zero and not some random value. Oh, wait, it's not.
Re: Check If Channel
July 07, 2009 01:45PM
According to the memory map at WiiBrew:
0x8000318C 4 0x00000000 Title Booted from NAND (Launch Code)
Re: Check If Channel
August 24, 2009 11:15AM
Quote
giantpune
I've been using this little snippet from snes9x to check it. Just have int HBC=0; then this and HBC will be 1 if this app was launched from there.
	#ifdef HW_RVL

    char * sig = (char *)0x80001804;
    if(
        sig[0] == 'S' &&
        sig[1] == 'T' &&
        sig[2] == 'U' &&
        sig[3] == 'B' &&
        sig[4] == 'H' &&
        sig[5] == 'A' &&
        sig[6] == 'X' &&
        sig[7] == 'X')
        HBC=1; // Exit to HBC
    #endif
It loadmii also makes HBC=1. Launching this app via forwarder channel or installed channel both leave HBC=0;. I haven't tested out any other methods so I can't say how it will respond, but it works well enough for me. Check the snes9x or usbloader gx code because we also have a check that isn't just for this stub if you want to go that way.

I don't find this code in loader GX! In wich file can i find it?
In fact, i've created a dol loader and the loader gx can't return to it (i haven't the option displayed, so i think the loader GX doesn't detect my stub). I wan't to investigate to check if i can make my dol loader more compatible.
Re: Check If Channel
September 02, 2009 11:40AM
That was in the promptwindows file. Not sure if it still is there, as I did some remodeling and feng shui when I started putting in the stuff about channel launching. Look in revisions before it could browse channels and it will surely be there. You can also check out the titlebrowser file is recent revs. it lists the installed titles on the wii, with the help of code i borrowed from ATD. (not all titles, but i think it will find what you are looking for). then compare the installed titles with whatever ID you want to give your app is one way to do it. but this is assuming that your app will only have 1 ID.
Re: Check If Channel
September 03, 2009 12:11AM
Can't you just check on argc/argv?

Won't they by 0/empty if launched from a channel, but it launched from the HBC, argv[0] will contain the full path to the dol/elf??



Edited 1 time(s). Last edit at 09/03/2009 12:11AM by pembo.
Sorry, only registered users may post in this forum.

Click here to login