SELF File Format: Difference between revisions

From Vita Developer wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(74 intermediate revisions by 8 users not shown)
Line 1: Line 1:
[[Category:Software]]
#REDIRECT [https://www.psdevwiki.com/ps3/SELF_-_SPRX]
 
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)
|-
| Encrypted size || 0x18 || u64 || The size of the encrypted part of the self file.
|-
| File size || 0x20 || u64 || The size of the encrypted part of the self file.  
|-
| unknown || 0x28 || u64 || Must be 0
|-
| unknown || 0x30 || u64 || Must be 4
|-
| App_info_offset || 0x38 || u64 || An offset in the header, usually at 0x80. See App info header.
|-
| elf_offset || 0x40 || u64 || offset to the elf header
|-
| phdr_offset  || 0x48 || u64 || offset to phdr
|-
| shdr_offset  || 0x50 || u64 || offset to shdr
|-
| encrypted phdr sizes/offsets table offset  || 0x58 || 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 || 0x60 || u64 || Offset to a header which contains some version information, including an offset to the .sceversion section of the encrypted elf.
|-
| Control Information || 0x68 || u64 || several information containers
|-
| Control Information Size  || 0x70  || u64 ||
|-
|}
 
===comments===
The real ELF data is located after the SCE header (see header size).

Latest revision as of 00:40, 31 January 2020

  1. REDIRECT [1]