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

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Hellcat
Posts: 83
Joined: Wed Jan 24, 2007 2:52 pm

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

Post by Hellcat »

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: Select all

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? :)
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

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.
Post Reply