Troubleshooting DLL loading

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Troubleshooting DLL loading

Richard Sargent
Administrator
I've spun this off from David Pennington's thread so that it can be more easily found.

There is a tool that can be very helpful in diagnosing load problems. It's located at http://www.dependencywalker.com/.


The following Smalltalk Do It can be helpful, as well. (There are Windows settings that would open a dialogue if there is a problem loading the DLL or its dependencies. The script doesn't mess with those settings, but could. See Microsoft's SetErrorMode function.)
 | module fileName |

fileName
:= GbsConfiguration current libraryName. "fileName can be fully qualified"
"get DLL handle to see if it is already loaded"
(module := OSHmodule getModuleHandle: fileName) isNull ifTrue:
 
["load the DLL"
 
module := OSHmodule loadLibrary: fileName].
module isNull
    ifTrue
: [self error: 'could not load the dll']
    ifFalse
: ["free the DLL"
       
module freeLibrary
            ifTrue
: ['success']
            ifFalse
: [self error: 'could not unload the dll']]





--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Troubleshooting DLL loading

Richard Sargent
Administrator
I'll add an extra tool to your arsenal. Microsoft's SysInternals tools include Process Monitor. (As of this writing, it can be found at https://docs.microsoft.com/en-us/sysinternals/downloads/procmon.)

Set the filter for abt.exe (or even your specific PID). Then try to load the file using the example I provided previously. Process Monitor will generate a lot of output, so be sure to use Edit/Clear Display to eliminate any previous noise.

Here is an example from trying to load the GemStone/S RPC DLL in C:\GemStone\2.4.8\fast\product\bin\libgcirpc64-248.dll. libgs64-248.dll was in the same directory but not getting found. You can see in the image where the system looked for it before finding in %PATH% (after I corrected the %GEMSTONE% environment variable to point at the right place).


On Friday, November 11, 2016 at 10:15:26 AM UTC-8, Richard Sargent wrote:
I've spun this off from David Pennington's thread so that it can be more easily found.

There is a tool that can be very helpful in diagnosing load problems. It's located at <a href="http://www.dependencywalker.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.dependencywalker.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNETTaaXPaIhbDC7oK2tpdwbB9Ku0w&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.dependencywalker.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNETTaaXPaIhbDC7oK2tpdwbB9Ku0w&#39;;return true;">http://www.dependencywalker.com/.


The following Smalltalk Do It can be helpful, as well. (There are Windows settings that would open a dialogue if there is a problem loading the DLL or its dependencies. The script doesn't mess with those settings, but could. See Microsoft's SetErrorMode function.)
 | module fileName |

fileName
:= GbsConfiguration current libraryName. "fileName can be fully qualified"
"get DLL handle to see if it is already loaded"
(module := OSHmodule getModuleHandle: fileName) isNull ifTrue:
 
["load the DLL"
 
module := OSHmodule loadLibrary: fileName].
module isNull
    ifTrue
: [self error: 'could not load the dll']
    ifFalse
: ["free the DLL"
       
module freeLibrary
            ifTrue
: ['success']
            ifFalse
: [self error: 'could not unload the dll']]





--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.