Important information: this site is currently scheduled to go offline indefinitely by end of the year.

Rebuilding archives with QuickBMS

Coders and would-be coders alike, this is the place to talk about programming.
User avatar
aluigi
VVIP member
VVIP member
Posts: 1916
Joined: Thu Dec 08, 2005 12:26 pm
Location: www.ZENHAX.com
Has thanked: 4 times
Been thanked: 664 times
Contact:

Rebuilding archives with QuickBMS

Post by aluigi »

The contents of this post was deleted because of possible forum rules violation.
User avatar
shekofte
mega-veteran
mega-veteran
Posts: 221
Joined: Sun Jan 18, 2009 1:45 pm
Location: Sagittarius
Has thanked: 301 times
Been thanked: 20 times
Contact:

Re: Rebuilding archives with QuickBMS

Post by shekofte »

adding more rebuilding functions to QuickBMS make it an acme tool ...
ILLUSORY VIDEO GAMES ARE MORE IMPORTANT THAN PRECIOUS INTERNATIONAL FOOTBALLs
brienj
VIP member
VIP member
Posts: 288
Joined: Mon May 02, 2005 1:48 pm
Location: Louisville, KY
Has thanked: 10 times
Been thanked: 70 times
Contact:

Re: Rebuilding archives with QuickBMS

Post by brienj »

Yeah, I made a script to rebuild headers on pac files that the files are all the same size. Came in handy for what I used it for. :)
ahon
n00b
Posts: 11
Joined: Thu Dec 17, 2009 5:35 am
Has thanked: 4 times

Re: Rebuilding archives with QuickBMS

Post by ahon »

is there a script to rebuild Svr 2010 pac files with quickbms?
Caboose
advanced
Posts: 67
Joined: Fri Sep 18, 2009 6:20 pm
Has thanked: 16 times
Been thanked: 1 time

Re: Rebuilding archives with QuickBMS

Post by Caboose »

I would love to have a script that rebuilds zip files with different compression methods and zip signatures.
User avatar
aluigi
VVIP member
VVIP member
Posts: 1916
Joined: Thu Dec 08, 2005 12:26 pm
Location: www.ZENHAX.com
Has thanked: 4 times
Been thanked: 664 times
Contact:

Re: Rebuilding archives with QuickBMS

Post by aluigi »

I already tried to write that script just for my tests and was ok except for 2 things:
  • quickbms doesn't have a crc function and the zip archives need the crc of each archived file otherwise the extraction program doesn't extract them (yes I have already tried using the magic crc 0xdebb20e3)
  • you can only store the files because quickbms doesn't support recompression (it's an extractor)
except for the first point the zip file rebuilt with my script is perfect
User avatar
aluigi
VVIP member
VVIP member
Posts: 1916
Joined: Thu Dec 08, 2005 12:26 pm
Location: www.ZENHAX.com
Has thanked: 4 times
Been thanked: 664 times
Contact:

Re: Rebuilding archives with QuickBMS

Post by aluigi »

first an update for my previous post: both the "exception" have been solved some versions ago, indeed quickbms supports a complete crc engine (plus tons of hashing algorithms) and supports also some recompression algorithms (zlib, xmem, lzo and so on).

instead now I want to talk about a feature I have implemented in version 0.4.6 for providing a solution for the current requests about endianess conversions.
I have implemented the -E option that costed me only 3 lines of code and automatically convert the endianess of any number read from a file.

imagine to have a file with the following format:

Code: Select all

32bit signature
32bit size
16bit crc
the script for reading it would be:

Code: Select all

get signature long
get size long
get crc short
if you add the -E and -w options at the command-line of quickbms the SAME reading/extracting script will automatically change the endianess of those 3 values :)

it's also possible to avoid to add the -w option by loading the file into a memory file, like the following example:

Code: Select all

get file_size asize
log MEMORY_FILE 0 file_size
get signature long MEMORY_FILE
get size long MEMORY_FILE
get crc short MEMORY_FILE
log dump.dat 0 file_size MEMORY_FILE
cool :)
Jurko
veteran
Posts: 86
Joined: Fri Jan 22, 2010 2:35 pm
Has thanked: 1 time
Been thanked: 3 times

Re: Rebuilding archives with QuickBMS

Post by Jurko »

Sorry for my bad English.
Can you create repacking script for Bad Company 2. For no gzip files. Please
User avatar
aluigi
VVIP member
VVIP member
Posts: 1916
Joined: Thu Dec 08, 2005 12:26 pm
Location: www.ZENHAX.com
Has thanked: 4 times
Been thanked: 664 times
Contact:

Re: Rebuilding archives with QuickBMS

Post by aluigi »

I have just released version 0.4.9 of QuickBMS which contains a feature that will make happy a lot of people :)

from now it's possible to use QuickBMS also for reimporting files back in the archives without modifying the original script, so just an automatic inverted operation.

