Skip to content

Commit

Permalink
frida-gum: add std feature
Browse files Browse the repository at this point in the history
The use of an ad-hoc list of features to enable std is weird. It's
better to centralize under one std feature that these features enable.

Fixes #154
  • Loading branch information
ajwerner committed Sep 9, 2024
1 parent fea112a commit 30586cb
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 47 deletions.
9 changes: 5 additions & 4 deletions frida-gum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ description.workspace = true

[features]
auto-download = ["frida-gum-sys/auto-download"]
backtrace = ["libc"]
backtrace = ["libc", "std"]
event-sink = ["frida-gum-sys/event-sink"]
invocation-listener = ["frida-gum-sys/invocation-listener"]
memory-access-monitor = []
module-names = []
memory-access-monitor = ["std"]
module-names = ["std"]
stalker-observer = ["frida-gum-sys/stalker-observer"]
stalker-params = ["frida-gum-sys/stalker-params"]
std = []

[dependencies]
cstr_core = { version = "0.2.6", default-features = false, features = ["alloc"] }
Expand All @@ -33,4 +34,4 @@ lazy_static = "1"
maintenance = { status = "experimental" }

[package.metadata.docs.rs]
features = ["event-sink", "invocation-listener", "stalker-observer", "stalker-params"]
features = ["event-sink", "invocation-listener", "stalker-observer", "stalker-params", "std"]
21 changes: 3 additions & 18 deletions frida-gum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,12 @@
//! }
//! ```
#![cfg_attr(
not(any(
feature = "module-names",
feature = "backtrace",
feature = "memory-access-monitor"
)),
no_std
)]
#![cfg_attr(not(feature = "std"), no_std)]
#![deny(warnings)]
#![allow(clippy::needless_doctest_main)]
#![allow(clippy::missing_safety_doc)]

#[cfg(not(any(
feature = "module-names",
feature = "backtrace",
feature = "memory-access-monitor"
)))]
#[cfg(not(feature = "std"))]
extern crate alloc;

extern crate num;
Expand All @@ -74,11 +63,7 @@ use core::{
fmt::{Debug, Display, Formatter, LowerHex, UpperHex},
};

#[cfg(not(any(
feature = "module-names",
feature = "backtrace",
feature = "memory-access-monitor"
)))]
#[cfg(not(feature = "std"))]
use alloc::string::String;

pub mod stalker;
Expand Down
6 changes: 1 addition & 5 deletions frida-gum/src/memory_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ use core::{
ops::Range,
};

#[cfg(not(any(
feature = "module-names",
feature = "backtrace",
feature = "memory-access-monitor"
)))]
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;

pub struct MatchPattern {
Expand Down
6 changes: 1 addition & 5 deletions frida-gum/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ use {
frida_gum_sys::{gboolean, gpointer, GumExportDetails, GumModuleDetails, GumSymbolDetails},
};

#[cfg(not(any(
feature = "module-names",
feature = "backtrace",
feature = "memory-access-monitor"
)))]
#[cfg(not(feature = "std"))]
use alloc::{boxed::Box, string::String, vec, vec::Vec};

extern "C" fn enumerate_ranges_callout(
Expand Down
6 changes: 1 addition & 5 deletions frida-gum/src/module_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ use {
frida_gum_sys as gum_sys,
};

#[cfg(not(any(
feature = "module-names",
feature = "backtrace",
feature = "memory-access-monitor"
)))]
#[cfg(not(feature = "std"))]
use alloc::{
boxed::Box,
string::{String, ToString},
Expand Down
6 changes: 1 addition & 5 deletions frida-gum/src/range_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ use {
frida_gum_sys as gum_sys,
};

#[cfg(not(any(
feature = "module-names",
feature = "backtrace",
feature = "memory-access-monitor"
)))]
#[cfg(not(feature = "std"))]
use alloc::{boxed::Box, string::String};

/// The memory protection of an unassociated page.
Expand Down
6 changes: 1 addition & 5 deletions frida-gum/src/stalker/transformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ use {
core::{ffi::c_void, marker::PhantomData},
};

#[cfg(not(any(
feature = "module-names",
feature = "backtrace",
feature = "memory-access-monitor"
)))]
#[cfg(not(feature = "std"))]
use alloc::boxed::Box;

pub struct StalkerIterator<'a> {
Expand Down

0 comments on commit 30586cb

Please sign in to comment.