Skip to content

Commit

Permalink
Review: removed a useless trait function
Browse files Browse the repository at this point in the history
  • Loading branch information
daladim committed Sep 16, 2021
1 parent 64b7a8b commit 7590b1a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
5 changes: 0 additions & 5 deletions src/endian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,11 +626,6 @@ impl<E: Endian> U32Bytes<E> {
pub fn set(&mut self, e: E, n: u32) {
self.0 = e.write_u32_bytes(n);
}

/// Get the underlying representation of this value.
pub fn as_slice(&self) -> &[u8; 4] {
&self.0
}
}

/// An unaligned `u64` value with an externally specified endianness of type `E`.
Expand Down
18 changes: 7 additions & 11 deletions src/read/pe/rich.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use alloc::vec::Vec;

use crate::{pe, ReadRef, LittleEndian as LE, U32};


/// Extracted infos about a possible Rich Header
#[derive(Debug, Clone, Copy)]
pub struct RichHeaderInfos<'data> {
Expand Down Expand Up @@ -48,18 +47,15 @@ impl<'data> RichHeaderInfos<'data> {
let xor_key = data.read_at::<U32<LE>>(dos_and_rich_header.len() as u64 + 4)
.ok()?;

let mut start_marker: Vec<u8> = U32::<LE>::new(LE, CLEARTEXT_MARKER)
.as_slice()
.iter()
.zip(xor_key.as_slice())
.map(|(a, b)| *a ^ *b)
.collect();
start_marker.extend_from_slice(xor_key.as_slice());
start_marker.extend_from_slice(xor_key.as_slice());
start_marker.extend_from_slice(xor_key.as_slice());
let marker = U32::new(LE, CLEARTEXT_MARKER ^ xor_key.get(LE));
let mut start_sequence: Vec<u8> = Vec::with_capacity(16);
start_sequence.extend_from_slice(crate::pod::bytes_of(&marker));
start_sequence.extend_from_slice(crate::pod::bytes_of(xor_key));
start_sequence.extend_from_slice(crate::pod::bytes_of(xor_key));
start_sequence.extend_from_slice(crate::pod::bytes_of(xor_key));

let rich_header_start =
match read_bytes_until_sequence(all_headers, &start_marker, nt_header_offset as usize) {
match read_bytes_until_sequence(all_headers, &start_sequence, nt_header_offset as usize) {
Err(()) => return None,
Ok(slice) => slice.len(),
};
Expand Down

0 comments on commit 7590b1a

Please sign in to comment.