PDA

View Full Version : Reconstruct Delphi control classes


Cherry
05-06-2009, 01:19 PM
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
05-06-2009, 05:58 PM
Fucntions in typinfo.pas will allow you to do almost anything to a component without decompiling. Start with GetTypeData and GetPropInfos.

Cherry
05-07-2009, 03:15 PM
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
05-07-2009, 06:20 PM
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
05-09-2009, 12:39 PM
you may also want to check out the source code for DeDe to see how it's doing a lot of its work.