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 

Finding a Driver (in mem) and it's functionlist

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



Joined: 24 Jan 2007
Posts: 84

PostPosted: Sat Feb 09, 2008 7:41 pm    Post subject: Finding a Driver (in mem) and it's functionlist Reply with quote

Hi there.

I want to find/locate a driver (MS, for example) in the memory during runtime and it's functions list.

Reasons are that for one project I want to call functions of the driver that don't have wrappers in the usual sceIo....() functions - at least not to my knowledge. (IoInit() would be one) - and for another app, I'd like to hook some (like done when doing flash-over-USB, but for something else).

I already have this snippet, which I also have successfully used:
Code:
PspIoDrv *FindDriver(char *drvname)
{
  u32 *mod = (u32 *)sceKernelFindModuleByName("sceIOFileManager");

  if (!mod)
  {
    return NULL;
  }

  u32 text_addr = *(mod+27);

  u32 *(* GetDevice)(char *) = (void *)(text_addr+0x16D4);
  u32 *u;

  u = GetDevice(drvname);

  if (!u)
  {
    return NULL;
  }

  return (PspIoDrv *)u[1];
}


But due to the hardcoded offsets this only works on 1.50 - but I'd like my stuff running on every FW.... well at least 3.xx CFWs.

So, I need a more generic way of finding the driver and it's functions list.


Anyone be willing to hint me into the right direction? :)
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Sat Feb 09, 2008 8:49 pm    Post subject: Reply with quote

CFW exports the function sctrlHENFindDriver that does what you want. (and thus, you don't need to use specific text_addr that differ between firmware versions). Given a driver name (without ":"), it will return a pointer to it (or NULL if no found).

Note that although the function can be called from user mode too, the returned pointer can only be manipulated by kernel code.
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