SceLibKernel

From Vita Development Wiki
Jump to navigation Jump to search

SceLibKernel, not to be confused with Kernel is a user module that implements wrappers to some common syscalls (for example, SceIofilemgr), some usermode standard library functions (including C standard library), and other common features like heap management. This module is the functionality similar to libc.so.6 on Linux.

Module

This is a usermode module and exists only in usermode. The SELF can be found in os0:us/libkernel.suprx.

Version World Privilege
1.00-3.73 Non-secure User

Libraries

Known NIDs

Version Name World Privilege NID
1.69-3.60 SceLibKernel Non-secure User 0xCAE9ACE6
1.69-3.60 SceLibRng Non-secure User 0xF9AC7CF8
1.69-3.60 SceLibGcc Non-secure User 0x567AF9A6
1.69-3.60 SceLibSsp Non-secure User 0x8FA98EF1
1.69-3.60 SceRtabi Non-secure User 0xA941943F
1.69-3.60 SceKernelForVM Non-secure User 0xA2B3EA8F
3.60 SceKernelForMono Non-secure User 0x5FEEA076

SceLibKernel

SceLibKernel_12D11F65

Version NID
0.930 0x12D11F65
3.60 not present
int SceLibKernel_12D11F65(SceUID mutex_id);

SceLibKernel_10A4976F

Version NID
0.930 0x10A4976F
3.60 not present

Official name is near of "CondVar::Signal".

SceBool SceLibKernel_10A4976F(int a1);

SceLibKernel_FD295414

Version NID
0.930 0xFD295414
3.60 not present

Official name is near of "CondVar::Delete".

SceBool SceLibKernel_FD295414(int *a1);

sceIoChstatAsync

Version NID
3.60 0x9739A5E2

derived from SceIofilemgr _sceIoChstatAsync

sceIoChstat

Version NID
3.60 0x29482F7F

sceIoChstatByFd

Version NID
3.60 0x6E903AB2

sceIoClose

Version NID
3.60 0xF5C6F098

derived from SceIofilemgr sceIoClose

sceIoDevctlAsync

Version NID
3.60 0x950F78EB

derived from SceIofilemgr _sceIoDevctlAsync

sceIoDevctl

Version NID
3.60 0x04B30CB2

sceIoDopen

Version NID
3.60 0xA9283DD0

sceIoDread

Version NID
3.60 0x9C8B6624

sceIoGetstatByFd

Version NID
3.60 0x57F8CD25

sceIoGetstatAsync

Version NID
3.60 0x82B20B41

derived from SceIofilemgr _sceIoGetstatAsync

sceIoGetstat

Version NID
3.60 0xBCA5B623

sceIoIoctlAsync

Version NID
3.60 0x099C54B9

derived from SceIofilemgr _sceIoIoctlAsync

sceIoIoctl

Version NID
3.60 0x54ABACFA

sceIoLseekAsync

Version NID
3.60 0xCAC5D672

derived from SceIofilemgr _sceIoLseekAsync

sceIoLseek

Version NID
3.60 0x99BA173E

sceIoMkdirAsync

Version NID
3.60 0x8E5FCBB1

derived from SceIofilemgr _sceIoMkdirAsync

sceIoMkdir

Version NID
3.60 0x9670D39F

sceIoOpenAsync

Version NID
3.60 0x6A7EA9FD

derived from SceIofilemgr _sceIoOpenAsync

sceIoOpen

Version NID
3.60 0x6C60AC61

sceIoPreadAsync

Version NID
3.60 0xA010141E

derived from SceIofilemgr _sceIoPreadAsync

sceIoPread

Version NID
3.60 0x52315AD7

sceIoPwriteAsync

Version NID
3.60 0xED25BEEF

derived from SceIofilemgr _sceIoPwriteAsync

sceIoPwrite

Version NID
3.60 0x8FFFF5A8

sceIoRead

Version NID
3.60 0x713523E1

derived from SceIofilemgr sceIoRead

sceIoRemoveAsync

Version NID
3.60 0x446A60AC

derived from SceIofilemgr _sceIoRemoveAsync

sceIoRemove

Version NID
3.60 0xE20ED0F3

sceIoRenameAsync

Version NID
3.60 0xEE9857CD

derived from SceIofilemgr _sceIoRenameAsync

sceIoRename

Version NID
3.60 0xF737E369

sceIoRmdirAsync

Version NID
3.60 0x9694D00F

derived from SceIofilemgr _sceIoRmdirAsync

sceIoRmdir

Version NID
3.60 0xE9F91EC8

sceIoSyncAsync

