Page 1 of 1

Help me not be stupid with QuickBMS please.

Posted: Sat Sep 24, 2011 10:27 am
by grandmasterjimmy
The contents of this post was deleted because of possible forum rules violation.

Re: Help me not be stupid with QuickBMS please.

Posted: Sat Sep 24, 2011 4:00 pm
by WRS
so the first attribute is the ascii signatures. this is our "id string" which helps identify the format

as there are 2 possible strings of the same length (the size of a dword - or 4 bytes) we can use this:

Code: Select all

getdstring IDSTR 4
which gets the first 4 characters in the file. we can now do an optional check that this string is correct

Code: Select all

if IDSTR == "Jdds"
elif IDSTR == "Jpng"
else
  # matched neither of these id strings
  cleanexit
endif
then we can continue getting the values you've listed:

Code: Select all

get IMGSIZE long
get FILENUM long
get WIDTH long
get HEIGHT long
get NULL long
next is the image data, and we can just use the "log" function to save it out from the current file position. something like this:

Code: Select all

savepos CURPOS
log "" CURPOS IMGSIZE
notice the blank filename. quickbms will identify the dds signature and give it a relevant filename for us! this is really helpful when formats like this dont store names!

we need to skip to the next image.. so we can add the image size to the current position and seek to it

Code: Select all

math CURPOS += IMGSIZE
goto CURPOS
now we're at the next image. because we don't really know how many images are here, we can wrap this into an infinite loop using FOR and NEXT like so:

Code: Select all

for

getdstring IDSTR 4

if IDSTR == "Jdds"
elif IDSTR == "Jpng"
else
  # matched neither of these id strings
  cleanexit
endif

get IMGSIZE long
get FILENUM long
get WIDTH long
get HEIGHT long
get NULL long

savepos CURPOS
log "" CURPOS IMGSIZE

math CURPOS += IMGSIZE
goto CURPOS

next
there is an error at the end of this script because we don't check for the end of the file. quickbms doesn't crash but we can avoid this by adding a filesize check:

Code: Select all

get SIZE asize

for

getdstring IDSTR 4

if IDSTR == "Jdds"
elif IDSTR == "Jpng"
else
  # matched neither of these id strings
  cleanexit
endif

get IMGSIZE long
get FILENUM long
get WIDTH long
get HEIGHT long
get NULL long

savepos CURPOS
log "" CURPOS IMGSIZE

math CURPOS += IMGSIZE

if CURPOS == SIZE
  cleanexit
endif

goto CURPOS
 
next
try commenting each line against the quickbms documentation if you need more understanding

8)

Re: Help me not be stupid with QuickBMS please.

Posted: Mon Sep 26, 2011 8:19 pm
by grandmasterjimmy
Thanks for the help, that's a lot easier to understand than the way the documentation is set up. I'm going to try to work with a more complicated format soon, but I'll probably get confused trying to work with the filenames, so I'll probably be back to ask for more help soon.