System components
LauncherCLI
Command-line interface and orchestration layer
virtual_FS_REG
Filesystem and registry virtualization
DrSemu Client
DynamoRIO-based instrumentation client
Detection Engine
Lua and Python rule execution
Architecture overview
Component lifecycle
1. Initialization phase
LauncherCLI starts
The launcher parses command-line arguments and initializes the environment (LauncherCLI.cpp:59-180).
Virtual environment setup
Creates VM-specific temp directory (e.g.,
dr_semu_0) and launches virtual_FS_REG.exe with elevated privileges (LauncherCLI.cpp:196-227).2. Execution phase
Target launch
Target executable is launched under DynamoRIO with the Dr.Semu client DLL (LauncherCLI.cpp:584-668).
System call interception
DynamoRIO intercepts system calls before they enter the kernel (DrSemu.cpp:414-741).
3. Analysis phase
Communication mechanisms
Mailslots
Dr.Semu uses Windows mailslots for inter-process communication:- Process tracking (
addandremovecommands) - Status reporting from instrumented processes
- Synchronization between components
Named pipes
Named pipes connect the launcher with the virtual filesystem provider:- Virtual environment initialization
- Configuration handshake
- Cleanup coordination
Events
Named events signal process termination:Data flow
Input
- Target executable - Malware sample or suspicious file
- Command-line arguments - Optional parameters passed to target
- Detection rules - Lua/Python scripts in
dr_rules/directory
Processing
- System call interception - Capture all filesystem, registry, process, and network operations
- Path translation - Redirect operations to virtual environment
- Behavior logging - Record parameters, return values, and timestamps
Output
- Starter report (
starter.json) - Process hierarchy and metadata - Dynamic reports (
{pid}.json) - Per-process behavior logs - Static reports (
{sha256}.json) - PE file analysis - Detection verdict - Classification result from rules
Isolation boundaries
All isolation is implemented in user-mode without kernel components.
Filesystem boundary
- Mechanism: Windows Projected File System (ProjFS)
- Implementation:
virtual_FS_REG/virtualizationInstance.cpp - Scope: All file operations are redirected to
%TEMP%\dr_semu_{vm_index}\
Registry boundary
- Mechanism: Hive cloning and path rewriting
- Implementation:
virtual_FS_REG/virtual_reg.cpp - Scope: All registry keys are prefixed with
dr_semu_{vm_index}!
Process boundary
- Mechanism: Process tracking and handle filtering
- Implementation:
DrSemu/process_handlers.hpp - Scope: Child processes are automatically instrumented; external processes are hidden
Network boundary
- Mechanism: Optional internet blocking
- Implementation:
DrSemu/networking_handlers.hpp - Scope: Configurable via
disable_internetflag (DrSemu.cpp:148)
Multi-sample support
Dr.Semu supports concurrent analysis through VM isolation:- Unique virtual filesystem root
- Separate registry hives
- Independent process tracking
- Isolated report directory
Performance considerations
Resource usage
- CPU: 2-10x overhead from DynamoRIO instrumentation
- Memory: Additional RAM for virtual filesystem cache and DynamoRIO code cache
- Disk: Temporary files in
%TEMP%for each VM instance - I/O: Registry cloning adds ~5-10 seconds startup time
Optimization strategies
- Parallel analysis: Run multiple samples concurrently (limited by CPU cores)
- Cache reuse: Registry hives can be cached with
use_cacheparameter - Time limits: Set appropriate timeouts to prevent indefinite execution
- Selective monitoring: Only configured system calls are intercepted
See also
Isolation mechanisms
Deep dive into ProjFS and registry virtualization
Monitoring
System call interception with DynamoRIO
Detection rules
Writing and running detection rules
Building from source
Build and customize Dr.Semu