I am fixing up someone else’s code and noticed that the person calls LoadLibrary several times, as per below:
LoadLibrary("C:\\Windows\\SysWOW64\\msjint40");
LoadLibrary("C:\\Windows\\SysWOW64\\msjtes40");
LoadLibrary("C:\\Windows\\SysWOW64\\expsrv");
What is the point of this? The return pointers are not saved! The program later then calls a bunch of other DLL’s that do use functions from MSJTES40, but not in the context of where the libraries are loaded.
The comment says – "else preload to optimize", but how does the rest of the program know where the DLL’s are?
Thanks for any info.
LoadLibrarybrings the specified module into the address space. Libraries can’t be loaded twice, so doing this causes the preload (the loaded module may have other dependencies) so this could be viewed as an optimization. The second call to the library (where they use the return value) should complete faster.See the documentation
Also from the documentation.
Assuming a hard-coded DLL location opens your program up to all sorts of mischief!