Version NID
3.60 0xF7C7FBFE

derived from SceIofilemgr _sceIoSyncAsync

sceIoSync

Version NID
3.60 0x98ACED6D

sceIoWrite

Version NID
3.60 0x11FED231

derived from SceIofilemgr sceIoWrite

sceIoCompleteMultiple

Version NID
3.60 0xA792C404

derived from SceIofilemgr _sceIoCompleteMultiple

sceKernelPrintBacktrace

Version NID
3.60-3.65 0x1C02A434

This is maybe a guessed name.

Wrapper to sceKernelPrintBacktraceForProcess.

/**
 * Prints call frames to STDOUT - does NOT perform a backtrace
 *
 * @return SCE_OK on success, < 0 on error
 *
 * @param pCallFrame Pointer to an array of filled up call frames
 * @param numFrames Number of frames in the buffer pointed to by pCallFrame
 */
SceInt32 sceKernelPrintBacktrace(SceKernelCallFrame* pCallFrame, SceUInt32 numFrames);

sceKernelPrintBacktraceForProcess

Version NID
3.60-3.65 0x20E2D4B7

This is a guessed name.

/**
 * Prints call frames to STDOUT - does NOT perform a backtrace
 *
 * @return SCE_OK on success, < 0 on error
 *
 * @param pid ?Process ID to operate under? - only SCE_KERNEL_PROCESS_ID_SELF or result of sceKernelGetProcessId is accepted
 * @param pCallFrame Pointer to an array of filled up call frames
 * @param numFrames Number of frames in the buffer pointed to by pCallFrame
 */
SceInt32 sceKernelPrintBacktraceForProcess(SceUID pid, SceKernelCallFrame* pCallFrame, SceUInt32 numFrames);

sceKernelBacktrace

Version NID
3.60-3.65 0x894037E8

Wrapper to SceKernelModulemgr#_sceKernelBacktrace.

SceInt32 sceKernelBacktrace(SceUID threadId, SceKernelCallFrame *pCallFrameBuffer, SceSize numBytesBuffer, SceUInt32 *pNumReturn, SceInt32 mode);

sceKernelBacktraceSelf

Version NID
3.60-3.65 0xD16C03B0
/**
 * Performs a walk back in the call stack and returns obtained stack frames.
 *
 * @return Call stack depth or SCE_OK on success, < 0 on error
 *
 * @param pCallFrameBuffer Pointer to an array of call frames that will recieve information
 * @param numBytesBuffer Number of bytes in the buffer pointed to by pCallFrameBuffer
 * @param pNumReturn Pointer to a variable that will obtain the actual number of call frames filled up
 * @param mode Specify SCE_KERNEL_BACKTRACE_MODE_USER - you can also specify the SCE_KERNEL_BACKTRACE_MODE_DONT_EXCEED option with a logical OR
 * @note Specifying SCE_KERNEL_BACKTRACE_MODE_DONT_EXCEED stops processing when the call frame buffer is filled up - SCE_OK is returned instead of call stack depth
 */
SceInt32 sceKernelBacktraceSelf(SceKernelCallFrame *pCallFrameBuffer, SceSize numBytesBuffer, SceUInt32 *pNumReturn, SceInt32 mode);

sceSblGcAuthMgrAdhocBB160UniCastDecrypt

Version NID
3.60 0x01E00CBF

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrAdhocBB160UniCastDecrypt.

sceKernelPuts

Version NID
0.902-3.60 0x023EAA62

Dummy function in FW 3.60.

int sceKernelPuts(const char* str);

sceKernelGetLibraryVariableAddress

Version NID
3.60 0x0A4DF821

Temp name was sceKernelGetModuleVariableByNID.

Gets variable address by NID.

Calls SceKernelModulemgr#_sceKernelGetLibraryInfoByNID.

Usage:

extern char _NID_libName[]; /* dummy array '_NID_libName' is ABS symbol in libName_stub.a */
extern char _NID_varName[]; /* dummy array '_NID_varName' is ABS symbol in libName_stub.a */

#define NAME2NID(name)   (unsigned int)(_NID_ ## name)

#define libName_GetVariableAddress(modid, varname, ptr) \
   sceKernelGetLibraryVariableAddress((modid),\
                NAME2NID(libName),\
                NAME2NID(varname),\
                (void **)(ptr))
int sceKernelGetLibraryVariableAddress(SceUID modid, SceNID libnid, SceNID var_nid, void **pVarAddr);

sceKernelLinkFunctionTable

Version NID
3.60 0xBEF71602

