Hacking LZSS compressed files in Wii games

Poryhack

Well-Known Member
OP
Member
Joined
Oct 18, 2009
Messages
332
Trophies
0
Age
29
XP
222
Country
United States
I guess I'm not sure if this applies to Wii games in general, but I recently decided to hunt for some files in Pokemon Battle Revolution and noticed that most of the interesting files are LZSS compressed. After some searching I found a tool called gbalzss which has apparently been successful in decompressing certain wii files in addition to GBA files. I tried it out on several of the files I had extracted with no luck; it was pretty apparent by looking at the output files that they were not decompressed properly. I did make sure to chop off the "LZSS" that was tacked onto the beginning of each file before doing this.

A couple observations:
-In traditional GBA/NDS/Wii compressed files there is a 4-byte header, the first byte of which specifies a compression method and the last 3 which give an decompressed filesize. The header is apparent here, but it is preceded by the identifier LZSS and it has a couple twists.
-The compression method byte is left blank, but that isn't a major issue because we already know it is LZSS.
-I am 99% sure the decompressed filesize is in big endian. As far as I can tell everything else, wii archive files included, are little endian.

Download a sample file here.

Does anybody have any insights on why gbalzss will not decompress these files correctly? Is anybody willing to do some debugging to figure out how wii games do it?

EDIT: To clarify, I have already tried standard LZSS decompression as well as Nintendo's LZ77 (both variants), RL, and Huffman with no success.
 

s3phir0th115

Well-Known Member
Member
Joined
Dec 31, 2008
Messages
728
Trophies
0
XP
803
Country
United States
I believe Triiforce has some code in it to deal with various compression types on the wii in order to work as it does. Maybe you could look at the source code and figure it out.

I will say though, having injected virtual console games and just messed with wii games, I can say with confidence that compression with Nintendo games is royal pain in the ass. I wish they'd use one fucking compression type and stay with it instead of having a million different ones.
 

WiiPower

Well-Known Member
Member
Joined
Oct 17, 2008
Messages
8,165
Trophies
0
XP
320
Country
Gambia, The
TriiForce source might help, but before i would try if it is able to load the game. If it does, you need to search for .dols. If there's only 1 and the rest is compressed or whatever, TriiForce decompression code is what you are looking for.
 

Poryhack

Well-Known Member
OP
Member
Joined
Oct 18, 2009
Messages
332
Trophies
0
Age
29
XP
222
Country
United States
PBR is an actual disc game though, not a VC/WiiWare game.

I see that there are two variants of compression; 0x10 is what all the tools I've seen so far have used so I assume there's nothing different about how your code unpacks it. 0x11 could be what I'm looking for...

Another question out of curiosity, why is it that LZSS and LZ77 are used interchangeably? At first I presumed they must be different but at least in the context of Nintendo's implementations they seem to be the same.
 

Poryhack

Well-Known Member
OP
Member
Joined
Oct 18, 2009
Messages
332
Trophies
0
Age
29
XP
222
Country
United States
I've tried and neither of the LZ77 variants work. I might as well mention that I previously tried Huffman and Run-Length for the hell of it.

Am I missing something or is this compression just something different? Would the fact that the file seems to be big-endian have any effect on decompression (keeping in mind here that I have converted the 3-byte decompressed filesize to little endian)?
 

Poryhack

Well-Known Member
OP
Member
Joined
Oct 18, 2009
Messages
332
Trophies
0
Age
29
XP
222
Country
United States
No I haven't made any changes. It puzzled me as well when I saw that LZ77 was the norm... (I'm still operating under the assumption that they mean the same thing, correct me if I'm wrong.) On the other hand, how often have people actually looked at files in ISOs? People hack Brawl and MKWii but the vast majority of research here went towards WADs.

DSdecmp is precisely what I used to test the 0x11 variant, with no luck. I don't expect there is any difference among the tools you listed.
 

Poryhack

Well-Known Member
OP
Member
Joined
Oct 18, 2009
Messages
332
Trophies
0
Age
29
XP
222
Country
United States
Omega Knight said:
Wii.py also has compress (and decompress?) code. And about hacking WOD's, uhh, the conduit was hacked a bit.
I'll look into that but if the Conduit doesn't have any similarly compressed files I don't think it will be of help.

QUOTE(stev418 @ Oct 19 2009, 04:05 PM) hmm : \ lol

maybe since in wads LZ77 = LZSS, maybe in ISO LZSS = LZ77 ill whip out pokemon and have another look.
I had the same thoughts, but after trying umpteen LZ77 decompression tools with no luck it appears that either they are not identical or something else is wrong.
 

Poryhack

Well-Known Member
OP
Member
Joined
Oct 18, 2009
Messages
332
Trophies
0
Age
29
XP
222
Country
United States
At this point I think that the implementation of LZSS used here is just plain different than the standards, which means I'm not going to find any kind of tool/sourcecode to help out.
 

hcs

Member
Newcomer
Joined
Aug 23, 2009
Messages
8
Trophies
0
Website
hcs64.com
XP
96
Country
United States
I've been doing some simple compression hacking lately, if you put the file back up I can take a look at it. The Conduit did have a LZSS-ish compression, fwiw.
 

hcs

Member
Newcomer
Joined
Aug 23, 2009
Messages
8
Trophies
0
Website
hcs64.com
XP
96
Country
United States
Took a look, haven't had any luck yet, if you put up some more files I might be able to pick up the pattern better. I notice at least that there seems often to be 0xF? in front of literal strings.

Better yet, consider posting it on XeNTaX, where someone might recognize it right away.
 

Poryhack

Well-Known Member
OP
Member
Joined
Oct 18, 2009
Messages
332
Trophies
0
Age
29
XP
222
Country
United States
My apologies for going AWOL, and I appreciate the advice. I just signed up and I'll post this just as soon as I'm approved.

EDIT: Also wanted to say thanks for the fsys program of yours. At first I did not realize you had made that. Came in very handy to actually get me to the point where I could see these "LZSS" files.
 

raydan

New Member
Newbie
Joined
Jan 13, 2010
Messages
1
Trophies
0
XP
1
Country
United States
i am try to get PBR model too
and i found a LZSS decompress code

http://pastebin.com/f67678659

the file is pkx_001.fsys
i use gcfsysd.exe extract to 2 file pkx_001.000. pkx_001.001

i use the above LZSS decompress code, it output a file, what next?


any one still can help?
 
General chit-chat
Help Users
    A @ Argimor: Anyone got any secret knowledge on Monster Hunter Rise Switch saves? Managed to pull the saves...