Please help extract this archive *.hpb

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
cardia
Posts: 11
Joined: Mon Oct 05, 2020 4:02 pm

Please help extract this archive *.hpb

Post by cardia »

Hello, i tried extract files from the psv game 帝国海軍恋慕情~明治横須賀行進曲~ , but I didn’t succeed. _(:з」∠)_
Could you please write bms script for this format *.hpb ?
https://mega.nz/folder/EMl0DagT#ZVFji2uC-rd0Fvl_aAD7BA
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: Please help extract this archive *.hpb

Post by AlphaTwentyThree »

Apply on the common.hpac, move the *.hph into the folder with the *.hpb, then apply to the *.hph.
Really easy format, you might learn to code a bit yourself with this example. ;)

Code: Select all

# 帝国海軍恋慕情~明治横須賀行進曲 - *.hpac/*.hph
# (c) 2022-06-15 by AlphaTwentyThree of Zenhax
# script for QuickBMS http://quickbms.aluigi.org

get BNAME basename
open FDDE hpb 1 EXIST
getDstring IDENT 4
if IDENT == "HLZS"
   comtype LZSS0
   get UNK long
   get CSIZE long
   get SIZE long
   clog TEMPORARY_FILE 0x20 CSIZE SIZE
   open FDSE TEMPORARY_FILE 0
endif
callfunction HPAC 1

startfunction HPAC
   goto 0
   getDstring IDENT 4
   if IDENT == "HGTC"
      callfunction HGTC 1
   elif IDENT == "HPAC"
   else
      print "Unsupported archive format, please contact me."
   endif
   get UNK long
   get FILES long
   get HSIZE long
   get NAMEOFF long
   goto 0x20
   for i = 1 <= FILES
      get HASH1 long
      get OFFSET long
      get SIZE long
      get UNK1 long
      get HASH2 long
      get UNK2 long
      getDstring ZERO 8
      savepos MYOFF
      goto NAMEOFF
      get NAME string
      savepos NAMEOFF
      goto MYOFF
      log NAME OFFSET SIZE EXIST
   next i
endfunction

startfunction HGTC
   get UNK long
   get FILES long
   goto 0x20
   for i = 1 <= FILES
      get HASH long
      get UNK1 long
      get UNK2 long
      get DUMMY long
      get OFFSET1 long
      get OFFSET2 long
      getDstring ZERO 8
      xmath SIZE "OFFSET2 - OFFSET1"
      string NAME p "%s_%d_%08x_%d_%d_1" BNAME i HASH UNK1 UNK2
      log NAME OFFSET1 SIZE EXIST
      savepos MYOFF
      getDstring DUMMY 0x10
      if i != FILES
         get SIZE long
      else
         get SIZE asize
      endif
      math SIZE -= OFFSET2
      string NAME p "%s_%d_%08x_%d_%d_2" BNAME i HASH UNK1 UNK2
      log NAME OFFSET2 SIZE EXIST
      goto MYOFF
   next i
endfunction
Last edited by AlphaTwentyThree on Wed Jun 15, 2022 4:29 pm, edited 2 times in total.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: Please help extract this archive *.hpb

Post by AlphaTwentyThree »

Just updated the script to also support HLZS headers (compressed HPAC).
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: Please help extract this archive *.hpb

Post by AlphaTwentyThree »

Also added the HTGC version of the archive. There are two offsets given for each file and the data seems to change between them so I decided to write both.
No names given, so I decided to write all the information from the TOC to the file name. Adjust as you need.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: Please help extract this archive *.hpb

Post by AlphaTwentyThree »

By the way, to play the resulting AT9 files, you'll need to correct the header. My scanner will do that for you, you'll just have to rename the resulting files. (viewtopic.php?f=17&t=7982&p=72090#p72090)
cardia
Posts: 11
Joined: Mon Oct 05, 2020 4:02 pm

Re: Please help extract this archive *.hpb

Post by cardia »

AlphaTwentyThree wrote:Just updated the script to also support HLZS headers (compressed HPAC).

Thank you!I get files,HPAC(stand) and HGTC(BG),but when I extract them,I only get temporary_file
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: Please help extract this archive *.hpb

Post by AlphaTwentyThree »

Made a small correction with the name but otherwise the script works as intended... Make sure you have the newest QuickBMS version and don't forget to add the QuickBMS folder to your path variable. There shouldn't be any TEMPORARY_FILE left, it's automatically deleted at the end.
mxscr
Posts: 4
Joined: Wed May 13, 2020 9:53 pm

Re: Please help extract this archive *.hpb

Post by mxscr »

Hello, and many thanks.

Your script also works for EPHEMERAL -FANTASY ON DARK- (PS Vita) and I succeded to obtain the "dialog" file were japanese text should be packed.
It's HGTC file so I am using your script a second time and I think it worked as intended too, so there should be nothing to change in the code.

But the result makes no sense to me, I've 14 files instead of 7 (although it seems there is one with the index and one with the content) and it's completely unreadable. Could anyone have a look and give me hints in order to manage text extraction/insertion ?