views:

413

answers:

4

I am writting some class, that is for handling security in my exe (checking serials, trial date check etc). After I compile exe even in Release build with all debug and RTTI generation turned off, when I open my exe in NotePad and search method name in a raw data, I can see all the name of the methods, that assemble my class. There is no published members in a class btw.

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

P.S. I just noticed this little fact. So, may be ANY method of ANY class in target exe is stored inside exe in text form.

UPDATE: this is caused by extended RTTI being turned on by default for all classes in Delphi 2010.

+12  A: 

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.

Serg
I guess you are right. But isn't this option controllable from GUI? If yes - then how?
FractalizeR
AFAIK there is no GUI control for the Enhanced RTTI. You need to add those directives to each unit.
Jim McKeeth
A: 

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
This is not about the forms, but about custom classes derived from TObject.
FractalizeR
@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
+4  A: 

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
It gives compiler error in Delphi 2010. What version is it intended for?
FractalizeR
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
+3  A: 

... 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