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.

My first quickBMS script

Featured Replies

  • Author
  • Localization

aluigi, posted Wed Sep 21, 2016 8:01 am (17568)


Probably with that format it's better to just dump all the RIFF files.
This is what I adopted in script 0.1.3 to skip the errors.
  • Replies 108
  • Views 23
  • Created
  • Last Reply

Top Posters In This Topic

  • Author
  • Localization

AnonBaiter, posted Wed Sep 21, 2016 12:18 pm (17573)


Except that in these archives, there are no signs of "RIFF" floating around anywhere, which makes finding them harder than it should be.
So far I'm left with these signs:
Code:
Original PS2 version:
"\x02\x00\x00\x80\x20" - DEMO.DAT
"ipu"\"ipum" - MOVIE.DAT
"\x00\x02\x10\x00"\"\x00\x00\xc0\x00" - VOX.DAT(each file has a varying number, these two are proof of this)
The Document of Metal Gear Solid 2:
"\x00\x00\x01\xBA\x44\x00\x04\x00" - MOVIE.DAT/MOVIE2.DAT
Metal Gear Solid 2 Substance(PS2):
Same as "Original PS2 version".
Metal Gear Solid 2 Substance(XBOX):
"\x00\x01\xc0\x00" - movie.dat
"\xb0\x00\x80\x00" - movievr.dat
Also, my script never goes beyond the first file no matter what I do. Perhaps it has to do with my inability with writing complex scripts or something...
(Nevermind I still don't know what to do by now, so I'll have to stick with dull hex strings like "1000000010000000000000000f000000")
  • Author
  • Localization

AnonBaiter, posted Fri Sep 23, 2016 1:46 am (17580)


So I decided to grab both versions of a PS1 game called Metal Gear Solid: the American version(two discs) and the Japanese Integral version(three discs; it served as the base of the inferior PC version sound-wise). So far I managed to write a script for the DEMO.DAT archive that was stored on both version I posess at hand. Here's the script:
Code:
get FULLSIZE asize
findloc START_OFFSET binary "\x10\x08\x00\x00\x05\x00\x00\x00\x05"

for i = 0
   savepos OFFSET
   findloc ALIGNMENT binary "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x08\x00\x00"
   findloc END_OFFSET string START_OFFSET 0 ""
   if END_OFFSET == ""
      math END_OFFSET = FULLSIZE
   endif
   math END_OFFSET x ALIGNMENT
   /*
   if ALIGNMENT != ""
      cleanexit
   endif
   */
   putarray 0 i START_OFFSET
   putarray 1 i END_OFFSET
   math SIZE = END_OFFSET
   math SIZE - OFFSET
   string NAME p "d.dmo" i
   if SIZE != 0
        log NAME OFFSET SIZE
    endif
   goto END_OFFSET
   padding 16
   do
      getdstring TMP 16
   while TMP == START_OFFSET
next i
So far the only problem with this script is that it doesn't dump the last file; perhaps it has to do with the "ALIGNMENT" argument. If you want a sample of DEMO.DAT(with filecutter, no less) then you should just ask.
  • Author
  • Localization

aluigi, posted Fri Sep 23, 2016 3:37 pm (17598)


There is for sure something wrong in that script :)
The pattern in START_OFFSET should be used directly in findloc, and there is something strange with the arrays.
Maybe check if the following works:
Code:
for i = 0
    findloc OFFSET binary "\x10\x08\x00\x00\x05\x00\x00\x00\x05"
    goto OFFSET
    findloc END_OFFSET binary "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x08\x00\x00"
    math SIZE = END_OFFSET
    math SIZE - OFFSET
    string NAME p "d.dmo" i
    log NAME OFFSET SIZE
    goto END_OFFSET
    padding 16
next i
  • Author
  • Localization

AnonBaiter, posted Fri Sep 23, 2016 6:31 pm (17611)


