14

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.

jordanhill123
  • 4,142
  • 2
  • 31
  • 40
Vladislav Rastrusny
  • 29,378
  • 23
  • 95
  • 156
  • @FractalizeR - don't take this the wrong way but if you are basing (part of) your security on obfuscation, you are taking the wrong approach. I know little to nothing about security but enough to know you shouldn't try to device your own 'unbreakable' scheme. I'd suggest you'd search for a commercial or open source solution to handle the security aspect of your application. – Lieven Keersmaekers Jan 30 '10 at 16:46
  • If you want to see what symbols (eg procedure and functions names) remain in your exe, a good test would be to load the exe in Ida (The Interactive Disassembler): http://www.hex-rays.com/idapro/ evaluation and freeware versions are available. – Remko Jan 30 '10 at 18:28
  • @Lieven I am planning to use Themida protector over my exe, but even in this case one needs to eliminate all excessive information from exe to strengthen protection. – Vladislav Rastrusny Jan 31 '10 at 13:50

4 Answers4

15

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.

Jim McKeeth
  • 38,225
  • 23
  • 120
  • 194
kludg
  • 27,213
  • 5
  • 67
  • 118
6

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}
Remko
  • 7,214
  • 2
  • 32
  • 52
  • It gives compiler error in Delphi 2010. What version is it intended for? – Vladislav Rastrusny Feb 01 '10 at 12:07
  • The constant is declared in Windows.pas: IMAGE_FILE_RELOCS_STRIPPED = $0001; { Relocation info stripped from file. } So you need to add the Windows unit to the uses clause in the dpr or declare it yourself. – Remko Feb 01 '10 at 12:47
6

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

Marco van de Voort
  • 25,628
  • 5
  • 56
  • 89
-1

What you probably will see is your form definition as a resource (eg the binary represetation of the DFM files of your project).

If you don't want to show these (for the serial info screen etc) you shouldcreate these forms "in code". Eg create a TForm, place a TButton and TEdit onto it, attach the event handlers in code.

To do this in a handly way: start with a form and create the DFM. When vieing the form, choose View as text from the context menu and you will know what things you should copy into code. And make sure NOT to place any varaiablerefernces under de published (always put public/protected/private as the first line within your class definition.

Ritsaert Hornstra
  • 5,013
  • 1
  • 33
  • 51
  • 1
    This is not about the forms, but about custom classes derived from TObject. – Vladislav Rastrusny Jan 30 '10 at 16:31
  • @FraktalizeR: Given the information that you gave earlier, it could have been about the embedded resources AND the RTTI. Only in your later update did you mention that it is about the new extended RTTI. Still: the rersources also give away class names so I cannot understand why you dismiss this information this way. It is correct that this is a method of embedding class names in an executable. – Ritsaert Hornstra Oct 30 '10 at 09:02