As you know, if the call to LoadLibrary specifies a DLL module already mapped into the address space of the calling process, the function simply returns a handle of the DLL and increments the module's reference count.
Somewhere, I need to get the reference count of a dll. How to get the dll's reference count? How to know where the dll was loaded? Thanks.
I googled it, and found this article which claims to provide the answer. Sorry I couldn't be more helpful:
If it is a non programmatic way (thanks to C.Johnson for giving that perspective), WinDBG could be helpful
http://windbg.info/doc/1-common-cmds.html#10_modules
Look at !dlls and it's variants.
!dll - all loaded modules with load count
EDIT 2:
If you want to know from where all the DLL is being loaded from the process, there are two ways:
a. Look at the command
"bu kernel32!LoadLibraryExW ";as /mu ${/v:MyAlias} poi(@esp+4); .if ( $spat( \"${MyAlias}\", \"MYDLL\" ) != 0 ) { kn; } .else { g }" "
in the above URL
b. Run the process under WinDBG. Debug->Even Filter and select "Load Module" and set it to "Enabled" under "Execution". Under "Continue" set it to "Not Handled".
One of these should help you definitely.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With