Re: How to get imagebase after a DLL gets loaded
- From: "anton bassov" <soviet_bloke@xxxxxxxxxxx>
- Date: 19 Dec 2006 22:30:05 -0800
David,
Anton, "library" != DLL.
This is true. However, we are speaking *STRICTLY* about DLLs here - as
I have said in my earlier reply to Kevin, if Will had said that he
plans to use his approach from within a static library, there would
have been no discussion whatsoever. However, Will *EXPLICITLY* said
that he wants to use his approach in a DLL, and Kevin says that Will's
approach is very usefull "when one does not want to share variables
between library and its client code".
In other words, all Kevin's "methodology" of sharing variables between
a library and its client code is meant to be used within DLL -
otherwise, from his perspective, there is just nothing to argue
about...
When you link with a static library, it's similar to linking with an
.obj file, so the names of variables are important. And you don't even
need to resolve all externals before creating a static library .lib
output file, because the linker will do that later when it links your
.lib with the client code (DLL or EXE or possibly another static
library).
If you don't believe me, try creating a static library with the
following code:
extern int nClientValue;
int GetModifiedClientValue(void)
{
return (nClientValue + 2);
}
Then create an EXE that links against it. If you try to link without
declaring the variable with the *exact name* "nClientValue", your client
(EXE) module will fail to link. If you then declare the variable, you
can verify that it doesn't create a DLL dependency (since you never
built one) and GetModifiedClientValue actually uses the value you set in
your client (EXE) code.
This is the situation that Kevin has been talking about this whole time,
only replace "nClientValue" with "hInstance", et al.
To be honest, I don't really know what he was talking about (I am still
in shock after having read his "advice" on drivers NG - check
http://groups.google.com/group/microsoft.public.development.device.drivers/browse_frm/thread/a484fb6537ec8d21/5cd43949b2311ccc?hl=en#5cd43949b2311ccc),
but if he spoke about
static library.... well, then it is even more ridiculous, taking into
account my statement earlier on the thread (i.e. the one that I would
have no objections to anything if we were speaking about static
libraries).
You can compile code to a static library (.lib
file) and link against it -- no DLLs required. It's a quite common
technique in user mode programming.
This is true as well. However, once we speak about DLLs here, how is it
related to this particular discussion?????
I strongly suggest you google the term "static
library"
No need - I know what it is
and learn something before putting your foot in your mouth again.
It looks like, on this particular occasion, it was you and not me who
put your foot into your mouth - you jumped into a discussion without
even having bothered yourself to read this thread properly, and, as a
result, came up with totally irrelevant post (although technically
correct one - I don't argue about it)
Anton Bassov
David Jones wrote:
anton bassov <soviet_bloke@xxxxxxxxxxx> wrote...
Kevin,
Again, nonsense - the only things linker deals with are EXPORTS.....
During the process of building the DLL, the linker deals with EXTERNs.
..... and these EXTERNs happen to be EXPORTS of some other libary that
your DLL links against. They cannot be in the client code, simply
because it is client code who links against your library and not the
other way around. Apparently, you just don't know it, but when you link
against some library, you need to have its .lib file, and this .lib
file just cannot get built until all externals its source refers to are
resolved....
Anton, "library" != DLL. You can compile code to a static library (.lib
file) and link against it -- no DLLs required. It's a quite common
technique in user mode programming.
When you link with a static library, it's similar to linking with an
.obj file, so the names of variables are important. And you don't even
need to resolve all externals before creating a static library .lib
output file, because the linker will do that later when it links your
.lib with the client code (DLL or EXE or possibly another static
library).
If you don't believe me, try creating a static library with the
following code:
extern int nClientValue;
int GetModifiedClientValue(void)
{
return (nClientValue + 2);
}
Then create an EXE that links against it. If you try to link without
declaring the variable with the *exact name* "nClientValue", your client
(EXE) module will fail to link. If you then declare the variable, you
can verify that it doesn't create a DLL dependency (since you never
built one) and GetModifiedClientValue actually uses the value you set in
your client (EXE) code.
This is the situation that Kevin has been talking about this whole time,
only replace "nClientValue" with "hInstance", et al.
If you think about it carefully, you will understand that *EVERYTHING*
you said in your post is plain nonsense.
I am really sorry, but you have to educate yourself before you start
posting messages - otherwise, you are just bound to make nonsensical
inputs.....
Took the words right out of my mouth, Anton. Kevin tried to explain it
to you already, but I strongly suggest you google the term "static
library" and learn something before putting your foot in your mouth
again.
David
.
- Follow-Ups:
- Re: How to get imagebase after a DLL gets loaded
- From: David Jones
- Re: How to get imagebase after a DLL gets loaded
- References:
- Re: How to get imagebase after a DLL gets loaded
- From: anton bassov
- Re: How to get imagebase after a DLL gets loaded
- From: William DePalo [MVP VC++]
- Re: How to get imagebase after a DLL gets loaded
- From: anton bassov
- Re: How to get imagebase after a DLL gets loaded
- From: William DePalo [MVP VC++]
- Re: How to get imagebase after a DLL gets loaded
- From: anton bassov
- Re: How to get imagebase after a DLL gets loaded
- From: William DePalo [MVP VC++]
- Re: How to get imagebase after a DLL gets loaded
- From: anton bassov
- Re: How to get imagebase after a DLL gets loaded
- From: William DePalo [MVP VC++]
- Re: How to get imagebase after a DLL gets loaded
- From: anton bassov
- Re: How to get imagebase after a DLL gets loaded
- From: William DePalo [MVP VC++]
- Re: How to get imagebase after a DLL gets loaded
- From: anton bassov
- Re: How to get imagebase after a DLL gets loaded
- From: Kevin
- Re: How to get imagebase after a DLL gets loaded
- From: anton bassov
- Re: How to get imagebase after a DLL gets loaded
- From: Kevin
- Re: How to get imagebase after a DLL gets loaded
- From: anton bassov
- Re: How to get imagebase after a DLL gets loaded
- From: Kevin
- Re: How to get imagebase after a DLL gets loaded
- From: anton bassov
- Re: How to get imagebase after a DLL gets loaded
- From: David Jones
- Re: How to get imagebase after a DLL gets loaded
- Prev by Date: Re: GetModuleHandle of Comdlg32.dll
- Next by Date: Re: Saving lots of files....
- Previous by thread: Re: How to get imagebase after a DLL gets loaded
- Next by thread: Re: How to get imagebase after a DLL gets loaded
- Index(es):
Relevant Pages
|
Loading