Additional fix for 2.4 beta (#3)

* fix: compression does not matter for decrypt

For versions 2.4+

* fix: Additional check for flags to decide partial decrypt or not
This commit is contained in:
Przemek 2025-06-10 02:20:48 -04:00 committed by GitHub
parent 2ad368a239
commit d297be401f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 7 deletions

View file

@ -13,6 +13,7 @@ compression = ["dep:flate2", "dep:zstd", "dep:lz4_flex"]
oodle = ["dep:oodle_loader", "compression"]
encryption = ["dep:aes"]
wuthering-waves = []
wuthering-waves-2_4 = []
[dependencies]
byteorder = "1.5"

View file

@ -1,4 +1,4 @@
use std::{io, process::exit};
use std::io;
use byteorder::{LE, ReadBytesExt, WriteBytesExt};
@ -70,6 +70,9 @@ impl Entry {
pub fn is_deleted(&self) -> bool {
0 != (self.flags >> 1) & 1
}
pub fn is_partial_encrypted(&self) -> bool {
0 != (self.flags >> 3) & 1
}
pub fn get_serialized_size(
version: super::Version,
compression: Option<u32>,
@ -330,7 +333,7 @@ impl Entry {
buf: &mut W,
) -> Result<(), super::Error> {
reader.seek(io::SeekFrom::Start(self.offset))?;
Entry::read(reader, version)?;
let entry_read = Entry::read(reader, version)?;
#[cfg(any(feature = "compression", feature = "oodle"))]
let data_offset = reader.stream_position()?;
#[allow(unused_mut)]
@ -348,11 +351,14 @@ impl Entry {
};
use aes::cipher::BlockDecrypt;
let mut data_len = data.len();
#[cfg(all(feature = "wuthering-waves", feature = "compression"))]
if let Some(Compression::Zlib) = self.compression_slot.and_then(|c| compression[c as usize]) {
data_len = data_len.min(2048);
}
#[cfg(not(feature = "wuthering-waves-2_4"))]
let data_len = data.len();
#[cfg(feature = "wuthering-waves-2_4")]
let data_len = if entry_read.is_partial_encrypted() {
data.len().min(2048)
} else {
data.len()
};
for block in data[..data_len].chunks_mut(16) {
key.decrypt_block(aes::Block::from_mut_slice(block))