
ATrace — это инструмент для трассировки выполнения бинарных файлов в Windows.

EhTrace (произносится 'ATrace') — это высокопроизводительный фреймворк для трассировки и инструментирования двоичных файлов Windows. Он предоставляет возможность глубокого анализа исполняемых файлов Windows во время выполнения без необходимости в исходном коде, модификации двоичных файлов или традиционной отладке.
EhTrace использует Vectored Exception Handling (VEH) Windows и методы блочного шага для обеспечения всесторонней трассировки выполнения с минимальными накладными расходами. В отличие от традиционных инструментов отладки или инструментирования, EhTrace работает полностью в рамках процесса и не требует патчей для целевых двоичных файлов.
flowchart TB
subgraph Target["🎯 Target Process"]
direction TB
APP[Application Code]
VEH[Vectored Exception Handler]
style APP fill:#e1f5ff,stroke:#01579b,stroke-width:3px,color:#000
style VEH fill:#fff3e0,stroke:#e65100,stroke-width:3px,color:#000
end
subgraph EhTrace["⚡ EhTrace Engine"]
direction TB
BLOCK[Block Stepper]
DISASM[Capstone Disassembler]
FIGHTERS[BlockFighters]
CTX[Context Manager]
style BLOCK fill:#f3e5f5,stroke:#4a148c,stroke-width:3px,color:#000
style DISASM fill:#e8f5e9,stroke:#1b5e20,stroke-width:3px,color:#000
style FIGHTERS fill:#ffebee,stroke:#b71c1c,stroke-width:3px,color:#000
style CTX fill:#e0f2f1,stroke:#004d40,stroke-width:3px,color:#000
end
subgraph Output["📊 Analysis Output"]
direction TB
SHMEM[Shared Memory Log]
GRAPHS[Visual Graphs]
REPORTS[Coverage Reports]
style SHMEM fill:#fce4ec,stroke:#880e4f,stroke-width:3px,color:#000
style GRAPHS fill:#f1f8e9,stroke:#33691e,stroke-width:3px,color:#000
style REPORTS fill:#fff8e1,stroke:#f57f17,stroke-width:3px,color:#000
end
APP -->|Exception| VEH
VEH -->|Single Step| BLOCK
BLOCK -->|Instruction| DISASM
DISASM -->|Analysis| FIGHTERS
FIGHTERS -->|State| CTX
CTX -->|Events| SHMEM
SHMEM -->|Data| GRAPHS
SHMEM -->|Data| REPORTS
style Target fill:#e3f2fd,stroke:#0d47a1,stroke-width:4px
style EhTrace fill:#f3e5f5,stroke:#6a1b9a,stroke-width:4px
style Output fill:#e8f5e9,stroke:#2e7d32,stroke-width:4px
EhTrace работает через сложный конвейер:
Фреймворк поддерживает состояние выполнения для каждого потока с помощью специализированных структур контекста и предоставляет хуки для настраиваемого инструментирования.
graph LR
subgraph Traditional["🐌 Traditional Debugger"]
T1[Single Step]
T2[Context Switch]
T3[Kernel Mode]
T4[~1M events/sec]
style T1 fill:#ffcdd2,stroke:#c62828,stroke-width:2px,color:#000
style T2 fill:#ffcdd2,stroke:#c62828,stroke-width:2px,color:#000
style T3 fill:#ffcdd2,stroke:#c62828,stroke-width:2px,color:#000
style T4 fill:#ef5350,stroke:#b71c1c,stroke-width:3px,color:#fff
end
subgraph EhTrace["⚡ EhTrace"]
E1[Block Step]
E2[In-Process]
E3[User Mode]
E4[~43M events/sec]
style E1 fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px,color:#000
style E2 fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px,color:#000
style E3 fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px,color:#000
style E4 fill:#66bb6a,stroke:#1b5e20,stroke-width:3px,color:#fff
end
T1 --> T2 --> T3 --> T4
E1 --> E2 --> E3 --> E4
style Traditional fill:#ffebee,stroke:#d32f2f,stroke-width:3px
style EhTrace fill:#e8f5e9,stroke:#388e3c,stroke-width:3px
EhTrace достигает высокой производительности за счет нескольких оптимизаций:
📊 Тест производительности: 428 833 152 события (по 32 байта каждое) за 10 секунд = ~43 млн событий/с
CSW16 демо-трассировка notepad.exe без символов:

График базовых блоков с дизассемблированием Capstone:

Визуализация покрытия кода:
