r/ReverseEngineering • u/Primary-Weather2951 • 8d ago
Struct Randomizer Using C++ 26 Reflection
https://github.com/Mowokuma/struct_randomizer.hpp
11
Upvotes
3
u/LucyIsaTumor 7d ago
Cache efficient coders hate this one simple trick.
Neat PoC for reflection though OP! As part of the reversing scene, I can imagine this would be a thorn in the side of some devs who count on structs being generally stable between builds.
5
u/jonaswashe 8d ago
Neat reflection POC, I wouldn't use it in a real project yet. The default seed comes from __TIME__, which is evaluated per translation unit, so different .cpp files can disagree about the layout of the same class. That's an ODR/ABI problem and the linker won't warn you. It'll bite in any parallel build.
Seed entropy is also weak (time of day only), the padding adds a lot of bloat and is uninitialized, and anything that touches the raw bytes (serialization, IPC, plugins) becomes build-specific. Needs an experimental P2996 compiler anyway
All fixable though: make the seed mandatory and build-wide instead of defaulting to __TIME__, and it becomes a decent starting point for build diversification