Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Commit

Permalink
1.05
Browse files Browse the repository at this point in the history
  • Loading branch information
wargio committed Jun 21, 2012
1 parent dda39f1 commit 49687a6
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 36 deletions.
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ all: $(TOOLS)
$(TOOLS): %: %.o $(COMMON) $(DEPS)
$(CC) $(CFLAGS) -o $@ $< $(COMMON) $(LDLIBS)

scekrit: LDLIBS += -lgmp

$(OBJS): %.o: %.c $(DEPS)
$(CC) $(CFLAGS) -c -o $@ $<

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ CHANGELOG
*added security_1 to pupunpack
*1.04
*added readself. it show information about the Playstation Vita Signed Executable and Linkable Format.
*1.05
*Updated readself. now shows more infos about selfs.
*Updated pupunpack. corrected some ID stuff (a self 0x200 is sprx, same for 0x204. it is a self).
6 changes: 3 additions & 3 deletions pupunpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
static u8 *pup = NULL;
static u32 file_count;

const u64 PSV_HDR = 0x5343455546000001;
const uint64_t PSV_HDR = 0x5343455546000001;

static int read_only = 0;

static struct id2name_tbl t_names[] = {
{0x100, "version.txt"},
{0x101, "license.xml"},
{0x200, "psp2swu.self"},
{0x204, "exec_file.self"},
{0x200, "psp2swu.sprx"},
{0x204, "psp2swu.self"},
{0x301, "package_data01.pkg"},
{0x302, "package_data02.pkg"},
{0x303, "package_data03.pkg"},
Expand Down
107 changes: 76 additions & 31 deletions readself.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,62 @@
#include "types.h"
#include "little_endian.h"


static u8 *self = NULL;

const u32 HDR = 0x53434500;

void app_info(u64 offset){
void elf(u32 offset){
uint16_t e_type = le16(self+offset+0x10); /* object file type */
uint16_t e_machine = le16(self+offset+0x12); /* machine type */
uint32_t e_version = le32(self+offset+0x14); /* object file version */
uint64_t e_entry = le64(self+offset+0x18); /* entry point address */
uint32_t e_phoff = le32(self+offset+0x24); /* program header offset */
uint32_t e_shoff = le32(self+offset+0x28); /* section header offset */
uint16_t e_flags = le16(self+offset+0x2c); /* processor-specific flags */
uint32_t e_ehsize = le16(self+offset+0x2e); /* ELF header size */
uint16_t e_phentsize = le16(self+offset+0x30); /* size of program header entry */
uint16_t e_phnum = le16(self+offset+0x34); /* number of program header entries */
uint16_t e_shentsize = le16(self+offset+0x38); /* size of section header entry */
uint16_t e_shnum = le16(self+offset+0x2c); /* number of section header entries */
uint16_t e_shstrndx = le16(self+offset+0x2e); /* section name string table index */

printf("--- ELF INFO ---\n");
printf("Type 0x%04x [%s]\n",e_type,(e_type==2) ? "EXEC" : "SPRX");
printf("Machine Type 0x%04x\n",e_machine);
printf("Version 0x%08x\n",e_version);
printf("Entry Point Address 0x%08x%08x\n",(u32)e_entry,(u32)(e_entry>>32));
printf("Program Header Offset 0x%08x\n",e_phoff);
printf("Section Header Offset 0x%08x\n",e_shoff);
printf("Flag 0x%04x\n",e_flags);
printf("ELF Header Size 0x%08x (%u Bytes)\n",e_ehsize,e_ehsize);
printf("Size Progr Hdr Entry 0x%04x (%u Bytes)\n",e_phentsize,e_phentsize);
printf("Number Hdr Entries 0x%04x (%u)\n",e_phnum,e_phnum);
printf("Size Sect Hdr Entry 0x%04x (%u Bytes)\n",e_shentsize,e_shentsize);
printf("Number Hdr Entries 0x%04x (%u)\n",e_shnum,e_shnum);
printf("Section String Table 0x%04x\n",e_shstrndx);


}

void app_info(u32 offset){
u64 authid = le64(self+offset); /* auth id */
u32 vendor_id = le32(self+offset+0x8); /* vendor id */
u32 self_type = le32(self+offset+0xC); /* app type */
u64 version = le64(self+offset+0x10); /* app version */
u64 padding = le64(self+offset+0x18); /* UNKNOWN */

printf("--- APP INFO ---\n");
printf("Authotiry ID 0x%08x%08x\n",authid,authid>>32);
printf("Authotiry ID 0x%08x%08x\n",(u32)authid,(u32)(authid>>32));
printf("Vendor ID 0x%08x\n",vendor_id);
printf("SELF Type 0x%08x\n",self_type);
printf("Version 0x%08x%08x\n",version,version>>32);
printf("Padding 0x%08x%08x\n",padding,padding>>32);
printf("Version 0x%08x%08x\n",(u32)version,(u32)(version>>32));
printf("Padding 0x%08x%08x\n",(u32)padding,(u32)(padding>>32));


}

void readself(){
printf("Reading...\n");
printf("\nReading...\n");

u32 magic = be32(self); /* 53434500 = SCE\0 */
u32 version = le32(self+0x4 ); /* header version 3*/
Expand All @@ -46,46 +79,58 @@ void readself(){
u64 self_filesize = le64(self+0x20); /* SELF file length */
u64 unknown1 = le64(self+0x28); /* UNKNOWN */
u64 unknown2 = le64(self+0x30); /* value is 4 */
u64 appinfo_offset = le64(self+0x38); /* app info offset */
u64 elf_offset = le64(self+0x40); /* ELF #1 offset */
u64 phdr_offset = le64(self+0x48); /* program header offset */
u64 shdr_offset = le64(self+0x50); /* section header offset */
u64 section_info_offset = le64(self+0x58); /* section info offset */
u64 sceversion_offset = le64(self+0x60); /* version offset */
u64 controlinfo_offset = le64(self+0x68); /* control info offset */
u32 appinfo_offset = le32(self+0x38); /* app info offset */
u32 elf_offset = le32(self+0x40); /* ELF #1 offset */
u32 phdr_offset = le32(self+0x48); /* program header offset */
u32 shdr_offset = le32(self+0x50); /* section header offset */
u32 section_info_offset = le32(self+0x58); /* section info offset */
u32 sceversion_offset = le32(self+0x60); /* version offset */
u32 controlinfo_offset = le32(self+0x68); /* control info offset */
u64 controlinfo_size = le64(self+0x70); /* control info size */
u64 padding = le64(self+0x78);

if(magic!=HDR)
fail("\nERROR! Not a PlayStation Vita Self File (Magic: %08x)",magic);

if(header_type!=1)
fail("\nERROR! Not a PlayStation Vita Self File (Type : %08x)",header_type);
if(header_type!=1){
char* HType;
if(header_type==2)
HType = "rvk";
else if(header_type==3)
HType = "pkg";
else if(header_type==4)
HType = "spp";
else
HType = "Unknown";

fail("\nERROR! Not a PlayStation Vita Self File (Type : %08x)\n"
" [%s]",header_type,HType);
}

printf("Magic 0x%08x\n",magic);
printf("Version 0x%08x\n",version);
printf("SDK Type 0x%08x\n",sdk_type);
printf("Header Type 0x%08x\n",header_type);
printf("Metadata offset 0x%08x\n",metadata_offset);
printf("Header Length 0x%08x%08x (%u Bytes)\n",header_len,header_len>>32,header_len);
printf("Elf Size 0x%08x%08x (%u Bytes)\n",elf_filesize,elf_filesize>>32,elf_filesize);
printf("Self Size 0x%08x%08x (%u Bytes)\n",self_filesize,self_filesize>>32,self_filesize);
printf("Unknown_1 0x%08x%08x\n",unknown1,unknown1>>32);
printf("Unknown_2 0x%08x%08x\n",unknown2,unknown2>>32);
printf("Application Info Offset 0x%08x%08x\n",appinfo_offset,appinfo_offset>>32);
printf("Elf Offset 0x%08x%08x\n",elf_offset,elf_offset>>32);
printf("Program hdr Offset 0x%08x%08x\n",phdr_offset,phdr_offset>>32);
printf("Section hdr Offset 0x%08x%08x\n",shdr_offset,shdr_offset>>32);
printf("Section Info Offset 0x%08x%08x\n",section_info_offset,section_info_offset>>32);
printf("Version Offset 0x%08x%08x\n",sceversion_offset,sceversion_offset>>32);
printf("Control Info Offset 0x%08x%08x\n",controlinfo_offset,controlinfo_offset>>32);
printf("Control Info Size 0x%08x%08x (%u Bytes)\n",controlinfo_size,controlinfo_size>>32,controlinfo_size);
printf("Padding 0x%08x%08x\n",padding,padding>>32);
printf("Header Length 0x%08x%08x (%u Bytes)\n",(u32)(header_len),(u32)(header_len>>32),(u32)(header_len>>32));
printf("Elf Size 0x%08x%08x (%u Bytes)\n",(u32)elf_filesize,(u32)(elf_filesize>>32),(u32)(elf_filesize>>32));
printf("Self Size 0x%08x%08x (%u Bytes)\n",(u32)self_filesize,(u32)(self_filesize>>32),(u32)(self_filesize>>32));
printf("Unknown_1 0x%08x%08x\n",(u32)unknown1,(u32)(unknown1>>32));
printf("Unknown_2 0x%08x%08x\n",(u32)unknown2,(u32)(unknown2>>32));
printf("Application Info Offset 0x%08x\n",appinfo_offset);
printf("Elf Offset 0x%08x\n",elf_offset);
printf("Program hdr Offset 0x%08x\n",phdr_offset);
printf("Section hdr Offset 0x%08x\n",shdr_offset);
printf("Section Info Offset 0x%08x\n",section_info_offset);
printf("Version Offset 0x%08x\n",sceversion_offset);
printf("Control Info Offset 0x%08x\n",controlinfo_offset);
printf("Control Info Size 0x%08x%08x (%u Bytes)\n",(u32)controlinfo_size,(u32)(controlinfo_size>>32),(u32)(controlinfo_size>>32));
printf("Padding 0x%08x%08x\n",(u32)padding,(u32)(padding>>32));

app_info(appinfo_offset);
elf(elf_offset);


printf("Done\n");
printf("\nDone\n");
}

int main(int argc, char *argv[]){
Expand Down

0 comments on commit 49687a6

Please sign in to comment.