pub struct Process { /* private fields */ }
Expand description
Wraps a native process and allows memory access/manipulation
§Examples
use mem_rs::prelude::*;
let mut process = Process::new("name_of_process.exe");
if process.refresh().is_ok()
{
process.write_memory_abs(0x1234, &u32::to_ne_bytes(10));
let result = process.read_u32_rel(Some(0x1234));
println!("Result: {}", result);
}
Implementations§
Source§impl Process
impl Process
Sourcepub fn inject_dll(&self, dll_path: &str) -> Result<(), String>
pub fn inject_dll(&self, dll_path: &str) -> Result<(), String>
Attempts to inject a dll into the attached process using LoadLibraryW
§Examples
use mem_rs::prelude::*;
let mut process = Process::new("name_of_process.exe");
process.refresh().expect("Failed to attach/refresh!");
process.inject_dll(r#"C:\temp\native.dll"#).expect("Failed to inject!");
Source§impl Process
impl Process
Sourcepub fn scan_abs(
&self,
error_name: &str,
pattern: &str,
scan_offset: usize,
pointer_offsets: Vec<usize>,
) -> Result<Pointer, String>
pub fn scan_abs( &self, error_name: &str, pattern: &str, scan_offset: usize, pointer_offsets: Vec<usize>, ) -> Result<Pointer, String>
Does an absolute scan (for x86 targets or for process code) where the target pointer is absolute Takes a list of offsets to create pointer jumps down a bigger complex structure. Pointers implement memory reading and writing.
§Examples
use mem_rs::prelude::*;
let mut process = Process::new("name_of_process.exe");
process.refresh()?;
let pointer = process.scan_abs("Error message", "56 8B F1 8B 46 1C 50 A1 ? ? ? ? 32 C9", 8, vec![0, 0, 0])?;
Sourcepub fn scan_rel(
&self,
error_name: &str,
pattern: &str,
scan_offset: usize,
instruction_size: usize,
pointer_offsets: Vec<usize>,
) -> Result<Pointer, String>
pub fn scan_rel( &self, error_name: &str, pattern: &str, scan_offset: usize, instruction_size: usize, pointer_offsets: Vec<usize>, ) -> Result<Pointer, String>
Does a relative scan (for x64 targets) where the target pointer is located relative to instruction’s size and location. Takes a list of offsets to create pointer jumps down a bigger complex structure. Pointers implement memory reading and writing.
§Examples
use mem_rs::prelude::*;
let mut process = Process::new("name_of_process.exe");
process.refresh()?;
let pointer = process.scan_rel("Error message", "48 8b 05 ? ? ? ? 48 8b 50 10 48 89 54 24 60", 3, 7, vec![0])?;
Examples found in repository?
51 52 53 54 55 56 57 58 59 60 61 62 63 64
pub fn refresh(&mut self) -> Result<(), String>
{
if !self.process.is_attached()
{
self.process.refresh()?;
self.game_data_man = self.process.scan_rel("GameDataMan", "48 8b 05 ? ? ? ? 48 8b 50 10 48 89 54 24 60", 3, 7, vec![0])?;
self.ai_timer = self.process.scan_rel("AI Timer", "48 8b 0d ? ? ? ? 48 85 c9 74 0e 48 83 c1 28", 3, 7, vec![0])?;
}
else
{
self.process.refresh()?;
}
Ok(())
}
Sourcepub fn create_pointer(
&self,
address: usize,
pointer_offsets: Vec<usize>,
) -> Pointer
pub fn create_pointer( &self, address: usize, pointer_offsets: Vec<usize>, ) -> Pointer
Create a pointer without scanning from an absolute address and a list of offsets. For special use cases where an address might be the result of some calculation.
let network = vanilla.process.create_pointer(network_ptr as usize, vec![0xc, 0x6c978])
§Examples
use mem_rs::prelude::*;
let mut process = Process::new("name_of_process.exe");
process.refresh()?;
let magic_address = 0x1234;
let pointer = process.create_pointer(magic_address, vec![0xc, 0x10]);
Source§impl Process
impl Process
Sourcepub fn refresh(&mut self) -> Result<(), String>
pub fn refresh(&mut self) -> Result<(), String>
Attempts to “attach” to a running process by name. Returns an error when the process is not running or when it has exited. Caches the main module so that pattern scans can be done against it.
§Examples
use mem_rs::prelude::*;
let mut process = Process::new("name_of_process.exe");
process.refresh().expect("Failed to attach/refresh!");
Examples found in repository?
51 52 53 54 55 56 57 58 59 60 61 62 63 64
pub fn refresh(&mut self) -> Result<(), String>
{
if !self.process.is_attached()
{
self.process.refresh()?;
self.game_data_man = self.process.scan_rel("GameDataMan", "48 8b 05 ? ? ? ? 48 8b 50 10 48 89 54 24 60", 3, 7, vec![0])?;
self.ai_timer = self.process.scan_rel("AI Timer", "48 8b 0d ? ? ? ? 48 85 c9 74 0e 48 83 c1 28", 3, 7, vec![0])?;
}
else
{
self.process.refresh()?;
}
Ok(())
}
Source§impl Process
impl Process
Sourcepub fn get_current_process_name() -> Result<String, ()>
pub fn get_current_process_name() -> Result<String, ()>
Returns the current process name, in which this very code is running. Does NOT return the name of the target attachment process.
§Examples
use mem_rs::prelude::*;
let name = Process::get_current_process_name()?;
Sourcepub fn get_running_process_names() -> Vec<String>
pub fn get_running_process_names() -> Vec<String>
Returns all the processes that are currently running
§Examples
use mem_rs::prelude::*;
let names = Process::get_running_process_names();
Examples found in repository?
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
fn main()
{
let str = r#"C:\soulmemory\soulmemory_rs.dll"#;
let w32_str = get_w32str_from_str(str);
println!("{:?}", w32_str);
println!("{:?}", vec_u16_to_u8(&w32_str));
let allocated_str = String::from(str);
let collected: Vec<u16> = allocated_str.encode_utf16().collect();
println!("{:?}", collected);
unsafe { println!("{:?}", collected.align_to::<u8>()); }
let processes = Process::get_running_process_names();
for p in &processes
{
println!("{}", p);
}
let mut ds1 = Ds1::new();
loop
{
match ds1.refresh()
{
Ok(()) => {}
Err(e) => println!("{}", e)
}
//ds1.inject_soulmemory_rs();
println!("igt: {}", ds1.get_in_game_time_milliseconds());
println!("ai: {}", ds1.get_ai_timer());
sleep(Duration::from_secs(1));
}
}
Source§impl Process
impl Process
Sourcepub fn new(name: &str) -> Self
pub fn new(name: &str) -> Self
Creates a new process based on the process name.
§Examples
use mem_rs::prelude::*;
let mut process = Process::new("name_of_process.exe");
Sourcepub fn is_attached(&self) -> bool
pub fn is_attached(&self) -> bool
Returns if the process is “attached” and can be read/written from/to
§Examples
use mem_rs::prelude::*;
let mut process = Process::new("name_of_process.exe");
//returns false
let not_attached = process.is_attached();
//refreshing the process will cause it to become attached
process.refresh().unwrap();
//if name_of_process.exe is running, will return true
let attached = process.is_attached();
Examples found in repository?
51 52 53 54 55 56 57 58 59 60 61 62 63 64
pub fn refresh(&mut self) -> Result<(), String>
{
if !self.process.is_attached()
{
self.process.refresh()?;
self.game_data_man = self.process.scan_rel("GameDataMan", "48 8b 05 ? ? ? ? 48 8b 50 10 48 89 54 24 60", 3, 7, vec![0])?;
self.ai_timer = self.process.scan_rel("AI Timer", "48 8b 0d ? ? ? ? 48 85 c9 74 0e 48 83 c1 28", 3, 7, vec![0])?;
}
else
{
self.process.refresh()?;
}
Ok(())
}