The situation:
The golf games load network modules for adhoc mode. Everybody's Golf is an old game and therefore doesn't use sceUtilityLoadModule to do this, but loads the files manually via sceKernelLoadModule. The network modules are user mode modules and kernel modules. HBL can unload the user modules, but the kernel modules remain in memory (sceNet_Service and sceNetAdhocAuth_Service).
Because of this the utility module PSP_MODULE_NET_COMMON cannot be loaded by HBL and network functions are broken for homebrew started through it.
What I tried:
- Unload the network modules with sceUtilityUnloadModule. This doesn't work, the function returns the error code indicating that the utility was not loaded.
- Unload the kernel modules through PSPLink. After that network functions work like normal. I think custom firmware allows homebrew to unload kernel modules with sceKernelUnloadModule, but OFW doesn't. So this is not very helpful.
- Not unload the sceNet module and hope that the other utility modules (PSP_MODULE_NET_INET etc) reuse the common module in memory.
Turns out they don't. The kernel doesn't resolve imports from sceNet and sceNet_Library. Instead the stubs for sceNet and sceNet_lib are filled with this:
Code: Select all
0x0883299C: 0x0000054C 'L...' - syscall 0x15
0x088329A0: 0x00000000 '....' - nop- Not unload the sceNet module and resolve the imports of the other network modules through HBL.
This seems possible, but the problem is that the version of sceNet_Library loaded by the golf game is not the one from the firmware, but from the UMD (apparently loaded from "umd0:/PSP_GAME/USRDIR/module/module/pspnet.prx").
It is an ancient version that only has 8 exports for sceNet and 96 for sceNet_lib (5.50 has 14 and 133 exports). Because of that not all functions can be resolved. Calling sceNetInetInit() crashes in sceNetInet_Library, looks like a NULL pointer. But I don't expect this to work because of the missing exports anyway.
What seems promising:
Unload the sceNet module and load the firmwares version from "flash0:/kd/pspnet.prx". This is possible on CFW when using sceKernelLoadModule, but OFW forbids loading the module from flash. So it has to be loaded through HBL, but I have not tried this yet. For this the module must be copied from flash0 to the memory stick and must be decrypted.
Resolving the stubs of sceNet_lib requires the imports from
- sceKernelLibrary. It is loaded to user memory and therefore all exports are known, but they are not yet resolvable through HBL. The easiest way to add this user mode library is to create a fake utility module id for it and then handle it like the other user mode utility modules. The other option is to add a special case for libraries that are neither utility modules nor kernel modules exporting syscalls.
- sceNetIfhandle. This one is kernel mode and not all syscalls can be resolved from the imports of Everybody's Golf. Maybe a problem, this could make the network functions unstable on firmwares without perfect syscall estimation.
Advertising