Lords Of The Fallen (*.PKG)

The Original Forum. Game archives, full of resources. How to open them? Get help here.
Ekey
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 1638
Joined: Wed Mar 31, 2010 6:54 am
Has thanked: 62 times
Been thanked: 817 times

Lords Of The Fallen (*.PKG)

Post by Ekey » Thu Oct 30, 2014 7:51 pm

Unpacker

About hashes - I have pirated game version but is not working. Unfortunately I do not know which algorithm is used. In game library i found 2 hash function djb2 and sdbm but no good results. Who knows? :(
You do not have the required permissions to view the files attached to this post.

SkacikPL
advanced
Posts: 53
Joined: Tue Oct 28, 2014 7:51 am
Has thanked: 3 times
Been thanked: 4 times

Re: Lords Of The Fallen (*.PKG)

Post by SkacikPL » Fri Jan 09, 2015 12:38 am

That's cool, i was curious about LOTF since a while.
I also found Quick BMS script which does about the same as your tool but extracts .dat files from the PKG.

I hope someone will try and chew through file formats, because at the bottom game seems to use pretty straightforward formats, plus anything in patch folder will override packages, so modding is a real possibility here.

Ekey
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 1638
Joined: Wed Mar 31, 2010 6:54 am
Has thanked: 62 times
Been thanked: 817 times

Re: Lords Of The Fallen (*.PKG)

Post by Ekey » Fri Jan 09, 2015 1:09 am

SkacikPL wrote:That's cool, i was curious about LOTF since a while.
I also found Quick BMS script which does about the same as your tool but extracts .dat files from the PKG.

I hope someone will try and chew through file formats, because at the bottom game seems to use pretty straightforward formats, plus anything in patch folder will override packages, so modding is a real possibility here.
My tool unpack the same files that QuickBMS, just without extensions ;)

SkacikPL
advanced
Posts: 53
Joined: Tue Oct 28, 2014 7:51 am
Has thanked: 3 times
Been thanked: 4 times

Re: Lords Of The Fallen (*.PKG)

Post by SkacikPL » Fri Jan 09, 2015 2:37 am

Ekey wrote:
SkacikPL wrote:That's cool, i was curious about LOTF since a while.
I also found Quick BMS script which does about the same as your tool but extracts .dat files from the PKG.

I hope someone will try and chew through file formats, because at the bottom game seems to use pretty straightforward formats, plus anything in patch folder will override packages, so modding is a real possibility here.
My tool unpack the same files that QuickBMS, just without extensions ;)
Though, different question is whether there is a way to get what's inside unpacked files.

hexaae
n00b
Posts: 13
Joined: Thu May 19, 2016 11:23 pm
Location: Italy
Has thanked: 1 time

Re: Lords Of The Fallen (*.PKG)

Post by hexaae » Mon Oct 08, 2018 8:35 am

Nothing new?
I'd still like to fix some Italian texts in this game. There's no need of repacker: you can just put files in "patch\" but they won't work if you alter just a single byte!
The problem is understanding that number block in blue:
Image
From a comparision between the French.bin and Italian.bin (see msg here with attachments) the first block is the same: FC89C5A3, next 4 bytes change between languages… If we understand that we should be able to edit the text and use it in the game simply putting the modified .bin under "...\Lords Of The Fallen\bundles\patch", skipping the unnecessary repack process.

merlinsvk
ultra-veteran
ultra-veteran
Posts: 409
Joined: Mon Oct 27, 2008 12:11 am
Location: Slovakia
Has thanked: 35 times
Been thanked: 114 times

Re: Lords Of The Fallen (*.PKG)

Post by merlinsvk » Mon Oct 08, 2018 6:01 pm

Can you upload/send me your modified .bin file? I don't have the game, so I can't test my script for recalculating the hash.

hexaae
n00b
Posts: 13
Joined: Thu May 19, 2016 11:23 pm
Location: Italy
Has thanked: 1 time

Re: Lords Of The Fallen (*.PKG)

Post by hexaae » Mon Oct 08, 2018 7:05 pm

merlinsvk wrote:Can you upload/send me your modified .bin file? I don't have the game, so I can't test my script for recalculating the hash.
You have PM

hexaae
n00b
Posts: 13
Joined: Thu May 19, 2016 11:23 pm
Location: Italy
Has thanked: 1 time

Re: Lords Of The Fallen (*.PKG)

Post by hexaae » Mon Oct 08, 2018 7:25 pm

Attached some .bin files (original, unmodified). If you need more language files tell me...
https://nofile.io/f/aS3AAYoZTva/languages_bin.7z

merlinsvk
ultra-veteran
ultra-veteran
Posts: 409
Joined: Mon Oct 27, 2008 12:11 am
Location: Slovakia
Has thanked: 35 times
Been thanked: 114 times

Re: Lords Of The Fallen (*.PKG)

Post by merlinsvk » Tue Oct 09, 2018 4:19 pm

Code: Select all

#------------------------------------------------
# Lords Of The Fallen language *.bin CRC fixer
# Script version: 0.2
#------------------------------------------------
idstring "\xFC\x89\xC5\xA3"		# just a test if the input file is a supported .bin file

encryption crc 0x01800063 "32 0 0 19 1 1"
get SIZE asize
xmath TXTSIZE "SIZE - 0x18"		# 0x18 = size of header
log MEMORY_FILE 0x18 TXTSIZE	# 0x18 = start of the data block
encryption "" ""

