pub struct MemoryModuleBuilder {
pub resolve_imports: bool,
pub process_relocations: bool,
pub call_dll_main: bool,
pub ignore_missing_imports: bool,
pub is_application_dll: bool,
pub alloc_function: Option<CustomAllocFunction>,
pub free_function: Option<CustomFreeFunction>,
pub load_library_function: Option<CustomLoadLibraryFunction>,
pub get_proc_address_function: Option<CustomGetProcAddressFunction>,
pub free_library_function: Option<CustomFreeLibraryFunction>,
pub user_data: *mut c_void,
}
Fields§
§resolve_imports: bool
§process_relocations: bool
§call_dll_main: bool
§ignore_missing_imports: bool
§is_application_dll: bool
§alloc_function: Option<CustomAllocFunction>
§free_function: Option<CustomFreeFunction>
§load_library_function: Option<CustomLoadLibraryFunction>
§get_proc_address_function: Option<CustomGetProcAddressFunction>
§free_library_function: Option<CustomFreeLibraryFunction>
§user_data: *mut c_void
Implementations§
Source§impl MemoryModuleBuilder
impl MemoryModuleBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/test_application_dll.rs (line 45)
5fn main() -> maple_rs::Result<()> {
6 println!("Testing focus.dll as an application DLL...");
7
8 // Change to the test/focus directory so dependencies are found
9 let current_dir = env::current_dir().expect("Failed to get current directory");
10 let focus_dir = current_dir.join("test").join("focus");
11 env::set_current_dir(&focus_dir).expect("Failed to change to focus directory");
12 println!("Changed working directory to: {:?}", focus_dir);
13
14 // Read the focus.dll file
15 let dll_data = fs::read("focus.dll").expect("Failed to read focus.dll");
16 println!("Loaded {} bytes from focus.dll", dll_data.len());
17
18 // Test 1: Load as application DLL using the new convenient method
19 println!("\nTest 1: Loading using Maple::load_application_dll_from_memory()...");
20 match Maple::load_application_dll_from_memory(&dll_data) {
21 Ok(module) => {
22 println!("Successfully loaded focus.dll as application DLL!");
23 println!("Base address: {:?}", module.base_address());
24 println!("Size: {} bytes", module.size());
25
26 println!("Executing DLL application...");
27 match module.execute_dll_application() {
28 Ok(()) => {
29 println!("DLL application started successfully!");
30 println!("Waiting 5 seconds to let the application run...");
31 std::thread::sleep(std::time::Duration::from_secs(5));
32 }
33 Err(e) => {
34 println!("Failed to execute DLL application: {}", e);
35 }
36 }
37 }
38 Err(e) => {
39 println!("Failed to load focus.dll as application DLL: {}", e);
40 }
41 }
42
43 // Test 2: Load using the builder with application DLL settings
44 println!("\nTest 2: Loading using MemoryModuleBuilder with application DLL settings...");
45 match MemoryModuleBuilder::new()
46 .resolve_imports(true)
47 .process_relocations(true)
48 .call_dll_main(false) // Don't auto-call DllMain
49 .is_application_dll(true)
50 .load_from_memory(&dll_data)
51 {
52 Ok(module) => {
53 println!("Successfully loaded focus.dll with builder!");
54 println!("Base address: {:?}", module.base_address());
55 println!("Size: {} bytes", module.size());
56
57 println!("Manually executing DLL application...");
58 match module.execute_dll_application() {
59 Ok(()) => {
60 println!("DLL application started successfully!");
61 println!("Waiting 5 seconds to let the application run...");
62 std::thread::sleep(std::time::Duration::from_secs(5));
63 }
64 Err(e) => {
65 println!("Failed to execute DLL application: {}", e);
66 }
67 }
68 }
69 Err(e) => {
70 println!("Failed to load focus.dll with builder: {}", e);
71 }
72 }
73
74 // Restore working directory
75 env::set_current_dir(¤t_dir).expect("Failed to restore working directory");
76
77 println!("\nTest completed!");
78 Ok(())
79}
Sourcepub fn resolve_imports(self, resolve: bool) -> Self
pub fn resolve_imports(self, resolve: bool) -> Self
Examples found in repository?
examples/test_application_dll.rs (line 46)
5fn main() -> maple_rs::Result<()> {
6 println!("Testing focus.dll as an application DLL...");
7
8 // Change to the test/focus directory so dependencies are found
9 let current_dir = env::current_dir().expect("Failed to get current directory");
10 let focus_dir = current_dir.join("test").join("focus");
11 env::set_current_dir(&focus_dir).expect("Failed to change to focus directory");
12 println!("Changed working directory to: {:?}", focus_dir);
13
14 // Read the focus.dll file
15 let dll_data = fs::read("focus.dll").expect("Failed to read focus.dll");
16 println!("Loaded {} bytes from focus.dll", dll_data.len());
17
18 // Test 1: Load as application DLL using the new convenient method
19 println!("\nTest 1: Loading using Maple::load_application_dll_from_memory()...");
20 match Maple::load_application_dll_from_memory(&dll_data) {
21 Ok(module) => {
22 println!("Successfully loaded focus.dll as application DLL!");
23 println!("Base address: {:?}", module.base_address());
24 println!("Size: {} bytes", module.size());
25
26 println!("Executing DLL application...");
27 match module.execute_dll_application() {
28 Ok(()) => {
29 println!("DLL application started successfully!");
30 println!("Waiting 5 seconds to let the application run...");
31 std::thread::sleep(std::time::Duration::from_secs(5));
32 }
33 Err(e) => {
34 println!("Failed to execute DLL application: {}", e);
35 }
36 }
37 }
38 Err(e) => {
39 println!("Failed to load focus.dll as application DLL: {}", e);
40 }
41 }
42
43 // Test 2: Load using the builder with application DLL settings
44 println!("\nTest 2: Loading using MemoryModuleBuilder with application DLL settings...");
45 match MemoryModuleBuilder::new()
46 .resolve_imports(true)
47 .process_relocations(true)
48 .call_dll_main(false) // Don't auto-call DllMain
49 .is_application_dll(true)
50 .load_from_memory(&dll_data)
51 {
52 Ok(module) => {
53 println!("Successfully loaded focus.dll with builder!");
54 println!("Base address: {:?}", module.base_address());
55 println!("Size: {} bytes", module.size());
56
57 println!("Manually executing DLL application...");
58 match module.execute_dll_application() {
59 Ok(()) => {
60 println!("DLL application started successfully!");
61 println!("Waiting 5 seconds to let the application run...");
62 std::thread::sleep(std::time::Duration::from_secs(5));
63 }
64 Err(e) => {
65 println!("Failed to execute DLL application: {}", e);
66 }
67 }
68 }
69 Err(e) => {
70 println!("Failed to load focus.dll with builder: {}", e);
71 }
72 }
73
74 // Restore working directory
75 env::set_current_dir(¤t_dir).expect("Failed to restore working directory");
76
77 println!("\nTest completed!");
78 Ok(())
79}
Sourcepub fn process_relocations(self, process: bool) -> Self
pub fn process_relocations(self, process: bool) -> Self
Examples found in repository?
examples/test_application_dll.rs (line 47)
5fn main() -> maple_rs::Result<()> {
6 println!("Testing focus.dll as an application DLL...");
7
8 // Change to the test/focus directory so dependencies are found
9 let current_dir = env::current_dir().expect("Failed to get current directory");
10 let focus_dir = current_dir.join("test").join("focus");
11 env::set_current_dir(&focus_dir).expect("Failed to change to focus directory");
12 println!("Changed working directory to: {:?}", focus_dir);
13
14 // Read the focus.dll file
15 let dll_data = fs::read("focus.dll").expect("Failed to read focus.dll");
16 println!("Loaded {} bytes from focus.dll", dll_data.len());
17
18 // Test 1: Load as application DLL using the new convenient method
19 println!("\nTest 1: Loading using Maple::load_application_dll_from_memory()...");
20 match Maple::load_application_dll_from_memory(&dll_data) {
21 Ok(module) => {
22 println!("Successfully loaded focus.dll as application DLL!");
23 println!("Base address: {:?}", module.base_address());
24 println!("Size: {} bytes", module.size());
25
26 println!("Executing DLL application...");
27 match module.execute_dll_application() {
28 Ok(()) => {
29 println!("DLL application started successfully!");
30 println!("Waiting 5 seconds to let the application run...");
31 std::thread::sleep(std::time::Duration::from_secs(5));
32 }
33 Err(e) => {
34 println!("Failed to execute DLL application: {}", e);
35 }
36 }
37 }
38 Err(e) => {
39 println!("Failed to load focus.dll as application DLL: {}", e);
40 }
41 }
42
43 // Test 2: Load using the builder with application DLL settings
44 println!("\nTest 2: Loading using MemoryModuleBuilder with application DLL settings...");
45 match MemoryModuleBuilder::new()
46 .resolve_imports(true)
47 .process_relocations(true)
48 .call_dll_main(false) // Don't auto-call DllMain
49 .is_application_dll(true)
50 .load_from_memory(&dll_data)
51 {
52 Ok(module) => {
53 println!("Successfully loaded focus.dll with builder!");
54 println!("Base address: {:?}", module.base_address());
55 println!("Size: {} bytes", module.size());
56
57 println!("Manually executing DLL application...");
58 match module.execute_dll_application() {
59 Ok(()) => {
60 println!("DLL application started successfully!");
61 println!("Waiting 5 seconds to let the application run...");
62 std::thread::sleep(std::time::Duration::from_secs(5));
63 }
64 Err(e) => {
65 println!("Failed to execute DLL application: {}", e);
66 }
67 }
68 }
69 Err(e) => {
70 println!("Failed to load focus.dll with builder: {}", e);
71 }
72 }
73
74 // Restore working directory
75 env::set_current_dir(¤t_dir).expect("Failed to restore working directory");
76
77 println!("\nTest completed!");
78 Ok(())
79}
Sourcepub fn call_dll_main(self, call: bool) -> Self
pub fn call_dll_main(self, call: bool) -> Self
Examples found in repository?
examples/test_application_dll.rs (line 48)
5fn main() -> maple_rs::Result<()> {
6 println!("Testing focus.dll as an application DLL...");
7
8 // Change to the test/focus directory so dependencies are found
9 let current_dir = env::current_dir().expect("Failed to get current directory");
10 let focus_dir = current_dir.join("test").join("focus");
11 env::set_current_dir(&focus_dir).expect("Failed to change to focus directory");
12 println!("Changed working directory to: {:?}", focus_dir);
13
14 // Read the focus.dll file
15 let dll_data = fs::read("focus.dll").expect("Failed to read focus.dll");
16 println!("Loaded {} bytes from focus.dll", dll_data.len());
17
18 // Test 1: Load as application DLL using the new convenient method
19 println!("\nTest 1: Loading using Maple::load_application_dll_from_memory()...");
20 match Maple::load_application_dll_from_memory(&dll_data) {
21 Ok(module) => {
22 println!("Successfully loaded focus.dll as application DLL!");
23 println!("Base address: {:?}", module.base_address());
24 println!("Size: {} bytes", module.size());
25
26 println!("Executing DLL application...");
27 match module.execute_dll_application() {
28 Ok(()) => {
29 println!("DLL application started successfully!");
30 println!("Waiting 5 seconds to let the application run...");
31 std::thread::sleep(std::time::Duration::from_secs(5));
32 }
33 Err(e) => {
34 println!("Failed to execute DLL application: {}", e);
35 }
36 }
37 }
38 Err(e) => {
39 println!("Failed to load focus.dll as application DLL: {}", e);
40 }
41 }
42
43 // Test 2: Load using the builder with application DLL settings
44 println!("\nTest 2: Loading using MemoryModuleBuilder with application DLL settings...");
45 match MemoryModuleBuilder::new()
46 .resolve_imports(true)
47 .process_relocations(true)
48 .call_dll_main(false) // Don't auto-call DllMain
49 .is_application_dll(true)
50 .load_from_memory(&dll_data)
51 {
52 Ok(module) => {
53 println!("Successfully loaded focus.dll with builder!");
54 println!("Base address: {:?}", module.base_address());
55 println!("Size: {} bytes", module.size());
56
57 println!("Manually executing DLL application...");
58 match module.execute_dll_application() {
59 Ok(()) => {
60 println!("DLL application started successfully!");
61 println!("Waiting 5 seconds to let the application run...");
62 std::thread::sleep(std::time::Duration::from_secs(5));
63 }
64 Err(e) => {
65 println!("Failed to execute DLL application: {}", e);
66 }
67 }
68 }
69 Err(e) => {
70 println!("Failed to load focus.dll with builder: {}", e);
71 }
72 }
73
74 // Restore working directory
75 env::set_current_dir(¤t_dir).expect("Failed to restore working directory");
76
77 println!("\nTest completed!");
78 Ok(())
79}
pub fn ignore_missing_imports(self, ignore: bool) -> Self
Sourcepub fn is_application_dll(self, is_app_dll: bool) -> Self
pub fn is_application_dll(self, is_app_dll: bool) -> Self
Examples found in repository?
examples/test_application_dll.rs (line 49)
5fn main() -> maple_rs::Result<()> {
6 println!("Testing focus.dll as an application DLL...");
7
8 // Change to the test/focus directory so dependencies are found
9 let current_dir = env::current_dir().expect("Failed to get current directory");
10 let focus_dir = current_dir.join("test").join("focus");
11 env::set_current_dir(&focus_dir).expect("Failed to change to focus directory");
12 println!("Changed working directory to: {:?}", focus_dir);
13
14 // Read the focus.dll file
15 let dll_data = fs::read("focus.dll").expect("Failed to read focus.dll");
16 println!("Loaded {} bytes from focus.dll", dll_data.len());
17
18 // Test 1: Load as application DLL using the new convenient method
19 println!("\nTest 1: Loading using Maple::load_application_dll_from_memory()...");
20 match Maple::load_application_dll_from_memory(&dll_data) {
21 Ok(module) => {
22 println!("Successfully loaded focus.dll as application DLL!");
23 println!("Base address: {:?}", module.base_address());
24 println!("Size: {} bytes", module.size());
25
26 println!("Executing DLL application...");
27 match module.execute_dll_application() {
28 Ok(()) => {
29 println!("DLL application started successfully!");
30 println!("Waiting 5 seconds to let the application run...");
31 std::thread::sleep(std::time::Duration::from_secs(5));
32 }
33 Err(e) => {
34 println!("Failed to execute DLL application: {}", e);
35 }
36 }
37 }
38 Err(e) => {
39 println!("Failed to load focus.dll as application DLL: {}", e);
40 }
41 }
42
43 // Test 2: Load using the builder with application DLL settings
44 println!("\nTest 2: Loading using MemoryModuleBuilder with application DLL settings...");
45 match MemoryModuleBuilder::new()
46 .resolve_imports(true)
47 .process_relocations(true)
48 .call_dll_main(false) // Don't auto-call DllMain
49 .is_application_dll(true)
50 .load_from_memory(&dll_data)
51 {
52 Ok(module) => {
53 println!("Successfully loaded focus.dll with builder!");
54 println!("Base address: {:?}", module.base_address());
55 println!("Size: {} bytes", module.size());
56
57 println!("Manually executing DLL application...");
58 match module.execute_dll_application() {
59 Ok(()) => {
60 println!("DLL application started successfully!");
61 println!("Waiting 5 seconds to let the application run...");
62 std::thread::sleep(std::time::Duration::from_secs(5));
63 }
64 Err(e) => {
65 println!("Failed to execute DLL application: {}", e);
66 }
67 }
68 }
69 Err(e) => {
70 println!("Failed to load focus.dll with builder: {}", e);
71 }
72 }
73
74 // Restore working directory
75 env::set_current_dir(¤t_dir).expect("Failed to restore working directory");
76
77 println!("\nTest completed!");
78 Ok(())
79}
pub fn alloc_function(self, func: CustomAllocFunction) -> Self
pub fn free_function(self, func: CustomFreeFunction) -> Self
pub fn load_library_function(self, func: CustomLoadLibraryFunction) -> Self
pub fn get_proc_address_function( self, func: CustomGetProcAddressFunction, ) -> Self
pub fn free_library_function(self, func: CustomFreeLibraryFunction) -> Self
pub fn user_data(self, data: *mut c_void) -> Self
Sourcepub fn load_from_memory(self, data: &[u8]) -> Result<Box<dyn MemoryModule>>
pub fn load_from_memory(self, data: &[u8]) -> Result<Box<dyn MemoryModule>>
Examples found in repository?
examples/test_application_dll.rs (line 50)
5fn main() -> maple_rs::Result<()> {
6 println!("Testing focus.dll as an application DLL...");
7
8 // Change to the test/focus directory so dependencies are found
9 let current_dir = env::current_dir().expect("Failed to get current directory");
10 let focus_dir = current_dir.join("test").join("focus");
11 env::set_current_dir(&focus_dir).expect("Failed to change to focus directory");
12 println!("Changed working directory to: {:?}", focus_dir);
13
14 // Read the focus.dll file
15 let dll_data = fs::read("focus.dll").expect("Failed to read focus.dll");
16 println!("Loaded {} bytes from focus.dll", dll_data.len());
17
18 // Test 1: Load as application DLL using the new convenient method
19 println!("\nTest 1: Loading using Maple::load_application_dll_from_memory()...");
20 match Maple::load_application_dll_from_memory(&dll_data) {
21 Ok(module) => {
22 println!("Successfully loaded focus.dll as application DLL!");
23 println!("Base address: {:?}", module.base_address());
24 println!("Size: {} bytes", module.size());
25
26 println!("Executing DLL application...");
27 match module.execute_dll_application() {
28 Ok(()) => {
29 println!("DLL application started successfully!");
30 println!("Waiting 5 seconds to let the application run...");
31 std::thread::sleep(std::time::Duration::from_secs(5));
32 }
33 Err(e) => {
34 println!("Failed to execute DLL application: {}", e);
35 }
36 }
37 }
38 Err(e) => {
39 println!("Failed to load focus.dll as application DLL: {}", e);
40 }
41 }
42
43 // Test 2: Load using the builder with application DLL settings
44 println!("\nTest 2: Loading using MemoryModuleBuilder with application DLL settings...");
45 match MemoryModuleBuilder::new()
46 .resolve_imports(true)
47 .process_relocations(true)
48 .call_dll_main(false) // Don't auto-call DllMain
49 .is_application_dll(true)
50 .load_from_memory(&dll_data)
51 {
52 Ok(module) => {
53 println!("Successfully loaded focus.dll with builder!");
54 println!("Base address: {:?}", module.base_address());
55 println!("Size: {} bytes", module.size());
56
57 println!("Manually executing DLL application...");
58 match module.execute_dll_application() {
59 Ok(()) => {
60 println!("DLL application started successfully!");
61 println!("Waiting 5 seconds to let the application run...");
62 std::thread::sleep(std::time::Duration::from_secs(5));
63 }
64 Err(e) => {
65 println!("Failed to execute DLL application: {}", e);
66 }
67 }
68 }
69 Err(e) => {
70 println!("Failed to load focus.dll with builder: {}", e);
71 }
72 }
73
74 // Restore working directory
75 env::set_current_dir(¤t_dir).expect("Failed to restore working directory");
76
77 println!("\nTest completed!");
78 Ok(())
79}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MemoryModuleBuilder
impl RefUnwindSafe for MemoryModuleBuilder
impl !Send for MemoryModuleBuilder
impl !Sync for MemoryModuleBuilder
impl Unpin for MemoryModuleBuilder
impl UnwindSafe for MemoryModuleBuilder
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