[PATCH 1/3] msvfw32: Fix driver enumeration.
Zebediah Figura
z.figura12 at gmail.com
Fri Feb 9 09:57:28 CST 2018
This behaviour matches that on Windows tested mainly by manually modifying
the registry. If this is appropriate for a test I will add one.
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
dlls/msvfw32/msvideo_main.c | 53 ++++++++++++++++++++++-----------------------
1 file changed, 26 insertions(+), 27 deletions(-)
diff --git a/dlls/msvfw32/msvideo_main.c b/dlls/msvfw32/msvideo_main.c
index d49ea74..3c9e098 100644
--- a/dlls/msvfw32/msvideo_main.c
+++ b/dlls/msvfw32/msvideo_main.c
@@ -223,48 +223,48 @@ static int compare_fourcc(DWORD fcc1, DWORD fcc2)
return strncasecmp(fcc_str1, fcc_str2, 4);
}
-typedef BOOL (*enum_handler_t)(const char*, unsigned int, void*);
+typedef BOOL (*enum_handler_t)(const char *name, const char *driver, unsigned int index, void *param);
static BOOL enum_drivers(DWORD fccType, enum_handler_t handler, void* param)
{
- CHAR buf[2048], fccTypeStr[5], *s;
+ char fccTypeStr[4];
+ char name_buf[10];
+ char buf[2048];
+
DWORD i, cnt = 0, lRet;
BOOL result = FALSE;
HKEY hKey;
fourcc_to_string(fccTypeStr, fccType);
- fccTypeStr[4] = '.';
/* first, go through the registry entries */
lRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE, HKLM_DRIVERS32, 0, KEY_QUERY_VALUE, &hKey);
if (lRet == ERROR_SUCCESS)
{
- DWORD name, data, type;
i = 0;
for (;;)
- {
- name = 10;
- data = sizeof buf - name;
- lRet = RegEnumValueA(hKey, i++, buf, &name, 0, &type, (LPBYTE)(buf+name), &data);
- if (lRet == ERROR_NO_MORE_ITEMS) break;
- if (lRet != ERROR_SUCCESS) continue;
- if (fccType && (name != 9 || strncasecmp(buf, fccTypeStr, 5))) continue;
- buf[name] = '=';
- if ((result = handler(buf, cnt++, param))) break;
- }
- RegCloseKey( hKey );
+ {
+ DWORD name_len = 10, driver_len = 128;
+ lRet = RegEnumValueA(hKey, i++, name_buf, &name_len, 0, 0, (BYTE *)buf, &driver_len);
+ if (lRet == ERROR_NO_MORE_ITEMS) break;
+ if (name_len != 9 || name_buf[4] != '.') continue;
+ if (fccType && strncasecmp(name_buf, fccTypeStr, 4)) continue;
+ if ((result = handler(name_buf, buf, cnt++, param))) break;
+ }
+ RegCloseKey( hKey );
}
if (result) return result;
/* if that didn't work, go through the values in system.ini */
if (GetPrivateProfileSectionA("drivers32", buf, sizeof(buf), "system.ini"))
{
- for (s = buf; *s; s += strlen(s) + 1)
- {
- TRACE("got %s\n", s);
- if (fccType && (strncasecmp(s, fccTypeStr, 5) || s[9] != '=')) continue;
- if ((result = handler(s, cnt++, param))) break;
- }
+ char *s;
+ for (s = buf; *s; s += strlen(s) + 1)
+ {
+ if (s[5] != '.' || s[9] != '=') continue;
+ if (fccType && strncasecmp(s, fccTypeStr, 4)) continue;
+ if ((result = handler(s, s + 10, cnt++, param))) break;
+ }
}
return result;
@@ -294,21 +294,20 @@ DWORD WINAPI VideoForWindowsVersion(void)
return 0x040003B6; /* 4.950 */
}
-static BOOL ICInfo_enum_handler(const char *drv, unsigned int nr, void *param)
+static BOOL ICInfo_enum_handler(const char *name, const char *driver, unsigned int nr, void *param)
{
ICINFO *lpicinfo = param;
- DWORD fccHandler = mmioStringToFOURCCA(drv + 5, 0);
+ DWORD fccHandler = mmioStringToFOURCCA(name + 5, 0);
if (lpicinfo->fccHandler != nr && compare_fourcc(lpicinfo->fccHandler, fccHandler))
return FALSE;
-
lpicinfo->fccHandler = fccHandler;
lpicinfo->dwFlags = 0;
lpicinfo->dwVersion = 0;
lpicinfo->dwVersionICM = ICVERSION;
lpicinfo->szName[0] = 0;
lpicinfo->szDescription[0] = 0;
- MultiByteToWideChar(CP_ACP, 0, drv + 10, -1, lpicinfo->szDriver,
+ MultiByteToWideChar(CP_ACP, 0, driver, -1, lpicinfo->szDriver,
sizeof(lpicinfo->szDriver)/sizeof(WCHAR));
return TRUE;
@@ -647,10 +646,10 @@ static HIC try_driver(driver_info_t *info)
return 0;
}
-static BOOL ICLocate_enum_handler(const char *drv, unsigned int nr, void *param)
+static BOOL ICLocate_enum_handler(const char *name, const char *driver, unsigned int nr, void *param)
{
driver_info_t *info = param;
- info->fccHandler = mmioStringToFOURCCA(drv + 5, 0);
+ info->fccHandler = mmioStringToFOURCCA(name + 5, 0);
info->hic = try_driver(info);
return info->hic != 0;
}
--
2.7.4
More information about the wine-devel
mailing list