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

QUICKBMS GUIDE 3 IF ELSE

Read or post any tutorial related to file format analysis for modding purposes.
Post Reply
chrrox
Moderator
Posts: 2602
Joined: Sun May 18, 2008 3:01 pm
Has thanked: 57 times
Been thanked: 1422 times

QUICKBMS GUIDE 3 IF ELSE

Post by chrrox »

Ok sorry it took me a little longer for this tutorial but I wanted to make sure I had a good example to show for this.
Step 1
The game we will be looking at is Beach Fun Summer Challenge for the WII.
Step 2
Open the file pc_only.dat in your favorite hex editor
I will be using HxD
Image
Step 3
Looking at this file I notice 2 Files in this archive right away
dvdpc\pc\misc\fonts\debug.timg and dvdpc\common\misc\fonts\debug.fnt
So this tells us we have 2 files and the directory path is included in the name.
Make sure you just take note of that and we will move on to the next step.
Step 4
The file starts with the words BeachFun
so this will be our idstring
so in bms we will write.

Code: Select all

idstring "BeachFun"
Step 5
Next we have 0x18 bytes of 0's so we could write
getdstring NULL1 0x18
but there is a better command called goto
so lets use this great command in bms like this
goto 0x20
this will take us to offset 0x20 in the archive
so now we have

Code: Select all

idstring "BeachFun"
goto 0x20
and we end up here
Image
Step 6
Now we are working with console archives so we need to change our endian
to get the right values and we do that with the command
endian BIG
this tells us to read the value as it appears in the archive so the number would be
00 00 00 02 and it will not get reversed to 02 00 00 00
so 00 00 00 02 is equal to 2 and hey that is the number of files in this archive :)
so lets write what we have so far in bms.

Code: Select all

idstring "BeachFun"
goto 0x20
endian BIG
get FILES long
Step 7
the next 0x1C bytes are the same in all archives from this game and so not seem to
mean anything so we will skip over them with out new command goto
so lets write it as this
goto 0x40
so far we have

Code: Select all

idstring "BeachFun"
goto 0x20
endian BIG
get FILES long
goto 0x40
Step 8
Now we are at the start of the file name.
lets see how long it goes on before we reach something besides a 0
remember always try to work in groups of 2 or 4 bytes as that is the
most common way variables will be stored.
so highlight the next 0x68 bytes and you will see it is the same length
between the archive name and the next long variable for both of the files.
so we will write in bms
getdstring NAME 0x68

Code: Select all

idstring "BeachFun"
goto 0x20
endian BIG
get FILES long
goto 0x40
getdstring NAME 0x68
Image
Step 9
ok now we have the next 4 bytes 00 00 01 40
and if we look at your archive that seems to be where the data begins
so we have our offset value lets store that
get OFFSET long

Code: Select all

idstring "BeachFun"
goto 0x20
endian BIG
get FILES long
goto 0x40
getdstring NAME 0x68
get OFFSET long
Step 10
so now we have 0x14 bytes remaining before the next name begins
so lets break those down into long variables for now so we can visualize it better
get UNK1 long
get UNK2 long
get NULL1 long
get UNK3 long
get NULL2 long
so this completes our pattern for writing our extractor so lets clean up our code.

Code: Select all

idstring "BeachFun"
goto 0x20
endian big
get FILES long
goto 0x40
for i = 0 < FILES
getdstring NAME 0x68
get OFFSET long
get UNK1 long
get UNK2 long
get NULL long
get UNK3 long
get NULL2 long
clog NAME OFFSET ZSIZE SIZE
next i
This code starts the loop with the command
for i = 0 < FILES
and it starts right at the begging of the file name.
I wrote clog NAME OFFSET ZSIZE SIZE
because there is nothing human readable and no 00's in
the archive where the data begins indicating it is compressed.
I saved the variables as UNK if they have a value other than 0
and as NULL if their value was 0
Step 11
Now we just need to figure out ZSIZE and SIZE to extract these files.
lets look at our variables
UNK1 = 00 00 64 D0
UNK2 = 00 00 00 01
UNK3 = 00 02 AB 20
There are a few ways to figure out what values go where
method 1.
subtract the offset of file 1 from the offset of file 2
that will give us the zipped size of the file so
00 00 66 20 - 00 00 01 40 = 00 00 64 E0
this tells us 00 00 64 D0 must be the zip size
and there must be some padding in between the files.
Method 2 is just look at the values and use common sense
it is not a size of 1 do UNK2 is crossed out
and now what one is bigger UNK1 or UNK3
UNK3 is bigger so therefore it must be the uncompressed size.
so we have our variables
UNK1 = zipped size
UNK2 = one
unk3 = SIZE
so lets write that in bms

Code: Select all

idstring "BeachFun"
goto 0x20
endian big
get FILES long
goto 0x40
for i = 0 < FILES
getdstring NAME 0x68
get OFFSET long
get ZSIZE long
get ONE long
get NULL long
get SIZE long
get NULL2 long
clog NAME OFFSET ZSIZE SIZE
next i
Step 11

