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: | ||
ORBIS SELFs (and PUP entries) have a different structure from the PS3 and PSVita ones. | |||
= SELF Header Structure = | = SELF Header Structure = | ||
Line 10: | Line 10: | ||
| 0x4 || 4 || Unknown || Always 00 01 01 12 | | 0x4 || 4 || Unknown || Always 00 01 01 12 | ||
|- | |- | ||
| 0x8 || 1 || | | 0x8 || 1 || Content Type || 1 on Self, 4 on PUP Entry | ||
|- | |- | ||
| 0x9 || 1 || [[Program Type]] || First Half denotes version (anything between 0, oldest and F, newest), second Half denotes true type, 4 for Games, 5 for sce_module modules, 6 for Video Apps like Netflix, 8 for System/EX Apps/Executables, 9 for System/EX modules/dlls | | 0x9 || 1 || [[Program Type]] || First Half denotes version (anything between 0, oldest and F, newest), second Half denotes true type, 4 for Games, 5 for sce_module modules, 6 for Video Apps like Netflix, 8 for System/EX Apps/Executables, 9 for System/EX modules/dlls | ||
Line 18: | Line 18: | ||
| 0xC || 2 || Header Size || | | 0xC || 2 || Header Size || | ||
|- | |- | ||
| 0xE || 2 || Signature Size || | | 0xE || 2 || Signature Size || Metadata Size? | ||
|- | |- | ||
| 0x10 || 4 || | | 0x10 || 4 || Size of SELF || | ||
|- | |- | ||
| 0x14 || 4 || Padding || | | 0x14 || 4 || Padding || | ||
|- | |- | ||
| 0x18 || 2 || Number of Segments || 1 Kernel, 2 SL and | | 0x18 || 2 || Number of Segments || 1 Kernel, 2 SL and Modules, 4 Kernel ELFs, 6 .selfs, 2 .sdll, 6 .sprx, 6 ShellCore, 6 eboot.bin, 2 sexe | ||
|- | |- | ||
| 0x1A || 2 || Unknown || Always 0x22 | | 0x1A || 2 || Unknown || Always 0x22 | ||
|- | |- | ||
| 0x1C || 4 || Padding || | | 0x1C || 4 || Padding || | ||
|- | |||
|} | |} | ||
== SELF Segment Structure == | == SELF Segment Structure == | ||
Depending on the number of segments, at | Depending on the number of segments, at 0x20 the following structure follows and presents a size multiple of 0x20. | ||
<pre> | <pre> | ||
typedef struct { | typedef struct | ||
{ | |||
unsigned long long flags; // 0x130006 / 0x00040F / 0x000006 / 0x110006 | unsigned long long flags; // 0x130006 / 0x00040F / 0x000006 / 0x110006 | ||
unsigned long long offset; | unsigned long long offset; | ||
Line 47: | Line 49: | ||
<pre> | <pre> | ||
enum SegFlags { | enum SegFlags | ||
{ | |||
SF_ORDR = 0x1, // ordered? | SF_ORDR = 0x1, // ordered? | ||
SF_ENCR = 0x2, // encrypted | SF_ENCR = 0x2, // encrypted | ||
Line 59: | Line 62: | ||
<pre> | <pre> | ||
uint32_t Id() { | uint32_t Id() | ||
{ | |||
return Flags >> 20; //0 or 1 | return Flags >> 20; //0 or 1 | ||
} | } | ||
bool IsOrdered() { | bool IsOrdered() | ||
{ | |||
return (Flags & 1) != 0;//0 or 1 | return (Flags & 1) != 0;//0 or 1 | ||
} | } | ||
bool IsEncrypted() { | bool IsEncrypted() | ||
{ | |||
return (Flags & 2) != 0;//0 or 2 | return (Flags & 2) != 0;//0 or 2 | ||
} | } | ||
bool IsSigned() { | bool IsSigned() | ||
{ | |||
return (Flags & 4) != 0;//0 or 4 | return (Flags & 4) != 0;//0 or 4 | ||
} | } | ||
bool IsCompressed() { | bool IsCompressed() | ||
{ | |||
return (Flags & 8) != 0;//0 or 8 | return (Flags & 8) != 0;//0 or 8 | ||
} | } | ||
bool IsBlocked() { | bool IsBlocked() | ||
{ | |||
return (Flags & 0x800) != 0;//0 or 0x800 | return (Flags & 0x800) != 0;//0 or 0x800 | ||
} | } | ||
Line 321: | Line 330: | ||
|} | |} | ||
= | = SCE Special = | ||
Just before the start of the metadata a special section exists which contains the following: | |||
{| class="wikitable" | {| class="wikitable" | ||
Line 332: | Line 341: | ||
| 0x8 || 0x8 || [[Program Type]] || | | 0x8 || 0x8 || [[Program Type]] || | ||
|- | |- | ||
| 0x10 || 0x8 || | | 0x10 || 0x8 || Version 1 || | ||
|- | |- | ||
| 0x18 || 0x8 || | | 0x18 || 0x8 || Version 2 || | ||
|- | |- | ||
| N.A/0x20 || 0x20 || Content ID || Only exists if the SELF is | | N.A/0x20 || 0x20 || Content ID || Only exists if the SELF is NPDRM | ||
|- | |- | ||
| 0x20/0x40 || 0x20 || Digest || SHA-256 of the decrypted elf (for example, on 7.55 retail decrypted/mmapped elf libc.sprx hash is 67c19a2b053ee386819dcd316d21c4381b35bd3de283ce7ca2e143c86b34f79a) | | 0x20/0x40 || 0x20 || Digest || SHA-256 of the decrypted elf (for example, on 7.55 retail decrypted/mmapped elf libc.sprx hash is 67c19a2b053ee386819dcd316d21c4381b35bd3de283ce7ca2e143c86b34f79a) | ||
|} | |} | ||
= | = Metadata = | ||
From leaked | From leaked 6.00b1 Kernel (containing only one segment) the following information can be deduced: | ||
{| class="wikitable" | {| class="wikitable" | ||
! Offset !! Size !! Description !! Notes | ! Offset !! Size !! Description !! Notes | ||
|- | |- | ||
| 0 || 0x10 || AES Key || | | 0 || 0x10 || AES Key || CBC 128 Key for Segment 1 | ||
|- | |- | ||
| 0x10 || 0x10 || AES IV || | | 0x10 || 0x10 || AES IV || CBC 128 IV for Segment 1 | ||
|- | |- | ||
| 0x20 || 0x20 || | | 0x20 || 0x20 || SHA256HMAC || SHA256HMAC for Segment 1 (Decrypted But Compressed in this case) (Without Extra at Footer) | ||
|- | |- | ||
| 0x40 || 0x10 || HMAC Key || SHA256HMAC Key for Segment 1 | | 0x40 || 0x10 || HMAC Key || SHA256HMAC Key for Segment 1 | ||
Line 358: | Line 367: | ||
| 0x50 || 0x40 || License + BMP Header || ??? | | 0x50 || 0x40 || License + BMP Header || ??? | ||
|- | |- | ||
| 0x90 || 0x20 || BMP Entries || 2 (0x10) Entries ( | | 0x90 || 0x20 || BMP Entries || 2 (0x10) Entries (First entry is NULL) | ||
|- | |||
| 0xB0 || 0x100 || RSA SIG || RSA Signature that validates Header Meta | |||
|- | |- | ||
|} | |} | ||
= Footer Signature | = Footer Signature (Extra) = | ||
Additionally, at the bottom, there is likely a footer signature as well as some extra data (relative size). | |||
{{File Formats}} | {{File Formats}} | ||
<noinclude>[[Category:Main]]</noinclude> | <noinclude>[[Category:Main]]</noinclude> |