Quick Start
Get up and running with STX, the modern C++23 systems toolbelt for low-level binary analysis, memory manipulation, and security research.What is STX?
STX is a header-only C++23 library providing type-safe, zero-overhead abstractions for:Memory Operations
Safe, low-level memory access and alignment primitives
Binary I/O
Type-safe file operations for binary parsing
Function Wrappers
Strongly-typed wrappers around memory addresses
Time Utilities
UNIX time conversions and high-resolution stopwatch
Prerequisites
For C++ Modules support, you’ll also need CMake 3.28+.Your First STX Program
Let’s create a simple program that demonstrates STX’s type-safe memory operations.Include STX
Start by including the main STX header:
The library provides both traditional headers and C++23 modules. Choose the approach that fits your build system.
Use Strong Types
STX provides strong types for type-safe operations:
Strong types like
offset_t, rva_t, and va_t provide compile-time safety and prevent mixing different address types.Complete Example: PE Section Reader
Here’s a real-world example from the STX documentation that demonstrates parsing a PE file:- Type-safe file reading with
readfs - Offset arithmetic using
offset_t - Bulk allocation with
dirty_vector - Strong-type safe iteration
Key Concepts
Strong Types
STX uses strong types to prevent common errors:| Type | Purpose | Example |
|---|---|---|
offset_t | File or buffer offsets | offset_t{0x1000} |
rva_t | Relative virtual addresses | rva_t{0x2000} |
va_t | Virtual addresses | va_t{0x400000} |
Type Aliases
Convenient shorthand for common types:Memory Safety
STX provides both safe and raw memory operations:
read<T>()/write<T>(): Usememcpy, safe for unaligned accessread_raw<T>()/write_raw<T>(): Direct dereference, requires alignment
Next Steps
Installation
Learn how to integrate STX into your project
Memory API
Explore memory manipulation utilities
File System API
Type-safe binary file operations
GitHub Repository
View the source code and examples