How monitoring works
From README.md:19-23:Dr.Semuuses DynamoRIO (Dynamic Instrumentation Tool Platform) to intercept a thread when it’s about to cross the user-kernel line. It has the same effect as hookingSSDTbut from the user-mode and without hooking anything. At this phase,Dr.Semuproduces a JSON file, which contains information from the interception.
DynamoRIO fundamentals
What is DynamoRIO?
DynamoRIO is a runtime code manipulation system that:- Intercepts application code at execution time
- Can modify or instrument any instruction
- Provides APIs for analyzing program behavior
- Works without source code or debugging symbols
Integration with Dr.Semu
Dr.Semu implements a DynamoRIO client - a DLL that hooks into the target process:DrSemu.cpp:114-284.
System call interception
Registration
Dr.Semu registers for system call events:Three-phase interception
Filter phase
DynamoRIO calls Only syscalls in the configured list are intercepted - others execute normally for performance.
event_filter_syscall to determine if a syscall should be intercepted.Pre-syscall phase
Before the syscall enters the kernel, This is where Dr.Semu:
event_pre_syscall is invoked.- Extracts parameters from CPU registers
- Translates virtual paths to real paths
- Logs the operation to JSON
- Can modify parameters or block the call
Monitored system calls
Dr.Semu monitors over 70 system calls across multiple categories:Filesystem
19 calls including NtCreateFile, NtWriteFile, NtDeleteFile
Registry
28 calls including NtSetValueKey, NtCreateKey, NtDeleteKey
Processes
15 calls including NtCreateUserProcess, NtWriteVirtualMemory
Networking
6 calls including URLDownloadToFileW, gethostbyname
Objects
10 calls including NtCreateMutant, NtCreateEvent
System
4 calls including NtQuerySystemInformation, NtLoadDriver
Complete list by category
Filesystem operations (19)
Filesystem operations (19)
- NtWriteFile
- NtClose
- NtCreateFile
- NtOpenFile
- NtCreateSection
- NtMapViewOfSection
- NtQueryInformationFile
- NtSetInformationFile
- NtQueryAttributesFile
- NtDeleteFile
- NtCreateDirectoryObject
- NtCreatePagingFile
- NtCreateIoCompletion
- NtQueryFullAttributesFile
- NtQueryDirectoryFile
- NtQueryDirectoryFileEx
- NtCreateSymbolicLinkObject
- NtFlushBuffersFile
Registry operations (28)
Registry operations (28)
- NtOpenKey, NtOpenKeyEx
- NtCreateKey
- NtDeleteValueKey, NtDeleteKey
- NtQueryValueKey, NtQueryKey
- NtEnumerateKey, NtEnumerateValueKey
- NtSetValueKey
- NtNotifyChangeKey, NtNotifyChangeMultipleKeys
- NtCreateKeyTransacted, NtOpenKeyTransacted, NtOpenKeyTransactedEx
- NtCompactKeys, NtCompressKey
- NtFlushKey, NtFreezeRegistry
- NtInitializeRegistry
- NtLoadKey, NtLoadKey2, NtLoadKeyEx
- NtSaveKey, NtSaveKeyEx
- NtLockRegistryKey
- NtQueryMultipleValueKey
- NtQueryOpenSubKeys, NtQueryOpenSubKeysEx
Process and thread operations (15)
Process and thread operations (15)
- NtCreateUserProcess
- NtOpenProcess
- NtCreateProcess, NtCreateProcessEx
- NtOpenThread
- NtDelayExecution
- NtSuspendProcess
- NtWriteVirtualMemory
- NtSetInformationProcess
- NtContinue
- NtProtectVirtualMemory
- NtSetContextThread
- NtQueryVirtualMemory
- NtQueryInformationProcess
Network operations (6)
Network operations (6)
- WSAStartup
- URLDownloadToFileW
- URLDownloadToCacheFileW
- gethostbyname
- InternetOpenUrlW
- InternetOpenUrlA
Object operations (10)
Object operations (10)
- NtCreateMutant, NtOpenMutant
- NtCreateMailslotFile
- NtCreateSemaphore, NtOpenSemaphore
- NtCreateEvent, NtOpenEvent
- NtWaitForSingleObject
- NtQueryObject
System operations (4)
System operations (4)
- NtQuerySystemInformation
- NtLoadDriver
- NtUserSystemParametersInfo
- NtRaiseHardError
Parameter extraction
Reading parameters
DynamoRIO provides thedrcontext handle to access CPU registers:
Dereferencing pointers
Many syscall parameters are pointers to structures:dr_safe_read is used to safely read memory that might be invalid.
Handling nested structures
Complex structures likeOBJECT_ATTRIBUTES contain pointers to other structures:
Behavior logging
JSON structure
Each intercepted call is logged as a JSON object:Concurrent vector
Logs are stored in a thread-safe concurrent vector:Writing reports
On process exit, the JSON is written to disk:1234.json).
Path translation
Virtual to real path conversion
When malware accesses a file, Dr.Semu translates the path: Malware sees:Device path translation
Dr.Semu converts DOS device paths to long paths:- DOS path:
C:\Windows\System32 - Device path:
\Device\HarddiskVolume3\Windows\System32
Module load tracking
Dr.Semu tracks when DLLs are loaded:Performance impact
Overhead sources
- Code cache - DynamoRIO translates and caches code blocks
- Instrumentation - Additional instructions injected at syscall boundaries
- Logging - JSON serialization and I/O
- Path translation - String operations for every filesystem access
Measured impact
From testing:- Light applications: 2-3x slowdown
- I/O heavy applications: 5-10x slowdown
- CPU heavy applications: 1.5-2x slowdown
The slowdown is detectable and may alert anti-analysis malware. Consider this when analyzing sophisticated samples.
Optimization strategies
- Selective monitoring - Only intercept necessary syscalls
- Lazy logging - Defer JSON serialization until process exit
- Efficient data structures - Use concurrent containers for thread safety without locks
- Minimal instrumentation - DynamoRIO’s lightweight mode
Time limits
Dr.Semu can terminate analysis after a timeout:--time_limit option:
Process termination handling
Soft kills
Dr.Semu implements “soft kills” for graceful shutdown:Exit event
On process exit, cleanup is performed:See also
Filesystem API
Complete list of filesystem syscalls
Registry API
Complete list of registry syscalls
DynamoRIO integration
Advanced DynamoRIO client details
JSON schema
Behavior report format