QuickBMS - Reimporting files in the archives

Videos, guides, manuals, documents and tutorials about using tools and performing tasks
SADEKFCB
Posts: 4
Joined: Thu Sep 15, 2016 10:17 pm

Re: QuickBMS - Reimporting files in the archives

Post by SADEKFCB »

thank you aluigi it's work :) :) :) :) :)
UnderTeach
Posts: 1
Joined: Sun Nov 27, 2016 10:50 am

Re: QuickBMS - Reimporting files in the archives

Post by UnderTeach »

Hi,
I am working on an italian translation of Undertale, still work in progress, but I want to test out the graphical translation. To decrypt the data file from data.win, I used yoyogames.bms script, which worked as expected, but now I can't encrypt them again in a data.win file.
Any suggestions on which script to run? I've tried reimport.bat but I can't comprehend the use of it. Such a noob I am :roll:
Thanks for the great job you're doing.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: QuickBMS - Reimporting files in the archives

Post by aluigi »

reimport.bat is very simple and it's explained in section 3 of http://aluigi.org/papers/quickbms.txt

In short you should click on reimport.bat and select the same script, archive (remember to make a backup!), and folder (that now acts as "input") you selected during the extraction.

The following are some rules to increase the chances of a good reimporting:
  • in the folder where you extracted the files, keep there only those you edited and delete the others (this is useful mainly for compressed files)
  • the edited files (for example graphics in your case) must have a size which is smaller or equal than the originals
  • for your translation you are probably going to edit STRG.txt, remember to keep your new strings (each line) shorter/equal than the originals
  • in some rare archive formats it's even necessary to keep the new string with the same length of the original, so filling it with spaces, but this is not the case of Undertale probably

If you have other doubts do a search on google with the following keywords because other people had success in modding Undertale and made videos and tutorials:

Code: Select all

undertale quickbms reimport
skiracing
Posts: 3
Joined: Thu Jan 12, 2017 11:18 pm

Re: QuickBMS - Reimporting files in the archives

Post by skiracing »

Hello

I try to edit some staff in alpine ski racing 2007 game. Sometimes re-importing works, sometimes not. Edit I tried is really simple. For example, I only exchanged one number for another or something like that.
When re-importing is not working, mostly, I got this message:

Last script line before the error or that produced error:
26 clog NAME OFFSET ZSIZE SIZE



Please, any ideas how to solve this?
Thank you so much
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: QuickBMS - Reimporting files in the archives

Post by aluigi »

That script (49games.bms) is not valid for reimporting because the re-compression algorithm is not available.
skiracing
Posts: 3
Joined: Thu Jan 12, 2017 11:18 pm

Re: QuickBMS - Reimporting files in the archives

Post by skiracing »

aluigi wrote:That script (49games.bms) is not valid for reimporting because the re-compression algorithm is not available.


Thank you for answer.
Is there available any scrip that has this algorithm? If not, is there any chance for this algorithm to be added there?
Btw, despite this fact, I even succeeded in re-importing some files.
Please help, I play this game every ski season for more 10 years now (because there is never new ski game... :cry: :cry: :cry: ) so if I could make at least slight editing to feel it more enjoyable. Thank you so much for your help. :)
Last edited by skiracing on Fri Jan 13, 2017 5:40 pm, edited 1 time in total.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: QuickBMS - Reimporting files in the archives

Post by aluigi »

