msvfw32: Fix enumeration of VFW video codecs that are registered in the registry.

Julien Muchembled jm at jm10.no-ip.com
Thu May 31 17:25:15 CDT 2007


Hello,


There are 2 ways to register a VFW video codec:
(1) the [drivers32] section of system.ini : "vidc.<FOURCC>=<dll_name>"
(2) the "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Drivers32" key:
    - value name: "vidc.<FOURCC>"
    - value data: "<dll_name>"

The current code of msvfw32 fails to enumerate codecs that are registered in the
registry because it enumerates keys (L127: RegEnumKeyExA) instead of values
(RegEnumValueA).
It doesn't even succeed to call RegEnumKeyExA because it only asked permission
to access values (L119: RegOpenKeyExA(KEY_QUERY_VALUE)).

The attached patch fixes this bug, solving many issues related to video codec
installation and apps like VirtualDub(Mod).

system.ini being deprecated, I also suggest to patch wine.inf to register codecs
in the registry.


Regards,
Julien Muchembled
-------------- next part --------------
Changelog:
	msvfw32: Fix enumeration of VFW video codecs that are registered in the
	registry.

--- a/dlls/msvfw32/msvideo_main.c
+++ b/dlls/msvfw32/msvideo_main.c
@@ -107,9 +107,8 @@
 static BOOL enum_drivers(DWORD fccType, enum_handler_t handler, void* param)
 {
     CHAR buf[2048], fccTypeStr[5], *s;
-    DWORD i, cnt = 0, bufLen, lRet;
+    DWORD i, cnt = 0, lRet;
     BOOL result = FALSE;
-    FILETIME lastWrite;
     HKEY hKey;
 
     fourcc_to_string(fccTypeStr, fccType);
@@ -119,14 +118,17 @@
     lRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE, HKLM_DRIVERS32, 0, KEY_QUERY_VALUE, &hKey);
     if (lRet == ERROR_SUCCESS) 
     {
-	DWORD numkeys;
-	RegQueryInfoKeyA( hKey, 0, 0, 0, &numkeys, 0, 0, 0, 0, 0, 0, 0);
-	for (i = 0; i < numkeys; i++) 
+	DWORD numvals, name, data, type;
+	RegQueryInfoKeyA( hKey, 0, 0, 0, 0, 0, 0, &numvals, 0, 0, 0, 0);
+	for (i = 0; i < numvals; i++)
 	{
-	    bufLen = sizeof(buf) / sizeof(buf[0]);
-	    lRet = RegEnumKeyExA(hKey, i, buf, &bufLen, 0, 0, 0, &lastWrite);
+	    name = 10;
+	    data = sizeof buf - name;
+	    type = REG_SZ;
+	    lRet = RegEnumValueA(hKey, i, buf, &name, 0, &type, (LPBYTE)(buf+name), &data);
 	    if (lRet != ERROR_SUCCESS) continue;
-	    if (strncasecmp(buf, fccTypeStr, 5) || buf[9] != '=') continue;
+	    if (name != 9 || strncasecmp(buf, fccTypeStr, 5)) continue;
+	    buf[name] = '=';
 	    if ((result = handler(buf, cnt++, param))) break;
 	}
     	RegCloseKey( hKey );


More information about the wine-patches mailing list