473,395 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

DLL Base Address VTABLEs and COM

Hello,

Apologies for being slightly off topic - but this group seems the best
fit for the question.

How does the compiler handle the problem of not knowing which address a
DLL will be loaded at when it tries to resolve calls to virtual
functions via the vtable?

Does the vtable hold pointers relative to itself or to the dll in which
it resides?

If the compiler places absolute memory addresses in the vtable there is
no guarantee these will be correct when the dll is loaded at a
different address than expected?

I am trying to write a COM client "manually" without using windows api
or vc++ compiler features as a learning exercise - I think I am missing
a bit of pointer arithmetic to get the last step to work.

All the best,

John

Apr 28 '06 #1
2 2376
fi*****@btinternet.com wrote:
Hello,

Apologies for being slightly off topic - but this group seems the best
fit for the question.

How does the compiler handle the problem of not knowing which address a
DLL will be loaded at when it tries to resolve calls to virtual
functions via the vtable?

Does the vtable hold pointers relative to itself or to the dll in which
it resides?

If the compiler places absolute memory addresses in the vtable there is
no guarantee these will be correct when the dll is loaded at a
different address than expected?

I am trying to write a COM client "manually" without using windows api
or vc++ compiler features as a learning exercise - I think I am missing
a bit of pointer arithmetic to get the last step to work.

All the best,

John


It's not the best fit. Try microsoft.public.vc.language
Apr 28 '06 #2
In message <11**********************@g10g2000cwb.googlegroups .com>,
fi*****@btinternet.com writes
Hello,

Apologies for being slightly off topic - but this group seems the best
fit for the question.
Something (highly) platform-specific would be better... but there are
generic answers:
How does the compiler handle the problem of not knowing which address a
DLL will be loaded at when it tries to resolve calls to virtual
functions via the vtable?
The same way it handles the problem of not knowing which address the
functions within any executable program will be loaded at, and the same
way it handles function pointers. Somewhere within the object code it
generates there will be information about pointers that need to be
adjusted when the executable code is loaded. How this is done is
platform-specific.
Does the vtable hold pointers relative to itself or to the dll in which
it resides?

If the compiler places absolute memory addresses in the vtable there is
no guarantee these will be correct when the dll is loaded at a
different address than expected?
There is no "expected" address. The program-loading mechanism provided
by the OS, in conjunction with the data output by the compiler, ensures
that by the time the program starts running, all its addresses have been
adjusted to contain the correct values.
I am trying to write a COM client "manually" without using windows api
or vc++ compiler features as a learning exercise
In platform-neutral terms, you have an array of pointers to functions.
So long as the compiler is aware of that, all the necessary adjustments
should happen automatically.
- I think I am missing
a bit of pointer arithmetic to get the last step to work.

--
Richard Herring
May 2 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Steve Guidos | last post by:
We are writing a set of Windows Services using C#.NET that will run on the same server. One of the developers here said that we should assign each service its own Base Address using the Properties...
1
by: Rene | last post by:
I keep reading about this vTables and it's killing me because I am not sure what they are. I have a feeling that vTables are used when you override virtual methods or properties but I really have...
12
by: sojin | last post by:
Hi all, I'm a new to c++... and I've some doubts on "virtual" topics. 1) Can abstract base class have V-table? Here's the way,, Class CTemp{
6
by: Todd A. Anderson | last post by:
I have a function foo of which I need to get the address. The problem is that when you say "&foo" (or just foo for that matter), you get the address of this function's entry in a jump table and...
32
by: moleskyca1 | last post by:
This may be stupid question, but why is sizeof(Base) == 1 in: int main(int argc, char* argv) { class Base { }; cout << sizeof(Base) << endl; return 0; }
3
by: Newish | last post by:
Hi Regarding DLL base address: 1) What does it mean? 2) Should it ever be changed? 3) What are the rules to change it?
4
by: RashmiS | last post by:
Hi! Are vtables created for two classes which has a common derived class and a common base class ( virtual base class) ? Please explain.
12
by: bgold | last post by:
Hey. I have a base class (SPRITE), and using this base class I have derived a large number of derived classes (PERSON, BULLET, MISSILE, etc.). Now, at a certain point in my program, I have a pair...
0
by: =?Utf-8?B?Zmplcm9uaW1v?= | last post by:
Hi all, As I mentioned in a previous thread (see 'Dbghelp, symbols and templates' in microsoft.public.windbg), we created a powerful symbol engine using dbghelp to dump the contents of the stack...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.