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 

vshctrl (vshmenu) + hooking vshCtrlReadBufferPositive

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



Joined: 28 May 2008
Posts: 842

PostPosted: Thu Oct 23, 2008 1:44 am    Post subject: vshctrl (vshmenu) + hooking vshCtrlReadBufferPositive Reply with quote

While patching syscall to vshCtrlReadBufferPositive, the M33 VSHMenu doesn't work anymore, obviously.

I see this function in vshctrl.h
int vctrlVSHRegisterVshMenu(int (* ctrl)(SceCtrlData *, int));

Is this useful to have menu working while calling your own patched function or what? I don't understand how to use it.

I just need to modify the original pad_data.
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Thu Oct 23, 2008 2:36 am    Post subject: Reply with quote

EDIT...
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Thu Oct 23, 2008 7:43 am    Post subject: Reply with quote

That function is to register a VSH menu, it is not useful for anything else.
Basically satelite.prx (vshmenu) needs to register itself using that function.

Your patch destroys M33 one

Code:

SceModule2 *mod = sceKernelFindModuleByName("sceVshBridge_Driver");

if (!config.novshmenu)
{
   MAKE_CALL(mod->text_addr+0x264, sceCtrlReadBufferPositivePatched);
   PatchSyscall(FindProc("sceController_Service", "sceCtrl", 0x1F803938), sceCtrlReadBufferPositivePatched);
}   


Well, you could still do something, patch sceCtrlReadBufferPostive function directly by getting his address using sctrlHENFindFunction, and patching two first instructions to cause a jump+nop to your function. Once in your function, you would have to restore original two insturctions to call it, and then patch it again.

Since that aproach is very innefeicient, the best is to have a third function written in asm that has as two first instructions the same two first instructions as sceCtrlReadBufferPositive, and as third/four instructionsa jump to sceCtrlReadBufferPositive+8. In this way you would call that third function each time you want to call original sceCtrlReadBufferPositive.
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Thu Oct 23, 2008 1:48 pm    Post subject: Reply with quote

moonlight wrote:

Your patch destroys M33 one

Code:

SceModule2 *mod = sceKernelFindModuleByName("sceVshBridge_Driver");

if (!config.novshmenu)
{
   MAKE_CALL(mod->text_addr+0x264, sceCtrlReadBufferPositivePatched);
   PatchSyscall(FindProc("sceController_Service", "sceCtrl", 0x1F803938), sceCtrlReadBufferPositivePatched);
}   



Since the M33 one hooks sceCtrl function, I just changed my module to call original vshCtrl function from my patched function to get the original pad_data instead of calling original sceCtrl one, now VSHMenu is working.

How ever I'd like to know about the ASM patch. Do I just declare the function like this and call it or what?
Code:
int sceCtrlReadBufferPositive_Loader(SceCtrlData *pad_data, int count)
{
asm("original 2 instructions here
     jump to +8");
}


And for patching the 2 instructions in original function like this?
Code:
void * addr = sctrlHENFindFunction(....)
addr[0] = 0xXX; (hex bytes here)
addr[1] = 0xXX;
addr[2] = 0xXX;
addr[3] = 0xXX;
....
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