Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * PS4 PKG CNT header parser
- * by Reisyukaku
- */
- #include <stdio.h>
- #include <stdint.h>
- #include <string.h>
- #include <malloc.h>
- typedef uint16_t u16;
- typedef uint32_t u32;
- typedef struct{
- u32 magic;
- u32 dummy1;
- u32 dummy2;
- u32 dummy3;
- u32 files;
- u16 dummy4;
- u16 dummy5;
- u32 infoOffset;
- u32 dummy7;
- u32 dummy8;
- u32 dummy9;
- u32 dummy10;
- u32 infoEnd;
- } header;
- unsigned endianFlip(int i){
- return ((i >> 24) & 0xFF) | ((i << 8) & 0xFF0000) | ((i >> 8) & 0xFF00) | ((i << 24) & 0xFF000000);
- }
- int main(int argc, char **argv){
- if(argc < 2){
- printf("Invalid args!\nUsage: %s <file>\n", argv[0]);
- return 1;
- }
- FILE *fp;
- header *hdr = NULL;
- unsigned char *blob = NULL;
- fp = fopen(argv[1], "rb");
- if(!fp){
- printf("File not found!\n");
- return 1;
- }
- blob = (unsigned char*)malloc(0x100);
- fread(blob, 1, 0x100, fp);
- hdr = (header*)blob;
- if (hdr->magic == 0x544E437F){ //\x7FCNT
- printf("CNT header\n"
- "-----------\n"
- "Files: %d\n"
- "Info Offset: 0x%X\n",
- endianFlip(hdr->files),
- endianFlip(hdr->infoOffset)
- );
- }else{
- printf("Unknown file type!\n");
- return 1;
- }
- fclose(fp);
- free(blob);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement