To anyone interested in the filexor command.
There is this particular format in this topic (
viewtopic.php?f=9&t=11577) where the entry is encrypted with xor, the content of the file follows the entry and the position of the key is kept the same since the last byte of the previous entry.
In short it's like if the entries are a contiguous stream of bytes during decryption (the content of the files is NOT encrypted).
It was very difficult to handle it with quickbms because the position of the key depends by the offset of the file.
After some tentatives I found the solution ("CHECK HERE" comments) and I want to share it with anyone who will have the same situation in the future:
Code:
# Resident Evil 4 Mobile H2Z
comtype deflate
idstring "H2Z\0"
get SOME_CRC long
get SIZE long
idstring "HIZ\0"
get FILES long
get SIZE long
math ENTRY_SIZE = 0
for i = 0 < FILES
# CHECK HERE
savepos OFFSET
math OFFSET - ENTRY_SIZE
filexor "bio4" OFFSET
#
get TYPE short
get ZSIZE long
get SIZE long
get NAMESZ short
getdstring NAME NAMESZ
# CHECK HERE
filexor ""
savepos ENTRY_SIZE
math ENTRY_SIZE - OFFSET
savepos OFFSET
#
if TYPE == 0
log NAME OFFSET SIZE
else # 8 for deflate
clog NAME OFFSET ZSIZE SIZE
endif
goto ZSIZE 0 SEEK_CUR
next i
Ah, I also finally added support for the FILENUM argument of filexor, filerot and filecrypt.
By default everything works as before: filexor applied to all the files using the offset of file 0 as position when the command is invoked
If you use FILENUM then filexor will work only with that specific file.
It's already available in the beta I just uploaded (both exe and source code).