Slightly better file detection

This commit is contained in:
987123879113 2024-02-16 13:02:22 +09:00
parent 64d590b5ce
commit e53472909f
2 changed files with 37 additions and 5 deletions

View File

@ -73,7 +73,7 @@ def decrypt_data(data, input_key):
common_extensions = [
'bin', 'exe', 'dat', 'rom', 'o'
'bin', 'exe', 'dat', 'rom', 'o', 'lz'
]
mambo_common_extensions = [
@ -95,6 +95,7 @@ dmx_common_extensions = [
]
common_extensions += mambo_common_extensions + ddr_common_extensions + gfdm_common_extensions + dmx_common_extensions
common_extensions += [x + ".lz" for x in common_extensions]
ddr_common_regions = [
'span', 'ital', 'germ', 'fren', 'engl', 'japa', 'kore'
@ -234,7 +235,9 @@ def parse_group_list_filenames_dmx(data, hash_list={}, skip_data=False):
while filename_len < entry_size and data[i*entry_size+filename_len] != 0:
filename_len += 1
filename = data[i*entry_size:i*entry_size+filename_len].decode('ascii').strip('\0')
filename = data[i*entry_size:i*entry_size+filename_len].decode('ascii').strip('\0').strip()
if not filename:
continue
hash_list[get_filename_hash(filename)] = filename
@ -263,7 +266,10 @@ def parse_group_list_filenames_dmx(data, hash_list={}, skip_data=False):
while filename_len < entry_size and data[i*entry_size+filename_len] != 0:
filename_len += 1
filename = data[i*entry_size:i*entry_size+filename_len].decode('ascii').strip('\0')
filename = data[i*entry_size:i*entry_size+filename_len].decode('ascii').strip('\0').strip()
if not filename:
continue
hash_list[get_filename_hash(filename)] = filename
for ext in common_extensions:
@ -865,6 +871,17 @@ def dump_data(input_folder, output_folder, candidate_result, main_card_filename=
except:
pass
elif hash_list[fileinfo['filename_hash']] == "object_2d_data.bin":
try:
hash_list = parse_group_list_filenames_dmx(get_file_data(input_folder, fileinfo, game_key), hash_list)
except:
pass
try:
hash_list = parse_group_list_filenames_dmx(get_file_data(input_folder, fileinfo, game_key), hash_list, True)
except:
pass
unknown_hash_list = {}
for idx, fileinfo in enumerate(files):
output_filename = "_output_%08x.bin" % (fileinfo['filename_hash'])
@ -988,6 +1005,14 @@ def main():
filenames = []
if os.path.exists("filenames.txt"):
with open("filenames.txt", "r") as infile:
for line in infile:
l = line.strip()
if not l:
continue
filenames.append(l)
for filename in filenames:
hash_list[get_filename_hash(filename)] = filename

View File

@ -26,6 +26,8 @@ def decrypt_data_internal(data, key):
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--input', help='Input GAME.DAT', required=False, default="GAME.DAT")
parser.add_argument('--output', help='Output file', required=False, default="config.txt")
parser.add_argument('--insert', help='Input configuration text into output file', default=False, action='store_true')
args = parser.parse_args()
@ -40,9 +42,14 @@ def main():
else:
# Extract from GAME.DAT
data = bytearray(open("GAME.DAT", "rb").read())[0x1fc4 * 0x800:0x1fc4 * 0x800 + 0x7f6]
data = bytearray(open(args.input, "rb").read())[0x1fc4 * 0x800:0x1fc4 * 0x800 + 0x7f6]
config = decrypt_data_internal(data, "/s573/config.dat")
open("config.txt", "wb").write(config)
open(args.output, "wb").write(config)
try:
print(config.decode('cp932'))
except:
pass
if __name__ == "__main__":