3

I'm looking at the documentation of RTTI which says:

If RTTI generation is enabled, the resulting binary includes special metadata that contains information about types (for example, class ancestry, declared fields, annotated attributes).

Where is the RTTI metadata stored in the PE file, and what structure does it have?

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
İsmail Kocacan
  • 1,204
  • 13
  • 38
  • 3
    It's stored in the .text section IIRC. You can reverse engineer the structure by studying the code in `TypInfo` and `Rtti`. There's a lot of detail in this. And it is subject to change at every release. Don't expect somebody to write a treatise on the matter for you. If you can't find all the details by websearch then they probably don't exist. Feel free to reverse engineer it and write it up yourself. Almost certainly you don't need to know the details though. – David Heffernan Sep 14 '17 at 10:30
  • @DavidHeffernan thanks for explain.I just wanted to know.You're great man. – İsmail Kocacan Sep 14 '17 at 10:45
  • 2
    While typeinfo/typedata might be extended by some things they don't change fundamentally. Since much of the information (especially any names/strings) are stored in the packed shortstring format not all information are actually fields on the records (you can see those in the code as commented out because you can only access them via pointer math) – Stefan Glienke Sep 14 '17 at 11:49

1 Answers1

1

Windows PE files do not have a standard section where RTTI is stored, its format and where it is stored is completely up to the compiler vendor.

Even though it does not specify the storage format (only the memory layout) the Itanium C++ ABI specification is a good place to start and then move on to the GCC source code if you want to know more. This answer reveals that GCC v3+ uses this ABI everywhere except Windows where I'm guessing they try to follow the Microsoft format instead.

The specifics should not matter that much because the compiler is free to change its implementation at any time and you would have to investigate a specific version if you want to interact with its RTTI data.

For Delphi specific information it might be worth taking a look at the Free Pascal code but I don't know if they are fully ABI compatible.

Anders
  • 97,548
  • 12
  • 110
  • 164