Temp name was sceKernelGetModuleFunctionsByNID.

Sets functions table for a module.

Calls SceKernelModulemgr#_sceKernelGetLibraryInfoByNID.

Usage:

typedef int (*funcName_t)(int a1);

extern char _NID_libName[]; /* dummy array '_NID_libName' is ABS symbol in libName_stub.a */
extern char _NID_funcName[]; /* dummy array '_NID_funcName' is ABS symbol in libName_stub.a */

#define NAME2NID(name)   (unsigned int)(_NID_ ## name)

typedef struct libName_Functions_table {
    funcName_t funcName;
} libName_Functions_table;

SceNID libName_nid_table[] = {
    NAME2NID(funcName),
};

#define _ARRAY_SIZE(array) (sizeof(array)/sizeof(array[0]))

#define libName_LinkFunctionTable(modid, table) \
   sceKernelLinkFunctionTable((modid),\
                NAME2NID(libName),\
                _ARRAY_SIZE(libName_nid_table), libName_nid_table,\
                (void **)(table))
int sceKernelLinkFunctionTable(SceUID modid, SceNID libnid, SceUInt32 nNID, const SceNID *pNids, void **pEntries);

sceKernelUnlinkFunctionTable

Version NID
3.60 0x70867F93

Temp name was sceClibBzeroWords.

This function only does sceClibMemset(pNids, 0, nNID << 2);.

Usage:

extern char _NID_libName[]; /* dummy array '_NID_libName' is ABS symbol in libName_stub.a */

#define NAME2NID(name)   (unsigned int)(_NID_ ## name)

#define libName_UnlinkFunctionTable_test(modid, table) \
   sceKernelUnlinkFunctionTable((modid),\
                NAME2NID(libName),\
                _ARRAY_SIZE(libName_nid_table),\
                (void **)(table))
int sceKernelUnlinkFunctionTable(SceUID modid, SceNID libnid, SceUInt32 nNID, const SceNID *pNids);

sceSblGcAuthMgrAdhocBB224Auth3

Version NID
3.60 0x104D802F

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrAdhocBB224Auth3.

sceSblGcAuthMgrPkgVry

Version NID
3.60 0x12C7CD2B

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrPkgVry.

sceSblGcAuthMgrMsSaveBBMacInit

Version NID
3.60 0x1693032E

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrMsSaveBBMacInit.

sceSblGcAuthMgrAdhocBB160Auth2

Version NID
3.60 0x1F4DF829

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrAdhocBB160Auth2.

sceSblGcAuthMgrAdhocBB224Auth1

Version NID
3.60 0x211BEDE8

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrAdhocBB224Auth1.

sceSblGcAuthMgrMsSaveBBCipherInit

Version NID
3.60 0x2E05B2DC

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrMsSaveBBCipherInit.

SceLibKernel_35D20E49

Version NID
3.60 0x35D20E49

It does not seem to call any imported function.

SceLibKernel_37F4ED04

Version NID
3.60 0x37F4ED04

It does not seem to call any imported function.

SceLibKernel_91FA6614

Version NID
3.00 not present
3.60 0x91FA6614

Temp name was sceKernelUnlockLwMutex.

It does not seem to call any imported function.

SceLibKernel_120AFC8C

Version NID
3.60 0x120AFC8C

Temp name was sceKernelUnlockLwMutex2.

It does not seem to call any imported function.

sceSblGcAuthMgrAdhocBB160Auth5

Version NID
3.60 0x3B595E1D

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrAdhocBB160Auth5.

sceKernelUnlockLwMutex

Version NID
3.60 0x499EA781

Wrapper to SceKernelThreadMgr#_sceKernelUnlockLwMutex.

sceSblGcAuthMgrAdhocBB224Auth5

Version NID
3.60 0x4AC7EFC9

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrAdhocBB224Auth5.

sceSblGcAuthMgrMsSaveBBCipherUpdate

Version NID
3.60 0x56A59D4F

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrMsSaveBBCipherUpdate.

sceSblGcAuthMgrPsmactCreateC1

Version NID
3.60 0x622A81E6

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrPsmactCreateC1.

sceSblGcAuthMgrAdhocBB160Auth4

Version NID
3.60 0x6314CAA3

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrAdhocBB160Auth4.

sceSblGcAuthMgrAdhocBB224Auth4

Version NID
3.60 0x65126005

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrAdhocBB224Auth4.

SceLibKernel_6C7365C4

Version NID
3.60 0x6C7365C4

It does not seem to call any imported function.

Related to #sceKernelBacktraceSelf.

sceKernelRegisterThreadEventHandler

