vtable

print address of virtual member function

I am trying to print the address of a virtual member function. If I only wants to print the address of the function I can write: print("address: %p", &A::func); But I want to do something like this: A *b = new B(); printf("address: %p", &b->func); printf("address: %p", &b->A::func); however this does not compile, is it possible t...

C++ vtable resolving with virtual inheritance

I was curious about C++ and virtual inheritance - in particular, the way that vtable conflicts are resolved between bass and child classes. I won't pretend to understand the specifics on how they work, but what I've gleamed so far is that their is a small delay caused by using virtual functions due to that resolution. My question then is...

COM method offsets in Delphi

In Delphi, how do I find out the the address of a COM method? I can hardcode the offsets //0 is the offset of the QueryInterface method p := TPonterArray(pointer(SomeInterface)^)[0]; but I would prefer to use symbolic names. The folllowing obviously does not work: var M : TMethod; ... M := TMethod(SomeInterface.QueryInterface); Tha...

suspicions of multithreading race conditions in c++ virtual calls w/ vtable implementation

I have a suspicion that there might be a race condition in a certain C++ multithreading situation involving virtual method calls in a vtable dynamic dispatching implementation (for which a vtable pointer is stored as a hidden member in the object with virtual methods). I would like to confirm whether or not this is actually an issue, an...

Inheritance Costs in C++

Taking the following snippet as an example: struct Foo { typedef int type; }; class Bar : private Foo { }; class Baz { }; As you can see, no virtual functions exist in this relationship. Since this is the case, are the the following assumptions accurate as far as the language is concerned? No virtual function table will be creat...

order of overloaded methods in the vtable (on win32)

Hi, is the order of overloaded methods in the vtable always the same across win32 compilers? Problem: I have "interfaces" (pure virtual classes with no data members). They can be used via pointer from different compilers (the client gets the pointer by calling a standard c dll factory method). This works fine across different compiler ...

Virtual tables and virtual pointers for multiple virtual inheritance and type casting.

I am little confused about vptr and representation of objects in the memory, and hope you can help me understand the matter better. Consider B inherits from A and both define virtual functions f(). From what I learned the representation of an object of class B in the memory looks like this:[ vptr | A | B ] and the vtbl that vptr points...

Building a COM object vtable in x86 assembly

I am building a COM object in x86 assembly using NASM. I understand COM quite well and I understand x86 assembly pretty well, but getting the two to mesh is getting me hung up... (by the way, if you're thinking of attempting to dissuade me from using x86 assembly, please refrain, I have very particular reasons why I'm building this in x8...

Why isn't the vtable created?

I'm making a memory patcher for a game but when compiling it with only a single patch implemented, no vtable was created (Using mingw). Could someone tell me what is the problem and how I can fix it? a_patch.cpp (Compile this) #include "a_patch.h" void a_patch::init_patch() { /* example initilisation */ init_var(); vector...

Incorrect vtable layout for class exported by DLL: request for clarification regarding headers and vtable construction.

Hello all, Although the problem at hand is solved, it has me a little confused as to what data is used to construct the vtables for a class and where the layout for the vtable is stored. If anyone can provide clarification or point me towards some information which might satiate my curiosity, I would greatly appreciate it. Background ...

Virtual Functions Object Slicing

Hi, My question is with reference to this question which explains how virtual functions work in case of object slicing which end up calling base class virtual function and Wikipedia article which explains the virtual table layout for a derived class for below code class A{ public: virtual void func(){ cout<<"\n In A:func"...

What is Vtable in C++

Possible Duplicate: why do I need virtual table? What is vtAble in C++. Got to know vtable is a virtual table which has an array of pointers to virtual functions. Is there a article with practical implementation. Any walk through is greatly appreciated. ...

How are vtables implemented in c++ and c#?

Lets have this situation (in c++, in c# classes A,B are interfaces): class A { virtual void func() = 0; }; class B { virtual void func() = 0; }; class X: public A, public B { virtual void func(){ var = 1; } int var;}; X * x = new X; // from what I know, x have 2 vtables, is this the same in c#? A * a = (A*)x; // a == x B * b = (B*)x; /...

C++ v-table: Part of the language or compiler dependent?

Is the v-table (virtual method table) a part of the C++ specification, or is it up to the compiler to solve the virtual method lookups? In case it's part of the spec: Why? (I'd guess that it's compiler dependent, but someone said to me that it's part of the spec.) (References are very welcome!) ...

API Hook on a COM object function?

Greetings StackOverflowians, As discovered here, Windows 7 features a bug in which the DISPID_BEFORENAVIGATE2 event does not fire for Windows Explorer instances. This event allows shell extensions to be notified when a navigation is about to take place, and (most importantly for me) have the opportunity to cancel the navigation. I've ...

How can a base class satisfy the definition of a parent's pure virtual function using another parent's function (C++)

I am extending an existing C++ project. I have a base class that derives from two parent classes. One of the parents has a pure virtual function. I want that pure virtual function to be defined by a function implemented in the other parent. So, I want another parent to satisfy the base class's obligation to define a parent's pure vir...

No "add esp,4" for virtual functions returning std::string

I've been looking at DynObj and decided to do my own experimentation with vftables. I'm working with Visual Studio 2010 and created a console main that instantiates an object with a virtual function that returns an std::string. The test code in main attempts to call the object's public virtual function using a pointer obtained from the...

Virtual dispatch implementation details

First of all, I want to make myself clear that I do understand that there is no notion of vtables and vptrs in the C++ standard. However I think that virtually all implementations implement the virtual dispatch mechanism in pretty much the same way (correct me if I am wrong, but this isn't the main question). Also, I believe I know how v...