get NAME basename
get EXT extension
string NAME p= "%s.%s_FIXED" NAME EXT
get SIZE asize
log MEMORY_FILE2 0 SIZE							# create copy of file into RAM
putVarChr MEMORY_FILE2 0x04 QUICKBMS_CRC long	# write new CRC value on position 0x04
putVarChr MEMORY_FILE2 0x14 TXTSIZE long		# write text block size
log NAME 0 SIZE MEMORY_FILE2					# write new file on disk
EDIT: Updated script. Now it also recalculates the size of "text block".
Last edited by merlinsvk on Wed Oct 10, 2018 4:47 pm, edited 1 time in total.

hexaae
n00b
Posts: 13
Joined: Thu May 19, 2016 11:23 pm
Location: Italy
Has thanked: 1 time

Re: Lords Of The Fallen (*.PKG)

Post by hexaae » Tue Oct 09, 2018 6:09 pm

merlinsvk wrote:

Code: Select all

#------------------------------------------------
# Lords Of The Fallen language *.bin CRC fixer
#------------------------------------------------
idstring "\xFC\x89\xC5\xA3"		# just a test if the input file is a supported .bin file

encryption crc 0x01800063 "32 0 0 19 1 1"
get SIZE asize
math SIZE - 0x18  				# 0x18 = size of header
log MEMORY_FILE 0x18 SIZE		# 0x18 = start of the data block
encryption "" ""

get NAME basename
get EXT extension
string NAME p= "%s.%s_FIXED" NAME EXT
get SIZE asize
log MEMORY_FILE2 0 SIZE							# create copy of file into RAM
putVarChr MEMORY_FILE2 0x04 QUICKBMS_CRC long	# write new CRC value on position 0x04
log NAME 0 SIZE MEMORY_FILE2					# write new file on disk
Use this script on language .bin file. It will create new file with "_FIXED" extension.
Rename it and put the fixed file into \patch folder.
:o

It does work!
It seems I can finally be able to fix broken Italian text! :dance:
Thank you very much!

Can I ask one more thing? As you can see in the picture above with hex-editor starting from byte 18->end is reported (red square in the pic) the size of the whole text block in reverse order. Could you automate also that part and improve the script?

merlinsvk
ultra-veteran
ultra-veteran
Posts: 409
Joined: Mon Oct 27, 2008 12:11 am
Location: Slovakia
Has thanked: 35 times
Been thanked: 114 times

Re: Lords Of The Fallen (*.PKG)

Post by merlinsvk » Tue Oct 09, 2018 6:16 pm

And how do you want to edit this text? By hand in hex editor?

EDIT: There has to be something else (a mean some length check or another hash) because, when I make single string bigger, recalculate the length of that string, recalculate text block size and CRC, some strings in the game are missing.

Image

hexaae
n00b
Posts: 13
Joined: Thu May 19, 2016 11:23 pm
Location: Italy
Has thanked: 1 time

Re: Lords Of The Fallen (*.PKG)

Post by hexaae » Tue Oct 09, 2018 8:07 pm

Indeed there are more string checks:
Image
The red square byte (0x98) defines the length of the string…
BUT, there is still a problem: if I make it shorter (e.g. 95), and I turn 98->95 it still won't work, unless I replace extra bytes (since I shortened the string) with 0x00 keeping file structure (and length) intact :(
Maybe we have to respect some bytes alignment when we extend/shorten strings.

merlinsvk
ultra-veteran
ultra-veteran
Posts: 409
Joined: Mon Oct 27, 2008 12:11 am
Location: Slovakia
Has thanked: 35 times
Been thanked: 114 times

Re: Lords Of The Fallen (*.PKG)

Post by merlinsvk » Tue Oct 09, 2018 9:19 pm

Maybe we have to respect some bytes alignment when we extend/shorten strings.
Yes, exactly. That's padding. When I added one NULL byte after my test string, all missing text was back.
But that means, you will need proper tool to recalculate all paddings and lengths. Or it will be nightmare to do it all manually.

hexaae
n00b
Posts: 13
Joined: Thu May 19, 2016 11:23 pm
Location: Italy
Has thanked: 1 time

Re: Lords Of The Fallen (*.PKG)

Post by hexaae » Tue Oct 09, 2018 9:37 pm

merlinsvk wrote:
Maybe we have to respect some bytes alignment when we extend/shorten strings.
Yes, exactly. That's padding. When I added one NULL byte after my test string, all missing text was back.
But that means, you will need proper tool to recalculate all paddings and lengths. Or it will be nightmare to do it all manually.
Indeed it works as I supposed.
When I manually "pad" them (thanks for the term, didn't know how to call it ;)) I can safely change strings length, as explained in the picture below.
E.g.:
Image
I can extend/shrink the text in the cyan rectangle (even colliding the red rectangle) but then I must always add this padding at the end: 0x00000000 80000000 respecting 4bytes+4bytes and, in case, adjusting with null bytes the string length.

Yep, would be great if your script would automagically do:
- recalculate final block length (written in reverse order into the bin)
- add padding correction
- recalculate strings length (the byte before the string itself)

EDIT: there is also the padding variant 0x00000001 80000000 used after dialogue strings...
Last edited by hexaae on Wed Oct 10, 2018 8:17 am, edited 6 times in total.

merlinsvk
ultra-veteran
ultra-veteran
Posts: 409
Joined: Mon Oct 27, 2008 12:11 am
Location: Slovakia
Has thanked: 35 times
Been thanked: 114 times

Re: Lords Of The Fallen (*.PKG)

Post by merlinsvk » Tue Oct 09, 2018 9:42 pm

I think that repacker/converter from .bin to .txt and back would be better. My script is only for the final stage - CRC fixing.

Post Reply