Skip to main content

Module

Struct Module 

Source
pub struct Module<'a> {
    pub module_name: &'a str,
    pub module_handle: HMODULE,
    pub module_size: u32,
    pub module_base_address: usize,
}

Fields§

§module_name: &'a str§module_handle: HMODULE§module_size: u32§module_base_address: usize

Implementations§

Source§

impl<'a> Module<'a>

Source

pub fn from_module_name(module_name: &'a str) -> Option<Self>

Examples found in repository?
examples/in_get_localplayer_health.rs (line 27)
26fn hack_main_thread() {
27    let module = Module::from_module_name("client.dll").unwrap();
28    unsafe {
29        //let dw_local_player = memory.read_mut::<LocalPlayer>(0xDA244C);
30        loop {
31            if let Some(i) = LocalPlayer::from_raw(module.read(DW_LOCAL_PLAYER)) {
32                println!("health = {:?}", (*i).get_health());
33            };
34            if toy_arms::detect_keypress(VirtualKeyCode::VK_INSERT) {
35                break;
36            }
37        }
38    }
39}
More examples
Hide additional examples
examples/in_pattern_scanning.rs (line 21)
18fn hack_main_thread() {
19    let mut once = false;
20
21    let client = Module::from_module_name("client.dll").unwrap();
22
23    match client.find_pattern(DW_FORCE_ATTACK_PATTERN) {
24        Some(i) => println!("address: 0x{:x}", i),
25        None => println!("Pattern not found"),
26    }
27
28    match client.pattern_scan(
29        DW_FORCE_ATTACK_PATTERN,
30        2,
31        0,
32    ) {
33        Some(i) => println!("address: 0x{:x}", i),
34        None => println!("Offset not found"),
35    }
36
37    loop {
38        if !once {
39            println!("Press INSERT to exit...");
40            once = !once;
41        }
42        // To exit this hack loop when you input INSEERT KEY
43        if detect_keypress(VirtualKeyCode::VK_INSERT) {
44            break;
45        }
46    }
47}
Source

pub fn read<T>(&self, address: u32) -> *mut T

read fetches the value that given address is holding.

  • base_address - the address that is supposed to have the value you want
Examples found in repository?
examples/in_get_localplayer_health.rs (line 31)
26fn hack_main_thread() {
27    let module = Module::from_module_name("client.dll").unwrap();
28    unsafe {
29        //let dw_local_player = memory.read_mut::<LocalPlayer>(0xDA244C);
30        loop {
31            if let Some(i) = LocalPlayer::from_raw(module.read(DW_LOCAL_PLAYER)) {
32                println!("health = {:?}", (*i).get_health());
33            };
34            if toy_arms::detect_keypress(VirtualKeyCode::VK_INSERT) {
35                break;
36            }
37        }
38    }
39}
Source

pub fn read_string(&self, address: i32) -> Result<String, Utf8Error>

read_string reads the string untill the null terminator that is in the given module

  • address - relative address of the head of the string.
Source

pub fn find_pattern(&self, pattern: &str) -> Option<usize>

find_pattern scans over entire module and returns the address if there is matched byte pattern in module.

  • pattern - pattern string you’re looking for. format: “8D 34 85 ? ? ? ? 89 15 ? ? ? ? 8B 41 08 8B 48 04 83 F9 FF”
Examples found in repository?
examples/in_pattern_scanning.rs (line 23)
18fn hack_main_thread() {
19    let mut once = false;
20
21    let client = Module::from_module_name("client.dll").unwrap();
22
23    match client.find_pattern(DW_FORCE_ATTACK_PATTERN) {
24        Some(i) => println!("address: 0x{:x}", i),
25        None => println!("Pattern not found"),
26    }
27
28    match client.pattern_scan(
29        DW_FORCE_ATTACK_PATTERN,
30        2,
31        0,
32    ) {
33        Some(i) => println!("address: 0x{:x}", i),
34        None => println!("Offset not found"),
35    }
36
37    loop {
38        if !once {
39            println!("Press INSERT to exit...");
40            once = !once;
41        }
42        // To exit this hack loop when you input INSEERT KEY
43        if detect_keypress(VirtualKeyCode::VK_INSERT) {
44            break;
45        }
46    }
47}
Source

pub fn pattern_scan( &self, pattern: &str, offset: isize, extra: usize, ) -> Option<usize>

pattern scan basically be for calculating offset of some value. It adds the offset to the pattern-matched address, dereferences, and add the extra.

  • pattern - pattern string you’re looking for. format: “8D 34 85 ? ? ? ? 89 15 ? ? ? ? 8B 41 08 8B 48 04 83 F9 FF”
  • offset - offset of the address from pattern’s base.
  • extra - offset of the address from dereferenced address.
Examples found in repository?
examples/in_pattern_scanning.rs (lines 28-32)
18fn hack_main_thread() {
19    let mut once = false;
20
21    let client = Module::from_module_name("client.dll").unwrap();
22
23    match client.find_pattern(DW_FORCE_ATTACK_PATTERN) {
24        Some(i) => println!("address: 0x{:x}", i),
25        None => println!("Pattern not found"),
26    }
27
28    match client.pattern_scan(
29        DW_FORCE_ATTACK_PATTERN,
30        2,
31        0,
32    ) {
33        Some(i) => println!("address: 0x{:x}", i),
34        None => println!("Offset not found"),
35    }
36
37    loop {
38        if !once {
39            println!("Press INSERT to exit...");
40            once = !once;
41        }
42        // To exit this hack loop when you input INSEERT KEY
43        if detect_keypress(VirtualKeyCode::VK_INSERT) {
44            break;
45        }
46    }
47}

Trait Implementations§

Source§

impl<'a> Debug for Module<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Default for Module<'a>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Module<'a>

§

impl<'a> RefUnwindSafe for Module<'a>

§

impl<'a> !Send for Module<'a>

§

impl<'a> !Sync for Module<'a>

§

impl<'a> Unpin for Module<'a>

§

impl<'a> UnsafeUnpin for Module<'a>

§

impl<'a> UnwindSafe for Module<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.