Summon Night Granthese

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
SMP112
Posts: 7
Joined: Wed Mar 24, 2021 4:42 am

Summon Night Granthese

Post by SMP112 »

Hi there.

For nothing more than my own interest I've been trying (With some success) to extract files from the games in this series. But this one has stumped me. They're XDA format. Looking it up on Google has shown practically nothing but phone related stuff and Sencha xda. But I'm sure these files are something else entirely.

Here.

https://drive.google.com/drive/folders/ ... sp=sharing

The files in question. I would have used the site file upload but it doesn't allow for XDA
aaa801
Posts: 48
Joined: Wed Oct 12, 2016 12:22 pm

Re: Summon Night Granthese

Post by aaa801 »

Got it working, including folders now :)

Code: Select all

# Summon Night Granthese
# script for QuickBMS http://quickbms.aluigi.org
# By aaa801

goto 2048
get TYPE long
get SECTION_SIZE long
get SECTION_END long
get FILE_NAME_COUNT long

# Array for names
PutArray 0 FILE_NAME_COUNT ""

# Array for offsets
PutArray 1 FILE_NAME_COUNT 0

# Array for folder names + ranges
PutArray 2 0 ""
PutArray 3 0 0

# Array for max sizes
PutArray 4 FILE_NAME_COUNT 0

# Read names
Set NAMES_PROCESSED long 0
Set FOLDERS_PROCESSED long 0
SavePos OFFSET
Do
   get TYPE long
   
   If TYPE == 1002 # Folder
      # TODO folder
      get FOLDER_ENTRIES_END long # end of folder entries for this folder containing folders / files      
      get UNK long
      get UNK long
      get UNK long
      get STR_LEN long
      GetDString FOLDER_NAME STR_LEN
      
      Math FOLDER_ENTRIES_END + OFFSET # To get true end
      PutArray 2 FOLDERS_PROCESSED FOLDER_NAME
      PutArray 3 FOLDERS_PROCESSED FOLDER_ENTRIES_END      
      
      Math FOLDERS_PROCESSED + 1
   Elif TYPE == 1003 # File
      get UNK long # size of entry?
      get FILE_ID long # seems to increase from a base number atleast
      get STR_LEN long
      GetDString FILE_NAME STR_LEN
      
      # Process folder name
      set NEW_NAME string ""
      for i = 0 < FOLDERS_PROCESSED
         GetArray FOLDER_NAME 2 i
         GetArray FOLDER_ENTRIES_END 3 i
         If FOLDER_ENTRIES_END > OFFSET
            string NEW_NAME + FOLDER_NAME
            string NEW_NAME + "/"
         Endif
      next i
      
      string NEW_NAME + FILE_NAME
      
      PutArray 0 NAMES_PROCESSED NEW_NAME
      Math NAMES_PROCESSED + 1
      
   Else
      print "Unknown Type: %TYPE%"
   Endif

SavePos OFFSET
While OFFSET < SECTION_END

If NAMES_PROCESSED != FILE_NAME_COUNT
   print "Didn't read enough names :|"
   exit
Endif

# Read offsets
goto SECTION_END

get TYPE long # 1020
get SECTION_SIZE long
get FILE_OFFSET_COUNT long
get UNK long

If FILE_OFFSET_COUNT != FILE_NAME_COUNT
   print "Mismatch of counts :|"
   exit
Endif


# Read offsets to file headers
for i = 0 < FILE_OFFSET_COUNT
   get F_HEADER_OFFSET long
   get F_MAX_SIZE long
   get UNK long
   
   PutArray 1 i F_HEADER_OFFSET
   PutArray 4 i F_MAX_SIZE
next i

# Parse headers
for i = 0 < FILE_OFFSET_COUNT
   GetArray HEADER_OFFSET 1 i
   goto HEADER_OFFSET
      
   GetArray F_NAME 0 i
   GetArray F_MAX_SIZE 4 i

   get TYPE long # 50 = nice good raw file, 12 = no idea :|   

   If TYPE != 50
      # Cursed file
      get UNK1 long # All seem to be 0's
      get UNK2 long # All seem to be 0's
      get UNK3 long # All seem to be 0's
      
      SavePos F_OFFSET
      Math F_MAX_SIZE - 16 # No idea if this is correct      
      log F_NAME F_OFFSET F_MAX_SIZE
   Elif TYPE == 50
      get F_CHUNK_SIZE long # size of the chunk containing this file
      get F_SIZE long # actual file size
      GetDString EXT 4
      
      SavePos F_OFFSET
      log F_NAME F_OFFSET F_SIZE   
   Else
      print "%i%"
      print "Unhandled file: %F_NAME%"
      print "Type: %TYPE%"
      SavePos F_OFFSET
      print "Offset: %F_OFFSET%"
      exit
   Endif

   
next i
SMP112
Posts: 7
Joined: Wed Mar 24, 2021 4:42 am

Re: Summon Night Granthese

Post by SMP112 »

Thank you I really appreciate this. Worked like a charm

Hm. pac files and PQRS (Which has sparse mentions here) text in hex. This is tricky. Just about every pac script and tool isn't working