PAK extractor with source code in C

CUECUE Posts: 16
edited September 2013 in Mod Showcase
This is my PAK extractor for the game.

Also include:
- source code
- .PAK file structure
- .PAK.MAN file structure

Updated link: http://www.mediafire.com/?ds7bw6wwbn0o6no
PACK is a command line tool to unpack/pack the file DATA.PAK

Usage: PACK source [target [n]]

* unpack 'source.pak' using 'source.pak.man' if no 'target' is specified
* pack 'target.pak' and 'target.pak.man' using unpacked 'source' files
* the optional 'n' parameter is the compression level, 0-9

* the unpacked data are stored in the same folder as the tool
* you should not specify the file extensions
* 'source' file must be different from 'target' file
* 'source.pak.man' file must be in the same folder as 'source.pak' file
* if 'n' is not specified or has an invalid value, use the default value
«1

Comments

  • kudos! and thanx for source code.
  • What folder should the program extract the files to?
    76561197996178860.png
  • CUECUE Posts: 16
    The program is a command line tool. You need specify the path: pack -u "C:\Program Files\Torchlight II\PAKS\DATA.PAK".

    Soon, maybe tonight, an updated version. Now you can unpack/pack the PAK/MAN files.
  • Yes, I did that and it successfully extracted the files. The problem is that they're not in the same folder as the extractor/pak file, and I can't seem to find them anywhere else.
    76561197996178860.png
  • CUE wrote:
    Soon, maybe tonight, an updated version. Now you can unpack/pack the PAK/MAN files.

    And if you can add, also, a patch option, like in Torchlight2Extractor, it would be great !!
    My website : http://www.cracrayol.org
    TL2 French Translation Project : http://sourceforge.net/projects/transmod2/
  • CUECUE Posts: 16
    cracrayol wrote:
    And if you can add, also, a patch option, like in Torchlight2Extractor, it would be great !!
    Nope, I'm sorry. The tool repack the files unsorted and you can indicate the compression level, so a patch has no sense.
    But the source code is available and anyone can add more options.


    ~~~ ADDED ~~~
    Updated the first post with the new link and a description.
  • WikusWikus Posts: 37
    Gracias señor CUE!
  • 1amcM.jpg
    820LcDeSURqbEMgv.jpg
    Evolve can track how long you play Torchlight 2 for, take screenshots of your awesome loot, record you epic boss fights, and has a VPN better then Tunngle and Hamachi combined, all for free (and with other games too)! What is Evolve? Find out here :)
  • cienislawcienislaw Posts: 243
    if you RUN if from \PAKS folder dont use full path but just a file name.
    C:\Program Files (x86)\Steam\steamapps\common\Torchlight II\PAKS> pack -u DATA.PAK
    
  • CUECUE Posts: 16
    edited October 2012
    CUE wrote:
    ...
    Usage: PACK source [target [n]]
    ...
    * you should not specify the file extensions
    ...
    
    Easy, remove the -u and the .PAK :)

    To unpack: PACK "C:\....\PAKS\DATA"
    To pack: PACK "C:\....\PAKS\DATA" NEW_DATA
  • cienislaw wrote:
    if you RUN if from \PAKS folder dont use full path but just a file name.
    C:\Program Files (x86)\Steam\steamapps\common\Torchlight II\PAKS> pack -u DATA.PAK
    

    Same thing:

    1amAM.jpg

    Edit:
    CUE wrote:
    CUE wrote:
    ...
    Usage: PACK source [target [n]]
    ...
    * you should not specify the file extensions
    ...
    
    Easy, remove the -u and the .PAK :)

    To unpack: PACK "C:\....\PAKS\DATA"
    To pack: PACK "C:\....\PAKS\DATA" NEW_DATA
    That works :)
    820LcDeSURqbEMgv.jpg
    Evolve can track how long you play Torchlight 2 for, take screenshots of your awesome loot, record you epic boss fights, and has a VPN better then Tunngle and Hamachi combined, all for free (and with other games too)! What is Evolve? Find out here :)
  • cienislawcienislaw Posts: 243
    CUE wrote:
    CUE wrote:
    Easy, remove the -u and the .PAK :)
    ahh, you removed switches. i still use first version;-)
  • KirasiN91KirasiN91 Posts: 207
    edited October 2012
    Can't seem to be able to pack.

    I have successfully unpacked the file. Yet me and a friend can't pack it.

    This is how it looks like: C:\Users\Me\Downloads\CUE> pack "MEDIA" NEWDATA 0
    Gives me a file open error, I'm running it as admin.

    EDIT: Figured it out, PACK "DATA" [MEDIA [0]]
  • CUECUE Posts: 16
    KirasiN91 wrote:
    Can't seem to be able to pack.

    I have successfully unpacked the file. Yet me and a friend can't pack it.

    This is how it looks like: C:\Users\Me\Downloads\CUE> pack "MEDIA" NEWDATA 0
    Gives me a file open error, I'm running it as admin.
    Use the same syntax, but adding the new name: PAK "C:\Progr....\PAKS\DATA" D:\TEMP\NEW and now you have NEW.PAK and NEW.PAK.MAN in D:\TEMP

    Compression level 0 is for no comrpession (very bog DATA.PAK file).
  • capa14capa14 Posts: 116
    Can someone post full line examples?

    I succeeded in unpack and the media folder is there...But im not understanding the syntax to pack it again.

    Thanks
    "Battles that could have been memorable, turned into our worst nightmare in stop motion" - CAPA
    ASUS M4A87TD; AMD Phenom II x 6 1090T Black 3.2 Ghz ; AMD XFX Radeon 6970 2GB GDDR5 880 Mhz/1375 Mhz; 4 x 2GB Kingston Hyper-X 1600Mhz
  • I still can't see the unpacked folder.
    I'm using <pack.exe file path> D:\...\DATA as the syntax, and the program supposedly extracts all the files and finishes the task, but the extracted folder is nowhere to be found.
    76561197996178860.png
  • bootboot Posts: 280
    Confused by paths? I have used this extractor, works fine if you read instructions.
    Let's say your only path is C:\Torchlight2
    Put DATA.PAK, DATA.PAK.MAN and pack.exe program in that folder.
    Open cmd, run "cd C:\Torchlight2" then run "pack.exe DATA" it will extract into C:\Torchlight2\MEDIA
    To pack it again just run "pack.exe DATA NEW 0" for no compression or "pack.exe DATA NEW 5" for compression rate of "5"
    This will create NEW.PAK and NEW.PAK.MAN which you can rename to DATA.PAK and DATA.PAK.MAN and use in your game until the next patch.
    fb1q.png
  • Oh, it works now.
    The reason is that I was running the program from my D: drive instead of my main C: drive.
    Thanks for the help! :)
    76561197996178860.png
  • capa14capa14 Posts: 116
    boot wrote:
    Confused by paths? I have used this extractor, works fine if you read instructions.
    Let's say your only path is C:\Torchlight2
    Put DATA.PAK, DATA.PAK.MAN and pack.exe program in that folder.
    Open cmd, run "cd C:\Torchlight2" then run "pack.exe DATA" it will extract into C:\Torchlight2\MEDIA
    To pack it again just run "pack.exe DATA NEW 0" for no compression or "pack.exe DATA NEW 5" for compression rate of "5"
    This will create NEW.PAK and NEW.PAK.MAN which you can rename to DATA.PAK and DATA.PAK.MAN and use in your game until the next patch.

    Thanks man!

    I thought you had to point the media folder in some point... i guess it just needs the original DATA as "template"

    Could repack it now!
    "Battles that could have been memorable, turned into our worst nightmare in stop motion" - CAPA
    ASUS M4A87TD; AMD Phenom II x 6 1090T Black 3.2 Ghz ; AMD XFX Radeon 6970 2GB GDDR5 880 Mhz/1375 Mhz; 4 x 2GB Kingston Hyper-X 1600Mhz
  • CUECUE Posts: 16
    boot wrote:
    Put DATA.PAK, DATA.PAK.MAN and pack.exe program in that folder.
    It is not necessary. Only put DATA.PAK, DATA.PAK.MAN in the same folder. You can specify the path in the command line

    Game installed in C:\T2
    Tool installed in D:\tools\CUE

    To unpack:
    - go to D:\tools\CUE
    - type PAK C:\T2\PAKS\DATA to create D:\tools\CUE\media with all extracted files

    To pack:
    - go to D:\tools\CUE
    - type PAK C:\T2\PAKS\DATA E:\NEWPACKS\TEST to create E:\NEWPACKS\TEST.PAK and E:\NEWPACKS\TEST.PAK.MAN using C:\T2\PAKS\DATA.PAK.MAN to get the file list and D:\tools\CUE\media to get the files

    The compression level is not needed. By default is 6 (zlib standard). With the maximum compression you can gain only a few megabytes.
  • DjKukucDjKukuc Posts: 11
    Just to point, remember that in the .PAK file is compressed 61 084 files so it can take on classic disc (not SSD like me) some time, around 5-10 minutes.

    Also i have problem - when i run command to unpack i got error with missing "zlib1.dll" so i've to download it manually and put it in the same folder as i have "pack.exe".

    Im now packing data with 0 compression and going to test if it do something with those framerate drops.

    Anyway thanks for help and tip.
  • Put it on GitHub.
  • bootboot Posts: 280
    Works both ways I guess. I just never liked writing paths so I just move them.
    Anyway, unpacked the files, forced defrag, stored them into new pak uncompressed and it solved one performance problem I had.
    Thanks a lot for release.
    fb1q.png
  • DjKukucDjKukuc Posts: 11
    Well I tested it w/o compression (set to 0) and i got if i tell you in percentage 2-5% to me.
    In heavy fight's i got improve from -+ 22 fps to 25 fps but nothing more.

    Oh yes! the game now loads much faster (thanks to my SSD where's TL 2 is).

    :P
  • What am I doing wrong?
    h_1349375303_9593256_80d61d86d9.png
    Tried without .exe - same thing.
  • 1.Go to PAKS dir
    2.Copy pack.exe here
    3.Magic sequence for unpack is """pack.exe DATA""" in cmd.exe window
    4.Magic sequence for pack is """pack.exe DATA SRATATA" in cmd.exe window to create pack SRATATA using MEDIA in dir where pack.exe exist.
    5.Hope that helps
    6.Enjoy
    7.Sometimes system dont have zlib1.dll you must take it from internet.
  • SamogonSamogon Posts: 2
    edited October 2012
    Thanks for suggestions.
    --dell---
    Worked well.
  • HomicideHomicide Posts: 1,071
    Nice stuff. Cheers. :P
    ...but when we stop acting civil and start calling people names, we're no longer interacting in the spirit of Runic Games.

    Zepheyr ~ 2012
  • RETSRETS Posts: 3
    Hello, Cue!

    I have to be honest- I'm not certain what I'm doing wrong. I've followed your instructions to the letter, (literally), and I cannot repack. I've tried several of the suggestions here as well, all to no avail. Let me give you the variations on the command lines I've tried:
    pack.exe C:\Games\Torchlight II\Media\DATA C:Games\Torchlight II\Media 0
    pack.exe DATA C:Games\Torchlight II\Media 0
    pack.exe C:\Games\Torchlight II\Media\DATA C:Games\Torchlight II\Media NEW_DATA 0
    pack.exe C:\Games\Torchlight II\Media\DATA &amp;#91;C:Games\Torchlight II\Media &amp;#91;0&amp;#93;&amp;#93;
    pack.exe C:\Games\Torchlight II\Media\DATA &amp;#91;C:Games\Torchlight II\Media NEW_DATA &amp;#91;0&amp;#93;&amp;#93;
    PACK C:\Games\Torchlight II\Media\DATA C:Games\Torchlight II\Media 0
    PACK C:\Games\Torchlight II\Media\DATA &amp;#91;C:Games\Torchlight II\Media &amp;#91;0&amp;#93;&amp;#93;
    PACK C:\Games\Torchlight II\Media\DATA C:Games\Torchlight II\Media NEW_DATA 0
    PACK C:\Games\Torchlight II\Media\DATA &amp;#91;C:Games\Torchlight II\Media NEW_DATA &amp;#91;0&amp;#93;&amp;#93;
    PAK C:\Games\Torchlight II\Media\DATA C:Games\Torchlight II\Media 0
    PAK C:\Games\Torchlight II\Media\DATA &amp;#91;C:Games\Torchlight II\Media &amp;#91;0&amp;#93;&amp;#93;
    PAK C:\Games\Torchlight II\Media\DATA C:Games\Torchlight II\Media NEW_DATA 0
    PAK C:\Games\Torchlight II\Media\DATA &amp;#91;C:Games\Torchlight II\Media NEW_DATA &amp;#91;0&amp;#93;&amp;#93;
    

    It just gets more pathetic from there, I'm sad to say. :?


    The one thing I can say about myself is that I can take an easy open lid and make it a two day project involving oxyacetylene and high-grade plastic explosive. ...In other words, I tend to make things that should be simple REALLY freakin' hard. :lol:

    If you or anyone else who comes across this post have some advice, I'm all ears. :shock: Or eyes, in this case. ;) Thanks!!
  • Hello :) Was wondering if I could use your app into mine http://forums.runicgames.com/viewtopic.php?f=48&t=44523
    and also is it possible to unpack to a user specified directory? that would be cool
«1
Sign In or Register to comment.