Add version information (16 and 32 bit) to core built-in dlls

Dmitry Timoshkov dmitry at sloboda.ru
Mon Feb 19 09:02:11 CST 2001


Hello.

This patch fixes a long standing problem that applications
can not query version information for built-in dlls.

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    Add version information (16 and 32 bit) to core built-in dlls:
    krnl386.exe/kernel32.dll, user.exe/user32.dll, gdi.exe/gdi32.dll.
    Provide a way for reading version information using standard API:
    GetFileVersionInfoSize -> GetFileVersionInfo -> VerQueryValue.

diff -u cvs/wine/dlls/gdi/Makefile.in wine/dlls/gdi/Makefile.in
--- cvs/wine/dlls/gdi/Makefile.in	Sat Dec  2 17:08:47 2000
+++ wine/dlls/gdi/Makefile.in	Sat Feb 17 19:30:59 2001
@@ -14,6 +14,10 @@
 	thunk.c \
 	wing.c
 
+RC_SRCS= \
+	version.rc \
+	version16.rc
+
 GLUE = printdrv.c thunk.c
 
 EXTRA_OBJS = \
@@ -34,6 +38,13 @@
 
 $(EXTRA_OBJS): dummy
 	@cd `dirname $@` && $(MAKE) `basename $@`
+
+# Special rules for 16-bit resource files
+
+version16.res: version16.rc
+	$(LDPATH) $(WRC) $(DIVINCL) -o $@ -w16 -m -r $(SRCDIR)/version16.rc
+
+gdi.spec.c: version16.res
 
 ### Dependencies:
 
diff -u cvs/wine/dlls/gdi/gdi.spec wine/dlls/gdi/gdi.spec
--- cvs/wine/dlls/gdi/gdi.spec	Sat Dec 16 14:58:56 2000
+++ wine/dlls/gdi/gdi.spec	Sat Feb 17 19:16:25 2001
@@ -3,6 +3,7 @@
 heap	65488  # 65536 - 16 (instance data) - 32 (stock objects)
 file	gdi.exe
 owner	gdi32
+rsrc	version16.res
 
 1   pascal   SetBkColor(word long) SetBkColor16
 2   pascal16 SetBkMode(word word) SetBkMode16
diff -u cvs/wine/dlls/gdi/gdi32.spec wine/dlls/gdi/gdi32.spec
--- cvs/wine/dlls/gdi/gdi32.spec	Fri Dec 29 15:12:07 2000
+++ wine/dlls/gdi/gdi32.spec	Sat Feb 17 20:01:56 2001
@@ -1,6 +1,7 @@
 name    gdi32
 type    win32
 init    MAIN_GdiInit
+rsrc	version.res
 
 import	advapi32.dll
 import	kernel32.dll
diff -u cvs/wine/dlls/gdi/version.rc wine/dlls/gdi/version.rc
--- /dev/null	Wed May  6 05:32:27 1998
+++ wine/dlls/gdi/version.rc	Sat Feb 17 19:50:47 2001
@@ -0,0 +1,5 @@
+#define WINE_FILEVERSION_STR "1.0"
+#define WINE_FILEDESCRIPTION_STR "Wine core dll"
+#define WINE_FILENAME_STR "gdi32.dll"
+
+#include "wine/wine_common_ver.rc"
diff -u cvs/wine/dlls/gdi/version16.rc wine/dlls/gdi/version16.rc
--- /dev/null	Wed May  6 05:32:27 1998
+++ wine/dlls/gdi/version16.rc	Sat Feb 17 19:50:57 2001
@@ -0,0 +1,5 @@
+#define WINE_FILEVERSION_STR "1.0"
+#define WINE_FILEDESCRIPTION_STR "Wine core dll"
+#define WINE_FILENAME_STR "gdi.exe"
+
+#include "wine/wine_common_ver.rc"
diff -u cvs/wine/dlls/kernel/Makefile.in wine/dlls/kernel/Makefile.in
--- cvs/wine/dlls/kernel/Makefile.in	Thu Jan 11 11:23:06 2001
+++ wine/dlls/kernel/Makefile.in	Sat Feb 17 20:05:07 2001
@@ -38,4 +38,11 @@
 
 kernel.res: $(MC_SRCS:.mc=.mc.rc)
 