Well, it did work somewhat but that doesn`t solve the problem of the last file not being extracted.
Code:
0EE32770  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0EE32780  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0EE32790  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0EE327A0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0EE327B0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0EE327C0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0EE327D0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0EE327E0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0EE327F0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0EE32800  10 08 00 00 05 00 00 00 05 9C 00 00 00 00 00 00  .........?......
0EE32810  6B 14 00 00 01 00 00 00 06 00 00 00 1C 00 00 00  k...............
0EE32820  24 00 00 00 31 F4 0A 00 31 F4 00 00 01 00 00 00  $...1o..1o......
0EE32830  00 00 00 00 2D 99 0A 00 2D 99 00 00 00 00 00 00  ....-T..-T......
0EE32840  02 00 00 00 00 00 00 00 88 0A 0A 00 88 0A 00 00  ........?...?...
0EE32850  00 00 00 00 03 00 00 00 00 00 00 00 BF FF 0A 00  ............?y..
0EE32860  BF FF 00 00 00 00 00 00 04 00 00 00 00 00 00 00  ?y..............
0EE32870  B6 21 0A 00 B6 21 00 00 00 00 00 00 05 00 00 00  !..!..........
0EE32880  00 00 00 00 3B 2D 0A 00 3B 2D 00 00 00 00 00 00  ....;-..;-......
0EE32890  06 00 00 00 00 00 00 00 59 E7 0A 00 59 E7 00 00  ........Yc..Yc..
0EE328A0  00 00 00 00 10 08 00 00 01 00 00 00 02 14 00 00  ................
0EE328B0  00 64 80 00 3F FF 0C 00 02 01 00 00 00 00 00 00  .d?.?y..........
0EE328C0  10 08 00 00 03 00 00 00 04 08 00 00 01 00 00 00  ................
0EE328D0  03 04 06 00 00 00 00 00 FF FF FF 7F 10 00 14 00  ........yyy.....
0EE328E0  00 06 00 00 F0 00 00 00 1C 00 00 00 71 00 00 00  ....?.......q...
Just so you know, the last file is located at offset 0xee32800. Yet the file ends at the 0xf69f7ff offset, which END_OFFSET is incapable of handing because there are a lot of zeroes instead of the hex-strings said function/argument is assigned to.
What I'm saying is this: is it possible to add an exception if the script is going to dump the last file?
  • Author
  • Localization

aluigi, posted Fri Sep 23, 2016 8:38 pm (17616)


It depends by what of the two findloc fails first.
Add the usual 0 "" to the findloc command and it will be able to handle the missing pattern.
  • Author
  • Localization

AnonBaiter, posted Fri Sep 23, 2016 11:13 pm (17617)


Well...
Code:
- open input file E:\MGS_USA\CD1\MGS\DEMO.DAT
- open script E:\MGS_USA\CD1\MGS\mgs_dat.bms
- set output folder E:\MGS_USA\CD1\MGS\DEMO
- the folder doesn't exist, do you want to create it (y/N)?:
  y

  offset   filesize   filename
--------------------------------------
  00000000 6572016    0000.dat
  00644800 1456112    0001.dat
  007a8000 2586608    0002.dat
  00a1f800 3399664    0003.dat
  00d5d800 2326512    0004.dat
  00f95800 1384432    0005.dat
  010e7800 3907568    0006.dat
  014a1800 673776     0007.dat
  01546000 1322992    0008.dat
  01689000 1058800    0009.dat
  0178b800 5144560    0010.dat
  01c73800 1699824    0011.dat
  01e12800 5152752    0012.dat
  022fc800 5486576    0013.dat
  02838000 3338224    0014.dat
  02b67000 3874800    0015.dat
  02f19000 4179952    0016.dat
  03315800 665584     0017.dat
  033b8000 1046512    0018.dat
  034b7800 1769456    0019.dat
  03667800 4986864    0020.dat
  03b29000 3987440    0021.dat
  03ef6800 3973104    0022.dat
  042c0800 9422832    0023.dat
  04bbd000 2080752    0024.dat
  04db9000 1189872    0025.dat
  04edb800 1683440    0026.dat
  05076800 7182320    0027.dat
  05750000 2795504    0028.dat
  059fa800 591856     0029.dat
  05a8b000 4315120    0030.dat
  05ea8800 483312     0031.dat
  05f1e800 778224     0032.dat
  05fdc800 931824     0033.dat
  060c0000 5431280    0034.dat
  065ee000 3487728    0035.dat
  06941800 3014640    0036.dat
  06c21800 3940336    0037.dat
  06fe3800 1310704    0038.dat
  07123800 741360     0039.dat
  071d8800 1495024    0040.dat
  07345800 983024     0041.dat
  07435800 1269744    0042.dat
  0756b800 2742256    0043.dat
  07809000 608240     0044.dat
  0789d800 475120     0045.dat
  07911800 2516976    0046.dat
  07b78000 2355184    0047.dat
  07db7000 6008816    0048.dat
  08372000 6008816    0049.dat
  0892d000 2691056    0050.dat
  08bbe000 6797296    0051.dat
  09239800 649200     0052.dat
  092d8000 1134576    0053.dat
  093ed000 1255408    0054.dat
  0951f800 2299888    0055.dat
  09751000 3203056    0056.dat
  09a5f000 7909360    0057.dat
  0a1ea000 7559152    0058.dat
  0a91f800 4583408    0059.dat
  0ad7e800 659440     0060.dat
  0ae1f800 514032     0061.dat
  0ae9d000 5699568    0062.dat
  0b40c800 5236720    0063.dat
  0b90b000 13840368   0064.dat
  0c63e000 94192      0065.dat
  0c655000 718832     0066.dat
  0c704800 5713904    0067.dat
  0cc77800 3213296    0068.dat
  0cf88000 1427440    0069.dat
  0d0e4800 1318896    0070.dat
  0d226800 2578416    0071.dat
  0d49c000 2582512    0072.dat
  0d712800 7786480    0073.dat
  0de7f800 1257456    0074.dat
  0dfb2800 1675248    0075.dat
  0e14b800 13529072   0076.dat
  0ee32800 4045199360 0077.dat

Error: impossible to write 0xf11cd800 bytes (total 0xf11cd800)
       Check your disk space

Last script line before the error or that produced the error:
  10  log NAME OFFSET SIZE
The last file increases the size for no reason. I think I'm a bit clueless at this point...
Or perhaps...
  • Author
  • Localization

aluigi, posted Fri Sep 23, 2016 11:18 pm (17618)


Eh, you have to add the "if" statement to handle the event of a missing findloc :)
  • Author
  • Localization

AnonBaiter, posted Fri Sep 23, 2016 11:24 pm (17619)


like this:
Code:
   if SIZE & 0xf0000000
      math SIZE & 0x3fffffff
      log NAME OFFSET SIZE
   else
      log NAME OFFSET SIZE
   endif

Or this:
Code:
   if END_OFFSET == ""
      math END_OFFSET = FULLSIZE
   endif
I think the latter works.
In any case, I think the problem should be solved now. I still have other archives I have to write the scripts for but that's about it for now.
  • Author
  • Localization

aluigi, posted Sat Sep 24, 2016 8:19 pm (17625)


Yeah, the latter is the right one.
  • Author
  • Localization

AnonBaiter, posted Sun Sep 25, 2016 7:31 pm (17640)


So what am I going to do if the size of the names vary by each file despite not being referenced in the index size itself?
Code:
open FDDE "whd"
open FDDE "wav" 1
open FDSE "streams.wav" 1
get WHD_SIZE long
get WHD_SIZE_TOTAL long

for CURR_OFF = 0 < WHD_SIZE_TOTAL
   get DUMMY long
   get DUMMY long
   get NAME string
   padding 4
   get UNKNOWN1 long
   get UNKNOWN2 long
   get UNKNOWN3 long
   get UNKNOWN4 long
   get UNKNOWN5 long
   get UNKNOWN6 long
   get UNKNOWN7 long
   get UNKNOWN8 long
   get UNKNOWN9 long
   savepos CURR_OFF
next
  • Author
  • Localization

chrrox, posted Sun Sep 25, 2016 11:55 pm (17641)


you just do a get name string
then pad to 4
  • Author
  • Localization

AnonBaiter, posted Mon Sep 26, 2016 12:13 am (17642)


Like this, right?
Code:
   get NAME string
   padding 4
Also, call me an idiot, but here's how it looked like after I did exactly what you said.
  • Author
  • Localization

aluigi, posted Mon Sep 26, 2016 8:45 am (17645)


Add another couple of UNKNOWN longs
  • Author
  • Localization

AnonBaiter, posted Mon Sep 26, 2016 10:07 am (17649)


Okay, I'm almost there...
Code:
open FDDE "whd"
open FDDE "wav" 1
open FDSE "streams.wav" 1
get WHD_SIZE long
get WHD_SIZE_TOTAL long
get DUMMY long
get DUMMY long

for CURR_OFF = 0 < WHD_SIZE
   get NAME string
   padding 4
   callfunction COPYPASTE 1
   log NAME OFFSET SIZE 1
next

startfunction COPYPASTE
      get SIX long
      get OFFSET long
      get FORMAT long
      get FREQUENCY long
      get BITS long
      get SIZE long
      get DUMMY long
      get CHANNELS long
      get DUMMY long
      get DUMMY long
      get DUMMY long
      get DUMMY long
      savepos CURR_OFF
endfunction

if BITS = 0x00000004
   open FDDE "wav" 1
elif BITS = 0x0000010
   open FDSE "streams.wav" 1
else
   cleanexit
endif
One thing to note is that on the GC version, the .whd file has that coeff part, which interferes with the files it`s trying to process.
  • Author
  • Localization