Version NID
3.60 0x6D8C0F13

Wrapper to SceKernelThreadMgr#_sceKernelRegisterThreadEventHandler.

int sceKernelRegisterThreadEventHandler(char *name, SceUID thread_id, SceUInt32 mask, SceKernelThreadEventHandler *handler, void *common);

sceKernelTryLockLwMutex_old

Version NID
3.60 0xA6A2C915

This is a guessed name. Temp name was sceKernelTryLockLwMutex.

PSP-like "sceKernelTryLockLwMutex".

int sceKernelTryLockLwMutex_old(SceLwMutex *mutex, SceUInt32 count);

sceKernelTryLockLwMutex_1

Version NID
3.60 0x6F9C4CC1

This is a guessed name.

It calls PSP-like #sceKernelTryLockLwMutex_old, and on failure SceKernelThreadMgr#_sceKernelLockLwMutex with flag 1.

int sceKernelTryLockLwMutex_1(SceLwMutex *mutex, SceUInt32 count, void *in_out);

sceKernelTryLockLwMutex_0

Version NID
3.60 0xA7819967

This is a guessed name.

It calls PSP-like #sceKernelTryLockLwMutex_old, and on failure SceKernelThreadMgr#_sceKernelLockLwMutex with flag 0.

int sceKernelTryLockLwMutex_0(SceLwMutex *mutex, SceUInt32 count, void *in_out);

sceSblGcAuthMgrMsSaveBBMacFinal

Version NID
3.60 0x774AE3CB

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrMsSaveBBMacFinal.

sceSblGcAuthMgrAdhocBB160GetKeys

Version NID
3.60 0x84C75DC3

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrAdhocBB160GetKeys.

sceSblGcAuthMgrAdhocBB160BroadCastEncrypt

Version NID
3.60 0x88E72157

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrAdhocBB160BroadCastEncrypt.

sceSblGcAuthMgrSclkGetData1

Version NID
3.60 0x93A6570E

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrSclkGetData1.

sceSblGcAuthMgrPcactGetChallenge

Version NID
3.60 0x9557D15C

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrPcactGetChallenge.

sceSblGcAuthMgrAdhocBB160Init

Version NID
3.60 0x9B28E1AF

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrAdhocBB160Init.

SceLibKernel_9EF798C1

Version NID
3.60 0x9EF798C1

It does not seem to call any imported function. Maybe related to low mutexes.

int SceLibKernel_9EF798C1(void *maybe_mutex, SceUInt32 maybe_count);

sceKernelGetMainModuleSdkVersion

Version NID
3.60 0x9F793F84

Gets the module SDK version from the process' SceKernelProcessParam. Used for PSN Auth in SceShell.

int sceKernelGetMainModuleSdkVersion(void);

sceSblGcAuthMgrAdhocBB160UniCastEncrypt

Version NID
3.60 0xA9002567

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrAdhocBB160UniCastEncrypt.

sceSblGcAuthMgrAdhocBB224GetKeys

Version NID
3.60 0xAC57B6A4

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrAdhocBB224GetKeys.

sceSblGcAuthMgrAdhocBB160Auth3

Version NID
3.60 0xC362ECD6

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrAdhocBB160Auth3.

sceSblGcAuthMgrAdhocBB224Init

Version NID
3.60 0xC8082804

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrAdhocBB224Init.

SceLibKernel_DC277B4D

Version NID
3.60 0xDC277B4D

Returns a 64bit value and uses 0xdeadbeef constant somehow.

ulonglong SceLibKernel_DC277B4D(int a1, SceUInt32 low);

sceSblGcAuthMgrAdhocBB224Auth2

Version NID
3.60 0xDEAD6277

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrAdhocBB224Auth2.

sceSblGcAuthMgrSclkSetData2

Version NID
3.60 0xE088B0D0

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrSclkSetData2.

sceSblGcAuthMgrAdhocBB160BroadCastDecrypt

Version NID
3.60 0xE2984A54

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrAdhocBB160BroadCastDecrypt.

sceSblGcAuthMgrPsmactVerifyR1

Version NID
3.60 0xEB6DA895

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrPsmactVerifyR1.

sceSblGcAuthMgrAdhocBB160Auth1

Version NID
3.60 0xEFD76235

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrAdhocBB160Auth1.

sceSblGcAuthMgrGetMediaIdType01

Version NID
3.60 0xF7027E6A

Wrapper to SceSblGcAuthMgr#_sceSblGcAuthMgrGetMediaIdType01.

SceKernelStackChkGuard

Version NID
3.60 0x4458BCF3

