In the omnipresent model of the stored-program computer, both the instructions and data are held in a single storage structure. Therefore, instructions can be read and written as if they were data. In practice however, instructions rarely change during the execution of the program. As a result, it is often assumed that the instructions are constant. Therefore, many tools and analyses fail in the presence of self-modifying code. In this paper, we present an extension to the control flow graph representation, which enables the analysis, optimization and generation of self-modifying code: the state-enhanced control flow graph.