Encrypt an EXE

I want to encrypt an exe file. There should be a launcher application that checks for a password or something and decrypts and executes the encrypted exe file. The decrypted file should not be saved to disk, other wise the user can copy the decrypted exe while the program is running. Im using an algorithm for encryption, but my problem is I dont know how to execute the decrypted file without saving it to a file. How do i do this ?
Who is Participating?
Well, the problem is, what YOU are asking for, is not
Encryption/Decryption. You are asking for an emulator.
You would need your program to decrypt, then run
the other program. If you simply want to Encrypt/Decrypt
that is easy. Best way to do what you want, is to actually
encrypt the EXE. Then when you decrypt, decrypt it to a
new location, under a new name. On unload, you delete
the new created program, and then the security continues.
However it is not full proof security, most basic users can
not break it. Your file would be named like RandName.ROU,
and saved to a folder such as System, where it would not
be noticed, then its deleted.

And here is an example of encryption:

Why ?
Exactly WHY?
no one will be able to read your code, if you want to limit access to the prog just password protect the program, so a user has to enter a password to run it.

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

The only way this is going to work is if you save the
decrypted file to disk. If you dont want to do that,
then have a launcher program.

Working Example:

     Shell "Project1.exe Mypass"
   End Sub
     If Command$ <> "Mypass" Then End
   End Sub

That will create a program that can not be opened without
a password. Also will save a lot of time with getting rid of
the need for encryption.
kurian2z5Author Commented:
I need to encrypt a third party exe so i cant use your method List244.

I want to implement a harddisk lock for a third party exe using a launcher program. The launcher should decrypt and execute the third party exe if the user provides the correct key.

Actually i made a program for which i lost the source and so i cant implement the protection in the program itself. But this method can be extended to any other program using the launcher.

This is how SafeDisc 1 CD protection works isnt it ?

The program's exe is encrypted and saved as a .icd file.

The launcher progam verifies the Disc and decrypts the .icd file and executes it WITHOUT saving it to disc. If you check the running processes it shows the progam.icd file and not an .exe file.
kurian2z5Author Commented:
I just need to make a harddisk lock for a program without modifying the exe of the program.

The user should not be able to run the program on another computer, unless he obtains the original exe of the program.

If i save the decrypted exe to a file, it can be copied while the program is running, if you view the running processes to see where the file is running from.

How do i go about it ?
Why not just use activelock

kurian2z5Author Commented:
I need to protect a third party exe, so i cant modify its source and hence i cant use activelock.

I would have used your method but if i decrypt the exe to a new location or in some cases even rename it the program amy not work because it wont find its files etc..
kurian2z5Author Commented:
Im going to use ur method List, (except for programs that dont run with exe renamed) Ill save the exe under a different name in the same folder, probably readme.txt or something, so most of them should work.

I need to know how to detect if a program is running (by its exe name - not caption) and wait for it to close before deleting the exe.
kurian2z5Author Commented:
i was waiting for list244 to reply. id give him 30 points for a near complete answer.

I would suggest something like this. If you can find the running processes you can
check if the certain exe is running.
kurian2z5Author Commented:
this lists all the processes. if i keep refreshing the list and checking if the program's name has been removed, then i presume it has closed. but this is rather inefficiend and CPU usage goes up. there has to be a way to check for a specific process running. like if AppActivate(window title) returns false then the progam with the window title u passes is not running..
As far as I am aware, the only way to do this, is to enumerate the running
processes. However, if you want another way of going about it:


But, other than enumerating processes, I do not know how to do this. Sorry.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.