Resident Evil 4 stage .das files[GC/WII]

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
KingOfGuns
Posts: 2
Joined: Sun Nov 20, 2016 12:06 am

Resident Evil 4 stage .das files[GC/WII]

Post by KingOfGuns »

I need help extracting these. Currently we can't open stage/room .das files, i think they are compressed. I've atached 2 .rar files, one contains a stage/room .das file, which cannot be extracted atm, and the other contains a regular .das file, which can be extracted with the current available tools.
mariokart64n
Posts: 12
Joined: Fri Aug 08, 2014 12:59 am

Re: Resident Evil 4 stage .das files[GC/WII]

Post by mariokart64n »

I'm looking for a way to decompress the resource blocks in RE4 so I can study the geometry data.

The header contains two strings, one for the compressed size, and the other is the decompressed size then the header is padded to 32bytes.

At address 32 the compressed stream begins, which always starts with the same dword 0xCE2843DD.
I've ran the compression scan script for quickBMS, but nothing looks correct.

I contacted the author of BioFAT (a generic resident evil unpacker) and they stated that the compression was a custom yz2.

So I've tried to manually configure the header to fit the yaz0 specification, but that also fails to decompress with quickBMS.

I've included samples from PC (Steam Version), Gamecube, and the xbox 360 which oddly only the PC version is missing this yz2 compression. Maybe because PC is little endian vs gamecube and xbox360 which are big endian?

Either way any additional input into what this compression is or how it could be defeated is greatly welcome. :)
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Resident Evil 4 stage .das files[GC/WII]

Post by aluigi »

Probably that compression is not available in quickbms.
Is there any source code or implementation of that compression? (I don't know if that biofat you mentioned supports it or not)

P.S.: is that "ce 28 43 dd" a magic value for recognizing that compression?
rabatini
Posts: 179
Joined: Tue Jan 18, 2022 12:21 am

Re: Resident Evil 4 stage .das files[GC/WII]

Post by rabatini »

Hello.

Did you try these tools?

take a look on this. maybe can help you.

In attachment has a yz2tool

https://residentevilmodding.boards.net/thread/2486/re4-model-importer-exporter-toolset
mariokart64n
Posts: 12
Joined: Fri Aug 08, 2014 12:59 am

Re: Resident Evil 4 stage .das files[GC/WII]

Post by mariokart64n »

Yes CE2843DD appears to be the magic, but I'm not able to locate any existing implementation of the compression.

I have the DOL of the gamecube demo for resident evil 4, but I don't know how to disassemble it. Doing a string search in hex I can see a reference to a function called 'ReadCompressData' but I cannot locate a reference to the magic CE2843DD or the extension yz2.

re4_e3_demo_dol.zip


As for the yz2tool there seems to be some confusion around it, on the pc version on steam the files have multiple extensions.
Example: 000000a0.pack.yz2.lfs

However the compression that was used was Xmem which is seen on both the xbox360 and PC versions. Except the Xbox360 is double compressed with yz2 compression where as the PC is not.

The yz2tool is deceiving in the sense it only unpacks the already decompressed pack files on the PC and does not actually decompress anything.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Resident Evil 4 stage .das files[GC/WII]

Post by aluigi »

mariokart64n wrote:The yz2tool is deceiving in the sense it only unpacks the already decompressed pack files on the PC and does not actually decompress anything.

Indeed, when I quickly checked it I didn't see any decompression code.
Thanks for confirming :)
Allen
Posts: 156
Joined: Tue Sep 01, 2015 9:44 am

Re: Resident Evil 4 stage .das files[GC/WII]

Post by Allen »

..
Last edited by Allen on Fri Feb 18, 2022 3:31 pm, edited 1 time in total.
Allen
Posts: 156
Joined: Tue Sep 01, 2015 9:44 am

Re: Resident Evil 4 stage .das files[GC/WII]

Post by Allen »

mariokart64n wrote:Yes CE2843DD appears to be the magic, but I'm not able to locate any existing implementation of the compression.

