Post Reply 
A peak at the PTF format
Author Message
ZiNgA BuRgA
Smart Alternative

Posts: 17,022.2988
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.1274
Offline
Post: #13
RE: A peak at the PTF format
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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// 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...
(This post was last modified: 12/09/2007 04:07 PM by ZiNgA BuRgA.)
12/09/2007 04:06 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
A peak at the PTF format - ZiNgA BuRgA - 12/09/2007, 04:55 AM
RE: A peak at the PTF format - dedat - 12/09/2007, 07:01 AM
RE: A peak at the PTF format - matchung - 12/09/2007, 07:35 AM
RE: A peak at the PTF format - lupus - 12/09/2007, 07:57 AM
RE: A peak at the PTF format - SchmilK - 12/09/2007, 08:55 AM
RE: A peak at the PTF format - lupus - 12/09/2007, 09:18 AM
RE: A peak at the PTF format - u_c_taker - 12/09/2007, 11:01 AM
RE: A peak at the PTF format - SchmilK - 12/09/2007, 11:21 AM
RE: A peak at the PTF format - Chroma - 12/09/2007, 12:45 PM
RE: A peak at the PTF format - afiser - 12/09/2007, 02:08 PM
RE: A peak at the PTF format - ZiNgA BuRgA - 12/09/2007 04:06 PM
RE: A peak at the PTF format - ZiNgA BuRgA - 12/09/2007, 04:53 PM
RE: A peak at the PTF format - Ketchup - 13/09/2007, 02:33 AM
RE: A peak at the PTF format - SnailsPace - 12/09/2007, 05:58 PM
RE: A peak at the PTF format - Vegetano1 - 13/09/2007, 05:45 AM
RE: A peak at the PTF format - SchmilK - 13/09/2007, 09:29 AM
RE: A peak at the PTF format - u_c_taker - 13/09/2007, 01:11 PM
RE: A peak at the PTF format - roberth - 13/09/2007, 01:40 PM
RE: A peak at the PTF format - bstronga - 13/09/2007, 06:01 PM
RE: A peak at the PTF format - Mr. Shizzy - 14/09/2007, 12:01 AM
RE: A peak at the PTF format - diego - 14/09/2007, 01:09 AM
RE: A peak at the PTF format - Mr. Shizzy - 14/09/2007, 01:36 AM
RE: A peak at the PTF format - diego - 14/09/2007, 01:53 AM
RE: A peak at the PTF format - gsmoke - 14/09/2007, 03:31 AM
RE: A peak at the PTF format - ZiNgA BuRgA - 14/09/2007, 05:13 AM
RE: A peak at the PTF format - gsmoke - 14/09/2007, 05:14 AM
RE: A peak at the PTF format - ZiNgA BuRgA - 14/09/2007, 05:21 AM
RE: A peak at the PTF format - gsmoke - 14/09/2007, 05:26 AM
RE: A peak at the PTF format - ZiNgA BuRgA - 14/09/2007, 05:29 AM
RE: A peak at the PTF format - gsmoke - 14/09/2007, 07:19 AM
RE: A peak at the PTF format - gsmoke - 14/09/2007, 05:42 AM
RE: A peak at the PTF format - roberth - 14/09/2007, 05:42 AM
RE: A peak at the PTF format - ZiNgA BuRgA - 14/09/2007, 05:53 AM
RE: A peak at the PTF format - roberth - 14/09/2007, 05:54 AM
RE: A peak at the PTF format - bstronga - 14/09/2007, 06:03 AM
RE: A peak at the PTF format - ZiNgA BuRgA - 14/09/2007, 06:36 AM
RE: A peak at the PTF format - bstronga - 14/09/2007, 02:29 PM
RE: A peak at the PTF format - Vegetano1 - 14/09/2007, 07:32 AM
RE: A peak at the PTF format - roberth - 14/09/2007, 08:07 AM
RE: A peak at the PTF format - gsmoke - 14/09/2007, 08:12 AM
RE: A peak at the PTF format - diego - 14/09/2007, 08:15 AM
RE: A peak at the PTF format - matchung - 14/09/2007, 08:16 AM
RE: A peak at the PTF format - gsmoke - 14/09/2007, 08:26 AM
RE: A peak at the PTF format - diego - 14/09/2007, 08:39 AM
RE: A peak at the PTF format - Maxime - 14/09/2007, 09:28 AM
RE: A peak at the PTF format - afiser - 14/09/2007, 02:47 PM
RE: A peak at the PTF format - Ac_K - 14/09/2007, 11:09 AM
RE: A peak at the PTF format - Ac_K - 14/09/2007, 02:31 PM
RE: A peak at the PTF format - Ac_K - 14/09/2007, 06:15 PM
RE: A peak at the PTF format - ZiNgA BuRgA - 14/09/2007, 07:32 PM
RE: A peak at the PTF format - ZiNgA BuRgA - 15/09/2007, 12:57 AM
RE: A peak at the PTF format - SchmilK - 15/09/2007, 06:47 AM
RE: A peak at the PTF format - Mr. Shizzy - 15/09/2007, 07:33 AM
RE: A peak at the PTF format - afiser - 15/09/2007, 03:05 PM
RE: A peak at the PTF format - gsmoke - 15/09/2007, 03:13 PM
RE: A peak at the PTF format - ZiNgA BuRgA - 15/09/2007, 07:03 PM
RE: A peak at the PTF format - gerbilboy - 19/09/2007, 03:34 PM
RE: A peak at the PTF format - afiser - 19/09/2007, 07:27 PM
RE: A peak at the PTF format - SchmilK - 20/09/2007, 10:56 AM
RE: A peak at the PTF format - Vegetano1 - 20/09/2007, 11:52 AM
RE: A peak at the PTF format - gerbilboy - 20/09/2007, 03:10 PM
RE: A peak at the PTF format - bboy_sonik - 20/09/2007, 04:02 PM
RE: A peak at the PTF format - ZiNgA BuRgA - 20/09/2007, 11:59 PM
RE: A peak at the PTF format - qwaxys - 21/09/2007, 11:06 AM
RE: A peak at the PTF format - ZiNgA BuRgA - 21/09/2007, 04:26 PM
RE: A peak at the PTF format - roberth - 22/09/2007, 05:10 AM
RE: A peak at the PTF format - vinrose67 - 24/09/2007, 03:06 AM
RE: A peak at the PTF format - ZiNgA BuRgA - 24/09/2007, 03:16 AM
RE: A peak at the PTF format - diego - 25/09/2007, 12:56 AM
RE: A peak at the PTF format - ZiNgA BuRgA - 26/09/2007, 09:30 PM
RE: A peak at the PTF format - yongobongo - 26/09/2007, 11:18 PM
RE: A peak at the PTF format - |-Anubis-| - 26/09/2007, 10:10 PM
RE: A peak at the PTF format - ZiNgA BuRgA - 26/09/2007, 10:24 PM
RE: A peak at the PTF format - matchung - 05/10/2007, 02:38 AM
RE: A peak at the PTF format - ZiNgA BuRgA - 05/10/2007, 03:00 AM
RE: A peak at the PTF format - matchung - 05/10/2007, 05:31 AM
RE: A peak at the PTF format - diego - 05/10/2007, 04:16 AM
RE: A peak at the PTF format - ZiNgA BuRgA - 05/10/2007, 05:51 AM
RE: A peak at the PTF format - matchung - 05/10/2007, 07:57 AM
RE: A peak at the PTF format - ZiNgA BuRgA - 05/10/2007, 08:00 AM
RE: A peak at the PTF format - matchung - 05/10/2007, 08:14 AM
RE: A peak at the PTF format - ZiNgA BuRgA - 05/10/2007, 08:35 AM
RE: A peak at the PTF format - matchung - 05/10/2007, 08:47 AM
RE: A peak at the PTF format - ZiNgA BuRgA - 05/10/2007, 05:09 PM
RE: A peak at the PTF format - matchung - 05/10/2007, 06:03 PM
RE: A peak at the PTF format - ZiNgA BuRgA - 05/10/2007, 06:34 PM
RE: A peak at the PTF format - matchung - 05/10/2007, 06:42 PM
RE: A peak at the PTF format - ZiNgA BuRgA - 05/10/2007, 07:39 PM
RE: A peak at the PTF format - matchung - 05/10/2007, 10:13 PM
RE: A peak at the PTF format - ZiNgA BuRgA - 06/10/2007, 12:43 AM
RE: A peak at the PTF format - matchung - 06/10/2007, 02:41 AM
RE: A peak at the PTF format - ZiNgA BuRgA - 06/10/2007, 06:13 AM
RE: A peak at the PTF format - kashell - 07/10/2007, 05:32 AM
RE: A peak at the PTF format - matchung - 07/10/2007, 07:25 PM
RE: A peak at the PTF format - Iguanahak - 04/11/2007, 11:30 AM
RE: A peak at the PTF format - Iguanahak - 04/11/2007, 07:19 PM
RE: A peak at the PTF format - ZiNgA BuRgA - 04/11/2007, 07:50 PM
RE: A peak at the PTF format - ZiNgA BuRgA - 06/11/2007, 10:05 PM
RE: A peak at the PTF format - fl0w - 09/08/2008, 11:32 AM
RE: A peak at the PTF format - ZiNgA BuRgA - 10/08/2008, 12:37 AM
RE: A peak at the PTF format - fl0w - 10/08/2008, 05:31 AM
RE: A peak at the PTF format - ZiNgA BuRgA - 10/08/2008, 03:58 PM
RE: A peak at the PTF format - mudbone - 05/05/2009, 05:16 AM
RE: A peak at the PTF format - ZiNgA BuRgA - 05/05/2009, 05:27 AM
RE: A peak at the PTF format - mudbone - 05/05/2009, 05:37 AM
RE: A peak at the PTF format - ZiNgA BuRgA - 05/05/2009, 07:58 PM
RE: A peak at the PTF format - mudbone - 06/05/2009, 05:34 AM
RE: A peak at the PTF format - SchmilK - 06/05/2009, 05:57 AM
RE: A peak at the PTF format - ZiNgA BuRgA - 06/05/2009, 05:26 PM
RE: A peak at the PTF format - mudbone - 06/05/2009, 06:00 PM
Thread Revived!!! - Necro-Bot - 05/05/2009, 05:16 AM

Forum Jump:


User(s) browsing this thread: 7 Guest(s)

 Quick Theme: