[Solved] Need help writing a script

Doubts, help and support about QuickBMS and other game research tools
bugmenot
Posts: 45
Joined: Sun Oct 09, 2016 6:27 pm

[Solved] Need help writing a script

Post by bugmenot »

I have a bunch of .png files that start with 16bytes of ID string that should be removed from the result followed by 16 bytes of xored data and the rest of the file in plain format.
I managed to find the xor string but now I need help in writing the bms script to do the decryption that i plan to run using a .bat file.

Code: Select all

for %%i in (*.ext) DO quickbms.exe -o script.bms "%%i" "%CD%\out"


Can anyone tell me what I'm missing? I prefer to learn how to do this myself than have someone give me the script but so far reading the quickbms.txt or other people scripts isn't helping.

Code: Select all

idstring "\x**\x**\x**\x**\x**\x**\x**\x**\x**\x**\x**\x**\x**\x**\x**\x**"
set KEY "0x** 0x** 0x** 0x** 0x** 0x** 0x** 0x** 0x** 0x** 0x** 0x** 0x** 0x** 0x** 0x**"
get FSIZE asize
GoTo 16
GetDString FHEADER 16
Math FHEADER ^= KEY
get BNAME basename
string BNAME += ".png"
Math FSIZE -= 16
log BNAME 16 FSIZE
Last edited by bugmenot on Mon Oct 10, 2016 7:28 pm, edited 1 time in total.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Need help writing a script

Post by aluigi »

Try this:

Code: Select all

# create the name
get BNAME basename
string BNAME += ".png"

# magic
idstring "\x**\x**\x**\x**\x**\x**\x**\x**\x**\x**\x**\x**\x**\x**\x**\x**"

# xor 16 bytes
savepos OFFSET
filexor "0x** 0x** 0x** 0x** 0x** 0x** 0x** 0x** 0x** 0x** 0x** 0x** 0x** 0x** 0x** 0x**" OFFSET
log BNAME OFFSET 16
filexor ""

# append the rest
savepos OFFSET
math FSIZE - OFFSET
append
log BNAME OFFSET FSIZE
append
bugmenot
Posts: 45
Joined: Sun Oct 09, 2016 6:27 pm

Re: Need help writing a script

Post by bugmenot »

aluigi wrote:Try this:

Thanks, and feel free to post the script on you're page - after all you're the one who did the heavy lifting ;p

P.S. Is there a way to optimize the script or make it work faster?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: [Solved] Need help writing a script

Post by aluigi »

There are no other ways to speed up the script, there are only few instructions without loops so it's fine.
I guess the slowness you have experienced is related to the calling of quickbms on every single file.

Try to use:
quickbmsexe -o -F "{}.rpgmv{}" RPGMakerMV.bms INPUT_FOLDER OUTPUT_FOLDER
bugmenot
Posts: 45
Joined: Sun Oct 09, 2016 6:27 pm

Re: [Solved] Need help writing a script

Post by bugmenot »

Unfortunately this will not keep the files sub-directory structure.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: [Solved] Need help writing a script

Post by aluigi »

In that case you can try one of the following two command-line options:

Code: Select all

-d     automatically create an additional output folder with the name of the
       input folder and file processed, eg. models/mychar/mychar.arc/FILES,
       -d works also if input and output folders are the same (rename folder)

-D     similar to -d but will not create the folder with the filename
I added them some years ago just to maintain the original directory tree and they are two separate options for meeting the different needs of the users.