forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

My plugin crashes

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
kralyk



Joined: 06 Apr 2008
Posts: 114
Location: Czech Republic, central EU

PostPosted: Tue Nov 25, 2008 8:36 am    Post subject: My plugin crashes Reply with quote

Hi,
Im trying to make a vsh plugin,
but it crashes the PSP when I load a game from XMB (its not unloaded correctly?)

the code:
Code:
int module_stop(void)
{
  sceKernelTerminateDeleteThread(mainthread);
  sceKernelSelfStopUnloadModule(1, 0, NULL);
  return 0;
}


int module_start(SceSize args, void *argp)
{
   mainthread = sceKernelCreateThread("My__Plugin", pluginMain, 6, 0x4000, 0, NULL);
   if (mainthread >= 0)
   {
    sceKernelStartThread(mainthread, args, argp);
   }

   return 0;
}


Exports:
Code:
PSP_BEGIN_EXPORTS

PSP_EXPORT_START(syslib, 0, 0x8000)
PSP_EXPORT_FUNC(module_start)
PSP_EXPORT_FUNC(module_stop)
PSP_EXPORT_VAR(module_info)
PSP_EXPORT_END

PSP_END_EXPORTS


Thanks for any help!
_________________
...sorry for my english...
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Tue Nov 25, 2008 9:07 am    Post subject: Reply with quote

You shouldn't use sceKernelSelfStopUnloadModule(1, 0, NULL); in module_stop.

That would return an error, since your module is already being stoped. Anyways, I don't know if this is reason enough for the crash, there maybe other reason.
Back to top
View user's profile Send private message
kralyk



Joined: 06 Apr 2008
Posts: 114
Location: Czech Republic, central EU

PostPosted: Tue Nov 25, 2008 9:50 am    Post subject: Reply with quote

Ok, I removed that, but still crashes (in fact crashes even with module_stop just returning 0)

Here is the pluginMain function:
Code:
int pluginMain(SceSize args, void *argp)
{
  SceCtrlData pad;

  sceKernelDelayThread(10*100000);

  sceCtrlSetSamplingCycle(0);
  sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);

  while (1)
  {
    sceCtrlPeekBufferPositive(&pad, 1);
    if ((pad.Buttons & PSP_CTRL_SQUARE) && (pad.Buttons & PSP_CTRL_LTRIGGER))
    {
      blit_string(30, 27, "HELLO WORLD!", 0xffffffff, 0x0);
    };

    if(sceKernelFindModuleByName("msvideo_plugin_module"))
    {
      blit_string(30, 30, "Video player loaded.", 0xffffffff, 0x0);
    }

    sceDisplayWaitVblankStart();
  }
  return 0;
}

_________________
...sorry for my english...
Back to top
View user's profile Send private message
kralyk



Joined: 06 Apr 2008
Posts: 114
Location: Czech Republic, central EU

PostPosted: Wed Nov 26, 2008 1:16 am    Post subject: Reply with quote

No idea?
Maybe someone could tell me about some open source plugin (besides piKey) which I could look into source of ......?

I dont have any experience making vsh plugins and I cant find any open source ones... =(
_________________
...sorry for my english...
Back to top
View user's profile Send private message
ne0h



Joined: 21 Feb 2008
Posts: 386

PostPosted: Wed Nov 26, 2008 3:42 am    Post subject: Reply with quote

Add a short delay in the while cycle, sceKernelDelayThread(1000) is enough...

Last edited by ne0h on Wed Nov 26, 2008 5:12 am; edited 1 time in total
Back to top
View user's profile Send private message
kralyk



Joined: 06 Apr 2008
Posts: 114
Location: Czech Republic, central EU

PostPosted: Wed Nov 26, 2008 4:32 am    Post subject: Reply with quote

wow thanks ne0h that did help.
So I guess the loop was too tight...
I though sceDisplayWaitVblankStart(); would be enough but apparently not...
thanks.
_________________
...sorry for my english...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group