Overview
The virtual filesystem provides:- Complete isolation - File operations are redirected to a virtual root
- Transparent access - Malware sees a normal Windows filesystem
- Zero kernel drivers - Entirely user-mode implementation
- On-demand population - Files are projected only when accessed
Architecture
ProjFS Integration
Dr.Semu implements a ProjFS provider invirtual_FS_REG/ that intercepts filesystem operations:
virtual_FS_REG/fs_provider.h and virtual_FS_REG/fs_provider.cpp
Virtualization Instance
The base classvirtualization_instance wraps the ProjFS C API:
File: virtual_FS_REG/virtualizationInstance.h
Key methods:
Start()- Initializes ProjFS virtualization rootStop()- Stops virtualizationWritePlaceholderInfo()- Creates placeholder filesWriteFileData()- Hydrates placeholders with content
How It Works
1. Virtualization Root Setup
When Dr.Semu starts, it creates a virtualization root:virtualizationInstance.cpp:166-263
The root directory (e.g., C:\temp\dr_semu_0\) becomes a ProjFS virtualization root where all file operations are intercepted.
2. Directory Enumeration
When malware lists directory contents: StartDirEnum - Called when enumeration begins:fs_provider.cpp:128-139
GetDirEnum - Called to return directory entries:
fs_provider.cpp:187-274
EndDirEnum - Called when enumeration completes:
fs_provider.cpp:150-156
3. File Metadata Projection
When malware accesses a file for the first time:fs_provider.cpp:277-304
This creates an empty placeholder file with correct:
- File size
- Timestamps (creation, modified, accessed)
- File attributes (hidden, system, etc.)
- Security descriptor
4. File Data Hydration
When malware reads file contents:fs_provider.cpp:333-399
This converts the placeholder to a hydrated placeholder containing actual file data.
Path Translation
Dr.Semu translates between virtual and real paths:fs_provider.cpp:5-21
Example
Malware accesses:C:\dr_semu_0\Windows\System32\kernel32.dll
Dr.Semu maps to: C:\Windows\System32\kernel32.dll
Isolation Enforcement
The virtual filesystem blocks access to Dr.Semu internals:fs_provider.cpp:22, 198-201, 283-286, 343-346
This prevents malware from:
- Detecting virtualization artifacts
- Tampering with Dr.Semu components
- Breaking out of isolation
File Notifications
Dr.Semu receives notifications for file operations:fs_provider.cpp:402-408
Notification types include:
PRJ_NOTIFICATION_FILE_OPENED- File openedPRJ_NOTIFICATION_PRE_DELETE- File about to be deletedPRJ_NOTIFICATION_PRE_RENAME- File about to be renamedPRJ_NOTIFICATION_FILE_OVERWRITTEN- File overwritten
Security Descriptor Handling
Dr.Semu applies security descriptors to projected files:fs_provider.h:5-12, fs_provider.cpp:57-87
Device Path Translation
Dr.Semu handles device path formats:DrSemu/DrSemu.cpp:42-57
This supports both formats:
- DOS path:
C:\dr_semu_0\file.txt - Device path:
\Device\HarddiskVolume2\dr_semu_0\file.txt
Performance Considerations
On-Demand Projection
ProjFS only projects files when accessed:- Initial directory listing is fast (metadata only)
- File data is read only when needed
- Reduces memory and I/O overhead
Caching
Windows file system cache applies:- Repeated reads are served from cache
- Write-through for modifications
- Cache coherency managed by ProjFS
Memory Alignment
For non-cached I/O compatibility:fs_provider.cpp:362-396
Limitations
Read-Only Projection
Dr.Semu projects the real filesystem as read-only in concept. New files created by malware exist only in the virtual root and don’t affect the real system.Windows Version Requirement
ProjFS requires:- Minimum: Windows 10 version 1809 (October 2018 Update)
- Or: Windows Server 2019
Filesystem Features
Some advanced features may have limitations:- Alternate data streams (supported via
StreamsInformation) - Extended attributes (supported via
EaInformation) - Hard links (see notification handling)
Source Files
Virtual filesystem implementation:virtual_FS_REG/virtualizationInstance.h- Base ProjFS wrapper classvirtual_FS_REG/virtualizationInstance.cpp- ProjFS API implementationvirtual_FS_REG/fs_provider.h- Filesystem provider interfacevirtual_FS_REG/fs_provider.cpp- Filesystem callback implementationsvirtual_FS_REG/dir_info.h- Directory enumeration helpervirtual_FS_REG/shared_config.h- Build configuration
Related Components
The virtual filesystem works with:- Registry Redirection - Virtual registry implementation
- DynamoRIO Integration - System call interception