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 

Some calls dont get hooked (in vsh mode) (solved)

 
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 Jun 16, 2009 8:09 pm    Post subject: Some calls dont get hooked (in vsh mode) (solved) Reply with quote

Hi, Im having hard time hooking some of the calls vsh modules import.

I wanted to do a simple test: with my vsh plugin print on the display the name of file that photo, music, video, etc.. players currently open,
so I looked up the imports of those modules here: http://silverspring.lan.st/5.00/index.html

So for example lets take module msvideo_main_plugin, imports are here: http://silverspring.lan.st/5.00/vsh/module/msvideo_main_pluginimp.xml
It clearly imports sceIoOpen() from IoFileMgrForUser, but when I hook that func, it never gets called.
(Im sure msvideo_main_plugin gets loaded when you enter video in XMB, I checked that)

My hooking generally works, I can hook the controller func for example without any problems... only those functons like IoFileMgr etc. are still a problem...

What am I missing?

Thanks for any help...
_________________
...sorry for my english...


Last edited by kralyk on Thu Jun 18, 2009 1:51 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: Tue Jun 16, 2009 9:53 pm    Post subject: Reply with quote

The problem seems to be that the address of the call is not found in syscall table.
I use this code:
Code:
void* pspGetSysCallAddr(u32 addr)
{
  SyscallHeader *head;
  u32 *syscalls;
  void **ptr;
  int size;
  int i;

  if (!addr) return NULL;

  asm(
    "cfc0 %0, $12\n"
    : "=r"(ptr)
  );

  if(!ptr)
  {
    return NULL;
  }

  head = (struct SyscallHeader *) *ptr;
  syscalls = (u32*)(*ptr + 0x10);
  size = (head->size - 0x10);

  for(i = 0; i < size; i++)
  {
    if(syscalls[i] == addr)
    {
      return &syscalls[i];
    }
  }

  return NULL;
}


the address of sceIoOpen is found as 0x880544d0 for me,
but pspGetSysCallAddr return 0 for this... =(
_________________
...sorry for my english...
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Tue Jun 16, 2009 11:16 pm    Post subject: Reply with quote

Those syscalls are already hooked by M33/other CFW in the VSH for creating the virtual PBPs for showing ISOs in the game menu. You can't hook them again without some extra work, since their entries in the syscall table will be replaced with the export from vshctrl.prx.

You can check the vshctrl.prx exports and identify which one is the hooked sceIoOpen etc and search for THAT address in syscall table and hook it. You must then call THAT function from your hook function instead of sceIoOpen etc so that you don't break the M33 hook.

The best thing in the long run is to have a managed chain of hooks. M33/CFW should export a chain type PatchSyscall function similar to sctrlHENSetStartModuleHandler where each hook must call the previous hook. All plugin developers should then use this new function to allow multiple hooks of the same syscall.


Last edited by Torch on Wed Jun 17, 2009 3:31 pm; 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: Tue Jun 16, 2009 11:56 pm    Post subject: Reply with quote

Thanks for all the information..

So when I cant find a syscall in syscall table it means its already hooked?
Because apart from IoFileMgr I also tried to hook some of the sceMpegVsh calls, but they could not have been found in syscalltable either...
Does CFW hook those as well? That'd be strange...
_________________
...sorry for my english...
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Wed Jun 17, 2009 12:15 am    Post subject: Reply with quote

kralyk wrote:
Thanks for all the information..

So when I cant find a syscall in syscall table it means its already hooked?
Because apart from IoFileMgr I also tried to hook some of the sceMpegVsh calls, but they could not have been found in syscalltable either...
Does CFW hook those as well? That'd be strange...


Yes if a function is a syscall and its address is not found in the table then it has been hooked (or module not loaded fully yet).

The sceMpeg* stuff are not syscalls. They are pure user function calls. To hook those look at Coldbird's user to kernel hook sample.
Back to top
View user's profile Send private message
kralyk



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

PostPosted: Wed Jun 17, 2009 1:37 am    Post subject: Reply with quote

Yes I read that tutorial by Coldbird, but Im afraid my func is ufortunatelly one of the unhookable ones, Ill try to figure out why...
Anyway, thanks for help...

EDIT: alright, I resolved the problem, the functions I need now get hooked ok.
Here's the link to Coldbird's sample in case someone came across this problem:
http://forums.ps2dev.org/viewtopic.php?t=11894
_________________
...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