Some sceNet / sceHttpInit usage questions

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

Moderators: cheriff, TyRaNiD

mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

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: Select all

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.
TRF-Yu-Ki
Posts: 15
Joined: Wed Jun 08, 2005 1:27 pm

Post by TRF-Yu-Ki »

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
Vampire
Posts: 138
Joined: Tue Apr 12, 2005 8:16 am

Post by Vampire »

TRF-Yu-Ki wrote:Has anyone seen the InfraRed API actually send out and receive stuff?
yes, search for IrDA or SIRCS...
User avatar
Agoln
Posts: 326
Joined: Wed Jun 08, 2005 3:14 am
Location: Fort Wayne, IN

Post by Agoln »

PspPet wrote:

Code: Select all

PSP_MAIN_THREAD_ATTR(0);
Damn... 12 hours workin on this thing and it's that simple.

YOU DA MAN!
Lego of my Ago!
Post Reply