obviously there are some limitations, the first of which is the size of the imported files that must be equal or minor than the original one (that's why it's a reimported and not a real rebuilder).

the following is the detail I have added in the documentation of quickbms.txt:

Code: Select all

The idea consists in being able to reimport the modified files for the
less complex archives without touching a single line of the script,
yeah just reusing the same bms scripts that already exist!

The function is experimental and it must be used in the following way:

- make a backup copy of the original archive!

- extract the files you want to modify (-f option) or just all the
  files as you do normally via the GUI or by command-line:

    quickbms script.bms archive.pak output_folder

- do your modifications to the extracted files and delete the files
  that have not been modified so that the reimporting process will be
  faster

- reimport the files in the archive:

    quickbms -w -r script.bms archive.pak output_folder

- test the game with the modified archive

Obviously you can use the GUI also for the reimporting procedure
because it's enough to create a file.bat containing the following line
and then double clicking it when you need to do this job:
quickbms.exe -w -r
anyway keep in mind that this is not guarantee with all the file formats and you can find an exaustive list of "exceptions" in the relative section quickbms.txt

@jurko
maybe you can try with this new feature but the result could not work, in any case I can't help.
but probably exist tools that already do the rebuilding job for that specific format
User avatar
cozy
beginner
Posts: 39
Joined: Mon Dec 07, 2009 10:18 pm
Been thanked: 21 times

Re: Rebuilding archives with QuickBMS

Post by cozy »

Thanx for the new features in a great tool,but when i come to rebuild the files back in a .cpk file the files are the same ones,i tested by filling the files with 1 byte,and the result is the same - 1650 files reimported in 5 seconds
Im` using the bms script for cpk files in a line command:-

quickbms cpk.bms *.cpk extracted

and to reimport:-

quickbms -w -r cpk.bms *.cpk extracted

thanx cozy
User avatar
aluigi
VVIP member
VVIP member
Posts: 1916
Joined: Thu Dec 08, 2005 12:26 pm
Location: www.ZENHAX.com
Has thanked: 4 times
Been thanked: 664 times
Contact:

Re: Rebuilding archives with QuickBMS

Post by aluigi »

oh finally a feedback about the new feature :)

can you check if you have the current version of quickbms?
it's 0.4.10, I have fixed various things lately after having implemented this feature

then the tool has reported that over 1600 files have been reimported so it seems correct, indeed the reimported files are counted only when each operation succeded at 100%.

are you sure the directory you selected contains the modified files?
if you have not modified all the 1600 files would be better to delete those that have not been modified.

as final test make a binary comparison between the original archive and the modified one.

I have verified the cpk.bms script and it uses a compression algorithm not supported in recompression mode so you can reimport in the archive ONLY the files that weren't compressed.
as far as I know doesn't exist code of the recompressor available publicly
User avatar
cozy
beginner
Posts: 39
Joined: Mon Dec 07, 2009 10:18 pm
Been thanked: 21 times

Re: Rebuilding archives with QuickBMS

Post by cozy »

aluigi wrote:oh finally a feedback about the new feature :)
I have verified the cpk.bms script and it uses a compression algorithm not supported in recompression mode so you can reimport in the archive ONLY the files that weren't compressed.
as far as I know doesn't exist code of the recompressor available publicly

I`ve got the new 0.4.10,and yes the files are compressed as i`ve looked at them using the CriPackedFileMaker.exe,so i guess thats why the files was not added,thanks for the reply,and keep up the good work!!!
User avatar
aluigi
VVIP member
VVIP member
Posts: 1916
Joined: Thu Dec 08, 2005 12:26 pm
Location: www.ZENHAX.com
Has thanked: 4 times
Been thanked: 664 times
Contact:

Re: Rebuilding archives with QuickBMS

Post by aluigi »

quickbms reports an error if the recompression algorithm is not available, so if you didn't see the error then it's something else
User avatar
shekofte
mega-veteran
mega-veteran
Posts: 221
Joined: Sun Jan 18, 2009 1:45 pm
Location: Sagittarius
Has thanked: 301 times
Been thanked: 20 times
Contact:

Re: Rebuilding archives with QuickBMS

Post by shekofte »

thanks Luigi
your tool is like a magic wand
ILLUSORY VIDEO GAMES ARE MORE IMPORTANT THAN PRECIOUS INTERNATIONAL FOOTBALLs
User avatar
aluigi
VVIP member
VVIP member
Posts: 1916
Joined: Thu Dec 08, 2005 12:26 pm
Location: www.ZENHAX.com
Has thanked: 4 times
Been thanked: 664 times
Contact:

Re: Rebuilding archives with QuickBMS

Post by aluigi »

I'm almost ready to release a new version of quickbms so if you have crazy ideas or suggestions, that's the moment to tell me :)
Post Reply