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.
So, I dug up my knowledge of portable executables and came up with this idea:
- Encrypt the executable
- Stick this to the end of a loader executable along with it's size
- The loader decrypts the data
- It copies the code to a page allocated with VirtualAlloc that has executable permissions
- It finds the entry point of the application
- Jumps there and we are all set.
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?
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?
Edit: Working on windows and compiling with GCC. I can switch the Microsoft compiler if necessary.
Edit2: To clarify: I KNOW it's mostly pointless. I believe that stands for any kind of DRM. It's up to my client to decide, and he still wants it despite me warning him about this.
Thanks in advance.