Decompressing zip message from Steam problem

23 views
Skip to first unread message

vuy...@gmail.com

unread,
Mar 31, 2018, 3:58:10 PM3/31/18
to libarchive-discuss

I'm writting a plugin for Steam protocol in C++. I'm using https://github.com/seishun/SteamPP which uses protobufs from https://github.com/SteamRE/SteamKit and generally it works. I can communicate Steam, I can send and receive single messages (including logging in) without problems, but Steam sends often few messages zipped in one message (EMsg::Multi from protobuf) and here is my problem. I cannot unzip them correctly. I can't understand what I'm doing wrong.

std::string unzip(std::string &input) {
auto archive = archive_read_new();

auto result = archive_read_support_filter_all(archive);
assert(result == ARCHIVE_OK);

result = archive_read_support_format_zip(archive);
assert(result == ARCHIVE_OK);

result = archive_read_open_memory(archive, &input[0], input.size());
assert(result == ARCHIVE_OK);

archive_entry* entry;
result = archive_read_next_header(archive, &entry);
if (result != ARCHIVE_OK) {
    return "read next header error " + std::to_string(result);
}
assert(result == ARCHIVE_OK);

std::string output;
output.resize(archive_entry_size(entry));

auto length = archive_read_data(archive, &output[0], output.size());
assert(length == output.size());
if (length != output.size()) {
    return "hello world" + std::to_string(length);
}

assert(archive_read_next_header(archive, &entry) == ARCHIVE_EOF);

result = archive_read_free(archive);
assert(result == ARCHIVE_OK);

return output;
}

in this function archive_read_data returns -25 which is an error code and next assert throws error. What is wrong? It's working well in C# SteamKit version and also in node.js version. I have tried also Crypto++ Gunzip but it throws an CryptoPP::Gunzip::HeaderErr exception.

Here you can se Debug GIF with data:



 


 Any help?



Tim Kientzle

unread,
Apr 1, 2018, 1:26:36 AM4/1/18
to vuy...@gmail.com, libarchiv...@googlegroups.com


> On Mar 29, 2018, at 12:17 PM, vuy...@gmail.com wrote:
>
> I'm writting a plugin for Steam protocol in C++. I'm using https://github.com/seishun/SteamPP which uses protobufs from https://github.com/SteamRE/SteamKit and generally it works. I can communicate Steam, I can send and receive single messages (including logging in) without problems, but Steam sends often few messages zipped in one message (EMsg::Multi from protobuf) and here is my problem. I cannot unzip them correctly. I can't understand what I'm doing wrong.
>
> auto length = archive_read_data(archive, &output[0], output.size());
>
> assert(length == output.size());
>
> in this function archive_read_data returns -25 which is an error code and next assert throws error. What is wrong? It's working well in C# SteamKit version and also in node.js version.

What does `archive_error_string()` return? Usually, `archive_error_string()` will provide more detail about the specific error.

I also recommend you write the `input` data to a file so you can examine it. In particular, you can check whether a command-line unzip tool can read the data.

> I have tried also Crypto++ Gunzip but it throws an CryptoPP::Gunzip::HeaderErr exception.

Gzip and Zip are not the same thing.

Tim


Message has been deleted

vuy...@gmail.com

unread,
Apr 3, 2018, 3:00:55 PM4/3/18
to libarchive-discuss
Problem solved, I didn't have Zlib in my libarchive.
Reply all
Reply to author
Forward
0 new messages