'Ejection' of Memory Stick

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

Moderators: cheriff, TyRaNiD

Post Reply
JumpR
Posts: 25
Joined: Sun Feb 10, 2008 1:07 am

'Ejection' of Memory Stick

Post by JumpR »

EDIT: Problem solved.

Hey,

I've been trying to get the game menu to recache for a while, and I've got it to work at random intervals. Below is the code I use to simulate an ejection and insertion of the memory stick.

Code: Select all

SceUID cbid = -1;

// Hook function (it's called from vshmain so syscall will do fine)
sctrlHENPatchSyscall(FindProc("sceThreadManager", "ThreadManForUser", 0xE81CAF8F), sceKernelCreateCallbackPatched);

// Patched function which stores callback id
int sceKernelCreateCallbackPatched(const char *name, SceKernelCallbackFunction func, void *arg) 
{
	int res = sceKernelCreateCallback(name, func, arg);
	u32 k1 = pspSdkSetK1(0);

	if (strcmp(name, "SceVshMediaDetectMS") == 0)
		cbid = res;

	pspSdkSetK1(k1);
	return res;
}

// Simulate an ejection and insertion event
if (sceKernelFindModuleByName("game_plugin_module"))
{
	sceKernelNotifyCallback(cbid, 2);
	sceKernelNotifyCallback(cbid, 1);
}
If you want me to be more exact, it only works if I execute the code right after I entered the game menu, and when it's still reading a file. This is a fraction of a second at which it works, which confuses me. Does anybody have any idea what's going on? I've also tried only ejecting it, but that doesn't work either, only on that fraction of a second.

I saw this post from Adrahil, which suggests me that it is possible. A different method to recache the game directory would also be greatly appreciated. I can't do a normal stop and unload module on game_plugin_module either, as that causes a crash.

Thanks in advance,
Bubbletune (JumpR)
Last edited by JumpR on Sun Nov 09, 2008 8:07 am, edited 1 time in total.
blu_eye4
Posts: 37
Joined: Sun Oct 26, 2008 8:41 pm

Post by blu_eye4 »

could you post all code? maybe memory card function is include only inside the function who declare your menu, i don't know i'am a noob ;) excuse me for my language, i'm italian :)
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

im not at home to test this, but i believe it can be done like boosters syscon hook sample. you can change the state of wlan, memory stick, buttons, even tamper the battery info at the lowest level before it reaches any other function call. it might be overkill for this purpose though.

also when registering the hook, i think you should also check for a previous hook and call that in your function so that it doesnt destroy a previous one (similar to sctrlHENSetStartModuleHandler)
Last edited by Torch on Wed Jun 17, 2009 3:32 pm, edited 1 time in total.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

i think memory stick is detected as a button press, so thats basically the root cause. might be overridable by hooking the scectrl_driver functions. if thats not possible then guess youll have to try the syscon hook. ex the hold button press can only be overridden before the ctrl function, or by patching the ctrl function to not ignore the other buttons. im noob at mips so i couldnt patch.
Post Reply