version: Always load library as a data file as native does

Dmitry Timoshkov dmitry at codeweavers.com
Thu Jan 31 00:15:35 CST 2008


Hello,

here is a comment I've added in the bug 7116:

The problem seems to be related to the fact that GetFileVersionInfoXXXX APIs
may trash the refcount of loaded DLLs. That happens because GetModuleHandleExW
increments the refcount *only* for the library handle passed to it, but
FreeLibrary which gets called later decrements refcounts for each linked in
library. This may imply a  bug in GetModuleHandleExW.

However. The testing with native version.dll shows that it doesn't care
about already loaded modules and always loads the library as a data file,
i.e calls LoadLibraryExW(filename, 0, LOAD_LIBRARY_AS_DATAFILE);

Changelog:
    version: Always load library as a data file as native does.

diff --git a/dlls/version/info.c b/dlls/version/info.c
index 935d0c1..09cde6a 100644
--- a/dlls/version/info.c
+++ b/dlls/version/info.c
@@ -246,8 +246,7 @@ static DWORD VERSION_GetFileVersionInfo_PE( LPCWSTR filename, DWORD datasize, LP
 
     TRACE("%s\n", debugstr_w(filename));
 
-    if (!GetModuleHandleExW(0, filename, &hModule))
-	hModule = LoadLibraryExW(filename, 0, LOAD_LIBRARY_AS_DATAFILE);
+    hModule = LoadLibraryExW(filename, 0, LOAD_LIBRARY_AS_DATAFILE);
 
     if(!hModule)
     {





More information about the wine-patches mailing list