Joonie86 / COBRA-7.3

63 stars 31 forks source link

Unload vsh plugins in reverse order #6

Closed jjolano closed 7 years ago

jjolano commented 7 years ago

Hey Joonie, is it possible to change the unloading of vsh plugins to be in reverse order (last to first)?

It's more of a personal request, but it's mainly for the purposes of some vsh plugins that may include exports for other vsh plugins. If the plugin that provides exported functions (that are used by other plugins loaded later) becomes unloaded first, it causes some sort of error which prevents the console from shutting down.

I briefly looked through the code and couldn't seem to find the unloading procedures (or i'm blind), so unfortunately I can't submit a patch for you.

... or maybe unloading in reverse order is the current behaviour and I'm coding things wrong? 😞

Joonie86 commented 7 years ago

https://github.com/Joonie86/COBRA-7.3/blob/master/481/REX/SRC/stage2/modulespatch.c#L1100

are you talking about this?

jjolano commented 7 years ago

I guess it's related to that, but it's mainly whatever calls that function when the PS3 is shutting down.

Here's a working example of what I mean: https://github.com/jjolano/openps3ftp/releases/tag/v4.2-prx

and then try the same steps again except unloading openps3ftp_prx_test.sprx before shutting down.

It's a bit weird how it works like this, but is it something to do with the PS3 itself?

Joonie86 commented 7 years ago

I haven't tested what you suggested, but normally for shutting down most homebrews use syscall 379 known as sm_shutdown

int sys_sm_shutdown(uint16_t op, const void * lpar_parameter, uint64_t parameter_size )

0x1100/0x100 = turn off, 0x1200 = Lv2 Hard Reboot, 0x200 = Lv2 Soft Reboot, 0x8201 = load lpar id 1 0x8202 = load lpar id 2 0x8204 = load lpar id 3 (PS2_NETEMU) HV System Manager access - ServiceID 1 (REQUEST)+ 10 (DELIVER INTER LPAR PARAMETER)

alternatively, you can use cobra opcode for cleaner shutdown via vsh_export https://github.com/Joonie86/COBRA-7.3/blob/master/481/REX/SRC/stage2/sm_ext.c