Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msvfw32/msvideo_main.c | 118 +++++++++++++++++------------------- 1 file changed, 56 insertions(+), 62 deletions(-)
diff --git a/dlls/msvfw32/msvideo_main.c b/dlls/msvfw32/msvideo_main.c index 4b09913667..da227402ce 100644 --- a/dlls/msvfw32/msvideo_main.c +++ b/dlls/msvfw32/msvideo_main.c @@ -40,6 +40,7 @@ #include "vfw.h" #include "msvideo_private.h" #include "wine/debug.h" +#include "wine/heap.h"
/* Drivers32 settings */ #define HKLM_DRIVERS32 "Software\Microsoft\Windows NT\CurrentVersion\Drivers32" @@ -366,8 +367,8 @@ BOOL VFWAPI ICInstall(DWORD fccType, DWORD fccHandler, LPARAM lParam, LPSTR szDe if (driver) return FALSE;
/* Register the driver */ - driver = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(reg_driver)); - if (!driver) goto oom; + if (!(driver = heap_alloc_zero(sizeof(*driver)))) + return FALSE; driver->fccType = fccType; driver->fccHandler = fccHandler;
@@ -375,29 +376,27 @@ BOOL VFWAPI ICInstall(DWORD fccType, DWORD fccHandler, LPARAM lParam, LPSTR szDe { case ICINSTALL_FUNCTION: driver->proc = (DRIVERPROC)lParam; - driver->name = NULL; break; case ICINSTALL_DRIVER: - driver->proc = NULL; len = MultiByteToWideChar(CP_ACP, 0, (char*)lParam, -1, NULL, 0); - driver->name = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - if (!driver->name) goto oom; + if (!(driver->name = heap_alloc(len * sizeof(WCHAR)))) + { + heap_free(driver); + return FALSE; + } MultiByteToWideChar(CP_ACP, 0, (char*)lParam, -1, driver->name, len); - break; + break; default: - ERR("Invalid flags!\n"); - HeapFree(GetProcessHeap(), 0, driver); - return FALSE; - } + ERR("Invalid flags!\n"); + heap_free(driver); + return FALSE; + }
/* Insert our driver in the list*/ driver->next = reg_driver_list; reg_driver_list = driver; - - return TRUE; -oom: - HeapFree(GetProcessHeap(), 0, driver); - return FALSE; + + return TRUE; }
/*********************************************************************** @@ -423,8 +422,8 @@ BOOL VFWAPI ICRemove(DWORD fccType, DWORD fccHandler, UINT wFlags) /* Remove the driver from the list */ drv = *pdriver; *pdriver = (*pdriver)->next; - HeapFree(GetProcessHeap(), 0, drv->name); - HeapFree(GetProcessHeap(), 0, drv); + heap_free(drv->name); + heap_free(drv);
return TRUE; } @@ -517,8 +516,7 @@ HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode) return 0; }
- whic = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_HIC)); - if (!whic) + if (!(whic = heap_alloc(sizeof(*whic)))) { CloseDriver(hdrv, 0, 0); return FALSE; @@ -557,8 +555,8 @@ HIC VFWAPI ICOpenFunction(DWORD fccType, DWORD fccHandler, UINT wMode, DRIVERPRO icopen.pV2Reserved = NULL; icopen.dnDevNode = 0; /* FIXME */
- whic = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_HIC)); - if (!whic) return 0; + if (!(whic = heap_alloc(sizeof(*whic)))) + return NULL;
whic->driverproc = lpfnHandler; while (MSVIDEO_GetHicPtr((HIC)(ULONG_PTR)IC_HandleRef) != NULL) IC_HandleRef++; @@ -573,7 +571,7 @@ HIC VFWAPI ICOpenFunction(DWORD fccType, DWORD fccHandler, UINT wMode, DRIVERPRO { WARN("DRV_LOAD failed for hic %p\n", whic->hic); MSVIDEO_FirstHic = whic->next; - HeapFree(GetProcessHeap(), 0, whic); + heap_free(whic); return 0; } /* return value is not checked */ @@ -587,7 +585,7 @@ HIC VFWAPI ICOpenFunction(DWORD fccType, DWORD fccHandler, UINT wMode, DRIVERPRO { WARN("DRV_OPEN failed for hic %p\n", whic->hic); MSVIDEO_FirstHic = whic->next; - HeapFree(GetProcessHeap(), 0, whic); + heap_free(whic); return 0; }
@@ -925,7 +923,7 @@ static BOOL enum_compressors(HWND list, COMPVARS *pcv, BOOL enum_all)
idx = SendMessageW(list, CB_ADDSTRING, 0, (LPARAM)icinfo.szDescription);
- ic = HeapAlloc(GetProcessHeap(), 0, sizeof(struct codec_info)); + ic = heap_alloc(sizeof(*ic)); ic->icinfo = icinfo; ic->hic = hic; SendMessageW(list, CB_SETITEMDATA, idx, (LPARAM)ic); @@ -978,7 +976,7 @@ static INT_PTR CALLBACK icm_choose_compressor_dlgproc(HWND hdlg, UINT msg, WPARA LoadStringW(MSVFW32_hModule, IDS_FULLFRAMES, buf, 128); SendDlgItemMessageW(hdlg, IDC_COMP_LIST, CB_ADDSTRING, 0, (LPARAM)buf);
- ic = HeapAlloc(GetProcessHeap(), 0, sizeof(struct codec_info)); + ic = heap_alloc(sizeof(*ic)); ic->icinfo.fccType = streamtypeVIDEO; ic->icinfo.fccHandler = comptypeDIB; ic->hic = 0; @@ -1099,7 +1097,7 @@ static INT_PTR CALLBACK icm_choose_compressor_dlgproc(HWND hdlg, UINT msg, WPARA if (!ic || (LONG_PTR)ic == CB_ERR) break;
if (ic->hic) ICClose(ic->hic); - HeapFree(GetProcessHeap(), 0, ic); + heap_free(ic); }
EndDialog(hdlg, LOWORD(wparam) == IDOK); @@ -1171,23 +1169,25 @@ BOOL VFWAPI ICCompressorChoose(HWND hwnd, UINT uiFlags, LPVOID pvIn, */ void VFWAPI ICCompressorFree(PCOMPVARS pc) { - TRACE("(%p)\n",pc); + TRACE("(%p)\n", pc);
- if (pc != NULL && pc->cbSize == sizeof(COMPVARS)) { - if (pc->hic != NULL) { - ICClose(pc->hic); - pc->hic = NULL; + if (pc && pc->cbSize == sizeof(COMPVARS)) + { + if (pc->hic) + { + ICClose(pc->hic); + pc->hic = NULL; + } + heap_free(pc->lpbiIn); + pc->lpbiIn = NULL; + heap_free(pc->lpBitsOut); + pc->lpBitsOut = NULL; + heap_free(pc->lpBitsPrev); + pc->lpBitsPrev = NULL; + heap_free(pc->lpState); + pc->lpState = NULL; + pc->dwFlags = 0; } - HeapFree(GetProcessHeap(), 0, pc->lpbiIn); - pc->lpbiIn = NULL; - HeapFree(GetProcessHeap(), 0, pc->lpBitsOut); - pc->lpBitsOut = NULL; - HeapFree(GetProcessHeap(), 0, pc->lpBitsPrev); - pc->lpBitsPrev = NULL; - HeapFree(GetProcessHeap(), 0, pc->lpState); - pc->lpState = NULL; - pc->dwFlags = 0; - } }
/*********************************************************************** @@ -1297,7 +1297,7 @@ LRESULT WINAPI ICClose(HIC hic) } }
- HeapFree(GetProcessHeap(), 0, whic); + heap_free(whic); return 0; }
@@ -1382,8 +1382,7 @@ HANDLE VFWAPI ICImageDecompress( cbHdr = ICDecompressGetFormatSize(hic,lpbiIn); if ( cbHdr < sizeof(BITMAPINFOHEADER) ) goto err; - pHdr = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,cbHdr+sizeof(RGBQUAD)*256); - if ( pHdr == NULL ) + if (!(pHdr = heap_alloc_zero(cbHdr + sizeof(RGBQUAD) * 256))) goto err; if ( ICDecompressGetFormat( hic, lpbiIn, pHdr ) != ICERR_OK ) goto err; @@ -1438,7 +1437,7 @@ err: ICDecompressEnd( hic ); if ( bReleaseIC ) ICClose(hic); - HeapFree(GetProcessHeap(),0,pHdr); + heap_free(pHdr); if ( pMem != NULL ) GlobalUnlock( hMem ); if ( !bSucceeded && hMem != NULL ) @@ -1509,14 +1508,14 @@ LPVOID VFWAPI ICSeqCompressFrame(PCOMPVARS pc, UINT uiFlags, LPVOID lpBits, BOOL
static void clear_compvars(PCOMPVARS pc) { - HeapFree(GetProcessHeap(), 0, pc->lpbiIn); - HeapFree(GetProcessHeap(), 0, pc->lpBitsPrev); - HeapFree(GetProcessHeap(), 0, pc->lpBitsOut); - HeapFree(GetProcessHeap(), 0, pc->lpState); + heap_free(pc->lpbiIn); + heap_free(pc->lpBitsPrev); + heap_free(pc->lpBitsOut); + heap_free(pc->lpState); pc->lpbiIn = pc->lpBitsPrev = pc->lpBitsOut = pc->lpState = NULL; if (pc->dwFlags & 0x80000000) { - HeapFree(GetProcessHeap(), 0, pc->lpbiOut); + heap_free(pc->lpbiOut); pc->lpbiOut = NULL; pc->dwFlags &= ~0x80000000; } @@ -1542,15 +1541,13 @@ BOOL VFWAPI ICSeqCompressFrameStart(PCOMPVARS pc, LPBITMAPINFO lpbiIn) */ DWORD ret; ICCOMPRESS* icComp; - pc->lpbiIn = HeapAlloc(GetProcessHeap(), 0, sizeof(BITMAPINFO)); - if (!pc->lpbiIn) + + if (!(pc->lpbiIn = heap_alloc(sizeof(BITMAPINFO)))) return FALSE;
*pc->lpbiIn = *lpbiIn;
- pc->lpState = HeapAlloc(GetProcessHeap(), 0, sizeof(ICCOMPRESS) - + sizeof(*icComp->lpckid) + sizeof(*icComp->lpdwFlags)); - if (!pc->lpState) + if (!(pc->lpState = heap_alloc(sizeof(ICCOMPRESS) + sizeof(*icComp->lpckid) + sizeof(*icComp->lpdwFlags)))) goto error;
pc->cbState = sizeof(ICCOMPRESS); @@ -1563,8 +1560,7 @@ BOOL VFWAPI ICSeqCompressFrameStart(PCOMPVARS pc, LPBITMAPINFO lpbiIn) if (size <= 0) goto error;
- pc->lpbiOut = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); - if (!pc->lpbiOut) + if (!(pc->lpbiOut = heap_alloc_zero(size))) goto error; /* Flag to show that we allocated lpbiOut for proper cleanup */ pc->dwFlags |= 0x80000000; @@ -1600,13 +1596,11 @@ BOOL VFWAPI ICSeqCompressFrameStart(PCOMPVARS pc, LPBITMAPINFO lpbiIn) pc->lpbiOut->bmiHeader.biSizeImage);
/* Buffer for compressed frame data */ - pc->lpBitsOut = HeapAlloc(GetProcessHeap(), 0, pc->lpbiOut->bmiHeader.biSizeImage); - if (!pc->lpBitsOut) + if (!(pc->lpBitsOut = heap_alloc(pc->lpbiOut->bmiHeader.biSizeImage))) goto error;
/* Buffer for previous compressed frame data */ - pc->lpBitsPrev = HeapAlloc(GetProcessHeap(), 0, pc->lpbiOut->bmiHeader.biSizeImage); - if (!pc->lpBitsPrev) + if (!(pc->lpBitsPrev = heap_alloc(pc->lpbiOut->bmiHeader.biSizeImage))) goto error;
TRACE("Compvars:\n"
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msvfw32/msvideo_main.c | 83 +++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 46 deletions(-)
diff --git a/dlls/msvfw32/msvideo_main.c b/dlls/msvfw32/msvideo_main.c index da227402ce..16238c2cca 100644 --- a/dlls/msvfw32/msvideo_main.c +++ b/dlls/msvfw32/msvideo_main.c @@ -41,6 +41,7 @@ #include "msvideo_private.h" #include "wine/debug.h" #include "wine/heap.h" +#include "wine/list.h"
/* Drivers32 settings */ #define HKLM_DRIVERS32 "Software\Microsoft\Windows NT\CurrentVersion\Drivers32" @@ -108,10 +109,10 @@ struct _reg_driver DWORD fccHandler; DRIVERPROC proc; LPWSTR name; - reg_driver* next; + struct list entry; };
-static reg_driver* reg_driver_list = NULL; +static struct list reg_driver_list = LIST_INIT(reg_driver_list);
HMODULE MSVFW32_hModule;
@@ -358,13 +359,14 @@ BOOL VFWAPI ICInstall(DWORD fccType, DWORD fccHandler, LPARAM lParam, LPSTR szDe TRACE("(%s,%s,%p,%p,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), (void*)lParam, szDesc, wFlags);
/* Check if a driver is already registered */ - for (driver = reg_driver_list; driver; driver = driver->next) + LIST_FOR_EACH_ENTRY(driver, ®_driver_list, reg_driver, entry) { if (!compare_fourcc(fccType, driver->fccType) && !compare_fourcc(fccHandler, driver->fccHandler)) - break; + { + return FALSE; + } } - if (driver) return FALSE;
/* Register the driver */ if (!(driver = heap_alloc_zero(sizeof(*driver)))) @@ -392,9 +394,7 @@ BOOL VFWAPI ICInstall(DWORD fccType, DWORD fccHandler, LPARAM lParam, LPSTR szDe return FALSE; }
- /* Insert our driver in the list*/ - driver->next = reg_driver_list; - reg_driver_list = driver; + list_add_tail(®_driver_list, &driver->entry);
return TRUE; } @@ -404,28 +404,23 @@ BOOL VFWAPI ICInstall(DWORD fccType, DWORD fccHandler, LPARAM lParam, LPSTR szDe */ BOOL VFWAPI ICRemove(DWORD fccType, DWORD fccHandler, UINT wFlags) { - reg_driver** pdriver; - reg_driver* drv; + reg_driver *driver;
TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wFlags);
- /* Check if a driver is already registered */ - for (pdriver = ®_driver_list; *pdriver; pdriver = &(*pdriver)->next) + LIST_FOR_EACH_ENTRY(driver, ®_driver_list, reg_driver, entry) { - if (!compare_fourcc(fccType, (*pdriver)->fccType) && - !compare_fourcc(fccHandler, (*pdriver)->fccHandler)) - break; + if (!compare_fourcc(fccType, driver->fccType) + && !compare_fourcc(fccHandler, driver->fccHandler)) + { + list_remove(&driver->entry); + heap_free(driver->name); + heap_free(driver); + return TRUE; + } } - if (!*pdriver) - return FALSE;
- /* Remove the driver from the list */ - drv = *pdriver; - *pdriver = (*pdriver)->next; - heap_free(drv->name); - heap_free(drv); - - return TRUE; + return FALSE; }
@@ -437,10 +432,10 @@ HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode) { WCHAR codecname[10]; ICOPEN icopen; - HDRVR hdrv; WINE_HIC* whic; static const WCHAR drv32W[] = {'d','r','i','v','e','r','s','3','2','\0'}; reg_driver* driver; + HDRVR hdrv = NULL;
TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wMode);
@@ -465,21 +460,21 @@ HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode) } }
- /* Check if there is a registered driver that matches */ - driver = reg_driver_list; - while(driver) - if (!compare_fourcc(fccType, driver->fccType) && - !compare_fourcc(fccHandler, driver->fccHandler)) { - fccType = driver->fccType; - fccHandler = driver->fccHandler; - break; - } else - driver = driver->next; - - if (driver && driver->proc) - /* The driver has been registered at runtime with its driverproc */ - return ICOpenFunction(fccType, fccHandler, wMode, driver->proc); - + LIST_FOR_EACH_ENTRY(driver, ®_driver_list, reg_driver, entry) + { + if (!compare_fourcc(fccType, driver->fccType) + && !compare_fourcc(fccHandler, driver->fccHandler)) + { + if (driver->proc) + return ICOpenFunction(driver->fccType, driver->fccHandler, wMode, driver->proc); + else + { + if (!(hdrv = OpenDriver(driver->name, NULL, (LPARAM)&icopen))) + return NULL; + } + } + } + /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the * same layout as ICOPEN */ @@ -493,7 +488,8 @@ HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode) icopen.pV2Reserved = NULL; icopen.dnDevNode = 0; /* FIXME */
- if (!driver) { + if (!hdrv) + { /* normalize to lower case as in 'vidc' */ ((char*)&fccType)[0] = tolower(((char*)&fccType)[0]); ((char*)&fccType)[1] = tolower(((char*)&fccType)[1]); @@ -509,11 +505,6 @@ HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode) hdrv = OpenDriver(codecname, drv32W, (LPARAM)&icopen); if (!hdrv) return 0; - } else { - /* The driver has been registered at runtime with its name */ - hdrv = OpenDriver(driver->name, NULL, (LPARAM)&icopen); - if (!hdrv) - return 0; }
if (!(whic = heap_alloc(sizeof(*whic))))
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msvfw32/tests/msvfw.c | 160 ++++++++++++++++++++++++++++++++++++- 1 file changed, 156 insertions(+), 4 deletions(-)
diff --git a/dlls/msvfw32/tests/msvfw.c b/dlls/msvfw32/tests/msvfw.c index 7555015ef1..ee7ed88850 100644 --- a/dlls/msvfw32/tests/msvfw.c +++ b/dlls/msvfw32/tests/msvfw.c @@ -285,16 +285,59 @@ static void test_ICSeqCompress(void) ok(err == ICERR_BADHANDLE, "Expected -8, got %d\n", err); }
+static ICINFO enum_info; + +static LRESULT CALLBACK enum_driver_proc(DWORD_PTR id, HDRVR driver, UINT msg, + LPARAM lparam1, LPARAM lparam2) +{ + ICINFO *info = (ICINFO *)lparam1; + + ok(!id, "Got unexpected id %#lx.\n", id); + ok(msg == ICM_GETINFO, "Got unexpected message %#x.\n", msg); + ok(info == &enum_info, "Expected lparam1 %p, got %p.\n", &enum_info, info); + ok(lparam2 == sizeof(ICINFO), "Got lparam2 %ld.\n", lparam2); + + ok(!info->fccType, "Got unexpected type %#x.\n", info->fccType); + ok(!info->fccHandler, "Got unexpected handler %#x.\n", info->fccHandler); + ok(!info->dwFlags, "Got unexpected flags %#x.\n", info->dwFlags); + ok(!info->dwVersion, "Got unexpected version %#x.\n", info->dwVersion); + ok(info->dwVersionICM == ICVERSION, "Got unexpected ICM version %#x.\n", info->dwVersionICM); + ok(!info->szName[0], "Got unexpected name %s.\n", wine_dbgstr_w(info->szName)); + ok(!info->szDescription[0], "Got unexpected name %s.\n", wine_dbgstr_w(info->szDescription)); + ok(!info->szDriver[0], "Got unexpected driver %s.\n", wine_dbgstr_w(info->szDriver)); + + info->dwVersion = 0xdeadbeef; + return sizeof(ICINFO); +} + static void test_ICInfo(void) { + static const WCHAR bogusW[] = {'b','o','g','u','s',0}; + static const DWORD test_type = mmioFOURCC('w','i','n','e'); + static const DWORD test_handler = mmioFOURCC('t','e','s','t'); + DWORD i = 0, found = 0; + char buffer[MAX_PATH]; ICINFO info, info2; - DWORD i, found; unsigned char *fcc; + DWORD size; + BOOL ret; + HKEY key; + LONG res;
- for (i = found = 0; ICInfo(0, i, &info); i++) + for (;;) { + memset(&info, 0x55, sizeof(info)); + info.dwSize = sizeof(info); + if (!ICInfo(0, i++, &info)) + break; trace("Codec name: %s, fccHandler: 0x%08x\n", wine_dbgstr_w(info.szName), info.fccHandler); - ok(info.fccType, "expected nonzero fccType\n"); + ok(info.fccType, "Expected nonzero type.\n"); + ok(info.fccHandler, "Expected nonzero handler.\n"); + ok(!info.dwFlags, "Got unexpected flags %#x.\n", info.dwFlags); + ok(!info.dwVersion, "Got unexpected version %#x.\n", info.dwVersion); + ok(info.dwVersionICM == ICVERSION, "Got unexpected ICM version %#x.\n", info.dwVersionICM); + ok(!info.szName[0], "Got unexpected name %s.\n", wine_dbgstr_w(info.szName)); + ok(!info.szDescription[0], "Got unexpected name %s.\n", wine_dbgstr_w(info.szDescription));
ok(ICInfo(info.fccType, info.fccHandler, &info2), "ICInfo failed on fcc 0x%08x\n", info.fccHandler); @@ -310,10 +353,119 @@ static void test_ICInfo(void) } ok(found != 0, "expected at least one codec\n");
- memset(&info, 0, sizeof(info)); + memset(&info, 0x55, sizeof(info)); + info.dwSize = sizeof(info); ok(!ICInfo(ICTYPE_VIDEO, mmioFOURCC('f','a','k','e'), &info), "expected failure\n"); ok(info.fccType == ICTYPE_VIDEO, "got 0x%08x\n", info.fccType); ok(info.fccHandler == mmioFOURCC('f','a','k','e'), "got 0x%08x\n", info.fccHandler); +todo_wine { + ok(!info.dwFlags, "Got unexpected flags %#x.\n", info.dwFlags); + ok(!info.dwVersion, "Got unexpected version %#x.\n", info.dwVersion); + ok(info.dwVersionICM == ICVERSION, "Got unexpected ICM version %#x.\n", info.dwVersionICM); + ok(!info.szName[0], "Got unexpected name %s.\n", wine_dbgstr_w(info.szName)); + ok(!info.szDescription[0], "Got unexpected name %s.\n", wine_dbgstr_w(info.szDescription)); + ok(!info.szDriver[0], "Got unexpected driver %s.\n", wine_dbgstr_w(info.szDriver)); +} + + if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows NT" + "\CurrentVersion\Drivers32", 0, KEY_ALL_ACCESS, &key)) + { + ret = ICInstall(test_type, test_handler, (LPARAM)"bogus", NULL, ICINSTALL_DRIVER); + ok(ret, "Failed to install driver.\n"); + + size = sizeof(buffer); + res = RegQueryValueExA(key, "wine.test", NULL, NULL, (BYTE *)buffer, &size); +todo_wine { + ok(!res, "Failed to query value, error %d.\n", res); + ok(!strcmp(buffer, "bogus"), "Got unexpected value "%s".\n", buffer); +} + + memset(&info, 0x55, sizeof(info)); + info.dwSize = sizeof(info); +todo_wine + ok(ICInfo(test_type, test_handler, &info), "Expected success.\n"); + ok(info.fccType == test_type, "Got unexpected type %#x.\n", info.fccType); + ok(info.fccHandler == test_handler, "Got unexpected handler %#x.\n", info.fccHandler); +todo_wine { + ok(!info.dwFlags, "Got unexpected flags %#x.\n", info.dwFlags); + ok(!info.dwVersion, "Got unexpected version %#x.\n", info.dwVersion); + ok(info.dwVersionICM == ICVERSION, "Got unexpected ICM version %#x.\n", info.dwVersionICM); + ok(!info.szName[0], "Got unexpected name %s.\n", wine_dbgstr_w(info.szName)); + ok(!info.szDescription[0], "Got unexpected name %s.\n", wine_dbgstr_w(info.szDescription)); + ok(!lstrcmpW(info.szDriver, bogusW), "Got unexpected driver %s.\n", wine_dbgstr_w(info.szDriver)); +} + + /* Drivers installed after msvfw32 is loaded are not enumerated. */ + ok(!ICInfo(test_type, 0, &info), "Expected failure.\n"); + + ret = ICRemove(test_type, test_handler, 0); + ok(ret, "Failed to remove driver.\n"); + + res = RegDeleteValueA(key, "wine.test"); + ok(res == ERROR_FILE_NOT_FOUND, "Got error %u.\n", res); + RegCloseKey(key); + } + else + win_skip("Not enough permissions to register codec drivers.\n"); + + if (WritePrivateProfileStringA("drivers32", "wine.test", "bogus", "system.ini")) + { + memset(&info, 0x55, sizeof(info)); + info.dwSize = sizeof(info); + ok(ICInfo(test_type, test_handler, &info), "Expected success.\n"); + ok(info.fccType == test_type, "Got unexpected type %#x.\n", info.fccType); + ok(info.fccHandler == test_handler, "Got unexpected handler %#x.\n", info.fccHandler); + ok(!info.dwFlags, "Got unexpected flags %#x.\n", info.dwFlags); + ok(!info.dwVersion, "Got unexpected version %#x.\n", info.dwVersion); + ok(info.dwVersionICM == ICVERSION, "Got unexpected ICM version %#x.\n", info.dwVersionICM); + ok(!info.szName[0], "Got unexpected name %s.\n", wine_dbgstr_w(info.szName)); + ok(!info.szDescription[0], "Got unexpected name %s.\n", wine_dbgstr_w(info.szDescription)); + ok(!lstrcmpW(info.szDriver, bogusW), "Got unexpected driver %s.\n", wine_dbgstr_w(info.szDriver)); + + /* Drivers installed after msvfw32 is loaded are not enumerated. */ +todo_wine + ok(!ICInfo(test_type, 0, &info), "Expected failure.\n"); + + ret = WritePrivateProfileStringA("drivers32", "wine.test", NULL, "system.ini"); + ok(ret, "Failed to remove INI entry.\n"); + } + + ret = ICInstall(test_type, test_handler, (LPARAM)enum_driver_proc, NULL, ICINSTALL_FUNCTION); + ok(ret, "Failed to install driver.\n"); + + memset(&enum_info, 0x55, sizeof(enum_info)); + enum_info.dwSize = sizeof(enum_info); +todo_wine { + ok(ICInfo(test_type, test_handler, &enum_info), "Expected success.\n"); + ok(!enum_info.fccType, "Got unexpected type %#x.\n", enum_info.fccType); + ok(!enum_info.fccHandler, "Got unexpected handler %#x.\n", enum_info.fccHandler); + ok(!enum_info.dwFlags, "Got unexpected flags %#x.\n", enum_info.dwFlags); + ok(enum_info.dwVersion == 0xdeadbeef, "Got unexpected version %#x.\n", enum_info.dwVersion); + ok(enum_info.dwVersionICM == ICVERSION, "Got unexpected ICM version %#x.\n", enum_info.dwVersionICM); + ok(!enum_info.szName[0], "Got unexpected name %s.\n", wine_dbgstr_w(enum_info.szName)); + ok(!enum_info.szDescription[0], "Got unexpected name %s.\n", wine_dbgstr_w(enum_info.szDescription)); + ok(!enum_info.szDriver[0], "Got unexpected driver %s.\n", wine_dbgstr_w(enum_info.szDriver)); +} + + /* Functions installed after msvfw32 is loaded are enumerated. */ + memset(&enum_info, 0x55, sizeof(enum_info)); + enum_info.dwSize = sizeof(enum_info); +todo_wine { + ok(ICInfo(test_type, 0, &enum_info), "Expected success.\n"); + ok(!enum_info.fccType, "Got unexpected type %#x.\n", enum_info.fccType); +} + ok(!enum_info.fccHandler, "Got unexpected handler %#x.\n", enum_info.fccHandler); +todo_wine { + ok(!enum_info.dwFlags, "Got unexpected flags %#x.\n", enum_info.dwFlags); + ok(enum_info.dwVersion == 0xdeadbeef, "Got unexpected version %#x.\n", enum_info.dwVersion); + ok(enum_info.dwVersionICM == ICVERSION, "Got unexpected ICM version %#x.\n", enum_info.dwVersionICM); + ok(!enum_info.szName[0], "Got unexpected name %s.\n", wine_dbgstr_w(enum_info.szName)); + ok(!enum_info.szDescription[0], "Got unexpected name %s.\n", wine_dbgstr_w(enum_info.szDescription)); + ok(!enum_info.szDriver[0], "Got unexpected driver %s.\n", wine_dbgstr_w(enum_info.szDriver)); +} + + ret = ICRemove(test_type, test_handler, 0); + ok(ret, "Failed to remove driver.\n"); }
static int get_display_format_test;
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=48881
Your paranoid android.
=== w8adm (32 bit report) ===
msvfw32: msvfw.c:379: Test failed: Failed to query value, error 2. msvfw.c:380: Test failed: Got unexpected value "XdU". msvfw.c:405: Test failed: Got error 5.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msvfw32/msvideo_main.c | 102 +++++++++++++++--------------------- 1 file changed, 41 insertions(+), 61 deletions(-)
diff --git a/dlls/msvfw32/msvideo_main.c b/dlls/msvfw32/msvideo_main.c index 16238c2cca..43c9afc4e5 100644 --- a/dlls/msvfw32/msvideo_main.c +++ b/dlls/msvfw32/msvideo_main.c @@ -623,89 +623,69 @@ LRESULT VFWAPI ICGetInfo(HIC hic, ICINFO *picinfo, DWORD cb) return ret; }
-typedef struct { - DWORD fccType; - DWORD fccHandler; - LPBITMAPINFOHEADER lpbiIn; - LPBITMAPINFOHEADER lpbiOut; - WORD wMode; - DWORD querymsg; - HIC hic; -} driver_info_t; - -static HIC try_driver(driver_info_t *info) -{ - HIC hic; - - if ((hic = ICOpen(info->fccType, info->fccHandler, info->wMode))) - { - if (!ICSendMessage(hic, info->querymsg, (DWORD_PTR)info->lpbiIn, (DWORD_PTR)info->lpbiOut)) - return hic; - ICClose(hic); - } - return 0; -} - -static BOOL ICLocate_enum_handler(const char *name, const char *driver, unsigned int nr, void *param) -{ - driver_info_t *info = param; - info->fccHandler = mmioStringToFOURCCA(name + 5, 0); - info->hic = try_driver(info); - return info->hic != 0; -} - /*********************************************************************** - * ICLocate [MSVFW32.@] + * ICLocate [MSVFW32.@] */ -HIC VFWAPI ICLocate(DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn, - LPBITMAPINFOHEADER lpbiOut, WORD wMode) +HIC VFWAPI ICLocate(DWORD type, DWORD handler, BITMAPINFOHEADER *in, + BITMAPINFOHEADER *out, WORD mode) { - driver_info_t info; - - TRACE("(%s,%s,%p,%p,0x%04x)\n", - wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), lpbiIn, lpbiOut, wMode); + ICINFO info = {sizeof(info)}; + UINT msg; + HIC hic; + DWORD i;
- info.fccType = fccType; - info.fccHandler = fccHandler; - info.lpbiIn = lpbiIn; - info.lpbiOut = lpbiOut; - info.wMode = wMode; + TRACE("type %s, handler %s, in %p, out %p, mode %u.\n", + wine_dbgstr_fcc(type), wine_dbgstr_fcc(handler), in, out, mode);
- switch (wMode) + switch (mode) { case ICMODE_FASTCOMPRESS: case ICMODE_COMPRESS: - info.querymsg = ICM_COMPRESS_QUERY; + msg = ICM_COMPRESS_QUERY; break; case ICMODE_FASTDECOMPRESS: case ICMODE_DECOMPRESS: - info.querymsg = ICM_DECOMPRESS_QUERY; + msg = ICM_DECOMPRESS_QUERY; break; case ICMODE_DRAW: - info.querymsg = ICM_DRAW_QUERY; + msg = ICM_DRAW_QUERY; break; default: - WARN("Unknown mode (%d)\n", wMode); + FIXME("Unhandled mode %#x.\n", mode); return 0; }
- /* Easy case: handler/type match, we just fire a query and return */ - info.hic = try_driver(&info); - /* If it didn't work, try each driver in turn. 32 bit codecs only. */ - /* FIXME: Move this to an init routine? */ - if (!info.hic) enum_drivers(fccType, ICLocate_enum_handler, &info); + if ((hic = ICOpen(type, handler, mode))) + { + if (!ICSendMessage(hic, msg, (DWORD_PTR)in, (DWORD_PTR)out)) + { + TRACE("Found codec %s.%s.\n", wine_dbgstr_fcc(type), + wine_dbgstr_fcc(handler)); + return hic; + } + ICClose(hic); + }
- if (info.hic) + for (i = 0; ICInfo(type, i, &info); ++i) { - TRACE("=> %p\n", info.hic); - return info.hic; + if ((hic = ICOpen(info.fccType, info.fccHandler, mode))) + { + if (!ICSendMessage(hic, msg, (DWORD_PTR)in, (DWORD_PTR)out)) + { + TRACE("Found codec %s.%s.\n", wine_dbgstr_fcc(info.fccType), + wine_dbgstr_fcc(info.fccHandler)); + return hic; + } + ICClose(hic); + } }
- if (fccType == streamtypeVIDEO) - return ICLocate(ICTYPE_VIDEO, fccHandler, lpbiIn, lpbiOut, wMode); - - ERR("Required media codec '%s %s' not found!\n", - wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler)); + if (type == streamtypeVIDEO) + return ICLocate(ICTYPE_VIDEO, handler, in, out, mode); + + WARN("Could not find a driver for codec %s.%s.\n", + wine_dbgstr_fcc(type), wine_dbgstr_fcc(handler)); + return 0; }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msvfw32/msvideo_main.c | 135 ++++++++++++++++-------------------- dlls/msvfw32/tests/msvfw.c | 11 ++- 2 files changed, 65 insertions(+), 81 deletions(-)
diff --git a/dlls/msvfw32/msvideo_main.c b/dlls/msvfw32/msvideo_main.c index 43c9afc4e5..81f4dde210 100644 --- a/dlls/msvfw32/msvideo_main.c +++ b/dlls/msvfw32/msvideo_main.c @@ -234,53 +234,6 @@ static DWORD get_size_image(LONG width, LONG height, WORD depth) return ret; }
-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 fccTypeStr[4]; - char name_buf[10]; - char buf[2048]; - - DWORD i, cnt = 0, lRet; - BOOL result = FALSE; - HKEY hKey; - - fourcc_to_string(fccTypeStr, fccType); - - /* first, go through the registry entries */ - lRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE, HKLM_DRIVERS32, 0, KEY_QUERY_VALUE, &hKey); - if (lRet == ERROR_SUCCESS) - { - i = 0; - for (;;) - { - 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")) - { - char *s; - for (s = buf; *s; s += strlen(s) + 1) - { - if (s[4] != '.' || s[9] != '=') continue; - if (fccType && strncasecmp(s, fccTypeStr, 4)) continue; - if ((result = handler(s, s + 10, cnt++, param))) break; - } - } - - return result; -} - /****************************************************************** * MSVIDEO_GetHicPtr * @@ -305,27 +258,6 @@ DWORD WINAPI VideoForWindowsVersion(void) return 0x040003B6; /* 4.950 */ }
-static BOOL ICInfo_enum_handler(const char *name, const char *driver, unsigned int nr, void *param) -{ - ICINFO *lpicinfo = param; - DWORD fccType = mmioStringToFOURCCA(name, 0); - DWORD fccHandler = mmioStringToFOURCCA(name + 5, 0); - - if (lpicinfo->fccHandler != nr && compare_fourcc(lpicinfo->fccHandler, fccHandler)) - return FALSE; - - lpicinfo->fccType = fccType; - lpicinfo->fccHandler = fccHandler; - lpicinfo->dwFlags = 0; - lpicinfo->dwVersion = 0; - lpicinfo->dwVersionICM = ICVERSION; - lpicinfo->szName[0] = 0; - lpicinfo->szDescription[0] = 0; - MultiByteToWideChar(CP_ACP, 0, driver, -1, lpicinfo->szDriver, ARRAY_SIZE(lpicinfo->szDriver)); - - return TRUE; -} - /*********************************************************************** * ICInfo [MSVFW32.@] * Get information about an installable compressor. Return TRUE if there @@ -336,14 +268,69 @@ static BOOL ICInfo_enum_handler(const char *name, const char *driver, unsigned i * fccHandler [I] real fcc for handler or <n>th compressor * lpicinfo [O] information about compressor */ -BOOL VFWAPI ICInfo( DWORD fccType, DWORD fccHandler, ICINFO *lpicinfo) +BOOL VFWAPI ICInfo(DWORD type, DWORD handler, ICINFO *info) { - TRACE("(%s,%s,%p)\n", - wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), lpicinfo); + char name_buf[10], buf[2048]; + DWORD ret_type, ret_handler; + DWORD i, count = 0; + LONG res; + HKEY key; + + TRACE("type %s, handler %s, info %p.\n", + wine_dbgstr_fcc(type), wine_dbgstr_fcc(handler), info); + + memset(info, 0, sizeof(*info)); + info->dwSize = sizeof(*info); + info->dwVersionICM = ICVERSION; + + if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, HKLM_DRIVERS32, 0, KEY_QUERY_VALUE, &key)) + { + i = 0; + for (;;) + { + DWORD name_len = ARRAY_SIZE(name_buf), driver_len = ARRAY_SIZE(info->szDriver);
- lpicinfo->fccType = fccType; - lpicinfo->fccHandler = fccHandler; - return enum_drivers(fccType, ICInfo_enum_handler, lpicinfo); + res = RegEnumValueA(key, i++, name_buf, &name_len, 0, 0, (BYTE *)buf, &driver_len); + if (res == ERROR_NO_MORE_ITEMS) break; + + if (name_len != 9 || name_buf[4] != '.') continue; + ret_type = mmioStringToFOURCCA(name_buf, 0); + ret_handler = mmioStringToFOURCCA(name_buf + 5, 0); + if (type && compare_fourcc(type, ret_type)) continue; + if (compare_fourcc(handler, ret_handler) && handler != count++) continue; + + info->fccType = ret_type; + info->fccHandler = ret_handler; + MultiByteToWideChar(CP_ACP, 0, buf, -1, info->szDriver, ARRAY_SIZE(info->szDriver)); + TRACE("Returning codec %s, driver %s.\n", debugstr_a(name_buf), debugstr_a(buf)); + return TRUE; + } + RegCloseKey(key); + } + + if (GetPrivateProfileSectionA("drivers32", buf, sizeof(buf), "system.ini")) + { + char *s; + for (s = buf; *s; s += strlen(s) + 1) + { + if (s[4] != '.' || s[9] != '=') continue; + ret_type = mmioStringToFOURCCA(s, 0); + ret_handler = mmioStringToFOURCCA(s + 5, 0); + if (type && compare_fourcc(type, ret_type)) continue; + if (compare_fourcc(handler, ret_handler) && handler != count++) continue; + + info->fccType = ret_type; + info->fccHandler = ret_handler; + MultiByteToWideChar(CP_ACP, 0, s + 10, -1, info->szDriver, ARRAY_SIZE(info->szDriver)); + TRACE("Returning codec %s, driver %s.\n", debugstr_an(s, 8), debugstr_a(s + 10)); + return TRUE; + } + } + + info->fccType = type; + info->fccHandler = handler; + WARN("No driver found for codec %s.%s.\n", wine_dbgstr_fcc(type), wine_dbgstr_fcc(handler)); + return FALSE; }
static DWORD IC_HandleRef = 1; diff --git a/dlls/msvfw32/tests/msvfw.c b/dlls/msvfw32/tests/msvfw.c index ee7ed88850..6788ca0403 100644 --- a/dlls/msvfw32/tests/msvfw.c +++ b/dlls/msvfw32/tests/msvfw.c @@ -358,14 +358,12 @@ static void test_ICInfo(void) ok(!ICInfo(ICTYPE_VIDEO, mmioFOURCC('f','a','k','e'), &info), "expected failure\n"); ok(info.fccType == ICTYPE_VIDEO, "got 0x%08x\n", info.fccType); ok(info.fccHandler == mmioFOURCC('f','a','k','e'), "got 0x%08x\n", info.fccHandler); -todo_wine { ok(!info.dwFlags, "Got unexpected flags %#x.\n", info.dwFlags); ok(!info.dwVersion, "Got unexpected version %#x.\n", info.dwVersion); ok(info.dwVersionICM == ICVERSION, "Got unexpected ICM version %#x.\n", info.dwVersionICM); ok(!info.szName[0], "Got unexpected name %s.\n", wine_dbgstr_w(info.szName)); ok(!info.szDescription[0], "Got unexpected name %s.\n", wine_dbgstr_w(info.szDescription)); ok(!info.szDriver[0], "Got unexpected driver %s.\n", wine_dbgstr_w(info.szDriver)); -}
if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows NT" "\CurrentVersion\Drivers32", 0, KEY_ALL_ACCESS, &key)) @@ -386,14 +384,13 @@ todo_wine ok(ICInfo(test_type, test_handler, &info), "Expected success.\n"); ok(info.fccType == test_type, "Got unexpected type %#x.\n", info.fccType); ok(info.fccHandler == test_handler, "Got unexpected handler %#x.\n", info.fccHandler); -todo_wine { ok(!info.dwFlags, "Got unexpected flags %#x.\n", info.dwFlags); ok(!info.dwVersion, "Got unexpected version %#x.\n", info.dwVersion); ok(info.dwVersionICM == ICVERSION, "Got unexpected ICM version %#x.\n", info.dwVersionICM); ok(!info.szName[0], "Got unexpected name %s.\n", wine_dbgstr_w(info.szName)); ok(!info.szDescription[0], "Got unexpected name %s.\n", wine_dbgstr_w(info.szDescription)); +todo_wine ok(!lstrcmpW(info.szDriver, bogusW), "Got unexpected driver %s.\n", wine_dbgstr_w(info.szDriver)); -}
/* Drivers installed after msvfw32 is loaded are not enumerated. */ ok(!ICInfo(test_type, 0, &info), "Expected failure.\n"); @@ -439,13 +436,14 @@ todo_wine { ok(ICInfo(test_type, test_handler, &enum_info), "Expected success.\n"); ok(!enum_info.fccType, "Got unexpected type %#x.\n", enum_info.fccType); ok(!enum_info.fccHandler, "Got unexpected handler %#x.\n", enum_info.fccHandler); +} ok(!enum_info.dwFlags, "Got unexpected flags %#x.\n", enum_info.dwFlags); +todo_wine ok(enum_info.dwVersion == 0xdeadbeef, "Got unexpected version %#x.\n", enum_info.dwVersion); ok(enum_info.dwVersionICM == ICVERSION, "Got unexpected ICM version %#x.\n", enum_info.dwVersionICM); ok(!enum_info.szName[0], "Got unexpected name %s.\n", wine_dbgstr_w(enum_info.szName)); ok(!enum_info.szDescription[0], "Got unexpected name %s.\n", wine_dbgstr_w(enum_info.szDescription)); ok(!enum_info.szDriver[0], "Got unexpected driver %s.\n", wine_dbgstr_w(enum_info.szDriver)); -}
/* Functions installed after msvfw32 is loaded are enumerated. */ memset(&enum_info, 0x55, sizeof(enum_info)); @@ -455,14 +453,13 @@ todo_wine { ok(!enum_info.fccType, "Got unexpected type %#x.\n", enum_info.fccType); } ok(!enum_info.fccHandler, "Got unexpected handler %#x.\n", enum_info.fccHandler); -todo_wine { ok(!enum_info.dwFlags, "Got unexpected flags %#x.\n", enum_info.dwFlags); +todo_wine ok(enum_info.dwVersion == 0xdeadbeef, "Got unexpected version %#x.\n", enum_info.dwVersion); ok(enum_info.dwVersionICM == ICVERSION, "Got unexpected ICM version %#x.\n", enum_info.dwVersionICM); ok(!enum_info.szName[0], "Got unexpected name %s.\n", wine_dbgstr_w(enum_info.szName)); ok(!enum_info.szDescription[0], "Got unexpected name %s.\n", wine_dbgstr_w(enum_info.szDescription)); ok(!enum_info.szDriver[0], "Got unexpected driver %s.\n", wine_dbgstr_w(enum_info.szDriver)); -}
ret = ICRemove(test_type, test_handler, 0); ok(ret, "Failed to remove driver.\n");
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=48883
Your paranoid android.
=== w8adm (32 bit report) ===
msvfw32: msvfw.c:377: Test failed: Failed to query value, error 2. msvfw.c:378: Test failed: Got unexpected value "Xd.". msvfw.c:402: Test failed: Got error 5.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msvfw32/msvideo_main.c | 96 ++++++++++++++++++++----------------- dlls/msvfw32/tests/msvfw.c | 5 +- 2 files changed, 53 insertions(+), 48 deletions(-)
diff --git a/dlls/msvfw32/msvideo_main.c b/dlls/msvfw32/msvideo_main.c index 81f4dde210..6631060d5d 100644 --- a/dlls/msvfw32/msvideo_main.c +++ b/dlls/msvfw32/msvideo_main.c @@ -108,7 +108,6 @@ struct _reg_driver DWORD fccType; DWORD fccHandler; DRIVERPROC proc; - LPWSTR name; struct list entry; };
@@ -336,77 +335,92 @@ BOOL VFWAPI ICInfo(DWORD type, DWORD handler, ICINFO *info) static DWORD IC_HandleRef = 1;
/*********************************************************************** - * ICInstall [MSVFW32.@] + * ICInstall [MSVFW32.@] */ -BOOL VFWAPI ICInstall(DWORD fccType, DWORD fccHandler, LPARAM lParam, LPSTR szDesc, UINT wFlags) +BOOL VFWAPI ICInstall(DWORD type, DWORD handler, LPARAM lparam, char *desc, UINT flags) { - reg_driver* driver; - unsigned len; + reg_driver *driver;
- TRACE("(%s,%s,%p,%p,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), (void*)lParam, szDesc, wFlags); + TRACE("type %s, handler %s, lparam %#lx, desc %s, flags %#x.\n", + wine_dbgstr_fcc(type), wine_dbgstr_fcc(handler), lparam, debugstr_a(desc), flags);
- /* Check if a driver is already registered */ LIST_FOR_EACH_ENTRY(driver, ®_driver_list, reg_driver, entry) { - if (!compare_fourcc(fccType, driver->fccType) && - !compare_fourcc(fccHandler, driver->fccHandler)) + if (!compare_fourcc(type, driver->fccType) + && !compare_fourcc(handler, driver->fccHandler)) { return FALSE; } }
- /* Register the driver */ - if (!(driver = heap_alloc_zero(sizeof(*driver)))) - return FALSE; - driver->fccType = fccType; - driver->fccHandler = fccHandler; - - switch(wFlags) + switch (flags) { case ICINSTALL_FUNCTION: - driver->proc = (DRIVERPROC)lParam; - break; + if (!(driver = heap_alloc_zero(sizeof(*driver)))) + return FALSE; + driver->fccType = type; + driver->fccHandler = handler; + driver->proc = (DRIVERPROC)lparam; + list_add_tail(®_driver_list, &driver->entry); + return TRUE; case ICINSTALL_DRIVER: - len = MultiByteToWideChar(CP_ACP, 0, (char*)lParam, -1, NULL, 0); - if (!(driver->name = heap_alloc(len * sizeof(WCHAR)))) - { - heap_free(driver); + { + const char *driver = (const char *)lparam; + char value[10]; + HKEY key; + LONG res; + + if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, HKLM_DRIVERS32, 0, KEY_SET_VALUE, &key)) return FALSE; - } - MultiByteToWideChar(CP_ACP, 0, (char*)lParam, -1, driver->name, len); - break; + fourcc_to_string(value, type); + value[4] = '.'; + fourcc_to_string(value + 5, handler); + value[9] = 0; + res = RegSetValueExA(key, value, 0, REG_SZ, (const BYTE *)driver, strlen(driver) + 1); + RegCloseKey(key); + return !res; + } default: - ERR("Invalid flags!\n"); - heap_free(driver); + FIXME("Unhandled flags %#x.\n", flags); return FALSE; } - - list_add_tail(®_driver_list, &driver->entry); - - return TRUE; }
/*********************************************************************** - * ICRemove [MSVFW32.@] + * ICRemove [MSVFW32.@] */ -BOOL VFWAPI ICRemove(DWORD fccType, DWORD fccHandler, UINT wFlags) +BOOL VFWAPI ICRemove(DWORD type, DWORD handler, UINT flags) { reg_driver *driver; + char value[10]; + HKEY key; + LONG res;
- TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wFlags); + TRACE("type %s, handler %s, flags %#x.\n", + wine_dbgstr_fcc(type), wine_dbgstr_fcc(handler), flags);
LIST_FOR_EACH_ENTRY(driver, ®_driver_list, reg_driver, entry) { - if (!compare_fourcc(fccType, driver->fccType) - && !compare_fourcc(fccHandler, driver->fccHandler)) + if (!compare_fourcc(type, driver->fccType) + && !compare_fourcc(handler, driver->fccHandler)) { list_remove(&driver->entry); - heap_free(driver->name); heap_free(driver); return TRUE; } }
+ if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, HKLM_DRIVERS32, 0, KEY_SET_VALUE, &key)) + { + fourcc_to_string(value, type); + value[4] = '.'; + fourcc_to_string(value + 5, handler); + value[9] = 0; + res = RegDeleteValueA(key, value); + RegCloseKey(key); + return !res; + } + return FALSE; }
@@ -452,13 +466,7 @@ HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode) if (!compare_fourcc(fccType, driver->fccType) && !compare_fourcc(fccHandler, driver->fccHandler)) { - if (driver->proc) - return ICOpenFunction(driver->fccType, driver->fccHandler, wMode, driver->proc); - else - { - if (!(hdrv = OpenDriver(driver->name, NULL, (LPARAM)&icopen))) - return NULL; - } + return ICOpenFunction(driver->fccType, driver->fccHandler, wMode, driver->proc); } }
diff --git a/dlls/msvfw32/tests/msvfw.c b/dlls/msvfw32/tests/msvfw.c index 6788ca0403..bb54d43921 100644 --- a/dlls/msvfw32/tests/msvfw.c +++ b/dlls/msvfw32/tests/msvfw.c @@ -373,14 +373,11 @@ static void test_ICInfo(void)
size = sizeof(buffer); res = RegQueryValueExA(key, "wine.test", NULL, NULL, (BYTE *)buffer, &size); -todo_wine { ok(!res, "Failed to query value, error %d.\n", res); ok(!strcmp(buffer, "bogus"), "Got unexpected value "%s".\n", buffer); -}
memset(&info, 0x55, sizeof(info)); info.dwSize = sizeof(info); -todo_wine ok(ICInfo(test_type, test_handler, &info), "Expected success.\n"); ok(info.fccType == test_type, "Got unexpected type %#x.\n", info.fccType); ok(info.fccHandler == test_handler, "Got unexpected handler %#x.\n", info.fccHandler); @@ -389,10 +386,10 @@ todo_wine ok(info.dwVersionICM == ICVERSION, "Got unexpected ICM version %#x.\n", info.dwVersionICM); ok(!info.szName[0], "Got unexpected name %s.\n", wine_dbgstr_w(info.szName)); ok(!info.szDescription[0], "Got unexpected name %s.\n", wine_dbgstr_w(info.szDescription)); -todo_wine ok(!lstrcmpW(info.szDriver, bogusW), "Got unexpected driver %s.\n", wine_dbgstr_w(info.szDriver));
/* Drivers installed after msvfw32 is loaded are not enumerated. */ +todo_wine ok(!ICInfo(test_type, 0, &info), "Expected failure.\n");
ret = ICRemove(test_type, test_handler, 0);
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=48884
Your paranoid android.
=== w8adm (32 bit report) ===
msvfw32: msvfw.c:376: Test failed: Failed to query value, error 2. msvfw.c:377: Test failed: Got unexpected value "Xd/". msvfw.c:399: Test failed: Got error 5.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- This will make tests for quartz VFW wrappers easier.
dlls/msvfw32/msvideo_main.c | 9 +++++++++ dlls/msvfw32/tests/msvfw.c | 6 ------ 2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/dlls/msvfw32/msvideo_main.c b/dlls/msvfw32/msvideo_main.c index 6631060d5d..d42b10956d 100644 --- a/dlls/msvfw32/msvideo_main.c +++ b/dlls/msvfw32/msvideo_main.c @@ -271,6 +271,7 @@ BOOL VFWAPI ICInfo(DWORD type, DWORD handler, ICINFO *info) { char name_buf[10], buf[2048]; DWORD ret_type, ret_handler; + reg_driver *driver; DWORD i, count = 0; LONG res; HKEY key; @@ -326,6 +327,14 @@ BOOL VFWAPI ICInfo(DWORD type, DWORD handler, ICINFO *info) } }
+ LIST_FOR_EACH_ENTRY(driver, ®_driver_list, reg_driver, entry) + { + if (type && compare_fourcc(type, driver->fccType)) continue; + if (compare_fourcc(handler, driver->fccHandler) && handler != count++) continue; + if (driver->proc(0, NULL, ICM_GETINFO, (DWORD_PTR)info, sizeof(*info)) == sizeof(*info)) + return TRUE; + } + info->fccType = type; info->fccHandler = handler; WARN("No driver found for codec %s.%s.\n", wine_dbgstr_fcc(type), wine_dbgstr_fcc(handler)); diff --git a/dlls/msvfw32/tests/msvfw.c b/dlls/msvfw32/tests/msvfw.c index bb54d43921..33fca56dc5 100644 --- a/dlls/msvfw32/tests/msvfw.c +++ b/dlls/msvfw32/tests/msvfw.c @@ -429,13 +429,10 @@ todo_wine
memset(&enum_info, 0x55, sizeof(enum_info)); enum_info.dwSize = sizeof(enum_info); -todo_wine { ok(ICInfo(test_type, test_handler, &enum_info), "Expected success.\n"); ok(!enum_info.fccType, "Got unexpected type %#x.\n", enum_info.fccType); ok(!enum_info.fccHandler, "Got unexpected handler %#x.\n", enum_info.fccHandler); -} ok(!enum_info.dwFlags, "Got unexpected flags %#x.\n", enum_info.dwFlags); -todo_wine ok(enum_info.dwVersion == 0xdeadbeef, "Got unexpected version %#x.\n", enum_info.dwVersion); ok(enum_info.dwVersionICM == ICVERSION, "Got unexpected ICM version %#x.\n", enum_info.dwVersionICM); ok(!enum_info.szName[0], "Got unexpected name %s.\n", wine_dbgstr_w(enum_info.szName)); @@ -445,13 +442,10 @@ todo_wine /* Functions installed after msvfw32 is loaded are enumerated. */ memset(&enum_info, 0x55, sizeof(enum_info)); enum_info.dwSize = sizeof(enum_info); -todo_wine { ok(ICInfo(test_type, 0, &enum_info), "Expected success.\n"); ok(!enum_info.fccType, "Got unexpected type %#x.\n", enum_info.fccType); -} ok(!enum_info.fccHandler, "Got unexpected handler %#x.\n", enum_info.fccHandler); ok(!enum_info.dwFlags, "Got unexpected flags %#x.\n", enum_info.dwFlags); -todo_wine ok(enum_info.dwVersion == 0xdeadbeef, "Got unexpected version %#x.\n", enum_info.dwVersion); ok(enum_info.dwVersionICM == ICVERSION, "Got unexpected ICM version %#x.\n", enum_info.dwVersionICM); ok(!enum_info.szName[0], "Got unexpected name %s.\n", wine_dbgstr_w(enum_info.szName));
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=48885
Your paranoid android.
=== w8adm (32 bit report) ===
msvfw32: msvfw.c:376: Test failed: Failed to query value, error 2. msvfw.c:377: Test failed: Got unexpected value "Xd-". msvfw.c:399: Test failed: Got error 5.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msvfw32/msvideo_main.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/dlls/msvfw32/msvideo_main.c b/dlls/msvfw32/msvideo_main.c index d42b10956d..235410b970 100644 --- a/dlls/msvfw32/msvideo_main.c +++ b/dlls/msvfw32/msvideo_main.c @@ -102,8 +102,7 @@ static const char *wine_dbgstr_icerr( int ret )
static WINE_HIC* MSVIDEO_FirstHic /* = NULL */;
-typedef struct _reg_driver reg_driver; -struct _reg_driver +struct reg_driver { DWORD fccType; DWORD fccHandler; @@ -271,7 +270,7 @@ BOOL VFWAPI ICInfo(DWORD type, DWORD handler, ICINFO *info) { char name_buf[10], buf[2048]; DWORD ret_type, ret_handler; - reg_driver *driver; + struct reg_driver *driver; DWORD i, count = 0; LONG res; HKEY key; @@ -327,7 +326,7 @@ BOOL VFWAPI ICInfo(DWORD type, DWORD handler, ICINFO *info) } }
- LIST_FOR_EACH_ENTRY(driver, ®_driver_list, reg_driver, entry) + LIST_FOR_EACH_ENTRY(driver, ®_driver_list, struct reg_driver, entry) { if (type && compare_fourcc(type, driver->fccType)) continue; if (compare_fourcc(handler, driver->fccHandler) && handler != count++) continue; @@ -348,12 +347,12 @@ static DWORD IC_HandleRef = 1; */ BOOL VFWAPI ICInstall(DWORD type, DWORD handler, LPARAM lparam, char *desc, UINT flags) { - reg_driver *driver; + struct reg_driver *driver;
TRACE("type %s, handler %s, lparam %#lx, desc %s, flags %#x.\n", wine_dbgstr_fcc(type), wine_dbgstr_fcc(handler), lparam, debugstr_a(desc), flags);
- LIST_FOR_EACH_ENTRY(driver, ®_driver_list, reg_driver, entry) + LIST_FOR_EACH_ENTRY(driver, ®_driver_list, struct reg_driver, entry) { if (!compare_fourcc(type, driver->fccType) && !compare_fourcc(handler, driver->fccHandler)) @@ -400,7 +399,7 @@ BOOL VFWAPI ICInstall(DWORD type, DWORD handler, LPARAM lparam, char *desc, UINT */ BOOL VFWAPI ICRemove(DWORD type, DWORD handler, UINT flags) { - reg_driver *driver; + struct reg_driver *driver; char value[10]; HKEY key; LONG res; @@ -408,7 +407,7 @@ BOOL VFWAPI ICRemove(DWORD type, DWORD handler, UINT flags) TRACE("type %s, handler %s, flags %#x.\n", wine_dbgstr_fcc(type), wine_dbgstr_fcc(handler), flags);
- LIST_FOR_EACH_ENTRY(driver, ®_driver_list, reg_driver, entry) + LIST_FOR_EACH_ENTRY(driver, ®_driver_list, struct reg_driver, entry) { if (!compare_fourcc(type, driver->fccType) && !compare_fourcc(handler, driver->fccHandler)) @@ -444,7 +443,7 @@ HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode) ICOPEN icopen; WINE_HIC* whic; static const WCHAR drv32W[] = {'d','r','i','v','e','r','s','3','2','\0'}; - reg_driver* driver; + struct reg_driver *driver; HDRVR hdrv = NULL;
TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wMode); @@ -470,7 +469,7 @@ HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode) } }
- LIST_FOR_EACH_ENTRY(driver, ®_driver_list, reg_driver, entry) + LIST_FOR_EACH_ENTRY(driver, ®_driver_list, struct reg_driver, entry) { if (!compare_fourcc(fccType, driver->fccType) && !compare_fourcc(fccHandler, driver->fccHandler))