Decompressing zipped message from Steam protocol

8 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 (libarchive) 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. CHECK DEBUG GIF

Reply all
Reply to author
Forward
0 new messages