Editing SELF File Format
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
[[Category:Software]] | |||
SELF stands for Signed Executable and Linkable Format. | |||
It is the format used by the executables on the PS3 (SCE Header Version 2), PS Vita (SCE Header Version 3) | |||
It consists of an elf whose sections might be encrypted using AES CTR and signed using ECDSA + HMAC-SHA1 | |||
It has a specific header here called SCE header where it stores all the parameters for this process | |||
= File Format = | |||
Notes: | |||
*Numbers are stored in little endian format. | |||
== SELF/SCE Header == | |||
=== Struct === | |||
typedef struct { | |||
uint32_t magic; /* 53434500 = SCE\0 */ | |||
uint32_t version; /* header version 3*/ | |||
uint16_t sdk_type; /* */ | |||
uint16_t header_type; /* 1 self, 2 unknown, 3 pkg */ | |||
uint32_t metadata_offset; /* metadata offset */ | |||
uint64_t header_len; /* self header length */ | |||
uint64_t elf_filesize; /* ELF file length */ | |||
uint64_t self_filesize; /* SELF file length */ | |||
uint64_t unknown; /* UNKNOWN */ | |||
uint64_t unknown; /* value is 4 */ | |||
uint64_t appinfo_offset; /* app info offset */ | |||
uint64_t elf_offset; /* ELF #1 offset */ | |||
uint64_t phdr_offset; /* program header offset */ | |||
uint64_t shdr_offset; /* section header offset */ | |||
uint64_t section_info_offset; /* section info offset */ | |||
uint64_t sceversion_offset; /* version offset */ | |||
uint64_t controlinfo_offset; /* control info offset */ | |||
uint64_t controlinfo_size; /* control info size */ | |||
uint64_t padding; | |||
} __attribute__((packed)) SELF; | |||
===Table=== | |||
{| class="wikitable" | |||
|- | |||
! field !! offset !! type !! notes | |||
|- | |||
| magic || 0x0 || u32 || Must be "SCE\0" | |||
|- | |||
| version || 0x4 || u32 || This must be 3 | |||
|- | |||
| sdk_type || 0x8 || u16|| This corresponds to the revision of the key to decrypt | |||
|- | |||
| header_type || 0xA || u16 || 1 self, 2 rvk, 3 pkg, 4 spp | |||
|- | |||
| metadata_offset || 0xC || u32 || Offset to the checksums. Must be at least 20 bytes before the end of the header | |||
|- | |||
| header_len || 0x10 || u64 || This is the length of the header (including the fake elf headers) | |||
*The total length of the header must be less that 8KB | |||
|- | |||
| Encrypted size || 0x18 || u64 || The size of the encrypted part of the self file. | |||
|- | |||
| unknown || 0x20 || u64 || Must be 3 | |||
|- | |||
| App_info_offset || 0x28 || u64 || An offset in the header, usually at 0x70. See App info header. | |||
|- | |||
| elf_offset || 0x30 || u64 || offset to the elf header | |||
|- | |||
| phdr_offset || 0x38 || u64 || offset to phdr | |||
|- | |||
| shdr_offset || 0x40 || u64 || offset to shdr | |||
|- | |||
| encrypted phdr sizes/offsets table offset || 0x48 || u64 || Offset to a table which maps phdr entries to the actual offset/size within the encrypted fself. | |||
Because fselfs can be compressed, they might not match the values listed within the elf. | |||
|- | |||
| sceversion header || 0x50 || u64 || Offset to a header which contains some version information, including an offset to the .sceversion section of the encrypted elf. | |||
The playstation 3 doesn't care about this, and doesn't even check the header | |||
|- | |||
| Digest || 0x58 || u64 || | |||
|- | |||
| Digest Size || 0x60 || u64 || | |||
|- | |||
|} | |||
===comments=== | |||
The real ELF data is located after the SCE header (see header size). |