Skip to content

Update packets.hexpat to support PPAC 4 (zstd) #3

@rockisch

Description

@rockisch

Thought it would be interesting to create a tracking issue for this, since I was looking into it.

One of the reasons I think parsing PPAC v4 wasn't possible is because the current implementation uses the zstd streaming API to save the files, and ImHex's zstd_decompress didn't support that.

This PR fixes that:
WerWolv/ImHex#1898

With that out of the way, it is now possible to parse the zstd data... but the way it is displayed is kinda weird. Here's the updated parts of the script:

import hex.dec;

...

struct file {
    Header header;
    if (header.Ver >= 3) {
        u8 is_ngs;
    }
    if (header.Ver >= 4) {
        u8 is_zstd;
    }
    if (header.Ver == 1) {
        Packet_v1 packet[while(!std::mem::eof())];
    } else if (header.Ver == 2 || header.Ver == 3 || (header.Ver == 4 && !is_zstd)) {
        Packet_v2 packet[while(!std::mem::eof())];
    } else if (header.Ver == 4 && is_zstd) {
        u8 packet_zstd[while(!std::mem::eof())] [[hidden]];
        std::mem::Section packet_section = std::mem::create_section("data_section") [[export]];
        hex::dec::zstd_decompress(packet_zstd, packet_section);
        Packet_v2 packet[while(!std::mem::eof())] @ 0x00 in packet_section;
    }
};

This works under the PR branch, but it seems like the way ImHex pattern scripts treats @ 0x00 in <section> is a bit weird:
WerWolv/ImHex#1899

In order to access the data you need to go to the sections tab which looks like this:
image

As of right now, you can't resize this window, which makes it pretty much useless. I'm trying to see if there are any better options on the above ticket.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions