Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Systemcluster committed Oct 8, 2024
1 parent b42bdb0 commit d914076
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 27 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ images = ["std", "dep:image"]

[dependencies]

indexmap = { version = "2.5", default-features = false }
indexmap = { version = "2.6", default-features = false }
log = { version = "0.4" }
zerocopy = { version = "0.7", features = ["derive"] }
zerocopy = { version = "0.8", features = ["derive"] }
debug-ignore = { version = "1.0" }
ahash = { version = "0.8", default-features = false, features = ["compile-time-rng"] }

image = { version = "0.25", default-features = false, optional = true, features = ["ico"] }
image = { version = "0.25.2", default-features = false, optional = true, features = ["ico"] }
thiserror = { version = "1.0", optional = true }

[dev-dependencies]

editpe = { path = ".", features = ["std", "images"] }
image = { version = "0.25", default-features = false, features = ["png"] }
image = { version = "0.25.2", default-features = false, features = ["png"] }

env_logger = { version = "0.11" }

Expand Down
6 changes: 3 additions & 3 deletions src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use alloc::{borrow::Cow, string::ToString, vec::Vec};
use ahash::RandomState;
use indexmap::IndexMap;
use log::{debug, error, info, warn};
use zerocopy::AsBytes;
use zerocopy::IntoBytes;

use crate::{constants::*, errors::*, resource::*, types::*, util::*};

Expand Down Expand Up @@ -54,7 +54,7 @@ pub struct Image<'a> {
directories_offset: u64,
}