This is a variable (4 bytes).

__stack_chk_guard

Version NID
3.60-3.65 0x93B8AA67

This is a variable (4 bytes).

SceLibGcc

         SceLibGcc_0DFF2B2C: 0x0DFF2B2C
         SceLibGcc_12472ADD: 0x12472ADD
         SceLibGcc_29C2EB11: 0x29C2EB11
         SceLibGcc_4BB45B70: 0x4BB45B70
         SceLibGcc_6214B80C: 0x6214B80C
         SceLibGcc_74274866: 0x74274866
         SceLibGcc_7772C028: 0x7772C028
         SceLibGcc_7DFC519A: 0x7DFC519A
         SceLibGcc_83A4F46F: 0x83A4F46F
         SceLibGcc_8A5F29D8: 0x8A5F29D8
         SceLibGcc_8D4953C7: 0x8D4953C7
         SceLibGcc_A22B2436: 0xA22B2436
         SceLibGcc_AC15DBA5: 0xAC15DBA5
         SceLibGcc_B1CD7AC2: 0xB1CD7AC2
         SceLibGcc_BAC00FF7: 0xBAC00FF7
         SceLibGcc_CD43FEDC: 0xCD43FEDC
         SceLibGcc_DA5097CE: 0xDA5097CE
         SceLibGcc_DAB28374: 0xDAB28374
         SceLibGcc_DBE840D6: 0xDBE840D6
         SceLibGcc_F16E32FC: 0xF16E32FC

SceLibSsp

sceKernelStackChkFail

Version NID
3.60 0x39AD080B
int sceKernelStackChkFail(void);

__stack_chk_guard

Version NID
3.60-3.65 0x1EA375E6

This is a variable (4 bytes). Same variable as [SceLibKernel#stack_chk_guard|SceLibKernel library's stack_chk_guard]].

SceRtabi

__aeabi_lcmp

Version NID
3.60 0x0D4F0635

__aeabi_lmul

Version NID
3.60 0x141BC4CE

__aeabi_lasr

Version NID
3.60 0x21FF67B9

__aeabi_ulcmp

Version NID
3.60 0x317B3774

__aeabi_idiv

Version NID
3.60 0x38D62D60

__aeabi_d2lz

Version NID
3.60 0x5024AB91

__aeabi_f2ulz

Version NID
3.60 0x609CA961

__aeabi_idivmod

Version NID
3.60 0x67104054

__aeabi_d2ulz

Version NID
3.60 0x6BB838EF

__aeabi_ldivmod

Version NID
3.60 0x6CBB0E84

__aeabi_llsl

Version NID
3.60 0xA5DB3A86

__aeabi_f2lz

Version NID
3.60 0xAA1F1B50

__aeabi_uidivmod

Version NID
3.60 0xC33391D1

__aeabi_llsr

Version NID
3.60 0xCBDA815C

__aeabi_uldivmod

Version NID
3.60 0xCDF7708E

__aeabi_uidiv

Version NID
3.60 0xFB311F87

SceKernelForVM

sceKernelGetThreadContextForVM

Version NID
3.60 0x010BB885

sceKernelResumeThreadForVM

Version NID
3.60 0x70F3F49D

sceKernelSuspendThreadForVM

Version NID
3.60 0xF5F8F795

SceLibRng

sceKernelGetRandomNumber

Version NID
3.60 0xB2700165

Wrapper to _sceKernelGetRandomNumber.

int sceKernelGetRandomNumber(void *dst, SceSize length);

SceKernelForMono

sceKernelWaitException

Version NID
3.60 0x1BECC64C

sceKernelSuspendThreadForVM

Version NID
3.60 0x38839DA2

sceKernelSetThreadContextForVM

Version NID
3.60 0x92A0964D

sceKernelResumeThreadForVM

Version NID
3.60 0x9A6D085B

sceKernelGetThreadContextForVM

Version NID
3.60 0xAD210F16

sceKernelWaitExceptionCB

Version NID
3.60 0xE513151F

Heap

The latest version of dlmalloc is included in SceLibKernel. Most of the assert checks and security are included.

Thread specific data

Each thread owns a private 2048bytes memory region with specific data (?TLS?). The end of this region is pointed by the TPIDRURO register (thus, the start address of it is TPIDRURO - 0x800).

Offset Size Description
0x000 4 ??
0x004 4 Thread ID
0x008 4 Stack start address
0x00C 4 Stack end address
0x010 4 Current VFP exception
0x014 4 LwMutex related
0x020 4 Current priority
0x024 4 CPU affinity mask