Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msdmo/dmoreg.c | 113 +++----------------------------------------- 1 file changed, 6 insertions(+), 107 deletions(-)
diff --git a/dlls/msdmo/dmoreg.c b/dlls/msdmo/dmoreg.c index 1a35b41f468..ffe64782d1c 100644 --- a/dlls/msdmo/dmoreg.c +++ b/dlls/msdmo/dmoreg.c @@ -32,8 +32,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(msdmo);
-#define MSDMO_MAJOR_VERSION 6 - static const WCHAR szDMORootKey[] = { 'D','i','r','e','c','t','S','h','o','w','\', @@ -139,40 +137,8 @@ static BOOL IsMediaTypeEqual(const DMO_PARTIAL_MEDIATYPE* mt1, const DMO_PARTIAL
static HRESULT write_types(HKEY hkey, LPCWSTR name, const DMO_PARTIAL_MEDIATYPE* types, DWORD count) { - LONG ret; - - if (MSDMO_MAJOR_VERSION > 5) - { - ret = RegSetValueExW(hkey, name, 0, REG_BINARY, (const BYTE*) types, - count* sizeof(DMO_PARTIAL_MEDIATYPE)); - } - else - { - HKEY skey1,skey2,skey3; - DWORD index = 0; - WCHAR szGuidKey[64]; - - ret = RegCreateKeyExW(hkey, name, 0, NULL, REG_OPTION_NON_VOLATILE, - KEY_WRITE, NULL, &skey1, NULL); - if (ret) - return HRESULT_FROM_WIN32(ret); - - while (index < count) - { - GUIDToString(szGuidKey,&types[index].type); - ret = RegCreateKeyExW(skey1, szGuidKey, 0, NULL, - REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &skey2, NULL); - GUIDToString(szGuidKey,&types[index].subtype); - ret = RegCreateKeyExW(skey2, szGuidKey, 0, NULL, - REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &skey3, NULL); - RegCloseKey(skey3); - RegCloseKey(skey2); - index ++; - } - RegCloseKey(skey1); - } - - return HRESULT_FROM_WIN32(ret); + return HRESULT_FROM_WIN32(RegSetValueExW(hkey, name, 0, REG_BINARY, + (const BYTE *)types, count * sizeof(DMO_PARTIAL_MEDIATYPE))); }
/*************************************************************** @@ -766,78 +732,11 @@ static const IEnumDMOVtbl edmovt =
HRESULT read_types(HKEY root, LPCWSTR key, ULONG *supplied, ULONG requested, DMO_PARTIAL_MEDIATYPE* types ) { - HRESULT ret = S_OK; + DWORD len = requested * sizeof(DMO_PARTIAL_MEDIATYPE); + LONG ret = RegQueryValueExW(root, key, NULL, NULL, (BYTE *)types, &len);
- if (MSDMO_MAJOR_VERSION > 5) - { - DWORD len; - LONG rc; - - len = requested * sizeof(DMO_PARTIAL_MEDIATYPE); - rc = RegQueryValueExW(root, key, NULL, NULL, (LPBYTE) types, &len); - ret = HRESULT_FROM_WIN32(rc); - - *supplied = len / sizeof(DMO_PARTIAL_MEDIATYPE); - } - else - { - HKEY hkey; - WCHAR szGuidKey[64]; - - *supplied = 0; - if (ERROR_SUCCESS == RegOpenKeyExW(root, key, 0, KEY_READ, &hkey)) - { - int index = 0; - WCHAR szNextKey[MAX_PATH]; - DWORD len; - LONG rc = ERROR_SUCCESS; - - while (rc == ERROR_SUCCESS) - { - len = MAX_PATH; - rc = RegEnumKeyExW(hkey, index, szNextKey, &len, NULL, NULL, NULL, NULL); - if (rc == ERROR_SUCCESS) - { - HKEY subk; - int sub_index = 0; - LONG rcs = ERROR_SUCCESS; - WCHAR szSubKey[MAX_PATH]; - - RegOpenKeyExW(hkey, szNextKey, 0, KEY_READ, &subk); - while (rcs == ERROR_SUCCESS) - { - len = MAX_PATH; - rcs = RegEnumKeyExW(subk, sub_index, szSubKey, &len, NULL, NULL, NULL, NULL); - if (rcs == ERROR_SUCCESS) - { - if (*supplied >= requested) - { - /* Bailing */ - ret = S_FALSE; - rc = ERROR_MORE_DATA; - rcs = ERROR_MORE_DATA; - break; - } - - wsprintfW(szGuidKey,szToGuidFmt,szNextKey); - CLSIDFromString(szGuidKey, &types[*supplied].type); - wsprintfW(szGuidKey,szToGuidFmt,szSubKey); - CLSIDFromString(szGuidKey, &types[*supplied].subtype); - TRACE("Adding type %s subtype %s at index %i\n", - debugstr_guid(&types[*supplied].type), - debugstr_guid(&types[*supplied].subtype), - *supplied); - (*supplied)++; - } - sub_index++; - } - index++; - } - } - RegCloseKey(hkey); - } - } - return ret; + *supplied = len / sizeof(DMO_PARTIAL_MEDIATYPE); + return HRESULT_FROM_WIN32(ret); }
/***************************************************************
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msdmo/dmoreg.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/dlls/msdmo/dmoreg.c b/dlls/msdmo/dmoreg.c index ffe64782d1c..3143cfc5e20 100644 --- a/dlls/msdmo/dmoreg.c +++ b/dlls/msdmo/dmoreg.c @@ -75,12 +75,6 @@ static const WCHAR szCat2Fmt[] = '%','s','\','%','s',0 };
-static const WCHAR szToGuidFmt[] = -{ - '{','%','s','}',0 -}; - - typedef struct { IEnumDMO IEnumDMO_iface; @@ -482,7 +476,6 @@ static HRESULT WINAPI IEnumDMO_fnNext( { HKEY hkey; WCHAR szNextKey[MAX_PATH]; - WCHAR szGuidKey[64]; WCHAR szKey[MAX_PATH]; WCHAR szValue[MAX_PATH]; DMO_PARTIAL_MEDIATYPE types[100]; @@ -490,7 +483,6 @@ static HRESULT WINAPI IEnumDMO_fnNext( UINT count = 0; HRESULT hres = S_OK; LONG ret; - GUID guid;
IEnumDMOImpl *This = impl_from_IEnumDMO(iface);
@@ -514,7 +506,7 @@ static HRESULT WINAPI IEnumDMO_fnNext( break; }
- if (string_to_guid(szNextKey, &guid) != S_OK) + if (string_to_guid(szNextKey, &pCLSID[count]) != S_OK) continue;
TRACE("found %s\n", debugstr_w(szNextKey)); @@ -622,8 +614,6 @@ static HRESULT WINAPI IEnumDMO_fnNext( lstrcpyW(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);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msdmo/dmoreg.c | 115 +++++++++++++------------------------------- 1 file changed, 33 insertions(+), 82 deletions(-)
diff --git a/dlls/msdmo/dmoreg.c b/dlls/msdmo/dmoreg.c index 3143cfc5e20..7e7f0c0fb88 100644 --- a/dlls/msdmo/dmoreg.c +++ b/dlls/msdmo/dmoreg.c @@ -32,49 +32,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(msdmo);
-static const WCHAR szDMORootKey[] = -{ - 'D','i','r','e','c','t','S','h','o','w','\', - 'M','e','d','i','a','O','b','j','e','c','t','s',0 -}; - -static const WCHAR szDMOInputType[] = -{ - 'I','n','p','u','t','T','y','p','e','s',0 -}; - -static const WCHAR szDMOOutputType[] = -{ - 'O','u','t','p','u','t','T','y','p','e','s',0 -}; - -static const WCHAR szDMOKeyed[] = -{ - 'K','e','y','e','d',0 -}; - -static const WCHAR szDMOCategories[] = -{ - 'C','a','t','e','g','o','r','i','e','s',0 -}; - -static const WCHAR szGUIDFmt[] = -{ - '%','0','8','X','-','%','0','4','X','-','%','0','4','X','-','%','0', - '2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','%','0','2', - 'X','%','0','2','X','%','0','2','X','%','0','2','X',0 -}; - -static const WCHAR szCat3Fmt[] = -{ - '%','s','\','%','s','\','%','s',0 -}; - -static const WCHAR szCat2Fmt[] = -{ - '%','s','\','%','s',0 -}; - typedef struct { IEnumDMO IEnumDMO_iface; @@ -98,21 +55,20 @@ static HRESULT read_types(HKEY root, LPCWSTR key, ULONG *supplied, ULONG request
static const IEnumDMOVtbl edmovt;
-static LPWSTR GUIDToString(LPWSTR lpwstr, REFGUID lpcguid) +static const WCHAR *GUIDToString(WCHAR *string, const GUID *guid) { - wsprintfW(lpwstr, szGUIDFmt, lpcguid->Data1, lpcguid->Data2, - lpcguid->Data3, lpcguid->Data4[0], lpcguid->Data4[1], - lpcguid->Data4[2], lpcguid->Data4[3], lpcguid->Data4[4], - lpcguid->Data4[5], lpcguid->Data4[6], lpcguid->Data4[7]); - - return lpwstr; + swprintf(string, 37, L"%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 string; }
static HRESULT string_to_guid(const WCHAR *string, GUID *guid) { WCHAR buffer[39]; buffer[0] = '{'; - lstrcpyW(buffer + 1, string); + wcscpy(buffer + 1, string); buffer[37] = '}'; buffer[38] = 0; return CLSIDFromString(buffer, guid); @@ -164,8 +120,8 @@ HRESULT WINAPI DMORegister( if (IsEqualGUID(guidCategory, &GUID_NULL)) return E_INVALIDARG;
- ret = RegCreateKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, NULL, - REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hrkey, NULL); + ret = RegCreateKeyExW(HKEY_CLASSES_ROOT, L"DirectShow\MediaObjects", 0, + NULL, 0, KEY_WRITE, NULL, &hrkey, NULL); if (ret) return E_FAIL;
@@ -177,27 +133,25 @@ HRESULT WINAPI DMORegister(
/* Set default Name value */ ret = RegSetValueExW(hkey, NULL, 0, REG_SZ, (const BYTE*) szName, - (lstrlenW(szName) + 1) * sizeof(WCHAR)); + (wcslen(szName) + 1) * sizeof(WCHAR));
/* Set InputTypes */ - hres = write_types(hkey, szDMOInputType, pInTypes, cInTypes); + hres = write_types(hkey, L"InputTypes", pInTypes, cInTypes);
/* Set OutputTypes */ - hres = write_types(hkey, szDMOOutputType, pOutTypes, cOutTypes); + hres = write_types(hkey, L"OutputTypes", pOutTypes, cOutTypes);
if (dwFlags & DMO_REGISTERF_IS_KEYED) { /* Create Keyed key */ - ret = RegCreateKeyExW(hkey, szDMOKeyed, 0, NULL, - REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hckey, NULL); + ret = RegCreateKeyExW(hkey, L"Keyed", 0, NULL, 0, KEY_WRITE, NULL, &hckey, NULL); if (ret) goto lend; RegCloseKey(hckey); }
/* Register the category */ - ret = RegCreateKeyExW(hrkey, szDMOCategories, 0, NULL, - REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hckey, NULL); + ret = RegCreateKeyExW(hrkey, L"Categories", 0, NULL, 0, KEY_WRITE, NULL, &hckey, NULL); if (ret) goto lend;
@@ -256,15 +210,14 @@ HRESULT WINAPI DMOUnregister(REFCLSID dmo, REFGUID category)
TRACE("%s %s\n", debugstr_guid(dmo), debugstr_guid(category));
- ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, KEY_WRITE, &rootkey); - if (ret) + if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"DirectShow\MediaObjects", 0, KEY_WRITE, &rootkey)) return S_FALSE;
GUIDToString(dmoW, dmo); RegDeleteKeyW(rootkey, dmoW);
/* open 'Categories' */ - ret = RegOpenKeyExW(rootkey, szDMOCategories, 0, KEY_WRITE|KEY_ENUMERATE_SUB_KEYS, &categorieskey); + ret = RegOpenKeyExW(rootkey, L"Categories", 0, KEY_WRITE|KEY_ENUMERATE_SUB_KEYS, &categorieskey); RegCloseKey(rootkey); if (ret) { @@ -309,7 +262,7 @@ HRESULT WINAPI DMOGetName(REFCLSID clsidDMO, WCHAR name[])
TRACE("%s %p\n", debugstr_guid(clsidDMO), name);
- if (RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, KEY_READ, &hrkey)) + if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"DirectShow\MediaObjects", 0, KEY_READ, &hrkey)) return E_FAIL;
ret = RegOpenKeyExW(hrkey, GUIDToString(szguid, clsidDMO), 0, KEY_READ, &hkey); @@ -386,14 +339,15 @@ static HRESULT IEnumDMO_Constructor( /* If not filtering by category enum from media objects root */ if (IsEqualGUID(guidCategory, &GUID_NULL)) { - RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, KEY_READ, &lpedmo->hkey); + RegOpenKeyExW(HKEY_CLASSES_ROOT, L"DirectShow\MediaObjects", 0, KEY_READ, &lpedmo->hkey); } else { WCHAR szguid[64]; WCHAR szKey[MAX_PATH];
- wsprintfW(szKey, szCat3Fmt, szDMORootKey, szDMOCategories, GUIDToString(szguid, guidCategory)); + swprintf(szKey, ARRAY_SIZE(szKey), L"DirectShow\MediaObjects\Categories\%s", + GUIDToString(szguid, guidCategory)); RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &lpedmo->hkey); }
@@ -476,7 +430,7 @@ static HRESULT WINAPI IEnumDMO_fnNext( { HKEY hkey; WCHAR szNextKey[MAX_PATH]; - WCHAR szKey[MAX_PATH]; + WCHAR path[MAX_PATH]; WCHAR szValue[MAX_PATH]; DMO_PARTIAL_MEDIATYPE types[100]; DWORD len; @@ -513,8 +467,8 @@ static HRESULT WINAPI IEnumDMO_fnNext(
if (!(This->dwFlags & DMO_ENUMF_INCLUDE_KEYED)) { - wsprintfW(szKey, szCat3Fmt, szDMORootKey, szNextKey, szDMOKeyed); - ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &hkey); + swprintf(path, ARRAY_SIZE(path), L"DirectShow\MediaObjects\%s\Keyed", szNextKey); + ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, path, 0, KEY_READ, &hkey); if (ERROR_SUCCESS == ret) { RegCloseKey(hkey); @@ -523,23 +477,22 @@ static HRESULT WINAPI IEnumDMO_fnNext( } }
- wsprintfW(szKey, szCat2Fmt, szDMORootKey, szNextKey); - ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &hkey); - TRACE("testing %s\n", debugstr_w(szKey)); + swprintf(path, ARRAY_SIZE(path), L"DirectShow\MediaObjects\%s", szNextKey); + ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, path, 0, KEY_READ, &hkey); + TRACE("Testing %s.\n", debugstr_w(path));
if (This->pInTypes) { UINT i, j; DWORD cInTypes;
- hres = read_types(hkey, szDMOInputType, &cInTypes, ARRAY_SIZE(types), types); + hres = read_types(hkey, L"InputTypes", &cInTypes, ARRAY_SIZE(types), types); if (FAILED(hres)) { RegCloseKey(hkey); continue; }
- TRACE("read %d intypes for %s:\n", cInTypes, debugstr_w(szKey)); for (i = 0; i < cInTypes; i++) { TRACE("intype %d: type %s, subtype %s\n", i, debugstr_guid(&types[i].type), debugstr_guid(&types[i].subtype)); @@ -569,14 +522,13 @@ static HRESULT WINAPI IEnumDMO_fnNext( UINT i, j; DWORD cOutTypes;
- hres = read_types(hkey, szDMOOutputType, &cOutTypes, ARRAY_SIZE(types), types); + hres = read_types(hkey, L"OutputTypes", &cOutTypes, ARRAY_SIZE(types), types); if (FAILED(hres)) { RegCloseKey(hkey); continue; }
- TRACE("read %d outtypes for %s:\n", cOutTypes, debugstr_w(szKey)); for (i = 0; i < cOutTypes; i++) { TRACE("outtype %d: type %s, subtype %s\n", i, debugstr_guid(&types[i].type), debugstr_guid(&types[i].subtype)); @@ -609,9 +561,9 @@ static HRESULT WINAPI IEnumDMO_fnNext( Names[count] = NULL; if (ret == ERROR_SUCCESS) { - Names[count] = CoTaskMemAlloc((lstrlenW(szValue) + 1) * sizeof(WCHAR)); + Names[count] = CoTaskMemAlloc((wcslen(szValue) + 1) * sizeof(WCHAR)); if (Names[count]) - lstrcpyW(Names[count], szValue); + wcscpy(Names[count], szValue); } }
@@ -748,8 +700,7 @@ HRESULT WINAPI DMOGetTypes(REFCLSID clsidDMO, pulInputTypesSupplied, pInputTypes, ulOutputTypesRequested, pulOutputTypesSupplied, pOutputTypes);
- if (ERROR_SUCCESS != RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, - KEY_READ, &root)) + if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"DirectShow\MediaObjects", 0, KEY_READ, &root)) return E_FAIL;
if (ERROR_SUCCESS != RegOpenKeyExW(root,GUIDToString(szguid,clsidDMO) , 0, @@ -761,7 +712,7 @@ HRESULT WINAPI DMOGetTypes(REFCLSID clsidDMO,
if (ulInputTypesRequested > 0) { - ret = read_types(hkey, szDMOInputType, pulInputTypesSupplied, ulInputTypesRequested, pInputTypes ); + ret = read_types(hkey, L"InputTypes", pulInputTypesSupplied, ulInputTypesRequested, pInputTypes ); } else *pulInputTypesSupplied = 0; @@ -769,7 +720,7 @@ HRESULT WINAPI DMOGetTypes(REFCLSID clsidDMO, if (ulOutputTypesRequested > 0) { HRESULT ret2; - ret2 = read_types(hkey, szDMOOutputType, pulOutputTypesSupplied, ulOutputTypesRequested, pOutputTypes ); + ret2 = read_types(hkey, L"OutputTypes", pulOutputTypesSupplied, ulOutputTypesRequested, pOutputTypes );
if (ret == S_OK) ret = ret2;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msdmo/dmoreg.c | 49 ++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 30 deletions(-)
diff --git a/dlls/msdmo/dmoreg.c b/dlls/msdmo/dmoreg.c index 7e7f0c0fb88..ab3fda743ca 100644 --- a/dlls/msdmo/dmoreg.c +++ b/dlls/msdmo/dmoreg.c @@ -417,6 +417,21 @@ static ULONG WINAPI IEnumDMO_fnRelease(IEnumDMO * iface) return refCount; }
+static BOOL any_types_match(const DMO_PARTIAL_MEDIATYPE *a, unsigned int a_count, + const DMO_PARTIAL_MEDIATYPE *b, unsigned int b_count) +{ + unsigned int i, j; + + for (i = 0; i < a_count; ++i) + { + for (j = 0; j < b_count; ++j) + { + if (IsMediaTypeEqual(&a[i], &b[j])) + return TRUE; + } + } + return FALSE; +}
/****************************************************************************** * IEnumDMO_fnNext @@ -483,8 +498,7 @@ static HRESULT WINAPI IEnumDMO_fnNext(
if (This->pInTypes) { - UINT i, j; - DWORD cInTypes; + DWORD cInTypes, i;
hres = read_types(hkey, L"InputTypes", &cInTypes, ARRAY_SIZE(types), types); if (FAILED(hres)) @@ -498,19 +512,7 @@ static HRESULT WINAPI IEnumDMO_fnNext( debugstr_guid(&types[i].subtype)); }
- for (i = 0; i < This->cInTypes; i++) - { - for (j = 0; j < cInTypes; j++) - { - if (IsMediaTypeEqual(&types[j], &This->pInTypes[i])) - break; - } - - if (j >= cInTypes) - break; - } - - if (i < This->cInTypes) + if (!any_types_match(types, cInTypes, This->pInTypes, This->cInTypes)) { RegCloseKey(hkey); continue; @@ -519,8 +521,7 @@ static HRESULT WINAPI IEnumDMO_fnNext(
if (This->pOutTypes) { - UINT i, j; - DWORD cOutTypes; + DWORD cOutTypes, i;
hres = read_types(hkey, L"OutputTypes", &cOutTypes, ARRAY_SIZE(types), types); if (FAILED(hres)) @@ -534,19 +535,7 @@ static HRESULT WINAPI IEnumDMO_fnNext( debugstr_guid(&types[i].subtype)); }
- for (i = 0; i < This->cOutTypes; i++) - { - for (j = 0; j < cOutTypes; j++) - { - if (IsMediaTypeEqual(&types[j], &This->pOutTypes[i])) - break; - } - - if (j >= cOutTypes) - break; - } - - if (i < This->cOutTypes) + if (!any_types_match(types, cOutTypes, This->pOutTypes, This->cOutTypes)) { RegCloseKey(hkey); continue;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msdmo/dmoreg.c | 76 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 61 insertions(+), 15 deletions(-)
diff --git a/dlls/msdmo/dmoreg.c b/dlls/msdmo/dmoreg.c index ab3fda743ca..a23bd95512d 100644 --- a/dlls/msdmo/dmoreg.c +++ b/dlls/msdmo/dmoreg.c @@ -32,6 +32,35 @@
WINE_DEFAULT_DEBUG_CHANNEL(msdmo);
+BOOL array_reserve(void **elements, unsigned int *capacity, unsigned int count, unsigned int size) +{ + unsigned int max_capacity, new_capacity; + void *new_elements; + + if (count <= *capacity) + return TRUE; + + max_capacity = ~0u / size; + if (count > max_capacity) + return FALSE; + + new_capacity = max(8, *capacity); + while (new_capacity < count && new_capacity <= max_capacity / 2) + new_capacity *= 2; + if (new_capacity < count) + new_capacity = count; + + if (!(new_elements = realloc(*elements, new_capacity * size))) + { + ERR("Failed to allocate memory.\n"); + return FALSE; + } + + *elements = new_elements; + *capacity = new_capacity; + return TRUE; +} + typedef struct { IEnumDMO IEnumDMO_iface; @@ -51,8 +80,6 @@ static inline IEnumDMOImpl *impl_from_IEnumDMO(IEnumDMO *iface) return CONTAINING_RECORD(iface, IEnumDMOImpl, IEnumDMO_iface); }
-static HRESULT read_types(HKEY root, LPCWSTR key, ULONG *supplied, ULONG requested, DMO_PARTIAL_MEDIATYPE* types); - static const IEnumDMOVtbl edmovt;
static const WCHAR *GUIDToString(WCHAR *string, const GUID *guid) @@ -443,11 +470,12 @@ static HRESULT WINAPI IEnumDMO_fnNext( WCHAR ** Names, DWORD * pcItemsFetched) { + DMO_PARTIAL_MEDIATYPE *types = NULL; + unsigned int types_size = 0; HKEY hkey; WCHAR szNextKey[MAX_PATH]; WCHAR path[MAX_PATH]; WCHAR szValue[MAX_PATH]; - DMO_PARTIAL_MEDIATYPE types[100]; DWORD len; UINT count = 0; HRESULT hres = S_OK; @@ -498,21 +526,29 @@ static HRESULT WINAPI IEnumDMO_fnNext(
if (This->pInTypes) { - DWORD cInTypes, i; + DWORD size = types_size, i;
- hres = read_types(hkey, L"InputTypes", &cInTypes, ARRAY_SIZE(types), types); - if (FAILED(hres)) + while ((ret = RegQueryValueExW(hkey, L"InputTypes", NULL, NULL, + (BYTE *)types, &size)) == ERROR_MORE_DATA) + { + if (!array_reserve((void **)&types, &types_size, size, 1)) + { + RegCloseKey(hkey); + free(types); + return E_OUTOFMEMORY; + } + } + if (ret) { RegCloseKey(hkey); continue; }
- for (i = 0; i < cInTypes; i++) { + for (i = 0; i < size / sizeof(DMO_PARTIAL_MEDIATYPE); ++i) TRACE("intype %d: type %s, subtype %s\n", i, debugstr_guid(&types[i].type), debugstr_guid(&types[i].subtype)); - }
- if (!any_types_match(types, cInTypes, This->pInTypes, This->cInTypes)) + if (!any_types_match(types, size / sizeof(DMO_PARTIAL_MEDIATYPE), This->pInTypes, This->cInTypes)) { RegCloseKey(hkey); continue; @@ -521,21 +557,29 @@ static HRESULT WINAPI IEnumDMO_fnNext(
if (This->pOutTypes) { - DWORD cOutTypes, i; + DWORD size = types_size, i;
- hres = read_types(hkey, L"OutputTypes", &cOutTypes, ARRAY_SIZE(types), types); - if (FAILED(hres)) + while ((ret = RegQueryValueExW(hkey, L"OutputTypes", NULL, NULL, + (BYTE *)types, &size)) == ERROR_MORE_DATA) + { + if (!array_reserve((void **)&types, &types_size, size, 1)) + { + RegCloseKey(hkey); + free(types); + return E_OUTOFMEMORY; + } + } + if (ret) { RegCloseKey(hkey); continue; }
- for (i = 0; i < cOutTypes; i++) { + for (i = 0; i < size / sizeof(DMO_PARTIAL_MEDIATYPE); ++i) TRACE("outtype %d: type %s, subtype %s\n", i, debugstr_guid(&types[i].type), debugstr_guid(&types[i].subtype)); - }
- if (!any_types_match(types, cOutTypes, This->pOutTypes, This->cOutTypes)) + if (!any_types_match(types, size / sizeof(DMO_PARTIAL_MEDIATYPE), This->pOutTypes, This->cOutTypes)) { RegCloseKey(hkey); continue; @@ -561,6 +605,8 @@ static HRESULT WINAPI IEnumDMO_fnNext( count++; }
+ free(types); + if (pcItemsFetched) *pcItemsFetched = count; if (count < cItemsToFetch) hres = S_FALSE;