 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Fri Jul 08, 2005 2:57 am Post subject: |
|
|
More progress...
TyRaNiD and I have worked out a way to load modules from user mode and have them resolve to syscalls - the caveat is that your initial program thread still must start in kernel mode.
The PSP's module loader looks at the calling thread's attributes to figure out what type of API the thread came from. If the thread attribute is 0x80000000 it knows it came from a user mode thread, if it's 0xc0000000 it knows it came from a VSH thread, and if it's 0xa0000000 it knows it came from a USB/WLAN API thread.
There's a ModuleMgr user library call named sceKernelLoadModuleBufferUsbWlan(), that will load a module from a buffer:
| Code: |
SceUID sceKernelLoadModuleBufferUsbWlan(SceSize len, void *buf, int flags, SceKernelLMOption *option);
...
SceKernelLMOption option;
memset(&option, 0, sizeof(option));
option.size = sizeof(option);
option.mpidtext = mpid;
option.mpiddata = mpid;
option.position = 0;
option.access = 1;
return sceKernelLoadModuleBufferUsbWlan(size, modbuf, flags, &option); // option can be NULL
|
The trick is that from your kernel mode program thread, you spawn another thread that has 0xa0000000 for it's thread attributes. This will fool the LoadModule call into thinking it's been called from the USB/WLAN API. The module buffer that you pass into sceKernelLoadModuleBufferUsbWlan() must be 64-byte aligned.
When we tested this (I tested with usbstor.prx) our user mode library stubs resolved to syscalls :). Unfortunately, in TyRaNiD's tests pspnet.prx crapped out SCE_KERNEL_ERROR_UNSUPPORTED_PRX_TYPE, but more testing is probably needed.
We're still working on a way to do all of this without ever needing kernel mode, but it's possible that you can only force that thread attribute if you're already in kernel mode (not confirmed yet). However it's a good start and we're looking at doing our own "bridge" module that can provide some kernel services from user mode. |
|
| Back to top |
|
 |
TRF-Yu-Ki
Joined: 08 Jun 2005 Posts: 15
|
Posted: Fri Jul 08, 2005 7:43 am Post subject: |
|
|
Whoa... I'm late to the party; thanks Psppet for the explaination & sample code! Well, with PSP doing network communication now..... I guess the world is at our finger-tips. =^) Has anyone seen the InfraRed API actually send out and receive stuff?
*Keyless-Entry into vehicles(that we legally own, of course).
*Garage Door opener?
*PSP telling you when Police-radars are around? LOL! This would be cool!
*PSP-Opticon(Traffic-Light controller http://www.skyoptics.com/How_Mirt_Works.htm)
*PSP-Barcode-scanner(I have no idea how this would be useful). _________________ Learning to hack is not bad in itself; it's what you do with your abilities that count. - a.k.a. Shadow-Me-Twice of ddrfreak.com |
|
| Back to top |
|
 |
Vampire
Joined: 12 Apr 2005 Posts: 138
|
Posted: Fri Jul 08, 2005 7:54 am Post subject: |
|
|
| TRF-Yu-Ki wrote: | | Has anyone seen the InfraRed API actually send out and receive stuff? |
yes, search for IrDA or SIRCS... |
|
| Back to top |
|
 |
Agoln

Joined: 08 Jun 2005 Posts: 326 Location: Fort Wayne, IN
|
Posted: Fri Jul 08, 2005 8:34 am Post subject: |
|
|
| PspPet wrote: | | Code: | | PSP_MAIN_THREAD_ATTR(0); |
|
Damn... 12 hours workin on this thing and it's that simple.
YOU DA MAN! _________________ Lego of my Ago! |
|
| Back to top |
|
 |
|
|
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
|