PSPSDK 2026-11-16
Loading...
Searching...
No Matches
psploadcore.h
Go to the documentation of this file.
1/*
2 * PSP Software Development Kit - https://github.com/pspdev
3 * -----------------------------------------------------------------------
4 * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
5 *
6 * psploadcore.h - Interface to LoadCoreForKernel.
7 *
8 * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
9 * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
10 * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
11 *
12 */
13
14#ifndef PSPLOADCORE_H
15#define PSPLOADCORE_H
16
17#include <pspkerneltypes.h>
18#include <pspmoduleinfo.h>
19
23#ifdef __cplusplus
24extern "C" {
25#endif
26
30#define SCE_KERNEL_MAX_MODULE_SEGMENT (4)
31
33typedef s32 (*SceKernelRebootBeforeForKernel)(void *arg1, s32 arg2, s32 arg3, s32 arg4);
34typedef s32 (*SceKernelRebootPhaseForKernel)(s32 arg1, void *arg2, s32 arg3, s32 arg4);
35
53
76
199
200typedef struct {
201 char *name;
202 void *buf;
203 int size;
205 int attr;
210
213typedef struct SceLibraryEntryTable {
215 const char * libname;
217 unsigned char version[2];
219 unsigned short attribute;
221 unsigned char len;
223 unsigned char vstubcount;
225 unsigned short stubcount;
230
233typedef struct SceLibraryStubTable {
234 /* The name of the library we're importing from. */
235 const char * libname;
237 unsigned char version[2];
238 /* Import attributes. */
239 unsigned short attribute;
241 unsigned char len;
243 unsigned char vstubcount;
245 unsigned short stubcount;
247 unsigned int * nidtable;
249 void * stubtable;
254
255/*
256 * Stub library system status.
257 */
259 /* The stub library is linked only the first time a resident
260 * library is registered. If a newer version of that res. lib
261 * is registered, the stub library won't be linked with that one
262 * again.
263 */
265 /* The stub library is linked with its corresponding resident
266 * library.
267 */
270};
271
282
293
303
307typedef struct {
312
367
374typedef struct {
376 const char *lib_name; // 0
383 u8 version[2]; // 4
391 u8 len; // 8
404 u16 unk16; // 16
406 u8 unk18; // 18
408 u8 unk19; // 19
410
491
592
601int sceKernelGetModuleList(int readbufsize, SceUID *readbuf);
602
609
618
627
636
642int sceKernelModuleCount(void);
643
648
660
674
685int sceKernelGetModuleIdListForKernel(SceUID *mod_id_list, u32 size, u32 *mod_count, u32 user_mods_only);
686
687
688int sceKernelCheckPspConfig(void *buf, int size, int flag);
689
692#ifdef __cplusplus
693}
694#endif
695
696#endif /* PSPLOADCORE_H */
int sceKernelProbeExecutableObject(void *buf, SceLoadCoreExecFileInfo *execInfo)
Probe an executable file.
int sceKernelCheckExecFile(void *buf, SceLoadCoreExecFileInfo *execInfo)
Check an executable file.
struct SceLibraryEntryTable SceLibraryEntryTable
Defines a library and its exported functions and variables.
void sceKernelIcacheClearAll(void)
Invalidate the CPU's instruction cache.
s32(* SceKernelRebootBeforeForKernel)(void *arg1, s32 arg2, s32 arg3, s32 arg4)
Reboot preparation functions.
Definition psploadcore.h:33
s32(* SceKernelRebootPhaseForKernel)(s32 arg1, void *arg2, s32 arg3, s32 arg4)
Definition psploadcore.h:34
int sceKernelGetModuleIdListForKernel(SceUID *mod_id_list, u32 size, u32 *mod_count, u32 user_mods_only)
Receive a list of UIDs of loaded modules.
SceModule * sceKernelFindModuleByName(const char *modname)
Find a module by it's name.
SceModule * sceKernelFindModuleByAddress(unsigned int addr)
Find a module from an address.
int sceKernelCheckPspConfig(void *buf, int size, int flag)
SceModulePrivilegeLevel
Module Privilege Levels - These levels define the permissions a module can have.
Definition psploadcore.h:58
int sceKernelModuleCount(void)
Get the number of loaded modules.
SceLibraryStubTable SceStubLibraryEntryTable
Definition psploadcore.h:253
SceModule * sceKernelFindModuleByUID(SceUID modid)
Find a module by it's UID.
struct SceLoadCoreExecFileInfo SceLoadCoreExecFileInfo
struct SceResidentLibrary SceResidentLibrary
This structure represents a resident library control block.
struct SceModule SceModule
Describes a loaded module in memory.
struct SceStubLibrary SceStubLibrary
This structure represents a stub library control block.
SceStubLibraryStatus
Definition psploadcore.h:258
#define SCE_KERNEL_MAX_MODULE_SEGMENT
Definition psploadcore.h:30
SceModuleAttribute
Module type attributes.
Definition psploadcore.h:37
int sceKernelGetModuleList(int readbufsize, SceUID *readbuf)
Gets the current module list.
struct SceLibraryStubTable SceLibraryStubTable
Specifies a library and a set of imports from that library.
@ SCE_MODULE_KIRK_MEMLMD_LIB
The module uses KIRK's memlmd resident library.
Definition psploadcore.h:72
@ SCE_MODULE_VSH
VSH module.
Definition psploadcore.h:68
@ SCE_MODULE_MS
POPS/Demo.
Definition psploadcore.h:62
@ SCE_MODULE_APP
Application module.
Definition psploadcore.h:66
@ SCE_MODULE_USER
Lowest permission.
Definition psploadcore.h:60
@ SCE_MODULE_USB_WLAN
Module Gamesharing.
Definition psploadcore.h:64
@ SCE_MODULE_KERNEL
Highest permission.
Definition psploadcore.h:70
@ SCE_MODULE_KIRK_SEMAPHORE_LIB
The module uses KIRK's semaphore resident library.
Definition psploadcore.h:74
@ STUB_LIBRARY_EXCLUSIVE_LINK
Definition psploadcore.h:264
@ STUB_LIBRARY_UNKNOWN
Definition psploadcore.h:269
@ STUB_LIBRARY_LINKED
Definition psploadcore.h:268
@ SCE_MODULE_ATTR_NONE
No module attributes.
Definition psploadcore.h:39
@ SCE_MODULE_ATTR_EXCLUSIVE_LOAD
Only one instance of the module (one version) can be loaded into the system.
Definition psploadcore.h:46
@ SCE_MODULE_ATTR_CANT_STOP
Resident module - stays in memory.
Definition psploadcore.h:41
@ SCE_MODULE_ATTR_EXCLUSIVE_START
Only one instance of the module (one version) can be started.
Definition psploadcore.h:51
unsigned int SceUInt
Definition pspkerneltypes.h:31
int SceUID
UIDs are used to describe many different kernel objects.
Definition pspkerneltypes.h:24
unsigned int SceSize
Definition psptypes.h:103
uint8_t u8
Definition psptypes.h:38
int16_t s16
Definition psptypes.h:45
uint16_t u16
Definition psptypes.h:39
int32_t s32
Definition psptypes.h:47
int(* SceKernelThreadEntry)(SceSize args, void *argp)
Definition psptypes.h:431
uint32_t u32
Definition psptypes.h:41
This structure represents a function stub belonging to same privilege-level linked libraries,...
Definition psploadcore.h:276
u32 delay_slot
The delay slot belonging to the call, typically a NOP instruction.
Definition psploadcore.h:280
u32 call
The call to the imported function via a MIPS ASM Jump instruction.
Definition psploadcore.h:278
Defines a library and its exported functions and variables.
Definition psploadcore.h:213
unsigned short attribute
Library attributes.
Definition psploadcore.h:219
void * entrytable
Pointer to the entry table; an array of NIDs followed by pointers to functions and variables.
Definition psploadcore.h:228
unsigned char vstubcount
The number of variables exported by the library.
Definition psploadcore.h:223
unsigned short stubcount
The number of functions exported by the library.
Definition psploadcore.h:225
unsigned char version[2]
Library version.
Definition psploadcore.h:217
unsigned char len
Length of this entry table in 32-bit WORDs.
Definition psploadcore.h:221
const char * libname
The library's name.
Definition psploadcore.h:215
Specifies a library and a set of imports from that library.
Definition psploadcore.h:233
unsigned char version[2]
Minimum required version of the library we want to import.
Definition psploadcore.h:237
const char * libname
Definition psploadcore.h:235
unsigned short stubcount
The number of functions imported from the library.
Definition psploadcore.h:245
void * vstubtable
Pointer to the imported variable stubs.
Definition psploadcore.h:251
unsigned short attribute
Definition psploadcore.h:239
unsigned char len
Length of this stub table in 32-bit WORDs.
Definition psploadcore.h:241
unsigned int * nidtable
Pointer to an array of NIDs.
Definition psploadcore.h:247
void * stubtable
Pointer to the imported function stubs.
Definition psploadcore.h:249
unsigned char vstubcount
The number of variables imported from the library.
Definition psploadcore.h:243
Definition psploadcore.h:200
int attr
Definition psploadcore.h:205
char * name
Definition psploadcore.h:201
int unk_20
Definition psploadcore.h:206
int argSize
Definition psploadcore.h:207
int size
Definition psploadcore.h:203
int argPartId
Definition psploadcore.h:208
void * buf
Definition psploadcore.h:202
int unk_12
Definition psploadcore.h:204
Definition psploadcore.h:492
u32 is_decompressed
Indicates whether the module is decompressed or not.
Definition psploadcore.h:556
u8 padding[3]
Reserved.
Definition psploadcore.h:580
void * imports_info
Pointer to the first stub library entry table of the module.
Definition psploadcore.h:572
u32 entry_addr
The entry address of the module.
Definition psploadcore.h:517
u8 num_segments
The number of segments in the executable.
Definition psploadcore.h:578
SceSize data_size
The size of the DATA segment.
Definition psploadcore.h:528
u16 mod_info_attribute
The module's attributes.
Definition psploadcore.h:550
u32 max_seg_align
The largest value of the segment_align array.
Definition psploadcore.h:590
u32 segment_size[(4)]
An array containing the size of each segment.
Definition psploadcore.h:584
u32 partition_id
The memory partition of the executable.
Definition psploadcore.h:532
void * strtab_offset
Pointer to the string table section.
Definition psploadcore.h:576
SceSize dec_size
The size of the decompressed module, including its headers.
Definition psploadcore.h:554
u32 unk104
Unknown.
Definition psploadcore.h:564
SceSize text_size
The size of the TEXT segment.
Definition psploadcore.h:526
void * exports_info
Pointer to the first resident library entry table of the module.
Definition psploadcore.h:568
void * file_base
Pointer to the compressed module data.
Definition psploadcore.h:508
u32 segment_addr[(4)]
An array containing the start address of each segment.
Definition psploadcore.h:582
SceSize imports_size
The size of all stub library entry tables of the module.
Definition psploadcore.h:574
SceUID mem_block_id
The ID of the ELF memory block containing the TEXT, DATA and BSS segment.
Definition psploadcore.h:586
u32 unk44
Unknown.
Definition psploadcore.h:519
SceSize exports_size
The size of all resident library entry tables of the module.
Definition psploadcore.h:570
u32 is_compressed
Indicates whether the module is compressed or not.
Definition psploadcore.h:548
u32 is_sign_checked
Indicates whether the module was signChecked or not.
Definition psploadcore.h:562
SceSize overlap_size
The size of the GZIP compression overlap.
Definition psploadcore.h:566
u32 unk12
Unknown.
Definition psploadcore.h:500
u32 segment_align[(4)]
An array containing the alignment information of each segment.
Definition psploadcore.h:588
SceSize largest_seg_size
The size of the largest module segment.
Definition psploadcore.h:524
void * top_addr
The start address of the TEXT segment of the executable in memory.
Definition psploadcore.h:512
u32 module_info_offset
The offset from the start address of the TEXT segment to the SceModuleInfo section.
Definition psploadcore.h:544
u32 unk0
Unknown.
Definition psploadcore.h:494
u16 exec_attribute
The attributes of the executable file.
Definition psploadcore.h:552
SceSize exec_size
The size of the executable, including the ~PSP header.
Definition psploadcore.h:502
SceUID decompression_mem_id
The memory ID of the decompression buffer.
Definition psploadcore.h:506
SceSize bss_size
The size of the BSS segment.
Definition psploadcore.h:530
u32 api_type
The API type.
Definition psploadcore.h:498
u32 elf_type
Indicates the ELF type of the executable.
Definition psploadcore.h:510
u32 is_kernel_mod
Indicates whether the executable is a kernel module or not.
Definition psploadcore.h:537
SceSize max_alloc_size
The maximum size needed for the decompression.
Definition psploadcore.h:504
u32 is_decrypted
Indicates whether the executable is decrypted or not.
Definition psploadcore.h:542
SceModuleInfo * module_info
The pointer to the module's SceModuleInfo section.
Definition psploadcore.h:546
u32 mode_attr
The mode attribute of the executable file.
Definition psploadcore.h:496
Describes a loaded module in memory.
Definition psploadcore.h:78
u32 segmentaddr[4]
An array containing the start address of each segment.
Definition psploadcore.h:163
SceUInt module_stop_thread_attr
The attributes of the module stop thread.
Definition psploadcore.h:179
char terminal
String terminator (always '\0').
Definition psploadcore.h:91
u32 text_addr
The start address of the TEXT segment.
Definition psploadcore.h:151
SceUID modid
The module's UID.
Definition psploadcore.h:101
u32 bss_size
The size of the BSS segment.
Definition psploadcore.h:157
SceUID mem_id
The ID of the memory block belonging to the module.
Definition psploadcore.h:105
SceSize ent_size
The size of all resident library entry tables of the module.
Definition psploadcore.h:113
u16 mod_state
The status of the module.
Definition psploadcore.h:96
u32 text_size
The size of the TEXT segment.
Definition psploadcore.h:153
u32 text_segment_checksum
TEXT segment checksum of the module.
Definition psploadcore.h:191
SceKernelThreadEntry module_bootstart
A pointer to a module's Bootstart entry function.
Definition psploadcore.h:132
char modname[27]
The module's name.
Definition psploadcore.h:89
u32 count_reg_val
The value of the coprocessor 0's count register when the module is created.
Definition psploadcore.h:187
SceKernelRebootBeforeForKernel module_reboot_before
A pointer to a module's rebootBefore entry function.
Definition psploadcore.h:137
u32 mpid_data
The ID of the DATA segment's memory partition.
Definition psploadcore.h:109
u8 padding2[3]
Reserved.
Definition psploadcore.h:161
u32 data_size
The size of the DATA segment.
Definition psploadcore.h:155
SceSize module_reboot_before_thread_stacksize
The stack size of the module reboot before thread.
Definition psploadcore.h:183
SceUInt module_reboot_before_thread_attr
The attributes of the module reboot before thread.
Definition psploadcore.h:185
void * stub_top
Pointer to the first stub library entry table of the module.
Definition psploadcore.h:115
u32 segmentalign[4]
An array containing the alignment information of each segment.
Definition psploadcore.h:167
SceUInt module_start_thread_attr
The attributes of the module start thread.
Definition psploadcore.h:173
s32 module_reboot_before_thread_priority
The priority of the module reboot before thread.
Definition psploadcore.h:181
SceSize stub_size
The size of all stub library entry tables of the module.
Definition psploadcore.h:117
u32 mpid_text
The ID of the TEXT segment's memory partition.
Definition psploadcore.h:107
u16 attribute
The attributes of a module.
Definition psploadcore.h:82
u32 gp_value
Contains the offset from the start of the TEXT segment of the program's GP register value.
Definition psploadcore.h:149
u32 segment_checksum
The segment checksum of the module's segments.
Definition psploadcore.h:189
SceUID sec_id
A secondary ID for the module.
Definition psploadcore.h:99
s32 module_start_thread_priority
The priority of the module start thread.
Definition psploadcore.h:169
SceSize segmentsize[4]
An array containing the size of each segment.
Definition psploadcore.h:165
SceKernelRebootPhaseForKernel module_reboot_phase
A pointer to a module's rebootPhase entry function.
Definition psploadcore.h:142
s32 module_stop_thread_priority
The priority of the module stop thread.
Definition psploadcore.h:175
SceSize module_start_thread_stacksize
The stack size of the module start thread.
Definition psploadcore.h:171
struct SceModule * next
Pointer to the next registered module.
Definition psploadcore.h:80
u8 nsegment
The number of segments the module consists of.
Definition psploadcore.h:159
u32 compute_text_segment_checksum
Whether to compute the text segment checksum before starting the module (see prologue).
Definition psploadcore.h:197
SceUID user_mod_thid
The thread ID of a user module.
Definition psploadcore.h:103
SceKernelThreadEntry module_start
A pointer to the (required) module's start entry function.
Definition psploadcore.h:122
void * ent_top
Pointer to the first resident library entry table of the module.
Definition psploadcore.h:111
SceKernelThreadEntry module_stop
A pointer to the (required) module's stop entry function.
Definition psploadcore.h:127
u32 entry_addr
The entry address of the module.
Definition psploadcore.h:147
u8 version[2]
The version of the module.
Definition psploadcore.h:87
SceSize module_stop_thread_stacksize
The stack size of the module stop thread.
Definition psploadcore.h:177
char padding[2]
Definition psploadcore.h:97
This structure is used to record the functions a resident library provides to other modules.
Definition psploadcore.h:374
u8 unk18
Unknown.
Definition psploadcore.h:406
u8 len
The length of this entry table in 32-Bit words.
Definition psploadcore.h:391
u16 func_stub_count
The number of exported functions by the resident library.
Definition psploadcore.h:395
u16 unk16
Unknown.
Definition psploadcore.h:404
u8 var_stub_count
The number of exported variables by the resident library.
Definition psploadcore.h:393
u8 unk19
Unknown.
Definition psploadcore.h:408
const char * lib_name
The name of the library.
Definition psploadcore.h:376
s16 attribute
The library's attributes.
Definition psploadcore.h:385
u32 * entry_table
Pointer to an array of NIDs, followed by an array of function- and variable pointers.
Definition psploadcore.h:402
This structure represents a resident library control block.
Definition psploadcore.h:415
u32 * entry_table
Pointer to the resident library's array of NIDs, exported subroutine/variable entries.
Definition psploadcore.h:460
u32 exports_size
The number of exported functions and variables + the number of NIDs used for them.
Definition psploadcore.h:464
u16 extra_export_entries
Extra export entries in the system call table entry belonging to the resident library.
Definition psploadcore.h:489
u16 stub_count
The number of exported functions by the resident library.
Definition psploadcore.h:434
u32 mid_func_index
The index into the middle of the exported functions/variables array.
Definition psploadcore.h:466
u8 version[2]
The version of the library.
Definition psploadcore.h:424
u32 is_user_lib
Indicates whether the resident library lives in User land or Kernel land.
Definition psploadcore.h:474
SceStubLibrary * stub_libs
Pointer to a linked list of corresponding loaded stub libraries.
Definition psploadcore.h:470
u8 unk21
Unknown.
Definition psploadcore.h:448
char * lib_name
The name of the library.
Definition psploadcore.h:478
u32 unk28
Unknown.
Definition psploadcore.h:454
u16 attribute
The library's attributes.
Definition psploadcore.h:429
u32 unk64
Unknown.
Definition psploadcore.h:476
u16 var_stub_count
The number of exported variables by the resident library.
Definition psploadcore.h:439
u32 unk48
Unknown.
Definition psploadcore.h:468
u8 unk20
Unknown.
Definition psploadcore.h:446
u8 unk22
Unknown.
Definition psploadcore.h:450
struct SceResidentLibrary * next
Pointer to the next resident library with the same hash value.
Definition psploadcore.h:417
u32 lib_name_in_heap
Indicates whether the library's name is located in the heap or not.
Definition psploadcore.h:480
u32 * exports_base_addr
A pointer to the first export entry (either a subroutine or variable).
Definition psploadcore.h:462
SceResidentLibraryEntryTable * lib_entry_table
Pointer to the corresponding entry table used to register this library.
Definition psploadcore.h:419
u16 sys_table_entry_start_index
The entry index into Loadcore's system call table for an exported function of the resident library.
Definition psploadcore.h:485
u32 sys_table_entry
The address of the system call table block belonging to the resident library.
Definition psploadcore.h:472
u32 num_exports
The number of total exports by the resident library (the sum of stubCount and vStubCount).
Definition psploadcore.h:444
s32 unk24
Unknown.
Definition psploadcore.h:452
This structure represents a stub library control block.
Definition psploadcore.h:317
u32 status
The current status of a stub library (control block) in memory.
Definition psploadcore.h:359
u16 fn_stub_count
The number of imported functions by the stub library.
Definition psploadcore.h:345
u8 stub_entry_table_len
The length of the corresponding stub library entry table in 32-Bit words.
Definition psploadcore.h:335
SceVariableStub * var_stub_table
Pointer to the imported variable stubs.
Definition psploadcore.h:351
struct SceStubLibrary * next
A linked list of stub libraries belonging to the same group, i.e.
Definition psploadcore.h:323
u32 * nid_table
Pointer to an array of NIDs identifying the imported functions/variables.
Definition psploadcore.h:347
u16 attribute
The library's attributes.
Definition psploadcore.h:333
SceLibraryStubTable * lib_stub_table
Pointer to the corresponding stub library entry table.
Definition psploadcore.h:355
u16 unk32
Unknown.
Definition psploadcore.h:353
u32 libname_in_heap
Indicates whether the library's name is located in the heap or not.
Definition psploadcore.h:365
u32 is_user_lib
Indicates whether the stub library lives in User land or Kernel land.
Definition psploadcore.h:361
SceStub * fn_stub_table
Pointer to the imported function stubs.
Definition psploadcore.h:349
u32 unk0
Unknown.
Definition psploadcore.h:319
u8 var_stub_count
The number of imported variables by the stub library.
Definition psploadcore.h:340
char * lib_name2
The name of the library.
Definition psploadcore.h:363
u8 version[2]
The version of the library.
Definition psploadcore.h:329
const char * lib_name
The name of the library.
Definition psploadcore.h:325
This structure represents a function stub belonging to different privilege-level linked libraries,...
Definition psploadcore.h:287
u32 syscall
The system call exception used to call the imported function.
Definition psploadcore.h:291
u32 return_addr
The return instruction from the stub.
Definition psploadcore.h:289
This structure represents an imported variable stub.
Definition psploadcore.h:307
u32 nid
The NID identifying the imported variable.
Definition psploadcore.h:310
u32 * addr
Definition psploadcore.h:308
Definition pspmoduleinfo.h:21
This structure represents an imported function stub.
Definition psploadcore.h:297
SceSyscallStub sc
Kernel/User function stub.
Definition psploadcore.h:301
SceDirectCallStub dc
User/User or Kernel/Kernel function stub.
Definition psploadcore.h:299