Endless Paradigm

Full Version: A peak at the PTF format
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13
*Waiting for 3.70/3.71 M33 and PTFEditor*
um there won't be an PTFEditor if they use RLZ compression.. atleast not for the PC.
dedat Wrote:so does this mean, if you have time wee might be seeing a PTF editor 1.0 ZiNgA?
but your probably busy at uni at the moment right?
Dunno - will need to see if it's possible to use a different compression scheme...

lupus Wrote:
Quote:I've been messing around a bit with the official theme files released for firmware 3.70 and I managed to split them apart into their various sections. I still have NO clue what the sections are, but I know for sure that the file is not encrypted, the data can be edited without corrupting the theme, the file has to be ≤512KB in size, and it is copied in its entirety into a file in flash (0, 1, 2, 3; I don't know which).

You can pad on as much data as you want, random or otherwise, up to exactly 512KB. You can even replace bits of one theme with bits of another so long as the stuff you're replacing is bigger than the stuff you're copying over it and you null out the trailing data to the end of the section. For example, I copied the 'classy pink' icon over the 'cookies' icon and it showed up with the 'classy pink' icon in the theme selector.

There doesn't even seem to be a checksum on the data in the theme header...

I made a tool for splitting the files apart. There seem to be three different types of section; they all have the same first two bytes (0xD9, 0x6B) preceded by either 0x05, 0x06, or 0x07 and followed by a header that is different depending on the section type.

Hope this inspires people to figure these out even more  I've attached the two currently existing official themes for testing purposes.
source: http://forums.qj.net/f-psp-development-f...20841.html
His program is rather basic - looking at the code, it just searches for RLZ signatures:

Code:
// PSP Theme File splitter
// (C) 2007 FreePlay

#include <stdio.h>

char comp1[]={0x00,0x00,0x00,0x05,0xD9,0x6B};
char comp2[]={0x00,0x00,0x00,0x06,0xD9,0x6B};
char comp3[]={0x00,0x00,0x00,0x07,0xD9,0x6B};

int main(int argc, char **argv)
{
	if(argc<2)
	{
		printf("Usage: %s filename.ptf\n", argv[0]);
		return 1;
	}
	FILE *f = fopen(argv[1],"rb"), *f2;
	if(!f)
	{
		printf("File %s not found!\n", argv[1]);
		return 1;
	}

	char *fname=argv[1];
	while(strstr(fname, "/") > 0) fname = (strstr(fname,"/")+1);
	char *themename=(char *)malloc(strlen(fname)+2);
	strcpy(themename, fname);
	((char *)strstr(themename,"."))[0]='_';
	strcat(themename,"/");
	char *dirname=(char *)malloc(strlen(themename)+3);
	printf("%s\n",dirname);
	mkdir(themename, 0777);
	sprintf(dirname, "%s05", themename);
	mkdir(dirname, 0777);
	sprintf(dirname, "%s06", themename);
	mkdir(dirname, 0777);
	sprintf(dirname, "%s07", themename);
	mkdir(dirname, 0777);

	fseek(f, 0, SEEK_END);
	int size=ftell(f);
	fseek(f, 0, SEEK_SET);
	int x=0;
	unsigned char buf[6];
	int begin=0, end;
	char *filename = (char *)malloc(strlen(themename)+18);
	filename[strlen(themename)+13]='\0';
	int y = 0;
	while(x<size)
	{
		buf[0]=buf[1];
		buf[1]=buf[2];
		buf[2]=buf[3];
		buf[3]=buf[4];
		buf[4]=buf[5];
		fread(buf+5, 1, 1, f);
		if((!memcmp(buf, comp1, 6))||(!memcmp(buf, comp2, 6))||(!memcmp(buf, comp3, 6)))
		{
			y++;
			if(begin != 0)
			{
				end=x-34;
				begin+=(y>3?-1:0);
				fseek(f, begin+28, SEEK_SET);
				fread(buf, 1, 6, f);
				sprintf(filename, "%s0%i/0x%08X.bin", themename, buf[3], begin);
				printf("0x%08X:{%i,%i,%i,%i,%i,%i}\n", begin+29, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
				printf("0%i // %s: begin 0x%08X, end 0x%08X, size 0x%08X\n", buf[3], filename, begin, end, end-begin+1);
				fseek(f, begin, SEEK_SET);
				unsigned char *buf2 = (unsigned char *)malloc(end-begin+1);
				fread(buf2, 1, end-begin+1, f);
				f2 = fopen(filename, "wb");
				fwrite(buf2, 1, end-begin+1, f2);
				free(buf2);
				fclose(f2);
				fseek(f, x, SEEK_SET);
			}
			begin=x-33;
		}
		x++;
	}
	free(filename);
	free(dirname);
	free(themename);
	fclose(f);
	return 0;
}

Interesting start nonetheless, and a great effort :P

Actually, RLZ is an interesting compression scheme - it seems to use very small blocks.  The signature only looks similar because all the compressed files will have a similar GIM header...

afiser Wrote:um there won't be an PTFEditor if they use RLZ compression.. atleast not for the PC.
Dunno - could be like RCOs - you might be able to use deflate compression instead...  But if not, yeah, wee're stuck...
Whilst I'm here, and don't have 3.7x, would someone mind testing this PTF file?  This will help confirm that I really have got the right values and stuff.

All I did was replace one of the icons with another (already RLZ compressed) icon.
If this works, then I'll see if deflate compression works as well later on...
im so excited i just pee'd a little :@
ZiNgA BuRgA Wrote:Whilst I'm here, and don't have 3.7x, would someone mind testing this PTF file?  This will help confirm that I really have got the right values and stuff.

All I did was replace one of the icons with another (already RLZ compressed) icon.
If this works, then I'll see if deflate compression works as well later on...


ok I've tested this. Now, i get the classy pink theme, with the original UMD icon. If this is what you change ...
O goodie goodie,.. go Zinga go!!
Dang dude...wee need to extract all the images from hte sony released themes and put them out to the world for 3.5x and 3.60 :D  That would be a slap to the fat cat belly for sure.  :D
i don think that is  a good idea schmilk that would be breaking copyrights n then sony could try n screw the people who did it
i would love those lemmings icons but really rethemed...
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13
Reference URL's