Page 1 of 1

hbl hook.c : Hook sceAudioOutput2GetRestSample

Posted: Tue Feb 21, 2012 9:48 pm
by wth
Hi,

currently adapting hbl to run on my 6.60 user exploit, it already loads a few homebrews pretty nicely (should work on vita too since vita apparently emulates 6.60, gonna try tomorrow hopefully)
but I still have some missing syscalls (since syscall estimation doesn't work on 6.60), like sceAudioOutput2GetRestSample which I need to hook somehow to avoid crashes

So I was wondering, anyone knows how to hook sceAudioOutput2GetRestSample using sceAudioGetChannelRestLength ? Is such a hook even possible ?

Edit:
Well apparently it must be possible, since there are only 8 channels I guess we'd just have to use sceAudioGetChannelRestLength on each one and return the sum of them all (assuming sceAudioOutput2GetRestSample returns the number of unplayed samples remaining on ALL channels). Gonna try this.
Edit2:
thx to biscottealacrevette for this link, but it still doesn't look so easy to hook properly, since we have no access to the SceAudio g_audio global in hbl <.<

Re: hbl hook.c : Hook sceAudioOutput2GetRestSample

Posted: Wed Feb 22, 2012 8:56 am
by m0skit0
That code looks like a kernel module (correct me if I'm wrong), so doesn't access to g_audio need kernel privileges?

Re: hbl hook.c : Hook sceAudioOutput2GetRestSample

Posted: Wed Feb 22, 2012 5:43 pm
by wth
m0skit0 wrote:That code looks like a kernel module (correct me if I'm wrong), so doesn't access to g_audio need kernel privileges?
Hm indeed I didn't even think of that
Well I guess it will stay a dirty hook then ^^'


// sceAudioOutput2GetRestSample lame hook (hopefully it's not super necessary)
int _hook_sceAudioOutput2GetRestSample()
{
int sum = 0, i, res;

for (i=0;i<PSP_AUDIO_CHANNEL_MAX;++i)
{
res = sceAudioGetChannelRestLength(i);
if (res >=0) sum+= res;
}


return sum;
}