Documenting PSP Library Imports

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

Moderators: cheriff, TyRaNiD

Post Reply
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Documenting PSP Library Imports

Post by TyRaNiD »

For lack of a better place to put it I am starting this thread so that known library imports can be documented. These should be legally (if that is possible) extracted, basically DO NOT copy&paste from the SDK or similar. Of course this is really going to be a grey area but I don't think there is alot we can do about it as without these imports the psp will be kinda useless :P

Oh and try and at least work out what the functions are, we can all just read numbers in a hex editor :)

So I will start the ball rolling, these are in nem format (thx nem ;)) so if you have checked out the helloworld source it should be fairly obvious.

Controller Library

Code: Select all

-= imports =-

	STUB_START	"sceCtrl",0x40010000,0x00030005
	STUB_FUNC	0x6a2774f3,CtrlInit
	STUB_FUNC	0x1f4011e6,CtrlSetAnalogMode
	STUB_FUNC	0x1f803938,CtrlRead
	STUB_END

-= Function Prototypes =-

/* Index for the two analog directions */
#define CTRL_ANALOG_X	0
#define CTRL_ANALOG_Y	1

/* Button bit masks */
#define CTRL_SQUARE		0x8000
#define CTRL_TRIANGLE	0x1000
#define CTRL_CIRCLE		0x2000
#define CTRL_CROSS		0x4000
#define CTRL_UP			0x0010
#define CTRL_DOWN		0x0040
#define CTRL_LEFT		0x0080
#define CTRL_RIGHT		0x0020
#define CTRL_START		0x0008
#define CTRL_SELECT		0x0001
#define CTRL_LTRIGGER	0x0100
#define CTRL_RTRIGGER	0x0200

/* Returned control data */
typedef struct _ctrl_data
{
	u32 frame;
	u32 buttons;
	u8  analog[4];
	u32 unused;
} ctrl_data_t;

/* Not 100% sure on this, init with 0 */
void CtrlInit(int unknown);
/* Pass 1 to enable analogue mode */
void CtrlSetAnalogMode(int on);
/* Read in the controller data. Unknown should be set to 1 */
void CtrlRead(ctrl_data_t* paddata, int unknown);
MrFreeze
Posts: 1
Joined: Sat May 07, 2005 10:45 pm

Post by MrFreeze »

Some more ... also worth noting that the function id appears to be the first 32 bits of SHA1 over the original function name.

Code: Select all

STUB_START     "IoFileMgrForUser",0x40010000,0x00030005  
STUB_FUNC     0xb29ddf9c,IoDopen
STUB_FUNC     0xe3eb004c,IoDread
STUB_FUNC     0xeb092469,IoDclose  
STUB_END  

enum {
    TYPE_DIR=0x10,
    TYPE_FILE=0x20 
};

struct dirent {
    u32 unk0;
    u32 type;
    u32 size;
    u32 unk[19];
    char name[0x108];
};

int IoDopen(const char *fn);
int IoDread(int fd, struct dirent *de);
void IoDclose(int fd);
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Re: Documenting PSP Library Imports

Post by mrbrown »

TyRaNiD wrote: Controller Library

Code: Select all

-= imports =-

	STUB_START	"sceCtrl",0x40010000,0x00030005
	STUB_FUNC	0x6a2774f3,CtrlInit
	STUB_FUNC	0x1f4011e6,CtrlSetAnalogMode
	STUB_FUNC	0x1f803938,CtrlRead
	STUB_END

/* Not 100% sure on this, init with 0 */
void CtrlInit(int unknown);
/* Pass 1 to enable analogue mode */
void CtrlSetAnalogMode(int on);
/* Read in the controller data. Unknown should be set to 1 */
void CtrlRead(ctrl_data_t* paddata, int unknown);
Please, let's not go through this again .. leave the "sce" on the function name, as there's no point in stripping it. You are calling into sceCtrlInit(), not providing an open source clone called CtrlInit(). This is no different than Win32 programming, say in WINE or mingw32.
blackdroid
Posts: 564
Joined: Sat Jan 17, 2004 10:22 am
Location: Sweden
Contact:

Post by blackdroid »

Have to second that, lets not make the same mistake we did with ps2sdk, keep the sce prefix. its just a name, but a useful one :)
Kung VU
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Marcus, there was no symbols where I got it from, I do not even know the _proper_ name for it. I suppose I could brute force it :P What would be the point of calling it sceCtrlInit if it wasn't actually called that, and doing a hash on all 3 of those names indicates that they are definetly _not_ called what I named them :)

Of course if you want me to just tag all functions with sce which come from the kernel I guess it makes some sense :P
Last edited by TyRaNiD on Sun May 08, 2005 1:35 am, edited 1 time in total.
Vampire
Posts: 138
Joined: Tue Apr 12, 2005 8:16 am

Post by Vampire »

yes, please leave the "sce" on the function name...
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

I apologize, I had assumed you got them from wherever folks are getting symbols these days :). nem had posted some lists elsewhere with the sce prefix on the sceCtrl imports. ooPo, is it alright to copy those into here so we don't duplicate work?
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Oki few more for fun, these will include sce prefixes as they match the hashes :P

Code: Select all

