1. A method of testing, protecting, or correcting binary code, comprising: generating a control flow representation of the binary code; defining binary software patches; determining where to install the software patches based on an analysis of the control flow representation; and rewriting the binary code by installing the binary software patches into the original binary code and further modifying the original binary code to account for the installed binary software patches.