Baldur's Gate 3 (*.PAK)

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Baldur's Gate 3 (*.PAK)

Post by Ekey »

Code: Select all

# Baldur's Gate 3 PAK format (script 0.1.1)
# script for QuickBMS http://quickbms.aluigi.org

callfunction QUICKBMS_4GB_CHECK 1

comtype lz4
idstring "LSPK"
get VERSION long #15
get TABLE_OFF longlong

goto TABLE_OFF
get FILES long
get TABLE_ZSIZE long
savepos TABLE_OFFSET

math TABLE_SIZE = FILES
math TABLE_SIZE *= 296

clog MEMORY_FILE TABLE_OFFSET TABLE_ZSIZE TABLE_SIZE

for i = 0 < FILES
    getdstring NAME 256 MEMORY_FILE
    get OFFSET longlong MEMORY_FILE
    get ZSIZE longlong MEMORY_FILE
    get SIZE longlong MEMORY_FILE
    get DUMMY longlong MEMORY_FILE
    get CRC long MEMORY_FILE
    get DUMMY long MEMORY_FILE
   
    if SIZE == 0
        log NAME OFFSET ZSIZE
    else
        clog NAME OFFSET ZSIZE SIZE
    endif
next i

startfunction QUICKBMS_4GB_CHECK
    math TMP64 = 0x10000000
    math TMP64 * 16
    if TMP64 == 0
        print ">>>> You must use quickbms_4gb_files.exe with this archive <<<<"
        cleanexit
    endif
endfunction
Last edited by Ekey on Wed Oct 14, 2020 3:15 pm, edited 3 times in total.
erik945
Posts: 23
Joined: Sat Nov 18, 2017 7:30 pm

Re: Baldur's Gate 3 (*.PAK)

Post by erik945 »

Thank you!
jayn23
Posts: 3
Joined: Sun Oct 11, 2020 3:24 pm

Re: Baldur's Gate 3 (*.PAK)

Post by jayn23 »

Just created an account to say Thanks :)

I dont know if this is an issue with the script, but some creature files contain only .bin files while others contain .gr2 + .bin files (.bin are 1kb files - probably some file info haven't checked them out yet)
this includes creatures that are in EA of the game so there should be gr2 files for them.

By the way could you please let me know how you identified the compression type is lz4?
while I pretty good with 3d meshes and skeleton/animation , I have almost 0 experience with compressed archives except for .zlib
any pointers would be great
chrrox
Posts: 388
Joined: Thu Aug 07, 2014 10:28 pm

Re: Baldur's Gate 3 (*.PAK)

Post by chrrox »

you can just use a compression scan tool here.
compscan bms scrip.
QuickBMS comtype scanner 2
https://aluigi.altervista.org/quickbms.htm
jayn23
Posts: 3
Joined: Sun Oct 11, 2020 3:24 pm

Re: Baldur's Gate 3 (*.PAK)

Post by jayn23 »

chrrox wrote:you can just use a compression scan tool here.
compscan bms scrip.
QuickBMS comtype scanner 2
https://aluigi.altervista.org/quickbms.htm


Thanks for the tip - just for practice sake ill try using this tool to figure out compression type and RE the archive.
Clearless
Posts: 2
Joined: Tue Nov 12, 2019 4:58 pm

Re: Baldur's Gate 3 (*.PAK)

Post by Clearless »

Thanks for the script! I have an issue tho. For some reason when I try to extract the 30gb textures.pak file, it only exports 0 byte textures.
farrarie
Posts: 2
Joined: Tue Oct 29, 2019 5:30 pm

Re: Baldur's Gate 3 (*.PAK)

Post by farrarie »

Thanks, but sadly it dont extract texture pak
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: Baldur's Gate 3 (*.PAK)

Post by Ekey »

Clearless wrote:Thanks for the script! I have an issue tho. For some reason when I try to extract the 30gb textures.pak file, it only exports 0 byte textures.

farrarie wrote:Thanks, but sadly it dont extract texture pak

Fixed. Check the first post :)

jayn23 wrote:I dont know if this is an issue with the script, but some creature files contain only .bin files while others contain .gr2 + .bin files (.bin are 1kb files - probably some file info haven't checked them out yet)
this includes creatures that are in EA of the game so there should be gr2 files for them.

The script extract everything in the archive entry table. I think that's what the developers intended

PS: Also you can use this tool for unpack/pack and convert models https://github.com/Norbyte/lslib/releases

Just example :)

