Hacking What's the difference between a game and a homebrew?

fuyukaidesu

Well-Known Member
OP
Newcomer
Joined
Mar 2, 2015
Messages
51
Trophies
0
Age
123
XP
765
Country
France
Hello.
I'm experimenting modding a game, and came across some weird behavior.

I wrote this very simple homebrew.
It uses the special fat device exposed by d2x's cIOS to create a file.

Code:
    ...
    int fatfd = IOS_Open("fat", 3);

    int p = 0;
    ioctlv args[] = {
        {&p, sizeof(p)}
    };
    ret = IOS_Ioctlv(fatfd, IOCTL_FAT_MOUNT_SD, 1, 0, args);

    args[0].data = "0:/test";
    args[0].len = strlen(args[0].data);
    ret = IOS_Ioctlv(fatfd, IOCTL_FAT_MKFILE, 1, 0, args);

    int logfd = IOS_Open("fat0:/test", 3);
    IOS_Seek(logfd, 0, 2);
    IOS_Write(logfd, "test\n", 10);
    ....

This of course doesn't work as is if you run it through the homebrew channel, as the homebrew channel loads by default with IOS 58. as you need to reload the correct IOS (with IOS_ReloadIOS(249) for example).

So from there I tried to get this homebrew to run from USBLoaderGX, by loading it over another game's DOL, and using USBLoaderGX setting to choose the starting IOS slot (249).
However, despite IOS_GetVersion telling me I'm indeed running on IOS249, IOS_Open fails with an error value. Which means that an IOS is loaded, but it doesn't understand the request.
If I IOS_ReloadIOS(249), then it works (even with BlockIOSReload turned on), but that's what I'm trying to avoid doing.
Looking at USBLoaderGX's source code, the only notable thing it does before jumping to the entry point is calling __IOS_ShutdownSubsystems, which in turn just closes the ES and STM file descriptors, but simply opening them again doesn't seem enough for these syscalls to work, it's like I HAVE to reload IOS.

Basically, my question is the following: are games expected to reload IOS, or is it the sysmenu responsibility? In that case, why am I unable to communicate with the cIOS through IPC?
 

cyberstudio

Member
Newcomer
Joined
Dec 2, 2020
Messages
17
Trophies
0
Age
53
XP
108
Country
Canada
Does this run as a homebrew outside of usb loader gx?

CIOS has lots of smarts to detect if you are a game or a homebrew. That's called stealth mode.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • K3Nv2 @ K3Nv2:
    I'll reformat and have a 3tb raid0 m. 2 at least
    +1
  • K3Nv2 @ K3Nv2:
    Lmao that sold out fast
    +1
  • Veho @ Veho:
    Yeet the cat.
    +1
  • K3Nv2 @ K3Nv2:
    Good idea
    +1
  • The Real Jdbye @ The Real Jdbye:
    i thought everybody knew cocktails are like 75% ice
  • Veho @ Veho:
    Yeah but not like this.
  • Veho @ Veho:
    It's not like they're complaining that their Slurpee is 99% ice or something, but if the cocktail calls for "shot of vodka, shot of vermouth, shot of gin, shot of Campari, three shots of juice, squirt of lemon" and ends up being a thimbleful of booze, that's a problem.
  • The Real Jdbye @ The Real Jdbye:
    the funny thing is cocktails in norway are only allowed to have 1 20ml shot of booze
  • The Real Jdbye @ The Real Jdbye:
    so..... yeah
  • The Real Jdbye @ The Real Jdbye:
    we're used to only having a thimbleful of booze
  • Veho @ Veho:
    Booo.
  • The Real Jdbye @ The Real Jdbye:
    same thing if you want whisky on the rocks or something, you can't get a double
  • The Real Jdbye @ The Real Jdbye:
    but you could buy as many shots of whisky (or anything else) as you want and ask for a glass of ice and pour them in
  • The Real Jdbye @ The Real Jdbye:
    it's dumb
  • Veho @ Veho:
    Maybe.
  • Veho @ Veho:
    There was a comparison of the number of Ibuprofen poisonings before and after they limited the maximum dosage per box or per pill (i'll look that up). No limit on the number of boxes you can still buy as many as you want, so people argued it was pointless.
  • Veho @ Veho:
    But the number of (accidental) poisonings dropped because drinking an entire package of ibuprofen pills went from "I need a new liver" to "I need a new box of Ibuprofen".
  • Veho @ Veho:
    Here we have ketoprofen that used to be prescription-only because of the risk of toxic dosages, but then they halved the dose per pill and sell them in bottles of six pills apiece instead of twenty and it doesn't need a prescription any more. Yes you can buy more than one bottle but people simply don't.
  • Psionic Roshambo @ Psionic Roshambo:
    Usually accidentally overdose of ibuprofen here is from people taking like cold medicine then ibuprofen for a headache and the combination is over what they need
    Veho @ Veho: https://imgur.com/gallery/QQkYnQu