Prerequisites
Required Software
- Visual Studio 2019 or later with C++ development tools
- CMake (version 3.10 or higher) - Download cmake-gui
- Python 3 x64 - Download Python 3
- Windows 10 version 1809 or later (required for ProjFS support)
Enable ProjFS
Before building, enable Windows Projected File System using PowerShell in an elevated window:Building Dependencies
1. Build pe-parse Library
Dr.Semu requires the Trail of Bits pe-parse library for PE file analysis. Generate Visual Studio Project:- Open cmake-gui
- Set source directory to:
DrSemu\shared_libs\pe_parse - Set build directory to:
DrSemu\shared_libs\pe_parse\build(for 32-bit) - Click “Configure” and select your Visual Studio version
- Click “Generate”
- Open the generated solution in
\shared_libs\pe_parse\build\ - Build the
pe-parser-libraryproject in Release mode - The output will be in
\shared_libs\pe_parse\build\pe-parser-library\Release\
- Repeat the cmake-gui process with build directory:
DrSemu\shared_libs\pe_parse\build64 - Generate the project
- Build in Release mode
- The output will be in
\shared_libs\pe_parse\build64\pe-parser-library\Release\
- Right-click the
pe-parser-libraryproject - Go to Properties → C/C++ → Code Generation
- Change Runtime Library to
/MT(Multi-threaded) - Rebuild the project
2. Download DynamoRIO
- Download the latest DynamoRIO release from GitHub
- Extract the archive to
DrSemu\bin\dynamorio
Building Dr.Semu
1. Open Solution
- Open
DrSemu.slnin Visual Studio - The solution contains multiple projects:
- DrSemu - DynamoRIO client (core instrumentation)
- virtual_FS_REG - Virtual filesystem and registry provider
- LauncherCLI - Command-line launcher
- fake_explorer - Isolated process host
- run_detections - Detection engine
2. Set Startup Project
Right-click LauncherCLI and select “Set as StartUp Project”3. Build Configuration
Select your build configuration:- Release|x64 - For 64-bit executables (recommended)
- Release|x86 - For 32-bit executables
4. Build Solution
- Build → Build Solution (Ctrl+Shift+B)
- Verify all projects build successfully
- Output binaries will be in
bin\directory
Project Components
DrSemu (DynamoRIO Client)
The core instrumentation client that hooks system calls:- Location:
DrSemu/DrSemu.cpp - Output:
DrSemu.dll(32-bit) andDrSemu64.dll(64-bit) - Dependencies: DynamoRIO SDK, pe-parse library
- System call interception using DynamoRIO
- Pre/post syscall handlers
- JSON logging of behavior
virtual_FS_REG
Provides virtual filesystem and registry redirection:- Location:
virtual_FS_REG/ - Output: Static library linked into LauncherCLI
- Dependencies: Windows ProjFS API
- ProjFS callbacks for file virtualization
- Registry hive cloning and redirection
LauncherCLI
Main executable that orchestrates analysis:- Location:
LauncherCLI/ - Output:
DrSemu.exe - Dependencies: virtual_FS_REG, DynamoRIO
Common Build Issues
pe-parse Library Errors
Problem: Linker errors about runtime library mismatch Solution: Ensure pe-parse is built with/MT runtime library option (see step 1 above)
ProjFS Not Available
Problem: Compilation errors about missing ProjFS headers Solution:- Verify Windows 10 version 1809 or later
- Ensure ProjFS feature is enabled
- Update Windows SDK to latest version
DynamoRIO Not Found
Problem: Runtime error about missing DynamoRIO DLLs Solution:- Verify DynamoRIO is extracted to
bin\dynamorio - Check folder structure matches expectations
Missing Dependencies
Problem: Compilation errors about missing headers Solution: The project uses git submodules for dependencies:- phnt (Process Hacker Native API headers)
- nlohmann/json (JSON library)
- spdlog (Logging library)
- cxxopts (Command-line parsing)
Build Output
After successful build, you’ll have:Next Steps
After building:- Run Dr.Semu:
DrSemu.exe --target file_path - Review generated JSON reports
- Create custom detection rules in
dr_rules/
For development and debugging, you can define
DR_TESTING in virtual_FS_REG/shared_config.h to disable certain features.Development Tips
Debugging DynamoRIO Client
The DrSemu.dll client runs inside the DynamoRIO process:- Set LauncherCLI as startup project
- Enable DynamoRIO logging: Use
-verbose 2option - Use
dr_printf()for logging from the client
Testing Isolation
Test virtual filesystem:- Check files are redirected to virtual root
- Verify registry keys are cloned to
virtual_reg/
Code Structure
Handler files:filesystem_handlers.hpp- File system call handlersregistry_handlers.hpp- Registry call handlersprocess_handlers.hpp- Process/thread handlersnetworking_handlers.hpp- Network call handlers