daily pastebin goal
90%
SHARE
TWEET

scimitar.bms

a guest Feb 13th, 2019 12 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Ubisoft Montreal - "scimitar" archive(.forge)
  2. # First used in Assassin`s Creed(PS3, XB0X360, PC).
  3. # ----------------------------------------------
  4. # Notes:
  5. # The files that start with the \x33\xaa\xfb\x57\x99\xfa\x04\x10 or \x10\x04\xfa\x99\x57\xfb\xaa\x33 sign
  6. # are the ones that hold all the compressed and decompressed data.
  7. # They usually have two files each(one for listing the hashes and the sizes and the other as an achive in itself).
  8. #
  9. # The compressed files need to be decompressed by using a separate script(scimitar_compressed.bms), which
  10. # in itself is based around aluigi's original script(assassins_creed2.bms).
  11.  
  12. ### config
  13.  
  14. set ADD_COMPRESSED_EXTENSION long 1
  15.  
  16. ######################
  17.  
  18. get FORGE_NAME basename
  19.  
  20. idstring "scimitar\x00"
  21. get VER long
  22. get INFO_OFF long
  23. get DUMMY3 long
  24. get DUMMY4 long
  25. get DUMMY5 long
  26. get DUMMY6 long
  27.  
  28. goto INFO_OFF
  29.  
  30.  
  31. #base header
  32. get TOTAL_FILES long
  33. get TOTAL_UNKNOWN long #version?
  34. get DUMMY9 long #0
  35. if VER >= 0x1b
  36.     get DUMMY10 longlong
  37. else
  38.     get DUMMY10 long #0
  39. endif
  40. get DUMMY11 longlong #-1
  41. get CHUNK_FILES_MAX long # 5000
  42. get CHUNK_COUNT long
  43. get CHUNK_NEXT longlong
  44.  
  45. set FILE_COUNT long 0
  46.  
  47. for
  48.     goto CHUNK_NEXT long
  49.  
  50.     get CHUNK_FILES long  #can be 0
  51.     get CHUNK_UNKNOWN long
  52.     get CHUNK_START longlong
  53.     get CHUNK_NEXT longlong
  54.     get FILE_MIN long # 0/5000/etc
  55.     get FILE_MAX long # 4999/9999/etc
  56.     get NAME_OFFSET longlong
  57.     get DATA_OFFSET longlong
  58.  
  59.     callfunction WRITE_CHUNK 1
  60.  
  61.     math FILE_COUNT += CHUNK_FILES
  62.  
  63.     if CHUNK_NEXT <= 0 #should be -1
  64.         break
  65.     endif
  66.  
  67.     #print "more chunks found"
  68. next
  69.  
  70. if FILE_COUNT != TOTAL_FILES
  71.     print "WARNING! wrong file_count=%FILE_COUNT% vs total_files=%TOTAL_FILES%"
  72. endif
  73.  
  74.  
  75. startfunction WRITE_CHUNK
  76.  
  77.     for i = 0 < CHUNK_FILES
  78.         if VER >= 0x1b
  79.             get OFFSET long
  80.             get DUMMY2 long
  81.             get NAME_HASH32 long
  82.             get DUMMY4 long
  83.             get SIZE long
  84.             putarray 1 i OFFSET
  85.             putarray 2 i NAME_HASH32
  86.             putarray 3 i SIZE
  87.         else
  88.             get OFFSET long
  89.             get ZERO long
  90.             get NAME_HASH32 long
  91.             get SIZE long
  92.             putarray 1 i OFFSET
  93.             putarray 2 i NAME_HASH32
  94.             putarray 3 i SIZE
  95.         endif
  96.     next i
  97.  
  98.     goto NAME_OFFSET
  99.  
  100.     for i = 0 < CHUNK_FILES
  101.         if VER >= 0x1d
  102.             set NAME_HASH64 string ""
  103.             get DUMMY28 long
  104.             for j = 0 < 8
  105.                 get HASHBYTE byte
  106.                 string HASH2 p "%02x" HASHBYTE
  107.                 string NAME_HASH64 + HASH2
  108.             next j
  109.             get DUMMY30 long
  110.             get DUMMY31 long
  111.             get DUMMY32 long
  112.             get DUMMY33 long
  113.             get DUMMY34 long
  114.             get DUMMY35 long
  115.             get DUMMY36 long
  116.             get DUMMY37 long
  117.             get DUMMY38 long
  118.             getdstring DUMMY39 0x110
  119.             getarray OFFSET 1 i
  120.             getarray NAME_HASH32 2 i
  121.             getarray SIZE 3 i
  122.             putarray 4 i NAME_HASH64
  123.             if DUMMY28 == SIZE
  124.                 math ALT_SIZE == SIZE
  125.             endif
  126.         else
  127.             get SIZE long
  128.             get DUMMY29 long
  129.             get DUMMY30-1 long
  130.             get DUMMY30-2 long
  131.             get DUMMY31 longlong
  132.             get DUMMY32-1 long
  133.             get DUMMY32-2 long
  134.             get DUMMY33 long
  135.             get DUMMY34 long
  136.             get TYPE long
  137.             getdstring NAME 0x80
  138.             if VER >= 0x1b
  139.                 get DUMMY37 longlong
  140.                 get DUMMY38 longlong
  141.                 get DUMMY39 long
  142.             else
  143.                 get DUMMY37 longlong
  144.                 get DUMMY38 longlong
  145.             endif
  146.             getarray OFFSET   1 i
  147.             getarray NAME_HASH32 2 i
  148.             getarray ALT_SIZE 3 i
  149.         endif
  150.        
  151.         callfunction CHECK_FILEDATA 1
  152.     next i
  153. endfunction
  154.  
  155. startfunction CHECK_FILEDATA
  156.     savepos TMP
  157.     goto OFFSET
  158.     if VER >= 0x1b && VER <= 0x1c
  159.         get DUMMY3-01 long
  160.         if DUMMY6 == 1
  161.             math ACTUAL_OFFSET == OFFSET
  162.             math ACTUAL_SIZE == SIZE
  163.         else
  164.             math ACTUAL_OFFSET == OFFSET
  165.             math ACTUAL_OFFSET + 4
  166.             xmath ACTUAL_SIZE "SIZE - 4"
  167.         endif
  168.     elif VER >= 0x1d
  169.         math ACTUAL_OFFSET == OFFSET
  170.         math ACTUAL_SIZE == SIZE
  171.     else
  172.         idstring "FILEDATA"
  173.         getdstring FILEDATA_NAME 0x80
  174.         getdstring ZERO 0xff
  175.         get ACTUAL_CRC1 long
  176.         get ACTUAL_SIZE long
  177.         get ACTUAL_CRC2 longlong
  178.         get DUMMY2-01 long
  179.         get DUMMY2-02 long
  180.         get DUMMY2-03 long
  181.         get DUMMY2-04 long
  182.         get DUMMY2-05 long
  183.         get DUMMY2-06 long
  184.         get ACTUAL_TYPE long
  185.         get DUMMY2-08 long
  186.         get DUMMY2-09 byte
  187.         if ACTUAL_SIZE == 0
  188.             math ACTUAL_SIZE == SIZE
  189.             # todo: validate the "extraction" process when the SIZE value is ultimately 0
  190.         endif
  191.         savepos ACTUAL_OFFSET
  192.     endif
  193.     if VER >= 0x1d
  194.         string FILEDATA_NAME p "0x%08x\0x%08x\0x%08x_0x%s" DUMMY37 DUMMY31 NAME_HASH32 NAME_HASH64
  195.     else
  196.         set FILEDATA_NAME string NAME
  197.         if FILEDATA_NAME == ""
  198.             if VER >= 0x1b
  199.                 string FILEDATA_NAME p "0x%08x\0x%08x" TYPE NAME_HASH32
  200.             else
  201.                 string FILEDATA_NAME p "0x%08x\0x%08x" ACTUAL_TYPE ACTUAL_CRC1
  202.             endif
  203.         endif
  204.     endif
  205.  
  206.  
  207.     if ADD_COMPRESSED_EXTENSION != 0
  208.         goto ACTUAL_OFFSET
  209.         get COMPRESSED_ID long
  210.         if COMPRESSED_ID  == 0x57FBAA33 || COMPRESSED_ID == 0x1004FA99 || COMPRESSED_ID == 0x99FA0410 || COMPRESSED_ID  == 0x57FBAA33
  211.             string FILEDATA_NAME += ".compressed"
  212.         endif
  213.     endif
  214.  
  215.     log FILEDATA_NAME ACTUAL_OFFSET ACTUAL_SIZE
  216.  
  217.     goto TMP
  218. endfunction
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top