Skip to content
View in the app

A better way to browse. Learn more.

ResHax

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Help us keep the site running.

C Switch-like statement in QuickBMS?

Featured Replies

  • Author
  • Localization

Garo, posted Mon Apr 12, 2021 11:12 am (63336)


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.
Code:
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
   log NAME OFFSET SIZE
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.
  • Author
  • Localization

aluigi, posted Mon Apr 12, 2021 10:30 pm (63348)


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:
Code:
set MEMORY_FILE string "TEX0:gxt;TEXT:txt;BLAH:blah;"

# read the magic
getdstring MAGIC 4

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

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

print "Extension: %EXT%"
Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.