G
G
Gennady Kruglov2021-05-06 16:00:50
.NET
Gennady Kruglov, 2021-05-06 16:00:50

Where is the reference to the method table in .NET anyway?

As far as I understand Richter and what is written in his CLR via C# - each instance of the type contains a link to the so-called. a type object, which in turn already contains its own method table. And already in this method table there are links to specific implementations of methods in IL. If I'm wrong on this part, please correct me.
However, the book Optimizing .NET Applications with C# says that the instance itself contains a reference to the method table. In particular, here is an illustration from this book:

6093e829a09bf608791000.png

So where is the reference to the method table, in the instance or in the type object that the instance refers to?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
none7, 2021-05-06
@robinzonejob

When you don't know what to believe, trust the debugger.
There it is:

static void test(object o) {
    Type t = o->type; // offset 0
    IntPtr *vt = t->vtable_of_type; // offset 0x28 на x86
    vt[3](); // call
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question