Issue
Is it possible using Windows to read a file into memory (keep data in byte array), delete original file from filesystem and execute it from memory?
EDIT
My goals is to protect my java code from reverse enginering.
I wrote a launcher in C++ that take my encrypted jar file, decrypt it and launch it. The little problem is that i have to write my decrypted jar file somewhere in the filesystem, so it can be easily captured and decompiled... there is no way to prevent this?
Solution
No, it's not possible to do like that. There's no system call that says "take this chunk of my memory and use just that part of it as the image of a new process".
You can load code into memory and jump to it within the current process, but that's an ugly thing to do because you have to handle all of the relocations.
With regards to the Java specific part:
You can embed a Java interpreter within your C++ executable. You can write your own class loader for Java (through the C++ interface to the JVM) that will load classes from your encrypted Jar file. That way you could avoid ever writing the unencrypted Jar file to disk. It will of course be visible in memory to anyone with a debugger...
Answered By - Flexo
Answer Checked By - Marie Seifert (JavaFixing Admin)