+# Special rules for 16-bit resource files
+
+version16.res: version16.rc
+	$(LDPATH) $(WRC) $(DIVINCL) -o $@ -w16 -m -r $(SRCDIR)/version16.rc
+
+kernel.spec.c: version16.res
+
 ### Dependencies:
diff -u cvs/wine/dlls/kernel/kernel.rc wine/dlls/kernel/kernel.rc
--- cvs/wine/dlls/kernel/kernel.rc	Wed Nov  8 14:47:31 2000
+++ wine/dlls/kernel/kernel.rc	Sat Feb 17 19:52:30 2001
@@ -1,3 +1,5 @@
 #include "locale_rc.rc"
 
 #include "messages/winerr_enu.mc.rc"
+
+#include "version.rc"
diff -u cvs/wine/dlls/kernel/kernel.spec wine/dlls/kernel/kernel.spec
--- cvs/wine/dlls/kernel/kernel.spec	Fri Jan  5 15:21:58 2001
+++ wine/dlls/kernel/kernel.spec	Sat Feb 17 19:53:33 2001
@@ -2,6 +2,7 @@
 type	win16
 file	krnl386.exe
 owner	kernel32
+rsrc    version16.res
 
 # 1-207 are the basic functions, those are (with minor variations)
 # present in win31, win95 and nt351
diff -u cvs/wine/dlls/kernel/kernel32.spec wine/dlls/kernel/kernel32.spec
--- cvs/wine/dlls/kernel/kernel32.spec	Thu Feb 15 19:19:39 2001
+++ wine/dlls/kernel/kernel32.spec	Sat Feb 17 19:08:49 2001
@@ -973,6 +973,7 @@
 @ stdcall LoadModule16(str long) LoadModule16
 @ stdcall LoadResource16(long long) LoadResource16
 @ stdcall LockResource16(long) LockResource16
+@ stdcall SizeofResource16(long long) SizeofResource16
 @ stdcall WinExec16(str long) WinExec16
 @ stdcall GlobalFlags16(long) GlobalFlags16
 @ stdcall GlobalReAlloc16(long long long) GlobalReAlloc16
diff -u cvs/wine/dlls/kernel/version.rc wine/dlls/kernel/version.rc
--- /dev/null	Wed May  6 05:32:27 1998
+++ wine/dlls/kernel/version.rc	Sat Feb 17 19:52:42 2001
@@ -0,0 +1,5 @@
+#define WINE_FILEVERSION_STR "1.0"
+#define WINE_FILEDESCRIPTION_STR "Wine core dll"
+#define WINE_FILENAME_STR "kernel32.dll"
+
+#include "wine/wine_common_ver.rc"
diff -u cvs/wine/dlls/kernel/version16.rc wine/dlls/kernel/version16.rc
--- /dev/null	Wed May  6 05:32:27 1998
+++ wine/dlls/kernel/version16.rc	Sat Feb 17 19:52:59 2001
@@ -0,0 +1,5 @@
+#define WINE_FILEVERSION_STR "1.0"
+#define WINE_FILEDESCRIPTION_STR "Wine core dll"
+#define WINE_FILENAME_STR "krnl386.exe"
+
+#include "wine/wine_common_ver.rc"
diff -u cvs/wine/dlls/user/Makefile.in wine/dlls/user/Makefile.in
--- cvs/wine/dlls/user/Makefile.in	Fri Dec  1 04:31:42 2000
+++ wine/dlls/user/Makefile.in	Sat Feb 17 20:07:28 2001
@@ -26,7 +26,8 @@
 RC_SRCS = \
 	resources/display.rc \
 	resources/mouse.rc \
-	resources/user32.rc
+	resources/user32.rc \
+	resources/version16.rc
 
 GLUE = thunk.c
 
@@ -54,8 +55,13 @@
 resources/mouse.res: resources/mouse.rc
 	$(LDPATH) $(WRC) $(DIVINCL) -o $@ -w16 -m -r $(SRCDIR)/resources/mouse.rc
 
+resources/version16.res: resources/version16.rc
+	$(LDPATH) $(WRC) $(DIVINCL) -o $@ -w16 -m -r $(SRCDIR)/resources/version16.rc
+
 display.spec.c: resources/display.res
 
 mouse.spec.c: resources/mouse.res
