Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 977851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:58:09+00:00 2026-05-16T03:58:09+00:00

Although the problem at hand is solved , it has me a little confused

  • 0

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

  1. Two separate VC6.0 projects: one for an exe, one for a dll.
  2. Application contains .lib, .dll and .h files from dll project releases.
  3. When a new release is ready, the .lib, .dll, and .h files are copied into the exe project from the dll project.
  4. I have inherited this scheme.

Problem:

I recently made a changes to the DLL and copied over the .lib and .dll but forgot to copy the header files. There had been some hierarchy changes and, as a result, the vtable for one particular class (call it InternalClass) had changed.

The exe does not directly invoke any methods on InternalClass. Instead, it creates an instance of a different class (call it InterfaceClass) which encapsulates a pointer to an InternalClass object and invokes various methods against that pointer.

At runtime, calls made from within InterfaceClass methods to InternalClass methods were actually invoking the wrong methods (i.e. InterfaceClass would invoke InternalClass::A and InternalClass::B would actually run). Looking at the asm, it turns out that the fixup or thunk (I’m sorry if this is the wrong jargon!) was using the correct offset into the vtable. However, the vtable itself contained the list of pointers you would expect from the old header files.

Actual Question:

I realized my mistake, copied the header files over, recompiled and all was well. However, I am left with one nagging question:

When is the layout for the vtables determined and what information is used to construct the vtable for these classes at runtime? That is, it seems to me that the proper vtable must have been assembled when the dll was compiled so that the offsets, etc could be used for the calls from InterfaceClass to InternalClass. Why, then, was an outdated vtable used at runtime? Is the layout also determined separately when the exe is compiled using the headers it has?

I’m not sure if this is at all clear. Let me know if what I’m asking is too convoluted. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T03:58:09+00:00Added an answer on May 16, 2026 at 3:58 am

    Hmm, heavy duty implementation details of a 12 year old compiler. When you use __declspec(dllexport) on a class, the linker exports the members of the class. Not the vtable. That gets reconstructed in the client of the class when the compiler parses the class declaration in the header file. The linker fills in that local vtable with the exported members addresses.

    Would it work better if the compiler simply exported the vtable from the DLL? Maybe, but exporting such implementation details is awfully brittle. The fear of painting yourself into a corner that you cannot get out of because of backwards compatibility is a strong motivator, I imagine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The problem is not solved although I accepted one answer. Problem: Vim updates very
I hope this is a relatively easy problem although I have spent hours websearching
Although I have found some solutions to this problem, none of them refer to
although I searched through existing threads for my problem I havent found a solution
i am trying to work out the following problem in Java (although it could
This is a really strange problem, that appears to be somewhat intermittent (although it
I have a pretty big problem with my TabHost. Although I have declared all
ACL seems to be very confusing and never problem-free. Although, I've had no major
There is an interesting problem at hand. I have a role-playing MMOG running through
I have problem with parsing XML. I parsed data of cities, Amsterdam & Den

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.