๐ maple-rs
A Rust library for loading Windows PE executables and DLLs directly from memory, without needing to write them to disk first. This is a modern, memory-safe Rust replacement for the C memorymodule library.
โ ๏ธ Security Notice
This library enables loading and executing code from memory buffers. While this has legitimate uses such as:
- Dynamic code loading in game engines
- Plugin systems
- Testing and debugging tools
- Memory-efficient application packaging
Users are responsible for ensuring they only load trusted code and comply with all applicable laws and security policies.
โจ Features
- ๐น In-Memory Loading: Load PE executables (.exe) and libraries (.dll) directly from memory
- ๐น Full PE Support: Complete PE parsing, import resolution, and relocation processing
- ๐น Native Execution: Code runs exactly as if loaded from disk
- ๐น Memory Safety: Proper memory management with automatic cleanup
- ๐น Cross-Platform Ready: Windows implementation complete, Linux planned
- ๐น Zero-Copy: Efficient memory usage with minimal overhead
๐ Quick Start
Add this to your Cargo.toml
:
[]
= "0.1.0"
Basic Usage
use ;
use fs;
Advanced Usage with Builder Pattern
use ;
use fs;
๐ Documentation
Comprehensive API documentation is available on docs.rs.
๐ ๏ธ Platform Support
Platform | Status | Features |
---|---|---|
Windows | โ Complete | Full PE parsing, import resolution, memory protection |
Linux | ๐ Planned | ELF support planned for future release |
macOS | ๐ Planned | Mach-O support planned for future release |
๐งช Testing
The library includes comprehensive tests covering:
# Run all tests
# Run with coverage
# Run examples
Tested with real-world executables including:
- Console applications with dependencies
- GUI applications with multiple DLLs
- Complex import/export scenarios
๐ง Error Handling
All operations return a Result<T, MapleError>
with detailed error information:
use ;
match load_executable_from_memory
๐๏ธ Architecture
maple-rs/
โโโ src/
โ โโโ lib.rs # Main library interface
โ โโโ error.rs # Error definitions
โ โโโ memory_module.rs # Core trait and builder
โ โโโ pe.rs # PE format parser
โ โโโ windows.rs # Windows implementation
โ โโโ linux.rs # Linux placeholder
โโโ examples/ # Usage examples
โโโ tests/ # Integration tests
โโโ .github/workflows/ # CI/CD pipeline
๐ Security Considerations
- Memory is properly allocated and protected with appropriate permissions
- No disk writes required (stealth loading capability)
- Import validation prevents malicious DLL injection
- Proper cleanup prevents memory leaks
- PE validation prevents malformed executables
- Comprehensive error handling for security failures
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Development Setup
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Inspired by the original MemoryModule C library
- Built with modern Rust safety and performance characteristics
- Thanks to the Rust community for excellent crates and tooling
๐ Related Projects
- MemoryModule - Original C implementation
- pe - PE format parsing
- goblin - Multi-format binary parsing
โ ๏ธ Disclaimer: This software is provided for educational and legitimate use cases only. Users must ensure compliance with all applicable laws and regulations in their jurisdiction.