Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msdmo/dmoreg.c | 8 +++----- dlls/msdmo/tests/Makefile.in | 2 +- dlls/msdmo/tests/msdmo.c | 36 +++++++++++++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/dlls/msdmo/dmoreg.c b/dlls/msdmo/dmoreg.c index ead8864..43b0438 100644 --- a/dlls/msdmo/dmoreg.c +++ b/dlls/msdmo/dmoreg.c @@ -390,7 +390,6 @@ static HRESULT IEnumDMO_Constructor( { IEnumDMOImpl* lpedmo; HRESULT hr; - LONG ret;
*obj = NULL;
@@ -405,6 +404,7 @@ static HRESULT IEnumDMO_Constructor( lpedmo->dwFlags = dwFlags; lpedmo->cInTypes = cInTypes; lpedmo->cOutTypes = cOutTypes; + lpedmo->hkey = NULL;
hr = dup_partial_mediatype(pInTypes, cInTypes, &lpedmo->pInTypes); if (FAILED(hr)) @@ -417,8 +417,7 @@ static HRESULT IEnumDMO_Constructor( /* If not filtering by category enum from media objects root */ if (IsEqualGUID(guidCategory, &GUID_NULL)) { - if ((ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, KEY_READ, &lpedmo->hkey))) - hr = HRESULT_FROM_WIN32(ret); + RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, KEY_READ, &lpedmo->hkey); } else { @@ -426,8 +425,7 @@ static HRESULT IEnumDMO_Constructor( WCHAR szKey[MAX_PATH];
wsprintfW(szKey, szCat3Fmt, szDMORootKey, szDMOCategories, GUIDToString(szguid, guidCategory)); - if ((ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &lpedmo->hkey))) - hr = HRESULT_FROM_WIN32(ret); + RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &lpedmo->hkey); }
lerr: diff --git a/dlls/msdmo/tests/Makefile.in b/dlls/msdmo/tests/Makefile.in index 105baba..22a8e35 100644 --- a/dlls/msdmo/tests/Makefile.in +++ b/dlls/msdmo/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = msdmo.dll -IMPORTS = msdmo +IMPORTS = advapi32 dmoguids msdmo uuid
C_SRCS = \ msdmo.c diff --git a/dlls/msdmo/tests/msdmo.c b/dlls/msdmo/tests/msdmo.c index 00ab656..32d79ce 100644 --- a/dlls/msdmo/tests/msdmo.c +++ b/dlls/msdmo/tests/msdmo.c @@ -18,7 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#include "initguid.h" +#include <stdio.h> +#define COBJMACROS #include "dmo.h" #include "wine/test.h"
@@ -27,8 +28,19 @@ static const GUID GUID_unknowndmo = {0x14d99047,0x441f,0x4cd3,{0xbc,0xa8,0x3e,0x static const GUID GUID_unknowncategory = {0x14d99048,0x441f,0x4cd3,{0xbc,0xa8,0x3e,0x67,0x99,0xaf,0x34,0x75}}; static const GUID GUID_wmp1 = {0x13a7995e,0x7d8f,0x45b4,{0x9c,0x77,0x81,0x92,0x65,0x22,0x57,0x63}};
+static const char *guid_to_string(const GUID *guid) +{ + static char buffer[50]; + sprintf(buffer, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + guid->Data1, guid->Data2, guid->Data3, + guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3], + guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]); + return buffer; +} + static void test_DMOUnregister(void) { + static char buffer[200]; static const WCHAR testdmoW[] = {'t','e','s','t','d','m','o',0}; HRESULT hr;
@@ -53,6 +65,10 @@ static void test_DMOUnregister(void)
hr = DMOUnregister(&GUID_unknowndmo, &GUID_NULL); ok(hr == S_FALSE, "got 0x%08x\n", hr); + + /* clean up category since Windows doesn't */ + sprintf(buffer, "DirectShow\MediaObjects\Categories\%s", guid_to_string(&GUID_unknowncategory)); + RegDeleteKeyA(HKEY_CLASSES_ROOT, buffer); }
static void test_DMOGetName(void) @@ -70,8 +86,26 @@ static void test_DMOGetName(void) ok(name[0] == 'a', "got %x\n", name[0]); }
+static void test_DMOEnum(void) +{ + IEnumDMO *enum_dmo; + HRESULT hr; + CLSID clsid; + WCHAR *name; + + hr = DMOEnum(&GUID_unknowncategory, 0, 0, NULL, 0, NULL, &enum_dmo); + ok(hr == S_OK, "DMOEnum() failed with %#x\n", hr); + + hr = IEnumDMO_Next(enum_dmo, 1, &clsid, &name, NULL); + todo_wine + ok(hr == S_FALSE, "expected S_FALSE, got %#x\n", hr); + + IEnumDMO_Release(enum_dmo); +} + START_TEST(msdmo) { test_DMOUnregister(); test_DMOGetName(); + test_DMOEnum(); }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msdmo/dmoreg.c | 9 ++++++--- dlls/msdmo/tests/msdmo.c | 9 ++++++++- 2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/dlls/msdmo/dmoreg.c b/dlls/msdmo/dmoreg.c index 43b0438..255849d3d 100644 --- a/dlls/msdmo/dmoreg.c +++ b/dlls/msdmo/dmoreg.c @@ -519,9 +519,12 @@ static HRESULT WINAPI IEnumDMO_fnNext(
TRACE("(%p)->(%d %p %p %p)\n", This, cItemsToFetch, pCLSID, Names, pcItemsFetched);
- if (!pCLSID || !Names || !pcItemsFetched) + if (!pCLSID || !Names) return E_POINTER;
+ if (!pcItemsFetched && cItemsToFetch > 1) + return E_INVALIDARG; + while (count < cItemsToFetch) { This->index++; @@ -656,8 +659,8 @@ static HRESULT WINAPI IEnumDMO_fnNext( count++; }
- *pcItemsFetched = count; - if (*pcItemsFetched < cItemsToFetch) + if (pcItemsFetched) *pcItemsFetched = count; + if (count < cItemsToFetch) hres = S_FALSE;
TRACE("<-- %i found\n",count); diff --git a/dlls/msdmo/tests/msdmo.c b/dlls/msdmo/tests/msdmo.c index 32d79ce..a78ee83 100644 --- a/dlls/msdmo/tests/msdmo.c +++ b/dlls/msdmo/tests/msdmo.c @@ -92,14 +92,21 @@ static void test_DMOEnum(void) HRESULT hr; CLSID clsid; WCHAR *name; + DWORD count;
hr = DMOEnum(&GUID_unknowncategory, 0, 0, NULL, 0, NULL, &enum_dmo); ok(hr == S_OK, "DMOEnum() failed with %#x\n", hr);
hr = IEnumDMO_Next(enum_dmo, 1, &clsid, &name, NULL); - todo_wine ok(hr == S_FALSE, "expected S_FALSE, got %#x\n", hr);
+ hr = IEnumDMO_Next(enum_dmo, 2, &clsid, &name, NULL); + ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr); + + hr = IEnumDMO_Next(enum_dmo, 2, &clsid, &name, &count); + ok(hr == S_FALSE, "expected S_FALSE, got %#x\n", hr); + ok(count == 0, "expected 0, got %d\n", count); + IEnumDMO_Release(enum_dmo); }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msdmo/dmoreg.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/dlls/msdmo/dmoreg.c b/dlls/msdmo/dmoreg.c index 255849d3d..1944a0a 100644 --- a/dlls/msdmo/dmoreg.c +++ b/dlls/msdmo/dmoreg.c @@ -571,7 +571,7 @@ static HRESULT WINAPI IEnumDMO_fnNext( continue; }
- pInTypes = (DMO_PARTIAL_MEDIATYPE*) szValue; + pInTypes = (DMO_PARTIAL_MEDIATYPE *)szValue;
TRACE("read %d intypes for %s:\n", cInTypes, debugstr_w(szKey)); for (i = 0; i < cInTypes; i++) { @@ -584,10 +584,10 @@ static HRESULT WINAPI IEnumDMO_fnNext( for (j = 0; j < cInTypes; j++) { if (IsMediaTypeEqual(&pInTypes[j], &This->pInTypes[i])) - break; + break; }
- if (j >= cInTypes) + if (j >= cInTypes) break; }
@@ -608,13 +608,13 @@ static HRESULT WINAPI IEnumDMO_fnNext( sizeof(szValue)/sizeof(DMO_PARTIAL_MEDIATYPE), (DMO_PARTIAL_MEDIATYPE*)szValue);
- if (FAILED(hres)) + if (FAILED(hres)) { RegCloseKey(hkey); continue; }
- pOutTypes = (DMO_PARTIAL_MEDIATYPE*) szValue; + pOutTypes = (DMO_PARTIAL_MEDIATYPE *)szValue;
TRACE("read %d outtypes for %s:\n", cOutTypes, debugstr_w(szKey)); for (i = 0; i < cOutTypes; i++) { @@ -627,10 +627,10 @@ static HRESULT WINAPI IEnumDMO_fnNext( for (j = 0; j < cOutTypes; j++) { if (IsMediaTypeEqual(&pOutTypes[j], &This->pOutTypes[i])) - break; + break; }
- if (j >= cOutTypes) + if (j >= cOutTypes) break; }
@@ -641,22 +641,22 @@ static HRESULT WINAPI IEnumDMO_fnNext( } }
- /* Media object wasn't filtered so add it to return list */ + /* Media object wasn't filtered so add it to return list */ Names[count] = NULL; - len = MAX_PATH * sizeof(WCHAR); + len = MAX_PATH * sizeof(WCHAR); ret = RegQueryValueExW(hkey, NULL, NULL, NULL, (LPBYTE)szValue, &len); if (ERROR_SUCCESS == ret) - { + { Names[count] = CoTaskMemAlloc((strlenW(szValue) + 1) * sizeof(WCHAR)); - if (Names[count]) + if (Names[count]) strcpyW(Names[count], szValue); - } + } wsprintfW(szGuidKey,szToGuidFmt,szNextKey); CLSIDFromString(szGuidKey, &pCLSID[count]);
TRACE("found match %s %s\n", debugstr_w(szValue), debugstr_w(szNextKey)); RegCloseKey(hkey); - count++; + count++; }
if (pcItemsFetched) *pcItemsFetched = count;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msdmo/dmoreg.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/dlls/msdmo/dmoreg.c b/dlls/msdmo/dmoreg.c index 1944a0a..96579df 100644 --- a/dlls/msdmo/dmoreg.c +++ b/dlls/msdmo/dmoreg.c @@ -117,6 +117,15 @@ static LPWSTR GUIDToString(LPWSTR lpwstr, REFGUID lpcguid) return lpwstr; }
+static HRESULT string_to_guid(const WCHAR *string, GUID *guid) +{ + WCHAR buffer[39] = {'{',0}; + strcatW(buffer, string); + buffer[37] = '}'; + buffer[38] = 0; + return CLSIDFromString(buffer, guid); +} + static BOOL IsMediaTypeEqual(const DMO_PARTIAL_MEDIATYPE* mt1, const DMO_PARTIAL_MEDIATYPE* mt2) {
@@ -514,6 +523,7 @@ static HRESULT WINAPI IEnumDMO_fnNext( UINT count = 0; HRESULT hres = S_OK; LONG ret; + GUID guid;
IEnumDMOImpl *This = impl_from_IEnumDMO(iface);
@@ -537,6 +547,9 @@ static HRESULT WINAPI IEnumDMO_fnNext( break; }
+ if (string_to_guid(szNextKey, &guid) != S_OK) + continue; + TRACE("found %s\n", debugstr_w(szNextKey));
if (!(This->dwFlags & DMO_ENUMF_INCLUDE_KEYED))