aluigi, posted Mon Sep 26, 2016 11:28 am (17652)


A suggestion: you can avoid long copy&paste parts of code by putting them in a function to call at their place.
For example:
Code:
...
callfunction COPYPASTE 1
...

startfunction COPYPASTE
      get UNKNOWN1 long
      get UNKNOWN2 long
      get UNKNOWN3 long
      get UNKNOWN4 long
      get UNKNOWN5 long
      get UNKNOWN6 long
      get UNKNOWN7 long
      get UNKNOWN8 long
      get UNKNOWN9 long
      get UNKNOWN10 long
      get UNKNOWN11 long
      get UNKNOWN12 long
      savepos CURR_OFF
endfunction
I use this trick often to make the multi-versions scripts more readable.
  • Author
  • Localization

AnonBaiter, posted Mon Sep 26, 2016 2:19 pm (17657)


Well, the script isn`t quite there with how compartible it is with other versions though... especially the GC version.
See the edited post for details.

On an unrelated note, I want the script to alternate between the two archives based on this argument right here:
Code:
if BITS & 0x10
   open FDDE "wav" 1
elif BITS & 0x4
   open FDSE "streams.wav" 1
else
   cleanexit
endif
Is there any way to do this?
  • Author
  • Localization

AnonBaiter, posted Fri Oct 14, 2016 8:07 pm (18059)


So, how can I find an AES key for these 2 dumped/unencrypted XEX2 files so that I can use it on an encrypted archive?
common.rar

I tried findaes, but nothing happened.

Another question I like to ask is how can I "decrypt" this header(which you can see it as an attachment for later use) of an archive file(STAGE.DAT)?

And yes, these questions came from two different games(Grand Theft Auto IV, Metal Gear Solid 2).
  • Author
  • Localization

AnonBaiter, posted Sat Oct 15, 2016 8:12 pm (18075)


OK, I think it's time for the third question:
So I have this .sdt file I extracted using my very own scripts, and I got this header:
Code:
00000000  10 00 00 00 10 00 00 00 00 00 00 00 02 00 00 00  ................
00000010  10 00 00 00 10 00 00 00 00 00 00 00 01 00 00 00  ................
00000020  10 00 00 00 10 00 00 00 00 00 00 00 04 00 00 00  ................
00000030  02 00 00 00 A0 05 00 00 00 00 00 00 00 00 00 00  ....?...........
Do note though that in that file, the header doesn't reference the number of entries - it only lists them.
So how can I make sure these entries are detected based on the "\x10\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00" string rather than with "set ENTRIES long [number]"(or maybe some other idea I didn't think of)? Also, the last four lines detects the sizes each format has before forming into a full file each...
Code:
math HDREMASTER_FORMAT = 0
math XORED = 0

get SDT_SIZE asize
#findloc DUMMY binary "\x10\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00"
set ENTRIES long 3

for i = 0 < ENTRIES
   getdstring DUMMY 12
   get FORMAT long
next i
get INITIAL_FORMAT long
get BLOCKSIZE long
get ALT_SIZE1 long
get ALT_SIZE2 long
putvarchr MEMORY_FILE SDT_SIZE 0
log MEMORY_FILE 0 0
putvarchr MEMORY_FILE2 SDT_SIZE 0
log MEMORY_FILE2 0 0
Here is the .sdt file in question.
  • Author
  • Localization

aluigi, posted Sun Oct 16, 2016 8:51 am (18081)


Code:
do
    get DUMMY1 long
    get DUMMY2 long
    getdstring DUMMY 8
while DUMMY1 == 0x10 && DUMMY2 == 0x10
goto -16 0 SEEK_CUR
  • Author
  • Localization

AnonBaiter, posted Sun Oct 16, 2016 10:59 am (18085)


OK, I think I got that now...
  • Author
  • Localization

AnonBaiter, posted Sun Oct 16, 2016 3:16 pm (18089)


Wait a minute, what about my two other questions?
  • Author
  • Localization

aluigi, posted Tue Oct 18, 2016 5:52 am (18144)


Open a new topic in the Game Archive section for them.
  • Author
  • Localization

AnonBaiter, posted Tue Oct 18, 2016 5:59 am (18145)


^ Will do.
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.