3DMGAME论坛

标题: pac解包方法 [打印本页]

作者: Geminize    时间: 2025-8-24 09:52
标题: pac解包方法
安装python,新建extractpac.py,输入以下内容保存,然后把pac直接拖到py上

import struct, glob, os, sys

def read_null_terminated_string (f, start_offset):
    current_loc = f.tell()
    f.seek(start_offset)
    null_term_string = f.read(1)
    while null_term_string[-1] != 0:
        null_term_string += f.read(1)
    f.seek(current_loc)
    return(null_term_string[:-1].decode())

def process_pac (pac_file):
    print("Processing {}...".format(pac_file))
    with open(pac_file, 'rb') as f:
        magic = f.read(4)
        if magic == b'FPAC':
            count, header_size, unk = struct.unpack("<3I", f.read(12))
            files = []
            for i in range(count):
                entry_dat = struct.unpack("<4Q", f.read(32))
                files.append({'name': read_null_terminated_string (f, entry_dat[1]),
                    'location': entry_dat[3],
                    'size': entry_dat[2],
                    'hash': entry_dat[0]})
            for i in range(count):
                f.seek(files[i]['location'])
                f_data = f.read(files[i]['size'])
                filedir = os.path.dirname(files[i]['name'])
                if not filedir == '' and not os.path.exists(filedir):
                    os.makedirs(filedir)
                with open(files[i]['name'], 'wb') as f2:
                    f2.write(f_data)
    return

if __name__ == "__main__":
    # Set current directory
    if getattr(sys, 'frozen', False):
        os.chdir(os.path.dirname(sys.executable))
    else:
        os.chdir(os.path.abspath(os.path.dirname(__file__)))

    # If argument given, attempt to extract from file in argument
    if len(sys.argv) > 1:
        import argparse
        parser = argparse.ArgumentParser()
        parser.add_argument('pac_filename', help="Name of pac file to extract from (required).")
        args = parser.parse_args()
        if os.path.exists(args.pac_filename) and args.pac_filename[-4:].lower() == '.pac':
            process_pac(args.pac_filename)
    else:
        pac_files = glob.glob('*.pac')
        for i in range(len(pac_files)):
            process_pac(pac_files[i])

作者: yihuxingkong    时间: 2025-8-24 11:28
感谢,礼貌问下,解包出来的tbl文件如何处理
作者: 1170759450    时间: 2025-8-24 12:28
谢谢大佬分享,还有怎么打包回去。
作者: Geminize    时间: 2025-8-24 13:15
不用打包,能读零散文件,把原pac删了就行

作者: 1170759450    时间: 2025-8-24 15:02
Geminize 发表于 2025-8-24 13:15
不用打包,能读零散文件,把原pac删了就行

好的谢谢大大。

作者: wky071036    时间: 2025-8-24 17:15
谢谢大佬  每次的轨迹修改指导
作者: qq95604014    时间: 2025-8-24 19:06
存档呢···
作者: Geminize    时间: 2025-8-24 19:24
qq95604014 发表于 2025-8-24 19:06
存档呢···

你这眼神我也是服了
https://bbs.3dmgame.com/thread-6614789-1-1.html

作者: Mr.冷水先森    时间: 2025-8-28 00:07
Geminize 发表于 2025-8-24 13:15
不用打包,能读零散文件,把原pac删了就行

大佬,把tbl和pac放一个文件夹;tbl放在文件夹再把这个文件夹和pac放一起?我两种都试了,游戏打不开QAQ。

作者: 1170759450    时间: 2025-8-29 10:03
本帖最后由 1170759450 于 2025-8-29 10:04 编辑
Mr.冷水先森 发表于 2025-8-28 00:07
大佬,把tbl和pac放一个文件夹;tbl放在文件夹再把这个文件夹和pac放一起?我两种都试了,游戏打不开QAQ ...

把解包后的文件夹放到exe文件同级的目录里不是pac文件夹里,还要把解包前的文件删除了。 屏幕截图 2025-08-29 100356.png
作者: Mr.冷水先森    时间: 2025-8-29 17:47
1170759450 发表于 2025-8-29 10:03
把解包后的文件夹放到exe文件同级的目录里不是pac文件夹里,还要把解包前的文件删除了。 ...

谢谢大佬!!!爱您!!感恩!

作者: yidaishiwang    时间: 2025-9-20 23:02
感谢教程,看来只能自己动手了
作者: Blank12    时间: 2025-9-22 17:03
可以把bgm的资源解出来嘛?想要新版默认的音频资源
作者: koujun    时间: 2025-9-26 09:57
谢谢!真是太棒了!
作者: 丶ˇ俊    时间: 2025-10-10 21:12
大佬问一下 怎么我的PAC不能放到解包软件上啊





欢迎光临 3DMGAME论坛 (https://bbs.3dmgame.com/) Powered by Discuz! X3.2