-= Imports =- 
	STUB_START	"IoFileMgrForUser",0x40010000,0x00050005
	STUB_FUNC	0x6a638d83,sceIoRead
	STUB_FUNC	0x42ec03ac,sceIoWrite
	STUB_FUNC	0x27eb27b8,sceIoLseek
	STUB_FUNC	0x810c4bc3,sceIoClose
	STUB_FUNC	0x109f50bc,sceIoOpen
	STUB_FUNC	0xF27A9C51,sceIoRemove
	STUB_FUNC	0x6A70004,sceIoMkdir
	STUB_FUNC	0x1117C65F,sceIoRmdir
	STUB_FUNC	0x54F5FB11,sceIoDevctl
	STUB_FUNC	0x779103A0,sceIoRename

-= Function Definitions =-

#define O_RDONLY    0x0001
#define O_WRONLY    0x0002
#define O_RDWR      0x0003
#define O_NBLOCK    0x0010
#define O_APPEND    0x0100
#define O_CREAT     0x0200
#define O_TRUNC     0x0400
#define O_NOWAIT    0x8000

int sceIoOpen(const char* file, int mode);
void sceIoClose(int fd);
int sceIoRead(int fd, void *data, int size);
int sceIoWrite(int fd, void *data, int size);
int sceIoLseek(int fd, int offset, int whence);
int sceIoRemove(const char *file);
int sceIoMkdir(const char *dir, int mode);
int sceIoRmdir(const char *dir);
int sceIoRename(const char *oldname, const char *newname);
int sceIoDevctl(const char *name int cmd, void *arg, size_t arglen, void *buf, size_t *buflen);

BIG NOTE:

I cannot as of yet work out how to create new files on the memstick, almost seems like it is locked unless you call something to unlock it. This means you cannot create new files although you can create an empty one from the PC and then open and truncate and then write to it. Very strange. This affects the mkdir/rmdir/rename etc as well.
Orion_
Posts: 69
Joined: Thu Jan 27, 2005 8:47 am

Post by Orion_ »

you find all this by reversing the bios code ? o_O
amazing.
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

mrbrown: I don't mind, but you should check with nem just to be sure.
lmx
Posts: 25
Joined: Fri Apr 01, 2005 6:23 pm

Post by lmx »

looks scarily like official sdk library call names to me, maybe use notscehonestgodIoOpen()
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

From this thread, if you had read carefully:
Please, let's not go through this again .. leave the "sce" on the function name, as there's no point in stripping it. You are calling into sceCtrlInit(), not providing an open source clone called CtrlInit(). This is no different than Win32 programming, say in WINE or mingw32.
Have to second that, lets not make the same mistake we did with ps2sdk, keep the sce prefix. its just a name, but a useful one :)
yes, please leave the "sce" on the function name...
The reasoning and general acceptance of using sce prefixes.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

*bump* :P

Anyway a couple more useless ones, and no I don't know the official names so please do not ask.

Code: Select all

	STUB_START	"sceSuspendForUser",0x40000000,0x00020005
	STUB_FUNC	0xEADB1BD7,"DisableSuspend"
	STUB_FUNC	0x3AEE7261,"EnableSuspend"
	STUB_END

/* Parameters unknown for these functions, set to 0 */

/* Disable the suspend facility */
void DisableSuspend(int param);
/* Enable the suspend facility, if someone tried to suspend it during the disable period it will immediately suspend */
void EnableSuspend(int param);

Vampire
Posts: 138
Joined: Tue Apr 12, 2005 8:16 am

Post by Vampire »

some library names:

Code: Select all

IoFileMgrForUser
Kernel_Library
LoadExecForUser
ModuleMgrForUser
StdioForUser
SysMemUserForUser
ThreadManForUser
UtilsForUser
sceAtrac3plus
sceAudio
sceCtrl
sceDisplay
sceGe_user
sceLibFont
sceHttp
sceMpeg
sceNet
sceNetAdhoc
sceNetAdhocctl
sceNetAdhocMatching
sceNetApctl
sceNetInet
sceNetResolver
sceOpenPSID
sceParseHttp
sceParseUri
scePower
sceRtc
sceSasCore
sceSsl
sceSuspendForUser
sceUmdUser
sceUtility
sceWlanDrv
Pikoro
Posts: 56
Joined: Thu Jan 13, 2005 9:57 am

Post by Pikoro »

This could all be dumped into the wiki... http://wiki.psphacks.net that was created because someone in #pspdev on irc requested it.

*shrugs* might make it all a little easier to read
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Also stickied. It's too bad we can't merge this with the 'Library function list' thread.
Vampire
Posts: 138
Joined: Tue Apr 12, 2005 8:16 am

Post by Vampire »

TyRaNiD wrote:I cannot as of yet work out how to create new files on the memstick, almost seems like it is locked unless you call something to unlock it. This means you cannot create new files although you can create an empty one from the PC and then open and truncate and then write to it. Very strange. This affects the mkdir/rmdir/rename etc as well.
sceIoMkdir(dir, 0777);
sceIoOpen(path,O_CREAT|O_WRONLY|O_TRUNC, 0777)
loser
Posts: 25
Joined: Mon Feb 07, 2005 10:27 am
Contact:

Post by loser »

sceIoOpen("ms0:/myfile.txt", O_CREAT|O_RDWR|O_TRUNC, 0777)

works fine for me
Arwin
Posts: 426
Joined: Tue Jul 12, 2005 7:00 pm

Post by Arwin »

Wouldn't it be better to just unsticky this and the other function thread now that we have http://svn.pspdev.org ?
Post Reply