dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Track vptr to VTABLE during object construction through inheritance chain...

  1. #1
    Join Date
    Oct 2005
    Posts
    22

    Question Track vptr to VTABLE during object construction through inheritance chain...

    I have a certain inheritance chain, when i make an object of any class in this chain, i want to include code in the constructors so that i can TRACK the initialization of vptrs through the inheritance chain from the most base to the current class!! i dont have any clue how i can really access vptr inside the object?? anybody if have any idea about accessing vptr, the pointer which points to the VTABLE, the table of addresses of virtual functions of the class, please help me...!!! :WAVE:

  2. #2
    Join Date
    Nov 2003
    Posts
    4,118
    you can't track the vptr initiailzation directly because the relevant code is "injected" as assembly directives straight into the prolog of the constructor. If you are convesrant in assmbly, you can disassemble the code of a constructor call and see the relevant parts. Notice that many modern linkers nowadays use a special segment for constructors and destructors so if you know how to read the .exe format of your platform, you can locate this segment and see what's going on.
    The vptr itself is located either at offset 0, i.e., it's the first data member of the object, occupying 4 bytes. This convention is used by most Windows compilers. On POSIX systems, the vptr is located at the end of the object, i.e., sizeof(obj) -sizeof(int). After initialization, this piece of data contains the address of the vtable.
    Danny Kalev

Similar Threads

  1. Even C++ had this much right...
    By Derek Mooney in forum .NET
    Replies: 94
    Last Post: 10-29-2001, 09:44 PM
  2. Object refs - vTable or what?
    By Paul Mc in forum .NET
    Replies: 2
    Last Post: 09-27-2001, 01:39 AM
  3. Replies: 3
    Last Post: 09-11-2001, 05:06 AM
  4. Validating XML
    By Jaco de Villiers in forum XML
    Replies: 1
    Last Post: 06-01-2001, 05:50 PM
  5. Re: COM object Password Security
    By Tom Shreve in forum Enterprise
    Replies: 0
    Last Post: 04-07-2000, 08:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center