Use data from `.so` file instead of the one loaded into the process

This commit is contained in:
Albert24GG 2024-03-01 21:00:53 +02:00
parent ede86928d8
commit 1ef287c535
2 changed files with 3 additions and 9 deletions

View File

@ -16,7 +16,6 @@ pub struct ModuleEntry {
pub path: PathBuf, pub path: PathBuf,
pub start_addr: usize, pub start_addr: usize,
pub data: Vec<u8>, pub data: Vec<u8>,
pub module_file_data: Vec<u8>,
} }
/// Represents a module loaded in a Windows process. /// Represents a module loaded in a Windows process.
pub struct Module<'a> { pub struct Module<'a> {
@ -54,7 +53,7 @@ impl<'a> Module<'a> {
// parse the elf // parse the elf
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
pub fn parse(name: &'a str, module_entry: &'a ModuleEntry) -> Result<Self> { pub fn parse(name: &'a str, module_entry: &'a ModuleEntry) -> Result<Self> {
let elf = Elf::parse(&module_entry.module_file_data)?; let elf = Elf::parse(&module_entry.data)?;
Ok(Self { Ok(Self {
name, name,
module_info: module_entry, module_info: module_entry,

View File

@ -355,19 +355,14 @@ impl Process {
for (module_name, (address_space, path)) in modules_info.into_iter() { for (module_name, (address_space, path)) in modules_info.into_iter() {
let (start, end) = address_space; let (start, end) = address_space;
let mut data = vec![0; (end - start + 1) as usize]; // let mut data = vec![0; (end - start + 1) as usize];
if let Ok(_) = self.read_memory_raw( if let Ok(data) = Process::read_elf_file(&path) {
(start as usize).into(),
data.as_mut_ptr() as *mut _,
data.len(),
) {
self.modules.insert( self.modules.insert(
module_name, module_name,
ModuleEntry { ModuleEntry {
path: path.clone(), path: path.clone(),
start_addr: start as usize, start_addr: start as usize,
data: data, data: data,
module_file_data: Process::read_elf_file(&path)?,
}, },
); );
} }