title: Execute data as code?
body: <p>My client asked me to write an custom encrypted executable to prevent easy cracking of the licensing system. Now, I understand that this is a false sense of security, but despite this he insisted on it. </p>
  
  <p>So, I dug up my knowledge of portable executables and came up with this idea: </p>
  
  <ul>
  <li>Encrypt the executable</li>
  <li>Stick this to the end of a loader executable along with it's size</li>
  <li>The loader decrypts the data</li>
  <li>It copies the code to a page allocated with VirtualAlloc that has executable permissions</li>
  <li>It finds the entry point of the application </li>
  <li>Jumps there and we are all set.</li>
  </ul>
  
  <p>I have a problem with the jumping there part. How can I do that? If I were to set a function pointer to it, what would be the signature? The signature of the loaded executable's main() function? Or do I need to resort to assembly?</p>
  
  <p>I understand that it might be needed to correct absolute addresses after loading the code. How do I check if I need to, and how do I actually perform this? </p>
  
  <p>Edit: Working on windows and compiling with GCC. I can switch the Microsoft compiler if necessary.</p>
  
  <p>Edit2: To clarify: I KNOW it's mostly pointless. I believe that stands for <strong>any</strong> kind of DRM. It's up to my client to decide, and he still wants it despite me warning him about this.</p>
  
  <p>Thanks in advance.</p>