No, the only solution would be to check if the game works with the extracted files and without the original archive (probably doesn't work or requires specific folders).
Writing a rebuilder (with compression disabled) may be an option but you have to do it by yourself or finding someone who wants to do it.
You can also try some hacks on the archive with a hex editor like disabling the compression for that file, appending the content of the new file to the archive and editing the offset, size and crc field (and the method as already said).
Unfortunately with edited files the options are ever quite limited and I offer no support on this stuff, sorry.
skiracing
Posts: 3
Joined: Thu Jan 12, 2017 11:18 pm

Re: QuickBMS - Reimporting files in the archives

Post by skiracing »

Ohh..thank you for explanation.

I'm totally dumb on hacking and stuff like that and even do not understand anything about those methods that you are telling. Oh well, it is only hope maybe sometimes in future it will be possible to re-import edited files in the game. For now, at least I know there is no sense to trying more. Thanks anyway.
Kryys
Posts: 5
Joined: Sun Feb 05, 2017 7:35 pm

Re: QuickBMS - Reimporting files in the archives

Post by Kryys »

aluigi wrote:It's a problem of physical space, so there is no ready solution except writing a rebuilder from scratch (the format is not complex) or just appending the new content to the file and then modifying the OFFSET and SIZE field in the archive (something that requires manual work but may be easy with the help of quickbms -l -V).

Hello, could you please provide (or link) an example on how to modify the offset and size field in an archive ? I'm currently making a voice mod, and i literally need to slaughter the soundtracks quality in order for them to "fit" in the original archive, which is not good at all :/
( If needed, i attached here the quickbms scipt i'm using, an archive and an ogg file i would like to inject in this archive)
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: QuickBMS - Reimporting files in the archives

Post by aluigi »

Ok, I will explain what's the normal method because you cannot use it in your situation since you have an encrypted TOC (the information about the archived files).
Sorry.

You need to run quickbms with the -l (list because you have already extracted the files) and -V option, example:

Code: Select all

quickbms -l -V script.bms archive.dat > info.txt

When you open info.txt you can notice the following fields:
  • a dot
  • hexadecimal offset where is located the data read from the file
  • bms instruction used
  • name of the variable
  • value that has been read
  • size or type of value, usually just the size of the field (1 for byte, 4 for long and so on, N for strings)

The following is an example of these information:

Code: Select all

. 00000012 get     comp_size  0x000032b4 4
. 00000016 get     uncomp_size 0x0000981a 4
. 0000001a get     name_len   0x0000000d 2
. 0000001c get     extra_len  0x00000000 2
. 0000001e getdstr name       "changelog.txt" 13
    63 68 61 6e 67 65 6c 6f 67 2e 74 78 74            changelog.txt
. 0000002b getdstr extra      "" 0
  0000002b 38938      changelog.txt

Now if you want to edit the offset and size of an archived file:
  • open the archive with a hex editor
  • go to the offset of the variable you want to change (the hexadecimal value after the dot)
  • put your new value overwriting the old one

So let's say you want to change the compressed and decompressed size of the previous example I provided, you have to go to offset 0x12 replacing 0x32b4 with the new one, and then do the same at offset 0x16 for 0x981a.

Yeah it's very simple if they are just few files.
Kryys
Posts: 5
Joined: Sun Feb 05, 2017 7:35 pm

Re: QuickBMS - Reimporting files in the archives

Post by Kryys »

Ah, that's sad :/ But as i can see (i think ...), the quickbms script i'm using contains decryption keys for my archive. So my question is, can impliment this method directly into a quickbms script, so that he list the files and change the offset variables i want ? Or Quickbms can't directly modify an archive ?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: QuickBMS - Reimporting files in the archives

Post by aluigi »

Quickbms can modify archives, there are instructions like Put that do this job and the log/clog commands can be used to write data into the input archive too (with "append 1").
If you have time, perfect skills with quickbms and you have the re-encryption function probably you can (but don't expect any time and help from me, sorry)
Kryys
Posts: 5
Joined: Sun Feb 05, 2017 7:35 pm

Re: QuickBMS - Reimporting files in the archives

Post by Kryys »

It's ok, thank you very much for the information, it will help me in the future :D
Kratos9999
Posts: 129
Joined: Mon Aug 22, 2016 10:30 am

Re: QuickBMS - Reimporting files in the archives

Post by Kratos9999 »

Hi aluigi, how I can do for reimport a folder with a file inside for a archive? I've read the section 3 of manual, but I didn't understood the steps for reimport folders with files inside.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: QuickBMS - Reimporting files in the archives

Post by aluigi »

The process is completely automatic and, remember, you can reimport only what has been extracted (what already existed in the archive and you have modified), so if you are thinking about adding new files/folders then you can't.
Kratos9999
Posts: 129
Joined: Mon Aug 22, 2016 10:30 am

Re: QuickBMS - Reimporting files in the archives

Post by Kratos9999 »

The folder that I'm trying to reimport has been extracted from archive. The archive have manys folders and chunked files, I'm using the asura script, here is the archive: https://drive.google.com/file/d/0B-izXc ... p=drivesdk
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: QuickBMS - Reimporting files in the archives

Post by aluigi »

Recent asura archives are entirely compressed so the script decompresses the input archive in a temporary file which is then used as source for the extraction.
In that scenario you can't use the reimport feature of quickbms because the data doesn't come directly from the input archive.
Luckily that's not your case but I want to warn people if they encounter that case.

Regarding your case there is nothing special except various files that have the same name and so they can't be reimported correctly.
What I mean is that if you can't reimport the files you are using the reimport feature in the wrong way.
Solution: READ section 3 for real and do the SAME steps you did during extraction.
Kratos9999
Posts: 129
Joined: Mon Aug 22, 2016 10:30 am

Re: QuickBMS - Reimporting files in the archives

Post by Kratos9999 »

I've searched in net and it seems there is a unpacker/repacker tool for the asura format, but all the links that I have tried are broken! I would like aluigi if you have this tool for send to me, I've read the SECTION 3 and the reimport didn't work, the quickbms close automatically. I need it so much of this tool, It looks like it was made by Terry Buttler, but the download link in official site is not working. In asura script there is a citation about this author, please, if you have this tool send for me, I will be very grateful, very
much.
AlexCooks
Posts: 1
Joined: Sun Jul 02, 2017 5:40 am

Re: QuickBMS - Reimporting files in the archives

Post by AlexCooks »

This has been addressed before, but since I can't find an answer, I'd like your help with it.
Following is the cmd log (I used the reimport batch file)

Code: Select all

QuickBMS generic files extractor and reimporter 0.8.0
by Luigi Auriemma
e-mail: me@aluigi.org
web:    aluigi.org
        (Mar 12 2017 - 15:03:46)

                   quickbms.aluigi.org  Homepage
                            zenhax.com  ZenHAX Forum
                               @zenhax  Twitter & Scripts

- GUI mode activated, remember that the tool works also from command-line
  where are available various options like folder scanning, filters and so on

- select the BMS script to use
- select the input archives/files to extract, type * or "" for whole folder and
subfolders
- select the output folder where extracting the files
- REIMPORT mode enabled!
  - remember to select the SAME script, file and folder you selected during
    the previous extraction
  - it's highly suggested to leave only the edited files in the folder, it's
    faster and less prone to errors with compressed files
- open input file C:\XYZ\!Games\Onigiri\MOD\ORG\avatar_body-000d.kxr
- open script C:\XYZ\!Games\Onigiri\MOD\SCRIPTS\onigiri_online.bms
- set output folder C:\XYZ\!Games\Onigiri\MOD\OP TRIAL

  offset   filesize   filename
--------------------------------------

- the script needs to load a pre-compiled function from the dll or code
  MEMORY_FILE3
  do you want to continue with this and any other requested dll/code (y/N)?
  y
- library MEMORY_FILE3 loaded at address 0F7C0000
- function found at offset 0F7C0000
-
- 0 files reimported in 3 seconds
  coverage file 0     1%   1350274    84488400   . offset 00000010
  coverage file -1  100%   21177      21177      . offset 000052b9
  coverage file -2    0%   0          363        . offset 00000000
  coverage file -3    0%   0          69         . offset 00000000

Press ENTER or close the window to quit


The game is Onigiri Online, so the script is correct.
Next about the files and folders,
-I extracted 'avatar_body-000d.kxr' from folder ORG to folder 'OP TRIAL'
-I edited .dds file '81.dds' (original file size 171 KB), and compressed it (modded file size 129 KB)
-I deleted everything else in the output folder
-I run reimport.bat
-I choose the same script, input folder as 'ORG' and .kxr file, and output folder as 'OP TRIAL'
-I continue as shown above

It says, as can be seen, 0 files reimported. I am tempted to try it out anyway, but common sense says it probably didn't work.

Any and all help would be appreciated.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: QuickBMS - Reimporting files in the archives

Post by aluigi »

The onigiri script has one type of file (type 0) that can't be reimported since it's dumped from the memory instead of the file (it requires custom decryption), while the other types are ok.
It "seems" you selected the same files and folders of the extraction so it should be ok, that's why I don't get why there are 0 files found.
The simplest test you can do is just the following, if reimporting works here then there is no problem:

Code: Select all

quickbms       onigiri_online.bms PATH\avatar_body-000d.kxr PATH\output
quickbms -r -w onigiri_online.bms PATH\avatar_body-000d.kxr PATH\output
I don't have an Onigiri sample so if the problem persists would be useful if you can provide avatar_body-000d.kxr