Code: Select all

so lets extract pc_only.dat with quickbms.
yay it worked we got 2 files
but now lets try it on Characters.dat
hey wait we got a few files and then it got an error.
Image
Step 12
If we do a ctrl + f and go to that location in the archive we see it listed there and it looks the same
but if we look closer the value of ONE is set to 00 00 00 00
this means it must indicate weather the file is compressed or not
1 gives a value of compressed 0 says the file is un compressed.
so lets write that in bms

Code: Select all

idstring "BeachFun"
goto 0x20
endian big
get FILES long
goto 0x40
for i = 0 < files
getdstring NAME 0x68
get OFFSET long
get ZSIZE long
get ZIP long
get NULL long
get SIZE long
get NULL2 long
if ZIP == 1
clog NAME OFFSET ZSIZE SIZE
else
log NAME OFFSET ZSIZE
endif
next i
This says that when the value of ZIP "what we called ONE earlier"
is equal to 1 run the command
clog NAME OFFSET ZSIZE SIZE
but if it is not equal to 1 run the command
log NAME OFFSET ZSIZE
then we end it with the endif statement.
Now when we run our extraction it works without errors :)

As a bonus you can view these models and animations in granny viewer.
http://www.radgametools.com/granny/download.html
let me know what you think of the new format.
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: QUICKBMS GUIDE 3 IF ELSE

Post by aluigi »

about the if/else statement it's also good to specify that from one of the recent versions of QuickBMS I have added the useful "elif"/"else if" which allows to specify multiple "if"... and it's very very useful in some cases.
example:

Code: Select all

set MYVAR long 123
if MYVAR < 0
    math MYVAR = 0
elif MYVAR == 0
    math MYVAR += 1
else if MYVAR == 2
    math MYVAR -= 2
elif MYVAR > 1000
    math MYVAR *= -1
else
    math MYVAR += 1000
endif
print "%MYVAR%"
User avatar
Gocha
veteran
Posts: 109
Joined: Fri Dec 12, 2008 8:16 pm
Location: Batumi, Georgia, GE
Has thanked: 57 times
Been thanked: 9 times
Contact:

Re: QUICKBMS GUIDE 3 IF ELSE

Post by Gocha »

Thanks guys! It's the great way you do!
My great respect and appreciation for them, who research game files! Special thanks to: aluigi, bacter, DerPlaya, Rick, Turfster, twig, Zench. Sorry if someone is missing in my list, I'll update when I'll notice it again
Kataah
beginner
Posts: 39
Joined: Thu May 24, 2007 7:21 pm
Has thanked: 13 times
Been thanked: 4 times

Re: QUICKBMS GUIDE 3 IF ELSE

Post by Kataah »

thx chrrox
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: QUICKBMS GUIDE 3 IF ELSE

Post by shekofte »

I Wish You Success in Whatever you want $
:angel: :keke:
ILLUSORY VIDEO GAMES ARE MORE IMPORTANT THAN PRECIOUS INTERNATIONAL FOOTBALLs
Mr.Mouse
Site Admin
Posts: 4073
Joined: Wed Jan 15, 2003 6:45 pm
Location: Dungeons of Doom
Has thanked: 450 times
Been thanked: 682 times
Contact:

Re: QUICKBMS GUIDE 3 IF ELSE

Post by Mr.Mouse »

I noticed I had not enabled the option to thank a user in this Tutorial forum yet. I have done so now ;)
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: QUICKBMS GUIDE 3 IF ELSE

Post by shekofte »

thanks if someone show us how can we decompress Granny Viewer .gr2 file formats ?
samples attached !
You do not have the required permissions to view the files attached to this post.
ILLUSORY VIDEO GAMES ARE MORE IMPORTANT THAN PRECIOUS INTERNATIONAL FOOTBALLs
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: QUICKBMS GUIDE 3 IF ELSE

Post by shekofte »

this problem solved thousands years ago !!! :stalk:
shekofte wrote:thanks if someone show us how can we decompress Granny Viewer .gr2 file formats ?
samples attached !
viewtopic.php?f=16&t=1805&start=30&st=0&sk=t&sd=a
ILLUSORY VIDEO GAMES ARE MORE IMPORTANT THAN PRECIOUS INTERNATIONAL FOOTBALLs
Ranker
ultra-n00b
Posts: 5
Joined: Tue Jan 04, 2011 10:03 pm
Been thanked: 2 times

Re: QUICKBMS GUIDE 3 IF ELSE

Post by Ranker »

I wish this tutorial was more pattern-based and not so "do this" and "do that". I really want to start extracting files, but I'm just not understanding the rational for any of the steps or how QUICKBMS intrinsically works - so I'm finding it very difficult to apply it to my project and construct my own strategies.

Thanks for the tutorial though.
chrrox
Moderator
Posts: 2602
Joined: Sun May 18, 2008 3:01 pm
Has thanked: 57 times
Been thanked: 1422 times

Re: QUICKBMS GUIDE 3 IF ELSE

Post by chrrox »

post a sample in the research area to get some help.
Post Reply