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

Fix crashes when loading WWEV files from H2016 #100

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/extract_wwev_to_ogg_from.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,16 @@ void rpkg_function::extract_wwev_to_ogg_from(std::string& input_path, std::strin

std::memcpy(&wwev_file_count_test, &wwev_data->data()[position], sizeof(bytes4));

if (wwev_file_count == -1 || wwev_file_count == 1 && wwev_file_count_test < 5000) {
// Hitman 2016 file format has an extra int32 here
// The 2000 in the check is a bit arbitrary, but I don't know anything better to test.
// Will give false negatives (2016 wwev detected as newer version) if there are more than 5000 embedded sounds
// Will give false positives (newer wwev detected as 2016 version) if there is exactly one embedded sound with a wem id lower than 5000
// -grappigegovert
wwev_file_count = wwev_file_count_test;
position += 4;
}

bool found = false;

uint64_t input_filter_index = 0;
Expand Down
10 changes: 10 additions & 0 deletions src/lib/rpkg_dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,16 @@ int create_ogg_file_from_hash_in_rpkg(char* rpkg_file, char* hash_string, int co

std::memcpy(&wwev_file_count_test, &(*sound_data)[position], sizeof(bytes4));

if (wwev_file_count == -1 || wwev_file_count == 1 && wwev_file_count_test < 5000) {
// Hitman 2016 file format has an extra int32 here
// The 2000 in the check is a bit arbitrary, but I don't know anything better to test.
// Will give false negatives (2016 wwev detected as newer version) if there are more than 5000 embedded sounds
// Will give false positives (newer wwev detected as 2016 version) if there is exactly one embedded sound with a wem id lower than 5000
// -grappigegovert
wwev_file_count = wwev_file_count_test;
position += 4;
}

std::string wem_ogg_path = util::uint64_t_to_hex_string(rpkg.hash.at(it->second).hash_value);

if (command == 0) {
Expand Down
Loading