Log in

View Full Version : Reconstruct Delphi control classes


Cherry
May 6th, 2009, 12:19
Hello!

I have a problem. I am manipulating a program written in Delphi 5/6 (depending on the program's version). Now, I have created a 2 DLLs, written in Delphi, one compiled with Delphi 5, the other one compiled with Delphi 6, and a loader which starts the target and injects the right DLL. Now, I can easily manipulate the controls used by the app, TMaskEdit's for example.

But the problem is: many of the controls used by the app are not default Delphi controls, but self-written by the app's programmer. I have seen that in the executable file there are written the names of the public properties of these classes. But is there any way to kind of "decompile" them to get Delphi source of the declarations again, or at least the offsets and sizes of the public properties?

Thanks in advance,

Cherry

reverser
May 6th, 2009, 16:58
Fucntions in typinfo.pas will allow you to do almost anything to a component without decompiling. Start with GetTypeData and GetPropInfos.

Cherry
May 7th, 2009, 14:15
I don't understand this.

I found a lot of examples, but all are using a unit called "rttiobj", which I can't find anywhere...

EDIT: Okay, I found it(http://fpc.freedoors.org/fpcbuild-2.2.0/fpcdocs/typinfex/rttiobj.pp), but I can't compile:
Code:
[Error] rttiobj.pas(3): Invalid compiler directive: 'Mode'
[Error] rttiobj.pas(15): Number of elements differs from declaration
[Error] rttiobj.pas(17): Undeclared identifier: 'tkbool'
[Error] rttiobj.pas(468): Undeclared identifier: 'PByte'
[Error] rttiobj.pas(478): Pointer type required
[Error] rttiobj.pas(478): Pointer type required
[Error] rttiobj.pas(479): Pointer type required
[Error] rttiobj.pas(481): Pointer type required
[Error] rttiobj.pas(494): Undeclared identifier: 'ptfield'
[Error] rttiobj.pas(495): Undeclared identifier: 'ptstatic'
[Error] rttiobj.pas(496): Undeclared identifier: 'ptVirtual'
[Error] rttiobj.pas(497): Undeclared identifier: 'ptconst'
[Fatal Error] Project1.dpr(7): Could not compile used unit 'rttiobj.pas'


Maybe it needs a newer version of Delphi...?

Could somebody give me an easy example how I can get class name and published properties (name, type) of an unknown object and then change its properties?

reverser
May 7th, 2009, 17:20
TypInfo unit should be included with Delphi. RttiObj is probably some FreePascal thing. Maybe check RTTI articles from here:
http://www.suite101.com/articles.cfm/delphi_programming

disavowed
May 9th, 2009, 11:39
you may also want to check out the source code for DeDe to see how it's doing a lot of its work.