Free Game Research Forum | Official QuickBMS support | twitter @zenhax
It is currently Sat Aug 13, 2022 2:58 am

All times are UTC

Post new topic  Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Apr 12, 2021 11:12 am 
User avatar

Joined: Wed Nov 18, 2020 5:54 pm
Posts: 20
I have an archive where data is stored like nodes, for each compressed file in this archive, there is a node-header, saying what kind of data it is. I want to log these compressed files' filename depending on the node type. So a file with the type of "TEX0", would have the extension ".gtx" and so on.

Here's the script I made for the archive.
idstring "ANP 151 "
endian big
get FILES long
get NAMESZ long

for i = 0 < FILES
   getdstring NODE 4
   goto 12 SEEK_CUR
   # this is where you do the node name parsing
   getdstring NAME NAMESZ
   get OFFSET longlong
   get SIZE longlong
next i

Heres the archive too.
I don't know why I can't attach an archive, but I renamed it from ".anp" to ".txt", so I could upload it.

simple.txt [300 Bytes]
Downloaded 131 times

PostPosted: Mon Apr 12, 2021 10:30 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 12982
Unfortunately there is no "switch/case"-like command in quickbms therefore the long sequence of "if/elif/else/endif" is the only option.

There are alternatives like storing the magic value and the relative in two arrays... but the script will look quite messy.

In my opinion the bestt alternative is storing the long list of "magic:extension;" in a MEMORY_FILE and searching them:
set MEMORY_FILE string "TEX0:gxt;TEXT:txt;BLAH:blah;"

# read the magic
getdstring MAGIC 4

# search the magic
string MAGIC + ":"
findloc POS binary MAGIC MEMORY_FILE ""

# set the extension
if POS == ""
    set EXT string "dat"
    math POS + 5
    getct EXT string ';' MEMORY_FILE

print "Extension: %EXT%"

Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 2 posts ] 

All times are UTC

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited