use crate::module;
use crate::nativepointer;
use crate::plumbing;
use crate::range::RangeDetails;
use crate::thread;
pub fn get_pid() -> u32 {
*plumbing::process::id
}
pub fn get_arch() -> &'static str {
&*plumbing::process::arch
}
pub fn get_platform() -> &'static str {
&*plumbing::process::platform
}
pub fn get_page_size() -> usize {
*plumbing::process::page_size
}
pub fn get_pointer_size() -> usize {
*plumbing::process::pointer_size
}
pub fn get_code_signing_policy() -> &'static str {
&*plumbing::process::code_signing_policy
}
pub fn is_debugger_attached() -> bool {
plumbing::process::is_debugger_attached()
}
pub fn get_tid() -> u32 {
plumbing::process::get_current_thread_id()
}
pub fn enumerate_threads() -> Vec<thread::ThreadDetails> {
let threads = plumbing::process::enumerate_threads();
let mut thread_details = Vec::new();
for thread in threads.iter() {
let td = thread::ThreadDetails::from(plumbing::thread::ThreadDetails::from(thread));
thread_details.push(td);
}
thread_details
}
pub fn enumerate_modules() -> Vec<module::Module> {
let modules = plumbing::process::enumerate_modules();
let mut m = Vec::new();
for module in modules.iter() {
let md = module::Module::from(plumbing::module::Module::from(module));
m.push(md);
}
m
}
pub fn get_module_by_name(name: &str) -> Option<module::Module> {
let ret = plumbing::process::get_module_by_name(name);
if ret.is_null() {
return None;
}
Some(module::Module::from(ret))
}
pub fn get_module_by_address(address: &nativepointer::NativePointer) -> Option<module::Module> {
let ret = plumbing::process::get_module_by_address(&address);
if ret.is_null() {
return None;
}
Some(module::Module::from(ret))
}
pub fn get_range_by_address(address: &nativepointer::NativePointer) -> Option<RangeDetails> {
let ret = plumbing::process::get_range_by_address(&address);
if ret.is_null() {
return None;
}
Some(RangeDetails::from(plumbing::range::RangeDetails::from(ret)))
}
pub fn enumerate_ranges(protection: &str) -> Vec<RangeDetails> {
let mut range_details = Vec::new();
let ranges = plumbing::process::enumerate_ranges(protection);
for range in ranges.iter() {
let i = RangeDetails::from(plumbing::range::RangeDetails::from(range));
range_details.push(i);
}
range_details
}
pub fn enumerate_malloc_ranges() -> Vec<RangeDetails> {
let mut range_details = Vec::new();
let ranges = plumbing::process::enumerate_malloc_ranges();
for range in ranges.iter() {
let i = RangeDetails::from(plumbing::range::RangeDetails::from(range));
range_details.push(i);
}
range_details
}