Skip to content

Commit

Permalink
use LazyLock & clean unnecessary crates (#175)
Browse files Browse the repository at this point in the history
- Use of LazyLock instead of lazy_static
- Clean up unnecessary frida-sys & lazy_static crates
  • Loading branch information
Xoffio authored Nov 6, 2024
1 parent 7f392bf commit 42d7f87
Show file tree
Hide file tree
Showing 13 changed files with 10 additions and 33 deletions.
1 change: 0 additions & 1 deletion examples/core/console_log/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ publish = false

[dependencies]
frida = { path = "../../../frida" }
lazy_static = "1.4"
6 changes: 2 additions & 4 deletions examples/core/console_log/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use frida::{DeviceManager, Frida, ScriptHandler, ScriptOption, ScriptRuntime};
use lazy_static::lazy_static;
use std::sync::LazyLock;

lazy_static! {
static ref FRIDA: Frida = unsafe { Frida::obtain() };
}
static FRIDA: LazyLock<Frida> = LazyLock::new(|| unsafe { Frida::obtain() });

fn main() {
let args: Vec<String> = std::env::args().collect();
Expand Down
2 changes: 0 additions & 2 deletions examples/core/get_processes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ publish = false

[dependencies]
frida = { path = "../../../frida" }
frida-sys = { path = "../../../frida-sys" }
lazy_static = "1.5.0"
6 changes: 2 additions & 4 deletions examples/core/get_processes/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use frida::Frida;
use lazy_static::lazy_static;
use std::sync::LazyLock;

lazy_static! {
static ref FRIDA: Frida = unsafe { Frida::obtain() };
}
static FRIDA: LazyLock<Frida> = LazyLock::new(|| unsafe { Frida::obtain() });

fn main() {
let device_manager = frida::DeviceManager::obtain(&FRIDA);
Expand Down
2 changes: 0 additions & 2 deletions examples/core/hello/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ publish = false

[dependencies]
frida = { path = "../../../frida" }
frida-sys = { path = "../../../frida-sys" }
lazy_static = "1.4"
6 changes: 2 additions & 4 deletions examples/core/hello/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/* This example is in the public domain */

use frida::Frida;
use lazy_static::lazy_static;
use std::sync::LazyLock;

lazy_static! {
static ref FRIDA: Frida = unsafe { Frida::obtain() };
}
static FRIDA: LazyLock<Frida> = LazyLock::new(|| unsafe { Frida::obtain() });

fn main() {
println!("Hello, world!");
Expand Down
1 change: 0 additions & 1 deletion examples/core/inject_lib_blob/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ crate-type = ["cdylib"]

[dependencies]
frida = { path = "../../../frida" }
frida-sys = { path = "../../../frida-sys" }
1 change: 0 additions & 1 deletion examples/core/inject_lib_file/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ crate-type = ["cdylib"]

[dependencies]
frida = { path = "../../../frida" }
frida-sys = { path = "../../../frida-sys" }
2 changes: 0 additions & 2 deletions examples/core/list_exports/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ publish = false

[dependencies]
frida = { path = "../../../frida" }
frida-sys = { path = "../../../frida-sys" }
lazy_static = "1.5.0"
6 changes: 2 additions & 4 deletions examples/core/list_exports/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use frida::{Frida, Message};
use lazy_static::lazy_static;
use std::sync::LazyLock;
use std::{thread, time::Duration};

lazy_static! {
static ref FRIDA: Frida = unsafe { Frida::obtain() };
}
static FRIDA: LazyLock<Frida> = LazyLock::new(|| unsafe { Frida::obtain() });

fn main() {
let device_manager = frida::DeviceManager::obtain(&FRIDA);
Expand Down
2 changes: 0 additions & 2 deletions examples/core/rpc_execute_function/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@ publish = false

[dependencies]
frida = { path = "../../../frida" }
frida-sys = { path = "../../../frida-sys" }
lazy_static = "1.5.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.127"
6 changes: 2 additions & 4 deletions examples/core/rpc_execute_function/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use frida::{Frida, Message};
use lazy_static::lazy_static;
use serde_json::json;
use std::sync::LazyLock;

lazy_static! {
static ref FRIDA: Frida = unsafe { Frida::obtain() };
}
static FRIDA: LazyLock<Frida> = LazyLock::new(|| unsafe { Frida::obtain() });

fn main() {
let device_manager = frida::DeviceManager::obtain(&FRIDA);
Expand Down
2 changes: 0 additions & 2 deletions examples/core/usb_device/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ publish = false

[dependencies]
frida = { path = "../../../frida" }
frida-sys = { path = "../../../frida-sys" }
lazy_static = "1.4"

0 comments on commit 42d7f87

Please sign in to comment.