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.
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?
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?