How ovxrfl0w/erebus works
Project Type and Purpose
• The project is a Windows kernel-mode driver written in Rust. Its primary purpose is to expose two IOCTL actions that allow user-mode programs to read and write process memory via the MmCopyVirtualMemory function.
• The README confirms that this is a learning exercise using the windows-drivers-rs crate for Windows kernel driver development.
File Structure and Key Components
• Three major crates (or modules) comprise the project:
• km: Contains the kernel module implementation. Files such as device.rs, ffi.rs, logger.rs, memory.rs, process.rs, and utils.rs indicate its responsibilities in setting up and handling driver operations.
• um: Contains the user-mode component that interacts with the driver. The files here (driver.rs, main.rs, utils.rs) are responsible for sending IOCTLs to the kernel driver.
• shared: Houses code common to both the kernel and user-mode parts. Files like constants.rs, ioctl.rs, ipc.rs suggest it manages shared definitions (e.g., constants, data structures during IOCTL transactions).
Main Components
• Kernel-Mode Driver (km)
• Acts as the core module handling IOCTL requests.
• Implements functionalities for reading and writing process memory.
• Uses helper files (logger, memory, process management, FFI wrappers).
• User-Mode Interface (um)
• Implements a user-space program that issues IOCTL requests.
• Contains the logic to communicate with the kernel driver.
• Shared Library (shared)
• Defines common data structures (IOCTL commands, constants, IPC mechanisms) making it easier to maintain consistency between kernel and user spaces.
• Windows OS Environment
• Both the kernel mode and user mode boundaries. Emphasize that the IOCTL calls traverse this boundary.
Relationships and Interactions
• The User-Mode Application (um) communicates with the OS’s device interface to send IOCTL commands.
• The Kernel-Mode Driver (km) listens for these IOCTL requests, processes them (invoking functions from its various components like memory and process handling), and then responds accordingly.
• Both km and um rely on the shared crate for common definitions, ensuring that data structures and command codes are consistent across both modes.
• The Windows operating system mediates the interaction between user-mode and kernel-mode components.
Architectural Patterns and Design Principles
• Clear separation of concerns: The division into km, um, and shared reflects separation between kernel operations, user interactions, and common utilities.
• Modularity: Each component handles a distinct part of the process—from low-level hardware interactions in km to user-triggered operations in um.
• Use of IOCTL: The communication mechanism between user and kernel spaces is explicit and central to the design.
• Emphasis on safety and logging (as seen with logger utilities and tight segregation of secure memory operations).