TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 230 subscribers
Post #25239 19
Conex – single-header C++20 library for condition-based binary pattern matching

I built a small single-header library called Conex for binary pattern matching with lambda conditions.

The idea: instead of hard-coded byte signatures, you express each match condition as a lambda that inspects the raw bytes. The pattern syntax is regex-style — (c0:4)(c1:8)\* means "4 bytes satisfying lambda 0, followed by zero or more 8-byte groups satisfying lambda 1".

// Find a struct by its signature + page-aligned address fields
auto result = conex::search_first(blob, "(c0:4)(c1:8)*",
[](std::span<const uint8_t> s) {
uint32_t sig; std::memcpy(&sig, s.data(), 4);
return sig == 0xDEADBEEF;
},
[](std::span<const uint8_t> s) {
uint64_t addr; std::memcpy(&addr, s.data(), 8);
return (addr & 0xFFF) == 0; // page-aligned
}
);

Useful for reverse engineering, game modding, firmware analysis, or anywhere you're scanning binary blobs for structures you can identify semantically but not by fixed offsets.

Single header, no dependencies, C++20.

[https://github.com/DanielCohen197/Conex](https://github.com/DanielCohen197/Conex)

Happy to hear feedback!

https://redd.it/1tiny5t
@r_cpp
GitHub GitHub - DanielCohen197/Conex: C++ single-header library for condition-based binary pattern matching. C++ single-header library for condition-based binary pattern matching. - DanielCohen197/Conex
More from @r_cpp
  1. Sep 29, 2026Boost.Graph 1.95 will be C++17 Dear Boost.Graph community, In two release cycles (Boost re…
  2. Sep 26, 2026Token Sequence Injection & Modern Macros: The Most Game-Changing Compile-Time Feature in C…
  3. Sep 25, 2026myStringStream.str("") Considered Harmful Under C++20 I was recently looking at some (rath…
  4. Sep 20, 2026A clever branch free optimization I'm the developer of memlz which is an extremely fast co…
  5. Sep 15, 2026Inside Boost.PolyCollection https://bannalia.blogspot.com/2026/09/inside-boostpolycollecti…
  6. Sep 11, 2026C++26: Standard Library Hardening Experiments https://www.cppstories.com/2026/hardening-ex…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →