sce-elf-defs.h (4609B)
1 /* This file gets included multiple times to generate the host-visible and target-visible versions of each struct */ 2 3 #if defined(SCE_ELF_DEFS_HOST) 4 # define SCE_TYPE(type) type ## _t 5 # define SCE_PTR(type) type 6 #elif defined(SCE_ELF_DEFS_TARGET) 7 # define SCE_TYPE(type) type ## _raw 8 # define SCE_PTR(type) uint32_t 9 #else 10 # error "Do not include sce-elf-defs.h directly! Include sce-elf.h!" 11 #endif 12 13 #include <stdint.h> 14 15 struct SCE_TYPE(sce_module_exports); 16 struct SCE_TYPE(sce_module_imports); 17 18 typedef struct SCE_TYPE(sce_module_info) { 19 uint16_t attributes; 20 uint16_t version; /* Set to 0x0101 */ 21 char name[27]; /* Name of the library */ 22 uint8_t type; /* 0x0 for executable, 0x6 for PRX */ 23 SCE_PTR(const void *) gp_value; 24 SCE_PTR(struct sce_module_exports_t *) 25 export_top; /* Offset to start of export table */ 26 SCE_PTR(struct sce_module_exports_t *) 27 export_end; /* Offset to end of export table */ 28 SCE_PTR(struct sce_module_imports_t *) 29 import_top; /* Offset to start of import table */ 30 SCE_PTR(struct sce_module_imports_t *) 31 import_end; /* Offset to end of import table */ 32 uint32_t library_nid; /* NID of this library */ 33 uint32_t field_38; 34 uint32_t field_3C; 35 uint32_t field_40; 36 SCE_PTR(const void *) module_start; /* Offset to function to run when library is started, 0 to disable */ 37 SCE_PTR(const void *) module_stop; /* Offset to function to run when library is exiting, 0 to disable */ 38 SCE_PTR(const void *) exidx_top; /* Offset to start of ARM EXIDX (optional) */ 39 SCE_PTR(const void *) exidx_end; /* Offset to end of ARM EXIDX (optional) */ 40 SCE_PTR(const void *) extab_top; /* Offset to start of ARM EXTAB (optional) */ 41 SCE_PTR(const void *) extab_end; /* Offset to end of ARM EXTAB (optional */ 42 43 // i decided to include process param into module_info (xyz) 44 uint32_t process_param_size; 45 uint32_t process_param_magic; 46 uint32_t process_param_unk[11]; 47 } SCE_TYPE(sce_module_info); 48 49 typedef struct SCE_TYPE(sce_module_exports) { 50 uint16_t size; /* Size of this struct, set to 0x20 */ 51 uint16_t version; /* 0x1 for normal export, 0x0 for main module export */ 52 uint16_t flags; /* 0x1 for normal export, 0x8000 for main module export */ 53 uint16_t num_syms_funcs; /* Number of function exports */ 54 uint32_t num_syms_vars; /* Number of variable exports */ 55 uint32_t num_syms_unk; 56 uint32_t module_nid; /* NID of this module */ 57 SCE_PTR(const char *) module_name; /* Pointer to name of this module */ 58 SCE_PTR(uint32_t *) nid_table; /* Pointer to array of 32-bit NIDs to export */ 59 SCE_PTR(const void **) entry_table; /* Pointer to array of data pointers for each NID */ 60 } SCE_TYPE(sce_module_exports); 61 62 typedef struct SCE_TYPE(sce_module_imports) { 63 uint16_t size; /* Size of this struct, set to 0x34 */ 64 uint16_t version; /* Set to 0x1 */ 65 uint16_t flags; /* Set to 0x0 */ 66 uint16_t num_syms_funcs; /* Number of function imports */ 67 uint16_t num_syms_vars; /* Number of variable imports */ 68 uint16_t num_syms_unk; 69 70 uint32_t reserved1; 71 uint32_t module_nid; /* NID of module to import */ 72 SCE_PTR(const char *) module_name; /* Pointer to name of imported module, for debugging */ 73 uint32_t reserved2; 74 SCE_PTR(uint32_t *) func_nid_table; /* Pointer to array of function NIDs to import */ 75 SCE_PTR(const void **) func_entry_table;/* Pointer to array of stub functions to fill */ 76 SCE_PTR(uint32_t *) var_nid_table; /* Pointer to array of variable NIDs to import */ 77 SCE_PTR(const void **) var_entry_table; /* Pointer to array of data pointers to write to */ 78 SCE_PTR(uint32_t *) unk_nid_table; 79 SCE_PTR(const void **) unk_entry_table; 80 } SCE_TYPE(sce_module_imports); 81 82 /* alternative module imports struct with a size of 0x24 */ 83 typedef struct SCE_TYPE(sce_module_imports_short) { 84 uint16_t size; /* Size of this struct, set to 0x24 */ 85 uint16_t version; /* Set to 0x1 */ 86 uint16_t flags; /* Set to 0x0 */ 87 uint16_t num_syms_funcs; /* Number of function imports */ 88 uint16_t num_syms_vars; /* Number of variable imports */ 89 uint16_t num_syms_unk; 90 91 uint32_t module_nid; /* NID of module to import */ 92 SCE_PTR(const char *) module_name; /* Pointer to name of imported module, for debugging */ 93 SCE_PTR(uint32_t *) func_nid_table; /* Pointer to array of function NIDs to import */ 94 SCE_PTR(const void **) func_entry_table; /* Pointer to array of stub functions to fill */ 95 SCE_PTR(uint32_t *) var_nid_table; /* Pointer to array of variable NIDs to import */ 96 SCE_PTR(const void **) var_entry_table; /* Pointer to array of data pointers to write to */ 97 } SCE_TYPE(sce_module_imports_short); 98 99 #undef SCE_TYPE 100 #undef SCE_PTR