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
756
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
  • No one is chatting at the moment.
    Psionic Roshambo @ Psionic Roshambo: https://www.youtube.com/watch?v=BjK2lPBzGzo