pub mod implement;
use std::{path::Path, sync::Arc};
use crate::sigscan::SigScan;
#[derive(Debug)]
pub struct Module<T: SigScan> {
pub(crate) name: Arc<str>,
pub(crate) path: Arc<Path>,
pub(crate) base_address: usize,
pub(crate) end_address: usize,
pub(crate) size: usize,
pub(crate) handle: isize,
pub(crate) owner: Arc<T>,
}
#[cfg(windows)]
use windows::Win32::Foundation::HANDLE;
impl<T: SigScan> Module<T> {
pub fn get_name(&self) -> &str {
&self.name
}
pub const fn get_base_address(&self) -> usize {
self.base_address
}
pub const fn get_end_address(&self) -> usize {
self.end_address
}
pub fn get_path(&self) -> &Path {
&self.path
}
pub const fn get_size(&self) -> usize {
self.size
}
#[cfg(not(windows))]
pub const fn get_handle(&self) -> ! {
panic!("Module handles are not supported on this platform")
}
#[cfg(windows)]
pub const fn get_handle(&self) -> HANDLE {
HANDLE(self.handle)
}
pub fn get_owner(&self) -> &T {
self.owner.as_ref()
}
}
#[derive(Debug, thiserror::Error)]
pub enum ModuleError {
#[error("'{0}' was not found in the process")]
NoModuleFound(String),
#[error("unable to open handle for '{0}'")]
UnableToOpenHandle(String),
}