"Deferred" syscall hook

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

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

"Deferred" syscall hook

Post by jean »

Before someone comes up shouting that's certainly a piracy related issue, i have to say it is not. I'm not referring to a particular case because i have 2 or 3 different projects that may need this.
I have to perform the following task:
hook functions of a module not normally loaded into memory (i.e. applications will load it when needed) and i only need it when a certain application is running (but i don't really care if this continues working when app is already exited). I had the following ideas:
1) (from prx plugin) keep checking if module has been loaded in a poll-and-wait cycle, then patch it
2) (from prx plugin) load the module and patch it, then leave it _always_ in memory for apps requiring it
3) (from prx plugin) first patch the sceUtility function used to load modules, then in the patched function perform a check: if module to load is the module we have to patch, load it and patch it.
4) (from eboot.pbp) load the required module, patch it and then load the second eboot/iso app. On exit, module can be unloaded (maybe sceKernelExitGame(); should be patched as well)

I see every method has pros and cons, so i would like some advices before i start a two months coding session and finally realize that it was the wrong method X(
First two methods are quick-and-dirty, the first consumes CPU while the second wastes a small amount of RAM. 3 is a real mess (and i can't swear it will work because i'm not sure on how the application loads the module); 4 seems to be the finer, but i had to deal with the eboot/iso loader hell....

Has something like this been already done? (of course yes, but i mean: something i can look into...) What method would you choose if you had to do something like this?? thanks in advance.

jean
alexp
Posts: 39
Joined: Tue Apr 17, 2007 12:06 am

Post by alexp »

I'm trying to do something really similar and until now i've tried the first two approach, the first one is too much dependent on timing issues. I've had some problem with the second approach too because trying to load a vsh module from a kernel mode prx result in an illegal permission error. If i load such module from seplugins using CF functionality it seems that the game will then load a second instance of the module, so overriding the patch.
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

seems that the game will then load a second instance of the module, so overriding the patch
S**T!! It was the most simple solution (and hence one of the first i was to check :P )
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

The modern CFs have a hook function which will be called when ever a module is loaded, at which point you can patch it. I don't recall the function, "USE THE SEARCH"!
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

"USE THE SEARCH"
Ok, ok...Sorry about it, but i don't even know how such a feature could be called (in fact i invented the "deferred hook" definition) and i did take a look into sdk before asking...This is not one of the "how can i sum two integer numbers?" questions we're reading here nowadays, i think you can save your voice for that :P
Thanks anyway
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

sctrlHENSetStartModuleHandler(SceModule2 *mod)
This is the functions TyraNid was speaking about....but the point is it's not working.... I'm trying to find the very moment an app is trying to access a usb device. I tryed logging modules loaded for instance by deniska while starting up usbgps.prx or the xmb starting up go!cam...
sceUsbStart(...) eventually does not depend upon the same functions loading standard modules....
Post Reply