impl<'a> PartialEq for Image<'a> {
impl PartialEq for Image<'_> {
fn eq(&self, other: &Self) -> bool {
self.pe_dos_magic == other.pe_dos_magic
&& self.pe_signature == other.pe_signature
Expand All @@ -66,7 +66,7 @@ impl<'a> PartialEq for Image<'a> {
&& self.resource_directory == other.resource_directory
}
}
impl<'a> Eq for Image<'a> {}
impl Eq for Image<'_> {}

impl<'a> Image<'a> {
/// Parse a portable executable image from a byte slice.
Expand Down
4 changes: 2 additions & 2 deletions src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use ahash::RandomState;
use debug_ignore::DebugIgnore;
use indexmap::{IndexMap, IndexSet};
use log::{error, trace, warn};
use zerocopy::AsBytes;
use zerocopy::IntoBytes;

#[cfg(feature = "images")]
pub use image::DynamicImage;
Expand Down Expand Up @@ -60,7 +60,7 @@ impl ToIcon for Vec<u8> {
#[cfg(feature = "images")]
impl ToIcon for &DynamicImage {
fn icons(&self) -> Result<Vec<Vec<u8>>, ResourceError> {
use image::{imageops::FilterType::Lanczos3, ImageFormat};
use image::{ImageFormat, imageops::FilterType::Lanczos3};
use std::io::Cursor;
const RESOLUTIONS: &[u32] = &[256, 128, 48, 32, 24, 16];
RESOLUTIONS
Expand Down
34 changes: 17 additions & 17 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@
use alloc::string::{String, ToString};
use core::{mem, slice};

use zerocopy::{AsBytes, FromBytes, FromZeroes};
use zerocopy::{FromBytes, Immutable, IntoBytes};

#[repr(C, packed(1))]
#[derive(
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, FromZeroes, AsBytes, Default,
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, IntoBytes, Immutable, Default,
)]
pub struct VersionU8 {
pub major: u8,
pub minor: u8,
}
#[repr(C, packed(2))]
#[derive(
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, FromZeroes, AsBytes, Default,
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, IntoBytes, Immutable, Default,
)]
pub struct VersionU16 {
pub major: u16,
pub minor: u16,
}
#[repr(C, packed(4))]
#[derive(
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, FromZeroes, AsBytes, Default,
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, IntoBytes, Immutable, Default,
)]
pub struct VersionU32 {
pub major: u32,
pub minor: u32,
}
#[repr(C, packed(2))]
#[derive(
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, FromZeroes, AsBytes, Default,
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, IntoBytes, Immutable, Default,
)]
pub struct CoffHeader {
pub machine: u16,
Expand All @@ -46,7 +46,7 @@ pub struct CoffHeader {
}
#[repr(C, packed(2))]
#[derive(
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, FromZeroes, AsBytes, Default,
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, IntoBytes, Immutable, Default,
)]
pub struct StandardHeader {
pub magic: u16,
Expand All @@ -58,7 +58,7 @@ pub struct StandardHeader {
pub base_of_code: u32,
}
#[repr(C)]
#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, FromZeroes, Default)]
#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, Default)]
pub struct WindowsHeader<UXX> {
pub image_base: UXX,
pub section_alignment: u32,
Expand All @@ -81,7 +81,7 @@ pub struct WindowsHeader<UXX> {
}
impl<UXX> WindowsHeader<UXX>
where
UXX: AsBytes,
UXX: IntoBytes,
{
pub fn as_bytes(&self) -> &[u8] {
// manually implement this here because zerocopy doesn't support derive for generic types
Expand Down Expand Up @@ -199,7 +199,7 @@ impl GenericWindowsHeader {

#[repr(C, packed(4))]
#[derive(
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, FromZeroes, AsBytes, Default,
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, IntoBytes, Immutable, Default,
)]
pub struct ImageDataDirectory {
pub virtual_address: u32,
Expand All @@ -208,7 +208,7 @@ pub struct ImageDataDirectory {

#[repr(C, packed(4))]
#[derive(
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, FromZeroes, AsBytes, Default,
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, IntoBytes, Immutable, Default,
)]
pub struct SectionHeader {
pub name: u64,
Expand Down Expand Up @@ -236,7 +236,7 @@ impl SectionHeader {

#[repr(C, packed(2))]
#[derive(
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, FromZeroes, AsBytes, Default,
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, IntoBytes, Immutable, Default,
)]
pub struct ResourceDirectoryTable {
pub characteristics: u32,
Expand All @@ -248,7 +248,7 @@ pub struct ResourceDirectoryTable {

#[repr(C, packed(4))]
#[derive(
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, FromZeroes, AsBytes, Default,
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, IntoBytes, Immutable, Default,
)]
pub struct ResourceDirectoryEntry {
pub name_offset_or_integer_id: u32,
Expand All @@ -257,7 +257,7 @@ pub struct ResourceDirectoryEntry {

#[repr(C, packed(4))]
#[derive(
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, FromZeroes, AsBytes, Default,
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, IntoBytes, Immutable, Default,
)]
pub struct ResourceDataEntry {
pub data_rva: u32,
Expand All @@ -268,7 +268,7 @@ pub struct ResourceDataEntry {

#[repr(C, packed(2))]
#[derive(
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, FromZeroes, AsBytes, Default,
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, IntoBytes, Immutable, Default,
)]
pub struct IconDirectory {
pub reserved: u16,
Expand All @@ -278,7 +278,7 @@ pub struct IconDirectory {

#[repr(C, packed(1))]
#[derive(
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, FromZeroes, AsBytes, Default,
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, IntoBytes, Immutable, Default,
)]
pub struct IconDirectoryEntry {
pub width: u8,
Expand All @@ -292,7 +292,7 @@ pub struct IconDirectoryEntry {
}

#[repr(C, packed(4))]
#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, FromZeroes, AsBytes)]
#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, IntoBytes, Immutable)]
pub struct FixedFileInfo {
pub signature: u32,
pub struct_version: VersionU16,
Expand Down Expand Up @@ -324,7 +324,7 @@ impl Default for FixedFileInfo {

#[repr(C, packed(2))]
#[derive(
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, FromZeroes, AsBytes, Default,
Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, FromBytes, IntoBytes, Immutable, Default,
)]
pub struct VersionHeader {
pub length: u16,
Expand Down
4 changes: 3 additions & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ use zerocopy::FromBytes;
use crate::ReadError;

pub fn read<T: FromBytes + Copy>(resource: &[u8]) -> Result<T, ReadError> {
T::read_from_prefix(resource).ok_or_else(|| ReadError(type_name::<T>().to_string()))
T::read_from_prefix(resource)
.map_err(|_| ReadError(type_name::<T>().to_string()))
.map(|(value, _)| value)
}

pub fn aligned_to<T: Add<Output = T> + Sub<Output = T> + Rem<Output = T> + Eq + Copy + Default>(
Expand Down

0 comments on commit d914076

Please sign in to comment.