Questions tagged [vmt]

18 questions
12
votes
5 answers

Where can I find information on the structure of the Delphi VMT?

The System.pas file contains a fair amount of information on hard-coded VMT offsets, but it doesn't seem to actually say much about the structure of the VMT itself. What I'd really like to know is, is there any way to find out the size of a VMT at…
Mason Wheeler
  • 82,511
  • 50
  • 270
  • 477
6
votes
10 answers

What is the right tool to detect VMT or heap corruption in Delphi?

I'm a member in a team that use Delphi 2007 for a larger application and we suspect heap corruption because sometimes there are strange bugs that have no other explanation. I believe that the Rangechecking option for the compiler is only for…
Roland Bengtsson
  • 5,058
  • 9
  • 58
  • 99
4
votes
1 answer

How to check if passed argument is class?

I have function (written in Delphi 7, 32-bit): Function GetVMTAddr(var C): Integer; Begin Result := Integer(C); Try PVmt(Result)^.SelfPtr := PVmt(C)^.SelfPtr; Except Result := 0; End; End; Which returns VMT Address (I think it is…
3
votes
1 answer

TObject virtual methods' signatures to update till Delphi XE2

For the time being, Delphi XE is only available on my box, I don't know wether Delphi 2010/XE2 has introduced some breaking changes. Please help me to update the following definition: TVmt = packed record SelfPtr : TClass; …
menjaraz
  • 7,551
  • 4
  • 41
  • 81
2
votes
2 answers

Completely overriding the VMT (Virtual Method Table)

I'm calling a virtual method on the vmt by dereferencing until I get the pointer to the method. This is all good however, how would I completely change the pointer to the VM table on the object? Example: PP A; // points to its default VM table PP…
otc
  • 431
  • 4
  • 15
1
vote
1 answer

How to get address of C++ interface VMT

Context: I'm trying to use a few COM Interface (Direct2D 1.1) from a Delphi application. For that purpose, I have to port the interfaces to Delphi. I have done that but I have a problem with one of the interfaces: the method I call is not the…
fpiette
  • 11,983
  • 1
  • 24
  • 46
1
vote
2 answers

How do I get the number of entries (virtual methods) in the VMT?

At positive offsets the VMT stores pointers to all user defined virtual methods. I need to write some code to hook the VMT. The way I do this is to get a pointer to a virtual method in an ancestor class. Let's say: TCustomForm.ShowModal. I then…
Johan
  • 74,508
  • 24
  • 191
  • 319
1
vote
4 answers

C++ Get Virtual Function Table Index

Is it possible (and how) to obtain the index of a virtual function in the virtual method table? class A { virtual void foo(); } I know foo is the first (0) item in the virtual method table However can I have foo and get 0?
Adam W
  • 317
  • 1
  • 3
  • 15
1
vote
1 answer

Changing VTable entries doesnt redirect function?

I have 3 classes (Cat, HouseCat:Cat, Lion:Cat). What I'm trying to do is change HouseCat's VTable to make HouseCat eat Meat instead of cat food. Classes I Use: class Cat { public: int age = 2; virtual void eat() { cout << "Meat" <<…
0
votes
1 answer

How to simulate metaclasses in C++?

In Object Pascal we can writing: type Animal = class end; Cat = class(Animal) end; Dog = class(Animal) end; MetaAnimal = class of Animal; function factory(m: MetaAnimal): Animal; begin Result :=…
Saku
  • 383
  • 2
  • 12
0
votes
1 answer

C++ How do i get a pointer to a class' virtual function table?

Given: Example.h struct Base { virtual ~Def() = default; virtual void accept(struct DerivedVisitor* v) = 0; }; struct Derived : Base { int num; void accept(struct DerivedVisitor* v) override; }; struct DerivedVisitor { virtual…
Django
  • 57
  • 6
0
votes
0 answers

Delphi: how to dynamically change the type of a class if just VMT differs?

Assume you have a TAncestorClass and its descendants TDescendantClass1 and TDescendantClass2. Also assume that the descendants differ from each other just in some differently overridden virtual methods. Otherwise all the fields are identical. That…
Zoltán Bíró
  • 346
  • 1
  • 12
0
votes
1 answer

How can I see VMT in pascal?

Can I see somehow an VMT table in FREE Pascal? I am interested if VMT table has the same number of items in two objects that are connected by heredity? For example in this model, what will be in the VMT table ? And will there be ONE table for all…
0
votes
1 answer

No Virtual Function Table for abstract class?

I am learning about virtual function tables and their representation by analyzing a binary of a simple program written in Visual C++ (with some optimizations on). A few days ago I asked this question while being stuck on virtual method table content…
Topper Harley
  • 375
  • 4
  • 17
0
votes
1 answer

Virtual Function Table entry from class that is not related

I am browsing through VFTs (VMTs) of a simple C++ Windows program (I don't have a source code, only binary), compiled by Visual Studio with some sort of optimization on. I noticed that is uses inheritance and polymorphism. I found the location of…
Topper Harley
  • 375
  • 4
  • 17
1
2