Demon's Soul - DCX/SDAT compressed format

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
Wulf
Posts: 49
Joined: Mon Oct 27, 2014 8:30 pm

Demon's Soul - DCX/SDAT compressed format

Post by Wulf »

This may already be a solved problem that I just need to get smarter for.

The DCX file contains an LUABND file, which itself contains a bunch of LUA scripts. The LUABND file appears to be a simple enough archive.

I'm not sure what the SDAT file is.

Offzip will decompress most of the DCX file, but it breaks it at odd points and doesn't seem like something that could be pieced back together again. Any input on how to write a script to decompress them, then recompress a modified copy would be appreciated.
Wulf
Posts: 49
Joined: Mon Oct 27, 2014 8:30 pm

Re: Demon's Soul - DCX/SDAT compressed format

Post by Wulf »

...Wait, I think I'm just dumb. It's not breaking at odd places, Windows file sorting isn't sorting the hex filenames appropriately.
Wulf
Posts: 49
Joined: Mon Oct 27, 2014 8:30 pm

Re: Demon's Soul - DCX/SDAT compressed format

Post by Wulf »

I do seem to be having some trouble getting QuickBMS to deflate it though. Anybody have a minute to type out the proper command?

Compressed data should start at offset 0x100.
Wulf
Posts: 49
Joined: Mon Oct 27, 2014 8:30 pm

Re: Demon's Soul - DCX/SDAT compressed format

Post by Wulf »

Alright, the below will get me the first 64Kb.

comtype deflate
string NAME = "m08.luabnd.tst"
clog NAME 0x100 0x1829f 0x80b2b

How would I get the rest?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Demon's Soul - DCX/SDAT compressed format

Post by aluigi »

For both luabnd and dcx I have just written this script:

http://aluigi.org/papers/bms/others/demons_soul.bms

SDAT maybe is something like an encrypted dcx? Don't know...
Wulf
Posts: 49
Joined: Mon Oct 27, 2014 8:30 pm

Re: Demon's Soul - DCX/SDAT compressed format

Post by Wulf »

It works great for exporting them, thanks.

Is it possible to reimport them? I get the following when trying to reimport to the dcx:
Error: script invalid for reimporting, it uses MEMORY_FILEs
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Demon's Soul - DCX/SDAT compressed format

Post by aluigi »

You cannot rebuild the dcx file but you can reimport the files in the luabnd one
Wulf
Posts: 49
Joined: Mon Oct 27, 2014 8:30 pm

Re: Demon's Soul - DCX/SDAT compressed format

Post by Wulf »

What would be needed to recreate the dcx? Would any existing deflate-based tools create an archive similar enough to be decompressed by the same game code?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Demon's Soul - DCX/SDAT compressed format

Post by aluigi »

Eh no, it's a custom format.
Basically you should first figure the the initial header (0x68 bytes) and then write a script that perform the whole work.

But why don't you use directly the luabnd file without compressing it?

The script, in fact, decompresses the dcx file so that you can try to delete the original dcx one leaving only the decompressed one on the disk, I "suppose" that the game loads this one.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Demon's Soul - DCX/SDAT compressed format

Post by aluigi »

Script updated 0.1.1.
Let me know if there are problems with other files.
Skykila
Posts: 7
Joined: Fri Aug 08, 2014 8:24 am

Re: Demon's Soul - DCX/SDAT compressed format

Post by Skykila »

All work! Many thanks!
Wulf
Posts: 49
Joined: Mon Oct 27, 2014 8:30 pm

Re: Demon's Soul - DCX/SDAT compressed format

Post by Wulf »

aluigi wrote:But why don't you use directly the luabnd file without compressing it?

The script, in fact, decompresses the dcx file so that you can try to delete the original dcx one leaving only the decompressed one on the disk, I "suppose" that the game loads this one.

If the DCX file doesn't exist, the game hangs at a black screen.

If you edit the name of the file the game's trying to load so that it loads the luabnd file instead, it crashes.

There are still thing I can try to make it work, but being able to replace the DCX would've been ideal. I could try my hand at modifying the game's decompressing code to be a simple copy, then just make sure every file is decompressed....

Thanks for the script thus far, it's a good start for what needs doing.
Wulf
Posts: 49
Joined: Mon Oct 27, 2014 8:30 pm

Re: Demon's Soul - DCX/SDAT compressed format

Post by Wulf »

Modifications to have Demon's Souls load unencrypted, uncompressed files. With the executable modified as shown below it will load the repacked bnd files from the script.


Don't load SDAT (encrypted):
0x0065B808 - FSELF
0x0066AF08 – RAM
409E0120 -> 60000000

0x0065B924 - FSELF
0x0066B024 - RAM
419EFEE8 -> 4BFFFEE8

Don't load SDAT (compressed):
0x0065B7FC - FSELF
0x0066AEFC - RAM
409e00cc -> 60000000
Wulf
Posts: 49
Joined: Mon Oct 27, 2014 8:30 pm

Re: Demon's Soul - DCX/SDAT compressed format

Post by Wulf »

I can probably figure this out when I get some time to focus on it, but any idea why the script is failing on the attached binder file? Different extension, same (similar?) BND format.
Wulf
Posts: 49
Joined: Mon Oct 27, 2014 8:30 pm

Re: Demon's Soul - DCX/SDAT compressed format

Post by Wulf »

Success with the below script, but I'll have to look closer into what I cut out to make it work.

Code: Select all

# Demon's Soul
# script for QuickBMS http://quickbms.aluigi.org

endian big

get EXT extension

idstring "BND"  # BND307D7R6
goto 12
get DUMMY long  # FLAGS with endianess?
get FILES long
get BASE_OFF long
get ZERO long
get ZERO long
goto 0x2C
for i = 0 < FILES
    get FLAGS long
    get SIZE long
    get OFFSET long

    log OFFSET OFFSET SIZE
next i
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Demon's Soul - DCX/SDAT compressed format

Post by aluigi »

I have updated the script to match the format.
Unfortunately I don't know the exact meaning of that FLAG so now there are 3 bits that I check together but they should be checked separately.
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: Demon's Soul - DCX/SDAT compressed format

Post by AnonBaiter »

You've been missing out the .moib/.mosb/.mowb files too, which isn't surprising given the diverse range of files used in the game(many variations of the BND archive, etc).
ds_bgm_m01.rar

Although the .mowb file seems to be the BND archive file, the .mosb file also has references for that file. There are even filenames at the end of the .mosb file, but there are no containers(no sign of .at3 for example).
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Demon's Soul - DCX/SDAT compressed format

Post by aluigi »

MOSI and MOSB have no data or not interesting data while ds_bgm_m01.mowb works correctly with my script.
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: Demon's Soul - DCX/SDAT compressed format

Post by AnonBaiter »

Oh... well...