+
+user.spec.c: resources/version16.res
 
 ### Dependencies:
diff -u cvs/wine/dlls/user/resources/user32.rc wine/dlls/user/resources/user32.rc
--- cvs/wine/dlls/user/resources/user32.rc	Sat Jan 20 19:00:42 2001
+++ wine/dlls/user/resources/user32.rc	Sat Feb 17 19:34:28 2001
@@ -49,3 +49,5 @@
 #include "resources/user32_Wa.rc"
 #include "resources/user32_Ja.rc"
 #include "resources/user32_Zh.rc"
+
+#include "resources/version.rc"
diff -u cvs/wine/dlls/user/resources/version.rc wine/dlls/user/resources/version.rc
--- /dev/null	Wed May  6 05:32:27 1998
+++ wine/dlls/user/resources/version.rc	Sat Feb 17 19:47:03 2001
@@ -0,0 +1,5 @@
+#define WINE_FILEVERSION_STR "1.0"
+#define WINE_FILEDESCRIPTION_STR "Wine core dll"
+#define WINE_FILENAME_STR "user32.dll"
+
+#include "wine/wine_common_ver.rc"
diff -u cvs/wine/dlls/user/resources/version16.rc wine/dlls/user/resources/version16.rc
--- /dev/null	Wed May  6 05:32:27 1998
+++ wine/dlls/user/resources/version16.rc	Sat Feb 17 19:49:48 2001
@@ -0,0 +1,5 @@
+#define WINE_FILEVERSION_STR "1.0"
+#define WINE_FILEDESCRIPTION_STR "Wine core dll"
+#define WINE_FILENAME_STR "user.exe"
+
+#include "wine/wine_common_ver.rc"
diff -u cvs/wine/dlls/user/user.spec wine/dlls/user/user.spec
--- cvs/wine/dlls/user/user.spec	Wed Jan 31 20:43:51 2001
+++ wine/dlls/user/user.spec	Sat Feb 17 19:35:44 2001
@@ -3,6 +3,7 @@
 heap	65520
 file	user.exe
 owner	user32
+rsrc	resources/version16.res
 
 1   pascal16 MessageBox(word str str word) MessageBox16
 2   stub OldExitWindows
diff -u cvs/wine/dlls/version/info.c wine/dlls/version/info.c
--- cvs/wine/dlls/version/info.c	Sat Feb 17 17:37:59 2001
+++ wine/dlls/version/info.c	Sun Feb 18 13:54:13 2001
@@ -260,6 +260,160 @@
                 info16->wLength, info16, child16 );
 }
 