I have the DOL of the gamecube demo for resident evil 4, but I don't know how to disassemble it. Doing a string search in hex I can see a reference to a function called 'ReadCompressData' but I cannot locate a reference to the magic CE2843DD or the extension yz2.

re4_e3_demo_dol.zip


Spent 10 days debugging, some progress, but still some bugs can't fully reverse decompress the code. I've been stuck getting the index value of the temp buffer and can't get the index right.

Here I give you some hints if you can debug.
If it is the DEMO version, you can debug these functions.

DOL of the gamecube demo for resident evil 4:

Code: Select all

void __fastcall sub_80178784(_BYTE *a1)
void __fastcall sub_8018A1F0(int *a1, _BYTE *a2, int a3, double a4)
int __fastcall sub_8018A5DC(int result, double a2, double a3, double a4, double a5, int a6, int a7, unsigned int *a8)
__int64 __fastcall sub_8018A3BC(double a1, double a2, double a3, double a4)


This is the version I debugged. RE4 USA GAMECUBE version.
Resident Evil 4 (USA) (Disc 1)_gamecube:

Code: Select all

void __fastcall sub_80170260(int outBufferPtr)
void __fastcall sub_8018F5CC(DecompressTempBufferInfo *tempBufferInfo, _BYTE *outBuffer, int decompressSize, double _f1)
int __fastcall sub_8018F9B8(int result, double a2, double _f2, double _f3, double _f4, int a6, int _dw1280_1, unsigned int *flags)
__int64 __fastcall sub_8018F798(double _f1, double _f2, double _f3, double _f4)
mariokart64n
Posts: 12
Joined: Fri Aug 08, 2014 12:59 am

Re: Resident Evil 4 stage .das files[GC/WII]

Post by mariokart64n »

thanks for looking at it, its interesting that the retail version is slightly different. I uploaded the demo dol because i figured it may have more debug symbols in it then the retail.

did you get this from IDApro? I seen there was a dol plugin but wasn't able to find a working link to it
Allen
Posts: 156
Joined: Tue Sep 01, 2015 9:44 am

Re: Resident Evil 4 stage .das files[GC/WII]

Post by Allen »

Allen
Posts: 156
Joined: Tue Sep 01, 2015 9:44 am

Re: Resident Evil 4 stage .das files[GC/WII]

Post by Allen »

After another 10 days of hard work, with more progress, I have successfully decompressed the file. The tool will be released after perfecting.
The process is quite painful, debugging the code line by line...
Allen
Posts: 156
Joined: Tue Sep 01, 2015 9:44 am

Re: Resident Evil 4 stage .das files[GC/WII]

Post by Allen »

Resident Evil 4 Gamecube / Xbox360 stage .das file decompression tool

Usage:
Just drag and drop the .das file or .bin file to the program and it will be automatically decompressed.
Leonhart
Posts: 2
Joined: Fri Jun 24, 2022 10:06 am

Re: Resident Evil 4 stage .das files[GC/WII]

Post by Leonhart »

Allen wrote:Resident Evil 4 Gamecube / Xbox360 stage .das file decompression tool

Usage:
Just drag and drop the .das file or .bin file to the program and it will be automatically decompressed.


Hey Allen, thank you for your hard work on this!
Would you be able to create a tool to compress the .das file?
Allen
Posts: 156
Joined: Tue Sep 01, 2015 9:44 am

Re: Resident Evil 4 stage .das files[GC/WII]

Post by Allen »

Leonhart wrote:
Hey Allen, thank you for your hard work on this!
Would you be able to create a tool to compress the .das file?

Hi Leonhart,

I can't yet.
To decompress the data, I only need to interpret assembly language to C++ code, no need to understand the principle.
The compression code needs to figure out how compression works, which is more complicated.
Leonhart
Posts: 2
Joined: Fri Jun 24, 2022 10:06 am

Re: Resident Evil 4 stage .das files[GC/WII]

Post by Leonhart »

Allen wrote:I can't yet.
To decompress the data, I only need to interpret assembly language to C++ code, no need to understand the principle.
The compression code needs to figure out how compression works, which is more complicated.

Thanks for the reply, do you know anyone who can do this?