#![cfg_attr(doc_cfg, feature(doc_cfg))]
#![deny(warnings)]
#![allow(clippy::needless_doctest_main)]
#![allow(clippy::missing_safety_doc)]
extern crate num;
#[allow(unused_imports)]
#[macro_use]
extern crate num_derive;
use std::convert::TryFrom;
use std::ffi::CStr;
use std::os::raw::{c_char, c_void};
pub mod stalker;
pub mod interceptor;
pub mod instruction_writer;
mod module;
pub use module::*;
mod module_map;
pub use module_map::*;
mod error;
pub use error::Error;
mod cpu_context;
pub use cpu_context::*;
mod memory_range;
pub use memory_range::*;
mod range_details;
pub use range_details::*;
mod debug_symbol;
pub use debug_symbol::*;
#[cfg(all(feature = "backtrace", not(target_os = "windows")))]
#[cfg_attr(doc_cfg, doc(cfg(feature = "backtrace")))]
mod backtracer;
#[cfg(all(feature = "backtrace", not(target_os = "windows")))]
#[cfg_attr(doc_cfg, doc(cfg(feature = "backtrace")))]
pub use backtracer::*;
#[doc(hidden)]
pub type Result<T> = std::result::Result<T, error::Error>;
pub struct Gum;
impl Gum {
pub unsafe fn obtain() -> Gum {
frida_gum_sys::gum_init_embedded();
Gum {}
}
}
impl Drop for Gum {
fn drop(&mut self) {
unsafe { frida_gum_sys::gum_deinit_embedded() };
}
}
pub struct NativePointer(pub *mut c_void);
impl NativePointer {
pub fn is_null(&self) -> bool {
self.0.is_null()
}
}
impl From<&NativePointer> for *mut c_void {
fn from(other: &NativePointer) -> Self {
other.0
}
}
impl From<NativePointer> for *mut c_void {
fn from(other: NativePointer) -> Self {
other.0
}
}
impl TryFrom<NativePointer> for String {
type Error = Error;
fn try_from(ptr: NativePointer) -> Result<Self> {
if ptr.is_null() {
Err(Error::MemoryAccessError)
} else {
unsafe {
Ok(
Self::from_utf8_lossy(CStr::from_ptr(ptr.0 as *const c_char).to_bytes())
.into_owned(),
)
}
}
}
}
impl AsRef<NativePointer> for NativePointer {
fn as_ref(&self) -> &NativePointer {
self
}
}