bms to pseudo code?

Doubts, help and support about QuickBMS and other game research tools
prixone
Posts: 12
Joined: Sun Mar 25, 2018 7:24 pm

bms to pseudo code?

Post by prixone »

What would be the equivalent pseudo code for this?

Code: Select all

# script for QuickBMS http://quickbms.aluigi.org

quickbmsver "0.7.1"
comtype zlibx

getdstring DUMMY 260
getdstring SIGN 32
math PKG_OLD = -1
get FULLSIZE asize
do
    get INDEX long
    get OFFSET long
    get SECSTART long
    get ZSIZE long
    get SOME_32BIT_CRC longlong
    get FLAGS longlong
    get CREATED longlong
    get ACCESSED longlong
    get MODIFIED longlong
    get SIZE long
    getdstring FILENAME 260
    getdstring PATH 260
    get DUMMY long
    get PKG long
    get DUMMY long
    if PKG != PKG_OLD
        string PKG_NAME p= "pkg%03d.pkg" PKG
        open FDSE PKG_NAME 1 EXISTS # just for working even if packages are missing...
        math PKG_OLD = PKG
    endif
    string NAME = PATH
    string NAME += FILENAME

    if EXISTS != 0
        if ZSIZE == SIZE
            log NAME OFFSET SIZE 1
        else
            clog NAME OFFSET ZSIZE SIZE 1
        endif
    endif
    savepos CURR
while CURR < FULLSIZE


I mean I get its reading the idx file but I don't see how its extracting or what it should use to extract the file from the above, what would be an actual pseudo code of the whole process?
prixone
Posts: 12
Joined: Sun Mar 25, 2018 7:24 pm

Re: bms to pseudo code?

Post by prixone »

OK, so I figured it out but, ini files seem to be either encrypted/xor'ed or are not compressed like the rest of the files.

What quickbms does with the list of files the script get? Does it run each file against some sort of encryption or packing test and then tries to break it or what?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: bms to pseudo code?

Post by aluigi »

there is no encryption, the files are compressed with a modified version of zlib/deflate that is available only in quickbms
prixone
Posts: 12
Joined: Sun Mar 25, 2018 7:24 pm

Re: bms to pseudo code?

Post by prixone »

aluigi wrote:there is no encryption, the files are compressed with a modified version of zlib/deflate that is available only in quickbms

I see, thanks for the information, do you know which file should I look into quickbms source to study?

Thanks again.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: bms to pseudo code?

Post by aluigi »

src/compression/tinf.h
src/compression/tinflatex.c
(my modifications are those tagged with ALUIGI)

How the code is used in quickbms, t32 is just a normal 32bit integer:

Code: Select all

            t32 = size;
            size = -1;
            tinf_init();
            if(tinf_uncompress(out, &t32, in + 2, zsize - 2) == TINF_OK) size = t32;