mirror of
https://github.com/xavo95/repak.git
synced 2025-06-16 06:31:14 +00:00
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:
parent
2ad368a239
commit
d297be401f
2 changed files with 14 additions and 7 deletions
|
@ -13,6 +13,7 @@ compression = ["dep:flate2", "dep:zstd", "dep:lz4_flex"]
|
||||||
oodle = ["dep:oodle_loader", "compression"]
|
oodle = ["dep:oodle_loader", "compression"]
|
||||||
encryption = ["dep:aes"]
|
encryption = ["dep:aes"]
|
||||||
wuthering-waves = []
|
wuthering-waves = []
|
||||||
|
wuthering-waves-2_4 = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
byteorder = "1.5"
|
byteorder = "1.5"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{io, process::exit};
|
use std::io;
|
||||||
|
|
||||||
use byteorder::{LE, ReadBytesExt, WriteBytesExt};
|
use byteorder::{LE, ReadBytesExt, WriteBytesExt};
|
||||||
|
|
||||||
|
@ -70,6 +70,9 @@ impl Entry {
|
||||||
pub fn is_deleted(&self) -> bool {
|
pub fn is_deleted(&self) -> bool {
|
||||||
0 != (self.flags >> 1) & 1
|
0 != (self.flags >> 1) & 1
|
||||||
}
|
}
|
||||||
|
pub fn is_partial_encrypted(&self) -> bool {
|
||||||
|
0 != (self.flags >> 3) & 1
|
||||||
|
}
|
||||||
pub fn get_serialized_size(
|
pub fn get_serialized_size(
|
||||||
version: super::Version,
|
version: super::Version,
|
||||||
compression: Option<u32>,
|
compression: Option<u32>,
|
||||||
|
@ -330,7 +333,7 @@ impl Entry {
|
||||||
buf: &mut W,
|
buf: &mut W,
|
||||||
) -> Result<(), super::Error> {
|
) -> Result<(), super::Error> {
|
||||||
reader.seek(io::SeekFrom::Start(self.offset))?;
|
reader.seek(io::SeekFrom::Start(self.offset))?;
|
||||||
Entry::read(reader, version)?;
|
let entry_read = Entry::read(reader, version)?;
|
||||||
#[cfg(any(feature = "compression", feature = "oodle"))]
|
#[cfg(any(feature = "compression", feature = "oodle"))]
|
||||||
let data_offset = reader.stream_position()?;
|
let data_offset = reader.stream_position()?;
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
|
@ -348,11 +351,14 @@ impl Entry {
|
||||||
};
|
};
|
||||||
use aes::cipher::BlockDecrypt;
|
use aes::cipher::BlockDecrypt;
|
||||||
|
|
||||||
let mut data_len = data.len();
|
#[cfg(not(feature = "wuthering-waves-2_4"))]
|
||||||
#[cfg(all(feature = "wuthering-waves", feature = "compression"))]
|
let data_len = data.len();
|
||||||
if let Some(Compression::Zlib) = self.compression_slot.and_then(|c| compression[c as usize]) {
|
#[cfg(feature = "wuthering-waves-2_4")]
|
||||||
data_len = data_len.min(2048);
|
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) {
|
for block in data[..data_len].chunks_mut(16) {
|
||||||
key.decrypt_block(aes::Block::from_mut_slice(block))
|
key.decrypt_block(aes::Block::from_mut_slice(block))
|
||||||
|
|
Loading…
Reference in a new issue