Image
jayn23
Posts: 3
Joined: Sun Oct 11, 2020 3:24 pm

Re: Baldur's Gate 3 (*.PAK)

Post by jayn23 »

PS: Also you can use this tool for unpack/pack and convert models https://github.com/Norbyte/lslib/releases


Thanks you can check out my .gr2 script for noesis - it supports more gr2 variations than norbytes tool

although norbytes code was my main reference with animation phrasing

https://forum.xentax.com/viewtopic.php? ... b20b082c28
Panzerdroid
Posts: 66
Joined: Sun Aug 30, 2015 12:51 pm

Re: Baldur's Gate 3 (*.PAK)

Post by Panzerdroid »

Hmm, lowtex.pak can't be unpacked still even with a newer script.
Clearless
Posts: 2
Joined: Tue Nov 12, 2019 4:58 pm

Re: Baldur's Gate 3 (*.PAK)

Post by Clearless »

Thank you Ekey.
Synyster328
Posts: 1
Joined: Tue Oct 13, 2020 7:05 pm

Re: Baldur's Gate 3 (*.PAK)

Post by Synyster328 »

Hi, thank you for putting this out there! I do have a question, will this script work for reimporting as well? After extracting, I tried changing some minor values like a number or string here or there, and depending on the change the game either won't load at all, or character creation will be entirely broken, or hitting "continue" will just leave me in a loading loop. It seems to me that maybe there's just an issue repacking in general, since I don't know why there would be these issues just by changing some item description text.

Anyway, thanks again!
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: Baldur's Gate 3 (*.PAK)

Post by Ekey »

The structure contains a DWORD similar to CRC, perhaps the game checks files by this CRC. If so then try the tool from this post
Butterbean
Posts: 6
Joined: Thu Oct 08, 2020 11:46 am

Re: Baldur's Gate 3 (*.PAK)

Post by Butterbean »

Hi everyone,

I've managed to unpack the PAK file with the following tool:

https://github.com/Norbyte/lslib/releases

Now I'm stuck on repacking it. I've tried many packers and the program starts, but always writes "not found.".

https://images2.imagebam.com/3e/9b/4d/8 ... 224540.jpg

Any help is appreciated,
Cheers,
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: Baldur's Gate 3 (*.PAK)

Post by Ekey »

Try the updated version lslib
Butterbean
Posts: 6
Joined: Thu Oct 08, 2020 11:46 am

Re: Baldur's Gate 3 (*.PAK)

Post by Butterbean »

Ekey wrote:Try the updated version lslib


Dear Ekey

thank you i try new version same problem i try only unpack and repack not modify and not work.
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: Baldur's Gate 3 (*.PAK)

Post by Ekey »

Butterbean wrote:Dear Ekey

thank you i try new version same problem i try only unpack and repack not modify and not work.

It works fine!

Some proofs
https://images2.imagebam.com/46/9d/a2/5 ... 365509.png
https://images2.imagebam.com/f3/68/73/f ... 365510.png
Butterbean
Posts: 6
Joined: Thu Oct 08, 2020 11:46 am

Re: Baldur's Gate 3 (*.PAK)

Post by Butterbean »

Ekey wrote:
Butterbean wrote:Dear Ekey

thank you i try new version same problem i try only unpack and repack not modify and not work.

It works fine!

Some proofs
https://images2.imagebam.com/46/9d/a2/5 ... 365509.png
https://images2.imagebam.com/f3/68/73/f ... 365510.png



and how work ? i see this lslib i try all variation and not work for me :(
Last edited by Butterbean on Wed Oct 14, 2020 4:43 pm, edited 1 time in total.
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: Baldur's Gate 3 (*.PAK)

Post by Ekey »

There is no difference, I think it will work the same with editing English.pak. Show me your settings of this app.
Butterbean
Posts: 6
Joined: Thu Oct 08, 2020 11:46 am

Re: Baldur's Gate 3 (*.PAK)

Post by Butterbean »

Ekey wrote:There is no difference, I think it will work the same with editing English.pak. Show me your settings of this app.



Thank you for helping!

russian pack only open and repack ( i try english.pak):

https://images2.imagebam.com/0f/5e/d2/2 ... 372134.png