|
| 1 | +use std::ffi::CString; |
| 2 | +use winapi::um::libloaderapi::{FreeLibrary, GetProcAddress, LoadLibraryA}; |
| 3 | + |
| 4 | +const PLU: &str = "[+]"; |
| 5 | + |
| 6 | +// Some shit i tried . dont laugh at me @_@ |
| 7 | +// fn calling(handle:*mut HINSTANCE__ ,name: &str) -> *mut __some_function{ |
| 8 | +// let name_cstr = Cstring::new(name).unwrap(); |
| 9 | +// let name_cstr_ptr = unsafe { |
| 10 | +// GetProcAddress(handle, name_cstr.as_ptr()); |
| 11 | +// }; |
| 12 | +// return name_cstr_ptr |
| 13 | +// } |
| 14 | + |
| 15 | +fn main(){ |
| 16 | + let dll_path = "hook.dll"; |
| 17 | + unsafe{ |
| 18 | + let dll_path_cstr = CString::new(dll_path).expect("Failed CString"); |
| 19 | + let dll_path_ptr = dll_path_cstr.as_ptr(); |
| 20 | + let handle = LoadLibraryA(dll_path_ptr); |
| 21 | + if handle.is_null(){ |
| 22 | + println!("Failed to load DLL"); |
| 23 | + return; |
| 24 | + } |
| 25 | + |
| 26 | + let name = CString::new("msg_frm_vx").unwrap(); |
| 27 | + let name_ptr = GetProcAddress(handle, name.as_ptr()); |
| 28 | + |
| 29 | + let name1 = CString::new("msg_frm_smukx").unwrap(); |
| 30 | + let name_ptr1 = GetProcAddress(handle, name1.as_ptr()); |
| 31 | + |
| 32 | + |
| 33 | + if name_ptr.is_null(){ |
| 34 | + println!("{} Failed to get function Address for vx",PLU); |
| 35 | + FreeLibrary(handle); |
| 36 | + return; |
| 37 | + } |
| 38 | + |
| 39 | + if name_ptr1.is_null(){ |
| 40 | + println!("{} Failed to get function Address for smukx",PLU); |
| 41 | + FreeLibrary(handle); |
| 42 | + return; |
| 43 | + } |
| 44 | + //unsafe |
| 45 | + type MyFunction = extern "stdcall" fn(); |
| 46 | + |
| 47 | + let my_func: MyFunction = std::mem::transmute(name_ptr); |
| 48 | + let my_func1: MyFunction = std::mem::transmute(name_ptr1); |
| 49 | + //exec the func |
| 50 | + my_func(); |
| 51 | + my_func1(); |
| 52 | + |
| 53 | + FreeLibrary(handle); |
| 54 | + } |
| 55 | +} |
0 commit comments