Search code examples
c++variablesoffsetportable-executable

How to to store variables at specific offset


Is there a way to store variable (in C++) at specific offset in PE file? Similar question: Can I define specific order of variables stored in data section?

I've heard there are programs which can store settings in their executables.


Solution

  • Depending on the size of data, you could use deprecated (unused) areas of a PE image (like the MS-DOS Stub) to store your variables. The offsets of many of these unused areas are well-known (since they are defined by the PE format).