| View previous topic :: View next topic |
| Author |
Message |
m0skit0
Joined: 02 Jun 2009 Posts: 226
|
Posted: Sun Mar 21, 2010 1:57 am Post subject: Unloading modules |
|
|
I would like to know if it's possible to call sceKernelStopModule and sceKernelUnloadModule over the main game module.
I tried sceKernelStopModule, but it crashes (throws an exception from SceModuleMgrStop thread). Also, I guess this one calls module_stop from the game itself, but unfortunately I don't know what args should be passed to module_stop.
Thus I think it can be stopped, because otherwise the function would just return an error, and also why have module_stop if it can't be stopped?
Also, can I stop a module from its own code or it must be from another module?
Also if you can link me to docs about what module attribute means, that would be great!
Thanks again for your time! _________________
| The Incredible Bill Gates wrote: | | The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers. |
|
|
| Back to top |
|
 |
Coldbird

Joined: 08 Feb 2007 Posts: 155
|
Posted: Sun Mar 21, 2010 5:45 am Post subject: |
|
|
Yes it is possible to unload oneself from memory.
I suggest you check the headers from the PSPSDK, especially the header of the modulemgr module. _________________ Been gone for some time. Now I'm back. Someone mind getting me up-2-date? |
|
| Back to top |
|
 |
m0skit0
Joined: 02 Jun 2009 Posts: 226
|
Posted: Sun Mar 21, 2010 6:44 am Post subject: |
|
|
Thanks for the reply. I checked pspmodulemgr.h but there's nothing new there.
I managed to get over the crash, but now it returns an error: SCE_KERNEL_ERROR_ILLEGAL_ARGUMENT.
I'm using this code:
| Code: | | ret = sceKernelStopModule(id, 0, NULL, &status, NULL); |
_________________
| The Incredible Bill Gates wrote: | | The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers. |
|
|
| Back to top |
|
 |
unsigned int
Joined: 13 Aug 2009 Posts: 22
|
Posted: Sun Mar 21, 2010 7:24 am Post subject: |
|
|
| I have a hard time understanding how a module could be able to stop itself. Even if sceKernelStopModule can stop the calling module, wouldn't this destroy the call stack of that function, so that it must crash when returning? |
|
| Back to top |
|
 |
m0skit0
Joined: 02 Jun 2009 Posts: 226
|
Posted: Sun Mar 21, 2010 10:43 am Post subject: |
|
|
Ok, maybe you're right, so that's why it gives that error about illegal argument (the module ID is wrong). I'll try sceKernelStopUnloadSelfModule
EDIT: this don't work either: SCE_KERNEL_ERROR_CAN_NOT_STOP _________________
| The Incredible Bill Gates wrote: | | The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers. |
|
|
| Back to top |
|
 |
willow :--)
Joined: 13 Jan 2007 Posts: 126
|
Posted: Sun Mar 21, 2010 11:16 am Post subject: |
|
|
m0skit0, this won't answer any of your questions, but it might help others to get a little bit more context:
Other functions using "Self" to unload the module itself apparently just find the modid based on ra, and then the code looks very similar to the other unload functions. So I'm guessing you get the crash/error even if you try with the "self" functions.
(note that for the "self" methods to work, the code that does the call has to be in the Ram boundaries of the module, since this is how the system detects which module you want to unload - and I believe you're not in the boundaries of the module you want to unload, so if you call the "self" methods, the system will not understand which module you are talking about)
By the way why are there 2 "self" unload methods ?
(Edit: in other words, I think the "Self" methods are just here for convenience when a module doesn't know its own id, but won't help much in your case)
Davee's reversed code of the module manager gives a bit of light on the whole process:
http://svn.lan.st/utopia/modulemgr.c
I think you get the error when dealing with the modMgr worker thread (spawning it or killing it ?), so (again looking at Davee's code on utopia, and assuming it's close enough to the real deal) I'd say the error happens somewhere in the "start_exe_thread" method. This method doesn't seem to return SCE_KERNEL_ERROR_ILLEGAL_ARGUMENT directly, but it seems like a "wide" error. Most likely the error comes from threadman.c ?
http://svn.lan.st/utopia/threadman/threadman.c
so I'm thinking the illegal arguments are the ones passed to the ModuleMgr threads, which is weird because all these arguments are pretty much computed for you :/
Anyways, it doesn't answer your questions, however I hope it gives hints at the kind of complexity you're dealing with, so that people don't foolishly reply "use Lua, it's easier". :) _________________ Wagic. Play that card game against an AI on your PSP |
|
| Back to top |
|
 |
Davee
Joined: 22 Jun 2009 Posts: 59
|
Posted: Sun Mar 21, 2010 9:59 pm Post subject: |
|
|
| You sure stop_module isn't returning 1? Also it might be worthwhile seeing where selfstop is called in the original code. As it may do some buffer de-allocations and stuff before hand. |
|
| Back to top |
|
 |
m0skit0
Joined: 02 Jun 2009 Posts: 226
|
Posted: Mon Mar 22, 2010 5:20 am Post subject: |
|
|
I think the problem is that I call that function from outside the module space address, so that's why it is crashing/not working. I need to keep my code running but unload the game module.
I got a couple of new ideas I'll try later, thanks for the answers guys, they helped a lot :D _________________
| The Incredible Bill Gates wrote: | | The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers. |
|
|
| Back to top |
|
 |
Coldbird

Joined: 08 Feb 2007 Posts: 155
|
Posted: Mon Mar 22, 2010 11:07 pm Post subject: |
|
|
Tried spawning a new thread for stopping your module already? _________________ Been gone for some time. Now I'm back. Someone mind getting me up-2-date? |
|
| Back to top |
|
 |
m0skit0
Joined: 02 Jun 2009 Posts: 226
|
Posted: Tue Mar 23, 2010 11:07 pm Post subject: |
|
|
Well yes, it's a separate thread, but anyway, it is stopped. _________________
| The Incredible Bill Gates wrote: | | The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers. |
|
|
| Back to top |
|
 |
|