frida / frida-rust

Frida Rust bindings
Other
188 stars 53 forks source link

frida-gum: force frida-gum init to use Module (#98) #172

Closed elazarl closed 3 weeks ago

elazarl commented 3 weeks ago

In order to use the underlying C API global init should be called.

We hence force the creation of Gum to use Module::* functions.

We also use OnceLock instead of lazy_static! as discussed in the issue.

elazarl commented 3 weeks ago

see #98, cc @s1341

Not all suggestion implemented, so not closing yet.

Note that OnceCell is not suitable for lazy initialisation of a static that requires thread safety to prevent initialization race, I hence used OnceLock + static instead, and required 'static lifetime for Gum.

To support single threaded cases without requiring a lock, one can consider to accept parametrized lifetime in Module but IMHO, as Gum is essentially global state, there's no significant gain.

s1341 commented 3 weeks ago

Module::from_gum should be renamed to Module::obtain for consistency.

s1341 commented 3 weeks ago

can you take a look at CI?

elazarl commented 3 weeks ago

can you take a look at CI?

Done, forgot to run clippy.