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: usizeImplementations§
Source§impl<'a> Module<'a>
impl<'a> Module<'a>
Sourcepub fn from_module_name(module_name: &'a str) -> Option<Self>
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
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}Sourcepub fn read<T>(&self, address: u32) -> *mut T
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}Sourcepub fn read_string(&self, address: i32) -> Result<String, Utf8Error>
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.
Sourcepub fn find_pattern(&self, pattern: &str) -> Option<usize>
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}Sourcepub fn pattern_scan(
&self,
pattern: &str,
offset: isize,
extra: usize,
) -> Option<usize>
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more