Comments on: Overriding the virtual table in a C++ object https://moythreads.com/wordpress/2007/09/14/overriding-the-virtual-table-in-a-c-object/ Abandon All Hope, Ye Who Read This Blog Fri, 14 Aug 2020 20:06:49 +0000 hourly 1 https://wordpress.org/?v=5.1.9 By: moy https://moythreads.com/wordpress/2007/09/14/overriding-the-virtual-table-in-a-c-object/comment-page-1/#comment-1837 Tue, 22 Oct 2013 14:47:22 +0000 http://www.moythreads.com/wordpress/2007/09/14/overriding-the-virtual-table-in-a-c-object/#comment-1837 @Leonard: That sounds like a cool hack! … thanks for sharing

]]>
By: Leonard https://moythreads.com/wordpress/2007/09/14/overriding-the-virtual-table-in-a-c-object/comment-page-1/#comment-1743 Wed, 28 Aug 2013 00:27:23 +0000 http://www.moythreads.com/wordpress/2007/09/14/overriding-the-virtual-table-in-a-c-object/#comment-1743 There definitely is a use. If you want to call a virtual member function of a class with a non-compatible compiler (one that stores/handle virtual classes or its members differently) then this is just a first step. The second step is to realize that most, if not all, C++ class member functions get passed a hidden *this pointer, and depending on how it’s done for a specific compiler usually means putting in ASM code to do it before making the actual call. The third step is to make sure you’re using the correct calling convention. In MSVC++ for example, the default calling convention for class member functions is __stdcall, not __cdecl.

I had to do this when I needed to call Winamp’s WASABI classes, which is compiled with MSVC++, from a Borland C++ Builder 5 compiled plugin, which handles classes and class member functions differently from MSVC++.

]]>