HookTrace
HookTrace is a sandbox setting in Sandboxie Ini available since v1.15.5 / 5.70.5. It enables detailed logging of all function hooking activities performed by the SbieDll component.
Usage
Overview
Function hooking is a core mechanism used by Sandboxie to intercept and redirect system calls from sandboxed processes. The HookTrace setting provides detailed visibility into this process, logging every hook attempt, success, failure, and related metadata. This is primarily useful for troubleshooting sandboxing issues and understanding how Sandboxie instruments applications.
How It Works
When HookTrace is enabled:
- Hook Detection: SbieDll logs all attempts to hook functions in loaded modules1.
- Status Tracking: Each hook operation is classified with status flags indicating success, failure reasons, or special conditions2.
- Module Resolution: The system identifies the source module for each hooked function using address lookup3.
- Monitor Output: Hook information is sent to the monitoring system using the MONITOR_HOOK flag4.
Output Format
Hook trace entries appear in the format:
Hooking: module!function
FAILED Hooking: module!function
Skipped Hooking: module!function
Hooking (trace): module!function
Additional status information may be appended:
(Chrome Hook Hooked)- Chrome-specific hook was successfully applied5.(Chrome Hook Unresolved)- Chrome-specific hook failed to resolve6.FFS Target not found, hooked x86 code instead- ARM64 fallback was used7.
Hook Status Types
The tracing system categorizes hook operations with several status flags:
- HOOK_STAT_CHROME: Chrome browser-specific hook handling8.
- HOOK_STAT_CHROME_FAIL: Chrome hook resolution failed9.
- HOOK_STAT_NO_FFS: ARM64 architecture-specific Fast Forward Sequence not found10.
- HOOK_STAT_SKIPPED: Hook was intentionally skipped based on configuration11.
- HOOK_STAT_TRACE: Hook is for API tracing purposes only12.
- HOOK_STAT_SYSCALL: ARM64 system call hooking (ARM64 EC only)13.
Application Hook Detection
When HookTrace is enabled, the system also monitors applications that attempt to modify other processes' memory, which may indicate application-level hooking attempts. This provides additional insight into potential conflicts with Sandboxie's own hooking mechanisms14.
Performance Considerations
- Increased Logging: Enabling HookTrace generates significant log output, particularly during process startup when many modules are loaded and hooked.
- Debug Purposes Only: This setting is primarily intended for debugging and troubleshooting, not for production use.
- Storage Impact: The verbose output can quickly consume log storage space.
Related Settings
- ApiTrace - Traces actual API calls after hooks are established.
- DebugTrace - General debug output from Sandboxie components.
- FuncSkipHook - Controls which functions should not be hooked.
- SkipHook - Module-specific hook skipping configuration.
-
Hook initialization occurs in
SbieDll_HookInit()whereDll_HookTrace = SbieApi_QueryConfBool(NULL, L"HookTrace", FALSE)↩ -
Hook status tracking is implemented using multiple flags defined as
HOOK_STAT_*constants, includingHOOK_STAT_CHROME,HOOK_STAT_CHROME_FAIL,HOOK_STAT_NO_FFS,HOOK_STAT_SKIPPED,HOOK_STAT_TRACE, andHOOK_STAT_SYSCALL↩ -
Module resolution is performed by
Trace_FindModuleByAddress((void*)module)to identify the source module of each hooked function ↩ -
Hook trace output is sent to the monitoring system via
SbieApi_MonitorPutMsg(MONITOR_HOOK | MONITOR_TRACE | ((HookStats & HOOK_STAT_SKIPPED) ? MONITOR_OPEN : 0), dbg)↩ -
Chrome hook success is indicated by
HookStats & HOOK_STAT_CHROMEand logged as "Chrome Hook Hooked" ↩ -
Chrome hook failure is indicated by
HookStats & HOOK_STAT_CHROME_FAILand logged as "Chrome Hook Unresolved" ↩ -
ARM64 fallback is indicated by
HookStats & HOOK_STAT_NO_FFSand logged as "FFS Target not found, hooked x86 code instead" ↩ -
HOOK_STAT_CHROMEflag value0x00000001indicates successful Chrome-specific hook handling ↩ -
HOOK_STAT_CHROME_FAILflag value0x00000002indicates failed Chrome hook resolution ↩ -
HOOK_STAT_NO_FFSflag value0x00000004indicates ARM64 Fast Forward Sequence target not found ↩ -
HOOK_STAT_SKIPPEDflag value0x00000008indicates the hook was intentionally skipped ↩ -
HOOK_STAT_TRACEflag value0x00000100indicates the hook is for API tracing purposes ↩ -
HOOK_STAT_SYSCALLflag value0x00000200is used for ARM64 system call hooking in ARM64 EC mode only ↩ -
Application hook detection is implemented in
file_misc.cwhereDll_HookTraceenables monitoring ofWriteProcessMemorycalls that may indicate application-level hooking attempts ↩