Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DLL Reference count and entry point

108 views
Skip to first unread message

Paolo Severini

unread,
Mar 20, 2001, 8:38:01 AM3/20/01
to
Hello kernel gurus,
two questions for you:

1. given a process, is there a way to know what is the reference count
of each DLL in the process?

2. given a DLL loaded in a process, is there a way to change its entry
point and intercept the OS calls to DllMain (DLL_PROCESS_DETACH)?

Thanks in advance,

-- Paolo


Michael (michka) Kaplan

unread,
Mar 20, 2001, 8:58:25 AM3/20/01
to
For #1, there is not really, a supported way, no.

For #2, unless the DllMain entry point is exported, then the answer is
generally no, since you have no idea *where* the function might be! Even if
it is exported, the effort required to write to the read-only section of
memory containing the code is pretty hacky. :-(

What are you trying to do, specifically? Maybe there is a better way?

--
MichKa

the only book on internationalization in VB at
http://www.i18nWithVB.com/

"Paolo Severini" <pao...@ares.omninet.it> wrote in message
news:#gUJrJUsAHA.1636@tkmsftngp05...

Paolo Severini

unread,
Mar 20, 2001, 9:29:13 AM3/20/01
to
Thanks for your answer.
I'm trying to write a DLL that, once loaded in a process, hooks
one (or more) functions exported by a DLL in *all* the modules
in the process that import it.
I've hooked LoadLibrary[Ex]A/W to detect when a module is
loaded at run-time, but I'd like to hook FreeLibrary, too, to do
some bookkeeping when a module is released.
But I'm having some problems with FreeLibrary because before
calling the 'true' FreeLibary I can't be sure that the module will
be really released since I don't know its ref count...

Thanks again for your help,

-- Paolo


"Michael (michka) Kaplan" <forme...@spamfree.trigeminal.nospam.com> wrote
in message news:uHdqWXUsAHA.2344@tkmsftngp05...

Michael (michka) Kaplan

unread,
Mar 20, 2001, 9:31:58 AM3/20/01
to
If you are hooking LoadLibrary than you have the refcount!

--
MichKa

the only book on internationalization in VB at
http://www.i18nWithVB.com/

"Paolo Severini" <pao...@ares.omninet.it> wrote in message

news:OBxMmmUsAHA.2152@tkmsftngp03...

Paolo Severini

unread,
Mar 20, 2001, 10:14:47 AM3/20/01
to
Not if I attach my DLL to a running process with a system wide hook.

-- paolo


"Michael (michka) Kaplan" <forme...@spamfree.trigeminal.nospam.com> wrote

in message news:umYzGqUsAHA.320@tkmsftngp05...

Michael (michka) Kaplan

unread,
Mar 20, 2001, 11:39:08 AM3/20/01
to
The refcount is not really available in any kind of documented way. And even
if you find the undocumented way, the hooks are hardly guaranteed to be the
same on all platforms....

--
MichKa

the only book on internationalization in VB at
http://www.i18nWithVB.com/

"Paolo Severini" <pao...@ares.omninet.it> wrote in message

news:e3ZOv$UsAHA.1456@tkmsftngp04...

0 new messages