By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,993 Members | 1,898 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,993 IT Pros & Developers. It's quick & easy.

DLL Base Address VTABLEs and COM

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.