+/***********************************************************************
+ *           VERSION_GetFileVersionInfo_PE             [internal]
+ *
+ *    NOTE: returns size of the PE VERSION resource.
+ *    FIXME: handle is not used.
+ */
+static DWORD WINAPI VERSION_GetFileVersionInfo_PE( LPCSTR filename, LPDWORD handle,
+                                    DWORD datasize, LPVOID data )
+{
+    VS_FIXEDFILEINFO *vffi;
+    DWORD len;
+    BYTE *buf;
+    HMODULE hModule;
+    HRSRC hRsrc;
+    HGLOBAL hMem;
+    BOOL do_free_library = FALSE;
+
+    TRACE("(%s,%p)\n", debugstr_a(filename), handle );
+
+    hModule = GetModuleHandleA(filename);
+    if(!hModule)
+    {
+	hModule = LoadLibraryExA(filename, 0, LOAD_LIBRARY_AS_DATAFILE);
+	do_free_library = TRUE;
+    }
+    if(!hModule)
+    {
+	WARN("Could not load %s\n", debugstr_a(filename));
+	return 0;
+    }
+    hRsrc = FindResourceW(hModule,
+			  MAKEINTRESOURCEW(VS_VERSION_INFO),
+			  MAKEINTRESOURCEW(VS_FILE_INFO));
+    if(!hRsrc)
+    {
+	WARN("Could not find VS_VERSION_INFO in %s\n", debugstr_a(filename));
+	if(do_free_library) FreeLibrary(hModule);
+	return 0;
+    }
+    len = SizeofResource(hModule, hRsrc);
+    hMem = LoadResource(hModule, hRsrc);
+    if(!hMem)
+    {
+	WARN("Could not load VS_VERSION_INFO from %s\n", debugstr_a(filename));
+	if(do_free_library) FreeLibrary(hModule);
+	return 0;
+    }
+    buf = LockResource(hMem);
+
+    vffi = (VS_FIXEDFILEINFO *)VersionInfo32_Value( (VS_VERSION_INFO_STRUCT32 *)buf );
+
+    if ( vffi->dwSignature != VS_FFI_SIGNATURE )
+    {
+        WARN("vffi->dwSignature is 0x%08lx, but not 0x%08lx!\n",
+                   vffi->dwSignature, VS_FFI_SIGNATURE );
+        len = 0;
+	goto END;
+    }
+
+    if ( TRACE_ON(ver) )
+        print_vffi_debug( vffi );
+
+    if(data)
+    {
+	if(datasize >= len)
+	    memcpy(data, buf, len);
+	else
+	    len = 0;
+    }
+END:
+    FreeResource(hMem);
+    if(do_free_library) FreeLibrary(hModule);
+
+    return len;
+}
+
+/***********************************************************************
+ *           VERSION_GetFileVersionInfo_16             [internal]
+ *
+ *    NOTE: returns size of the 16-bit VERSION resource.
+ *    FIXME: handle is not used.
+ */
+static DWORD WINAPI VERSION_GetFileVersionInfo_16( LPCSTR filename, LPDWORD handle,
+                                    DWORD datasize, LPVOID data )
+{
+    VS_FIXEDFILEINFO *vffi;
+    DWORD len;
+    BYTE *buf;
+    HMODULE16 hModule;
+    HRSRC16 hRsrc;
+    HGLOBAL16 hMem;
+    BOOL do_free_library = FALSE;
+
+    TRACE("(%s,%p)\n", debugstr_a(filename), handle );
+
+    hModule = GetModuleHandle16(filename);
+    if(hModule < 32)
+    {
+	hModule = LoadLibrary16(filename);
+	do_free_library = TRUE;
+    }
+    if(hModule < 32)
+    {
+	WARN("Could not load %s\n", debugstr_a(filename));
+	return 0;
+    }
+    hRsrc = FindResource16(hModule,
+			  MAKEINTRESOURCEA(VS_VERSION_INFO),
+			  MAKEINTRESOURCEA(VS_FILE_INFO));
+    if(!hRsrc)
+    {
+	WARN("Could not find VS_VERSION_INFO in %s\n", debugstr_a(filename));
+	if(do_free_library) FreeLibrary16(hModule);
+	return 0;
+    }
+    len = SizeofResource16(hModule, hRsrc);
+    hMem = LoadResource16(hModule, hRsrc);
+    if(!hMem)
+    {
+	WARN("Could not load VS_VERSION_INFO from %s\n", debugstr_a(filename));
+	if(do_free_library) FreeLibrary16(hModule);
+	return 0;
+    }
+    buf = LockResource16(hMem);
+
+    if(!VersionInfoIs16(buf))
+	goto END;
+
+    vffi = (VS_FIXEDFILEINFO *)VersionInfo16_Value( (VS_VERSION_INFO_STRUCT16 *)buf );
+
+    if ( vffi->dwSignature != VS_FFI_SIGNATURE )
+    {
+        WARN("vffi->dwSignature is 0x%08lx, but not 0x%08lx!\n",
+                   vffi->dwSignature, VS_FFI_SIGNATURE );
+        len = 0;
+	goto END;
+    }
+
+    if ( TRACE_ON(ver) )
+        print_vffi_debug( vffi );
+
+    if(data)
+    {
+	if(datasize >= len)
+	    memcpy(data, buf, len);
+	else
+	    len = 0;
+    }
+END:
+    FreeResource16(hMem);
+    if(do_free_library) FreeLibrary16(hModule);
+
+    return len;
+}
 
 /***********************************************************************
  *           GetFileVersionInfoSizeA         [VERSION.2]
@@ -272,6 +426,11 @@
 
     TRACE("(%s,%p)\n", debugstr_a(filename), handle );
 
+    len = VERSION_GetFileVersionInfo_PE(filename, handle, 0, NULL);
+    if(len) return len;
+    len = VERSION_GetFileVersionInfo_16(filename, handle, 0, NULL);
+    if(len) return len;
+
     len = GetFileResourceSize16( filename,
                                  MAKEINTRESOURCEA(VS_FILE_INFO),
                                  MAKEINTRESOURCEA(VS_VERSION_INFO),
@@ -329,11 +488,16 @@
     TRACE("(%s,%ld,size=%ld,data=%p)\n",
                 debugstr_a(filename), handle, datasize, data );
 
+    if(VERSION_GetFileVersionInfo_PE(filename, &handle, datasize, data))
+	goto DO_CONVERT;
+    if(VERSION_GetFileVersionInfo_16(filename, &handle, datasize, data))
+	goto DO_CONVERT;
+
     if ( !GetFileResource16( filename, MAKEINTRESOURCEA(VS_FILE_INFO),
                                        MAKEINTRESOURCEA(VS_VERSION_INFO),
                                        handle, datasize, data ) )
         return FALSE;
-
+DO_CONVERT:
     if (    datasize >= sizeof(VS_VERSION_INFO_STRUCT16)
          && datasize >= ((VS_VERSION_INFO_STRUCT16 *)data)->wLength  
          && !VersionInfoIs16( data ) )
@@ -361,6 +525,11 @@
     TRACE("(%s,%ld,size=%ld,data=%p)\n",
                 debugstr_w(filename), handle, datasize, data );
 
+    if(VERSION_GetFileVersionInfo_PE(fn, &handle, datasize, data))
+	goto END;
+    if(VERSION_GetFileVersionInfo_16(fn, &handle, datasize, data))
+	goto END;
+
     if ( !GetFileResource16( fn, MAKEINTRESOURCEA(VS_FILE_INFO),
                                  MAKEINTRESOURCEA(VS_VERSION_INFO),
                                  handle, datasize, data ) )
@@ -373,7 +542,7 @@
         ERR("Cannot access NE resource in %s\n", debugstr_a(fn) );
         retv =  FALSE;
     }
-
+END:
     HeapFree( GetProcessHeap(), 0, fn );
     return retv;
 }
diff -u cvs/wine/include/wine/wine_common_ver.rc wine/include/wine/wine_common_ver.rc
--- /dev/null	Wed May  6 05:32:27 1998
+++ wine/include/wine/wine_common_ver.rc	Sat Feb 17 19:48:28 2001
@@ -0,0 +1,47 @@
+#include "winver.h"
+
+#ifndef WINE_FILEVERSION
+#define WINE_FILEVERSION 1,0,0,0
+#endif
+
+#ifndef WINE_FILEVERSION_STR
+#define WINE_FILEVERSION_STR "1.0"
+#endif
+
+#ifndef WINE_FILEDESCRIPTION_STR
+#define WINE_FILEDESCRIPTION_STR "Wine core dll"
+#endif
+
+#ifndef WINE_FILENAME_STR
+#define WINE_FILENAME_STR ""
+#endif
+
+VS_VERSION_INFO VERSIONINFO
+FILEVERSION    WINE_FILEVERSION
+PRODUCTVERSION 1,0,0,0
+FILEFLAGSMASK  0
+FILEFLAGS      0
+FILEOS         VOS_UNKNOWN
+FILETYPE       VFT_DLL
+FILESUBTYPE    VFT2_UNKNOWN
+{
+    BLOCK "StringFileInfo"
+    {
+	BLOCK "040904E4" /* LANG_ENGLISH/SUBLANG_DEFAULT, CP 1252 */
+	{
+	    VALUE "CompanyName", "Wine Team"
+	    VALUE "FileDescription", WINE_FILEDESCRIPTION_STR
+	    VALUE "FileVersion", WINE_FILEVERSION_STR
+	    VALUE "InternalName", WINE_FILENAME_STR
+	    VALUE "LegalCopyright", "Copyright (c) 1993-2001 the Wine project authors " \
+				    "(see the file AUTHORS for a complete list)"
+	    VALUE "OriginalFilename", WINE_FILENAME_STR
+	    VALUE "ProductName", "Wine"
+	    VALUE "ProductVersion", "1.0"
+	}
+    }
+    BLOCK "VarFileInfo"
+    {
+	VALUE "Translation", 0x0409, 0x04E4 /* LANG_ENGLISH/SUBLANG_DEFAULT, CP 1252 */
+    }
+}






More information about the wine-patches mailing list