Post Reply 
A peak at the PTF format
Author Message
Chroma
Chromatic Nutjob

Posts: 2,626.3796
Threads: 435
Joined: 1st Mar 2007
Reputation: -5.01013
E-Pigs: 40.2135
Offline
Post: #11
RE: A peak at the PTF format
*Waiting for 3.70/3.71 M33 and PTFEditor*

PSN ID: Chroma3000
My Steam Page
ADD ME
superdouche Wrote:
TheGuy Wrote:
superdouche Wrote:You need at least an 8 inch penis, that's what I heard.
Man, if I had 8 inches, I would find a better use for it :P
Like what, pushing elevator buttons?
12/09/2007 12:45 PM
Visit this user's website Find all posts by this user Quote this message in a reply
afiser
Paradigmatic Apprentice

Posts: 44.1835
Threads: 0
Joined: 13th Apr 2007
Reputation: 0
E-Pigs: 0.5304
Offline
Post: #12
RE: A peak at the PTF format
um there won't be an PTFEditor if they use RLZ compression.. atleast not for the PC.
12/09/2007 02:08 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA
Smart Alternative

Posts: 17,023.4213
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.0333
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
ZiNgA BuRgA
Smart Alternative

Posts: 17,023.4213
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.0333
Offline
Post: #14
RE: A peak at the PTF format
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...


Attached File(s)
.rar  classypink.rar (Size: 283.19 KB / Downloads: 329)
12/09/2007 04:53 PM
Visit this user's website Find all posts by this user Quote this message in a reply
SnailsPace
$T3a\tH m()D3 gU3ri\\a

Posts: 198.3785
Threads: 21
Joined: 14th Aug 2007
Reputation: 3.37413
E-Pigs: 1.1183
Offline
Post: #15
RE: A peak at the PTF format
im so excited i just pee'd a little :@

[Image: abstractsigcopylk5.jpg]
(This post was last modified: 12/09/2007 05:59 PM by SnailsPace.)
12/09/2007 05:58 PM
Find all posts by this user Quote this message in a reply
Ketchup
Neophitic Presence

Posts: 1.1162
Threads: 0
Joined: 12th Sep 2007
Reputation: 0
E-Pigs: 0.5000
Offline
Post: #16
RE: A peak at the PTF format
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 ...
(This post was last modified: 13/09/2007 02:48 AM by Ketchup.)
13/09/2007 02:33 AM
Find all posts by this user Quote this message in a reply
Vegetano1
$urf

Posts: 9,083.2507
Threads: 397
Joined: 2nd Mar 2007
Reputation: 6.06988
E-Pigs: 2756.6280
Offline
Post: #17
RE: A peak at the PTF format
O goodie goodie,.. go Zinga go!!


Make loads of $$!! it wurks!!
[Image: csbanner_anim_03.gif]
Signed Homebrew by bsanehi & OMightyBuggy
http://endlessparadigm.com/forum/showthr...?tid=25707
Spoiler for My miniBlog:
13/09/2007 05:45 AM
Visit this user's website Find all posts by this user Quote this message in a reply
SchmilK
Noob

Posts: 4,698.2833
Threads: 359
Joined: 16th Apr 2007
Reputation: 0.38918
E-Pigs: 82.0266
Offline
Post: #18
RE: A peak at the PTF format
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

limneosgreen Wrote:Take my advice, don't try to install custom themes ... it's possible to brick ur psp.. why just don't change wallpaper
(This post was last modified: 13/09/2007 09:31 AM by SchmilK.)
13/09/2007 09:29 AM
Find all posts by this user Quote this message in a reply
u_c_taker
hacks=drama

Posts: 3,185.2011
Threads: 102
Joined: 29th Jan 2007
Reputation: -1.03084
E-Pigs: 36.7855
Offline
Post: #19
RE: A peak at the PTF format
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

13/09/2007 01:11 PM
Find all posts by this user Quote this message in a reply
roberth
Resident Full Stop Abuser.....

Posts: 4,580.2098
Threads: 200
Joined: 18th Jun 2007
Reputation: -5.5814
E-Pigs: 43.8419
Offline
Post: #20
RE: A peak at the PTF format
i would love those lemmings icons but really rethemed...

13/09/2007 01:40 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


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

 Quick Theme: