Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi: Prevent method names from appearing in executables

I am writing a class to handle security in my executable (checking serials, trial date check etc). After I compile the executable (even in Release build, with all debug and RTTI generation turned off), when I open it in NotePad and search the method name in the raw data, I can see all the names of the methods that assemble my class. There are no published members in any class in the code base.

This is bad for protection. Is there any way to tell Delphi not to store method names in the executable ? Why is it storing them at all if there is no RTTI needed and no COM explosion? Is there any compiler option controlling this?

It may be that ANY method of ANY class in the target executable is stored inside the executable in text form. Apparently this is caused by the extended RTTI being turned on by default for all classes in Delphi 2010.

like image 657
Vladislav Rastrusny Avatar asked Jan 30 '10 16:01

Vladislav Rastrusny


3 Answers

If you are asking about the extended RTTI in Delphi 2010, it can be switched off by

{$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}

see also docwiki.

like image 137
kludg Avatar answered Nov 19 '22 12:11

kludg


Also strip relocations, take up the following in the project's dpr file:

{$IFDEF RELEASE}
  // Leave out Relocation Table in Release version
  {$SetPEFlags IMAGE_FILE_RELOCS_STRIPPED}
{$ENDIF RELEASE}
like image 36
Remko Avatar answered Nov 19 '22 12:11

Remko


... and don't forget to turn off "td 32 debug info" (in older versions) or debug info in the linker tab in later ones.

like image 6
Marco van de Voort Avatar answered Nov 19 '22 13:11

Marco van de Voort