Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract compressed files from respawn.Vpk #205

Open
snake-biscuits opened this issue Dec 4, 2024 · 3 comments
Open

Extract compressed files from respawn.Vpk #205

snake-biscuits opened this issue Dec 4, 2024 · 3 comments
Assignees
Labels
archives related to archives module slow burn lots of work & will take a long time

Comments

@snake-biscuits
Copy link
Owner

Tried https://github.com/Galaxy1036/pylzham and it didn't go well

maps/mp_angel_city.bsp.0053.bsp_lump is a nice small sample to test
uses a single VpkFilePart

>>> compressed_data
b'\xd4\x1f\xd3\x1f@\x04\x00\x00\x10\x03,\x03\xbd\x1f\x01\x80\x01q\x80\xc0\x03g\x00)'

Attempt 1

>>> filters = {
...     "compute_adler32_during_decomp": True,
...     "dict_size_log2": 20,
...     "unbuffered_decompression": True}
>>> lzham.decompress(compressed_data, 40, filters)
# raises "ValueError: Decompression failed with status code: 8", adler32 failure

Attempt 2

>>> filters = {
...     "compute_adler32_during_decomp": False,
...     "dict_size_log2": 20,
...     "unbuffered_decompression": True}
>>> lzham.decompress(compressed_data, 40, filters)
b'd\x1b\xfd\xbf\xady\x00\x00unbuffered_decompression\x00comp\x00e\x00'

Attempt 3

>>> lzham.decompress(compressed_data, 40, {"dict_size_log2": 20})
# raises "ValueError: Decompression failed with status code: 8", adler32 failure

Attempt 4

>>> lzham.decompress(compressed_data, 40, {
...     "dict_size_log2": 20,
...     "compute_adler32_during_decomp": False})
b'dV\xb2\xbf\xady\x00\x00compute_adler32_during_decomp\x00e\x00'

Attempt 5

>>> decompressor = lzham.LZHAMDecompressor(filters)
... decompressor.decompress(compressed_data, 40)
b'\x80\xbb\xb3\xbf\xady\x00\x00@LH\xc5\xady\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@R\xfe\xbf\xady\x00\x00'
@snake-biscuits snake-biscuits added the archives related to archives module label Dec 4, 2024
@snake-biscuits snake-biscuits self-assigned this Dec 4, 2024
@snake-biscuits snake-biscuits added the slow burn lots of work & will take a long time label Dec 4, 2024
@snake-biscuits snake-biscuits moved this to Todo: Research in bsp_tool Format Coverage Dec 4, 2024
@snake-biscuits
Copy link
Owner Author

I tried to compress the bytes and search for them, but pylzham doesn't give you fine enough control

couldn't set LZHAM_COMP_FLAG_DETERMINISTIC_PARSING

@snake-biscuits
Copy link
Owner Author

For reference, I looked at the lzham implementation in https://github.com/barnabwhy/TFVPKTool/
specifically: src/lzham.cpp

@snake-biscuits
Copy link
Owner Author

Forking pylzham is an option, but idk how python compiles C++ in the background
But presumably I could test that w/ pip:

$ python -m pip install ../pylzham-fork/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
archives related to archives module slow burn lots of work & will take a long time
Projects
Status: Todo: Research
Development

No branches or pull requests

1 participant