RANDSTRUCT works by introducing variability in how data structures are organized in memory. This means that each time an application runs, the layout of its data structures is different, making it harder for attackers to exploit predictable patterns.