BMS Script - Help

Doubts, help and support about QuickBMS and other game research tools
h3x3r
Posts: 165
Joined: Wed Jun 01, 2016 5:53 pm

BMS Script - Help

Post by h3x3r »

Hi there i need your help. I have edited aluigi's script to unpack files. But i need to unpack files to the folders specified by file_type with their original names specified by file_ID.
Here is script. Thanks in advance!

Code: Select all

idstring YBIG
get DUMMY long
get DUMMY long
get DUMMY long
get OFFSET long
goto OFFSET
get DUMMY short
get DUMMY short
get FILES long
getdstring DUMMY 0x51
getdstring MAINFOLDER 0x4
#get MAINFOLDER long
getdstring DUMMY 0x23

savepos TMP
math BASE_OFF = FILES
math BASE_OFF *= 10
math BASE_OFF += TMP
math BASE_OFF x= 8

for i = 0 < FILES

    get OFFSET long
    get file_ID long   
    get file_type byte
    get bComplex byte   
   
    math OFFSET *= 8
    math OFFSET += BASE_OFF
    savepos TMP   
   goto OFFSET   

   if file_type < 126   
      get SIZE long
      savepos OFFSET
      log file_ID OFFSET SIZE
   endif   
   
   if file_type == 126
      getdstring DUMMY 0xE
      get COMCHAR byte
      if COMCHAR == 0
         goto OFFSET
         get SIZE long
         savepos OFFSET
         log file_ID OFFSET SIZE
      else
         goto OFFSET
         math OFFSET += 22
         get ZSIZE long
         math ZSIZE -= 18      
         get DUMMY0 long
         get DUMMY1 long
         get DUMMY2 long
         get SIZE long
         get TEXCOUNT short
         clog file_ID OFFSET ZSIZE SIZE
      endif
   endif
   
   if file_type > 126
      goto OFFSET   
      get SIZE long
      savepos OFFSET
      log file_ID OFFSET SIZE
   endif   
    goto TMP
next i
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: BMS Script - Help

Post by aluigi »

I guess you want to use this code:

Code: Select all

string NAME p "%d/%d.dat" file_type file_id

Put it under "get bComplex byte" and replace all the file_ID in the *log operations with NAME
h3x3r
Posts: 165
Joined: Wed Jun 01, 2016 5:53 pm

Re: BMS Script - Help

Post by h3x3r »

Hell yes! Thanks aluigi.
BTW i must only change "%d/%d.dat" to "%d/%u.dat" because some values of file_ID was negative.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: BMS Script - Help

Post by aluigi »

:D
h3x3r
Posts: 165
Joined: Wed Jun 01, 2016 5:53 pm

Re: BMS Script - Help

Post by h3x3r »

Hi aluigi, I have another question regarding string. I need to search specific strings and return long value before string. How to do that? Thanks!
The long value should be SIZE. String name is "NodsNoHe"

Tried this but no luck...

For
FindLoc OFFSET string "\x4E\x6F\x64\x73\x4E\x6F\x48\x65" 0 ""
if OFFSET == ""
savepos OFFSET
goto OFFSET-4
Get SIZE long
goto OFFSET
log NAME OFFSET SIZE
endif
Next
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: BMS Script - Help

Post by aluigi »

I would use something like:

Code: Select all

findloc TMP string "NodsNoHe"
math TMP - 4
goto TMP
get SIZE long
By default findloc terminated quickbms if it doesn't find the string.
This is the alternative that doesn't terminate:

Code: Select all

findloc TMP string "NodsNoHe" 0 ""
if TMP != ""
    math TMP - 4
    goto TMP
    get SIZE long
endif
h3x3r
Posts: 165
Joined: Wed Jun 01, 2016 5:53 pm

Re: BMS Script - Help

Post by h3x3r »

Thanks! It works but only for one occurrence. There are more then one occurrences of that string.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: BMS Script - Help

Post by aluigi »

just close that code between a for cycle, for example:

Code: Select all

for
findloc TMP string "NodsNoHe"
math TMP - 4
goto TMP
get SIZE long
getdstring SKIP SIZE # or findloc will find the same string again
next