Source code encryption

CiaoBaby
CiaoBaby used Ask the Experts™
on
How can I encrypt my delphi source code so that the .exe and dlls can't be reverse compiled?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2009

Commented:
Top Expert 2010

Commented:
actually, you can't decrypt exe, dll or dcu to original delphi source code. some decryptors (like in the above link) can extract some information like delphi forms, some rtti about classes, records, other types but they can't extract original delphi code.

Author

Commented:
I have an exe that I know is written in Delphi.  When I run any of the decompilers I get nothing.  No forms, nothing.  How did they do that?
Freelance Project Manager
Top Expert 2010
Commented:
as aflarin said, decompile and retrieve the original code is just impossible.
What you can get at most is assembler code.

Think about it : it would require a perfect knowledge of the Delphi compiler, of the exact version with which it has been compiled.
But let's suppose that someone with Delphi compiler OWN source code wants to do that, he could reverse some parts, by recognizing patterns of ASM and therefore replace those by Delphi snippet. But even then, there would be parts that are optimized at the ASM level by very smart algo of the compiler, and the result would be that it would be next to impossible to decompile large portion of code. And even if some parts would produce a fair snippet of delphi, there would remain a lot of ASM mixed, and of course even the original coder would have a difficult time to recognize his own code.
But ok, let's imagine further that one could achieve a full decompilation of ASM to Delphi code, it would be impossible to recognize the exact type of variables. an ANSIChar is a Byte from ASM point of view. An Integer and a Cardinal will very often generate the same code, a pointer is unrecognizable from another pointer on a structured type, except that some memory access that are based on pointers or indexed ( [BP+10] are typical to record pointers or arrays.
And I wouldn't even talk about objects, inheritance etc... What a plate of spaghetti it would be to sort out with only ASM code....

And last , what would really kill you is the fact that every variable or function, method etc... even with the right type, would have lost its name, therefore its purpose would be extremely difficult to find out by looking only how it is used.

That said, you can get and even change some resources in the exe. Typical examples are icons, or string resources. But less known are the DFM files that initialize all the forms and components created at design-time. That can help you to recreate the visual aspect of one application, leaving you 'only' with the coding of its behaviour

this great tool can give you this :
http://www.wilsonc.demon.co.uk/d10resourceeditor.htm

try it for size (and keep it in your toolbox, that's a must have)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial