Xaymar / Hellextractor

A simple tool to extract things from Helldivers 2 for your 3D printing needs.
BSD 3-Clause "New" or "Revised" License
32 stars 5 forks source link

Reversed exploded package file header #29

Open Zekfad opened 6 months ago

Zekfad commented 6 months ago

Seems that bitsquid (stingray) partially moved to 64bit offsets and header includes some clues for read buffers E.g. aligned offsets seems to suggest that during load they allocate full buffer size or smth like that. Here's file header as I see it:

    struct file_header_t {
        le hash::hash_name name;
        le hash::file_type type;

        // aligned to alignment
        le u64 offset;
        // unaligned raw aux buffer
        le u64 stream_offset;
        // aligned to gpu_alignment
        le u64 gpu_offset;

        // aligned to 0x200
        // seems to be an offset of read buffer that have size of 0x200 per element
        le u64 buffer_offset;
        // aligned to 0x600
        // seems to be an offset of read buffer that have size of 0x600 per element
        le u64 gpu_buffer_offset;

        le u32 size;
        le u32 stream_size;
        le u32 gpu_stream_size;

        le u32 alignment;
        le u32 gpu_alignment;
        le u32 index;

        file_t<size> inline_file @ offset;
    };
Xaymar commented 6 months ago

Has there been an update to the package/data structure? There's a few entries missing between gpu_offset and size, which would make the new structure smaller than before. Edit: Nevermind, I did not see the "buffer" part of the variable.

Xaymar commented 6 months ago

It seems to be a better match than the original structure. While I don't know what the two other offsets would be used for - too far from the actual data to be of use to anything - everything aligns well and it does remove the unknowns. Plus if the game ever decides to go above 4GB for a single file, it'll be supported now.

xypwn commented 6 months ago

The type header seems to also have the alignment and gpu_alignment fields at the end, since they always have the same set of values. EDIT: Although I don't really understand how a type having an alignment would make sense if the file itself already has an alignment.

Zekfad commented 6 months ago

buffer offsets seems to be related to how game read files. If my understanding is correct internal structure have a known size, some array is allocated and then files are read (mapped?) to array elements. e.g. buffer_offset seems to be aligned to 0x200 bytes per element