From 5c91d011bbdff0cac6535c866ef5498b1ddc42c7 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 29 Dec 2014 00:13:56 +0300 Subject: [PATCH] msdmo: Registry API functions don't return HRESULT codes. --- dlls/msdmo/dmoreg.c | 83 +++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 37 deletions(-) diff --git a/dlls/msdmo/dmoreg.c b/dlls/msdmo/dmoreg.c index e8f67c56d6d..77ddfa60ec8 100644 --- a/dlls/msdmo/dmoreg.c +++ b/dlls/msdmo/dmoreg.c @@ -129,10 +129,11 @@ 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) { - HRESULT hres = S_OK; + LONG ret; + if (MSDMO_MAJOR_VERSION > 5) { - hres = RegSetValueExW(hkey, name, 0, REG_BINARY, (const BYTE*) types, + ret = RegSetValueExW(hkey, name, 0, REG_BINARY, (const BYTE*) types, count* sizeof(DMO_PARTIAL_MEDIATYPE)); } else @@ -141,15 +142,18 @@ static HRESULT write_types(HKEY hkey, LPCWSTR name, const DMO_PARTIAL_MEDIATYPE* DWORD index = 0; WCHAR szGuidKey[64]; - hres = RegCreateKeyExW(hkey, name, 0, NULL, REG_OPTION_NON_VOLATILE, + 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); - hres = RegCreateKeyExW(skey1, szGuidKey, 0, NULL, + ret = RegCreateKeyExW(skey1, szGuidKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &skey2, NULL); GUIDToString(szGuidKey,&types[index].subtype); - hres = RegCreateKeyExW(skey2, szGuidKey, 0, NULL, + ret = RegCreateKeyExW(skey2, szGuidKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &skey3, NULL); RegCloseKey(skey3); RegCloseKey(skey2); @@ -158,7 +162,7 @@ static HRESULT write_types(HKEY hkey, LPCWSTR name, const DMO_PARTIAL_MEDIATYPE* RegCloseKey(skey1); } - return hres; + return HRESULT_FROM_WIN32(ret); } /*************************************************************** @@ -256,29 +260,29 @@ lend: */ HRESULT WINAPI DMOUnregister(REFCLSID clsidDMO, REFGUID guidCategory) { - HRESULT hres; WCHAR szguid[64]; HKEY hrkey = 0; HKEY hckey = 0; + LONG ret; GUIDToString(szguid, clsidDMO); TRACE("%s %p\n", debugstr_w(szguid), guidCategory); - hres = RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, KEY_WRITE, &hrkey); - if (ERROR_SUCCESS != hres) + ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, KEY_WRITE, &hrkey); + if (ERROR_SUCCESS != ret) goto lend; - hres = RegDeleteKeyW(hrkey, szguid); - if (ERROR_SUCCESS != hres) + ret = RegDeleteKeyW(hrkey, szguid); + if (ERROR_SUCCESS != ret) goto lend; - hres = RegOpenKeyExW(hrkey, szDMOCategories, 0, KEY_WRITE, &hckey); - if (ERROR_SUCCESS != hres) + ret = RegOpenKeyExW(hrkey, szDMOCategories, 0, KEY_WRITE, &hckey); + if (ERROR_SUCCESS != ret) goto lend; - hres = RegDeleteKeyW(hckey, szguid); - if (ERROR_SUCCESS != hres) + ret = RegDeleteKeyW(hckey, szguid); + if (ERROR_SUCCESS != ret) goto lend; lend: @@ -287,7 +291,7 @@ lend: if (hrkey) RegCloseKey(hrkey); - return hres; + return HRESULT_FROM_WIN32(ret); } @@ -299,27 +303,24 @@ lend: HRESULT WINAPI DMOGetName(REFCLSID clsidDMO, WCHAR szName[]) { WCHAR szguid[64]; - HRESULT hres; HKEY hrkey = 0; HKEY hkey = 0; static const INT max_name_len = 80; DWORD count; + LONG ret; TRACE("%s\n", debugstr_guid(clsidDMO)); - hres = RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, - 0, KEY_READ, &hrkey); - if (ERROR_SUCCESS != hres) + ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, KEY_READ, &hrkey); + if (ERROR_SUCCESS != ret) goto lend; - hres = RegOpenKeyExW(hrkey, GUIDToString(szguid, clsidDMO), - 0, KEY_READ, &hkey); - if (ERROR_SUCCESS != hres) + ret = RegOpenKeyExW(hrkey, GUIDToString(szguid, clsidDMO), 0, KEY_READ, &hkey); + if (ERROR_SUCCESS != ret) goto lend; count = max_name_len * sizeof(WCHAR); - hres = RegQueryValueExW(hkey, NULL, NULL, NULL, - (LPBYTE) szName, &count); + ret = RegQueryValueExW(hkey, NULL, NULL, NULL, (LPBYTE) szName, &count); TRACE(" szName=%s\n", debugstr_w(szName)); lend: @@ -328,10 +329,9 @@ lend: if (hkey) RegCloseKey(hkey); - return hres; + return HRESULT_FROM_WIN32(ret); } - /************************************************************************** * IEnumDMOImpl_Destructor */ @@ -506,6 +506,7 @@ static HRESULT WINAPI IEnumDMO_fnNext( DWORD len; UINT count = 0; HRESULT hres = S_OK; + LONG ret; IEnumDMOImpl *This = impl_from_IEnumDMO(iface); @@ -519,17 +520,20 @@ static HRESULT WINAPI IEnumDMO_fnNext( This->index++; len = MAX_PATH; - hres = RegEnumKeyExW(This->hkey, This->index, szNextKey, &len, NULL, NULL, NULL, &ft); - if (hres != ERROR_SUCCESS) + ret = RegEnumKeyExW(This->hkey, This->index, szNextKey, &len, NULL, NULL, NULL, &ft); + if (ret != ERROR_SUCCESS) + { + hres = HRESULT_FROM_WIN32(ret); break; + } TRACE("found %s\n", debugstr_w(szNextKey)); if (!(This->dwFlags & DMO_ENUMF_INCLUDE_KEYED)) { wsprintfW(szKey, szCat3Fmt, szDMORootKey, szNextKey, szDMOKeyed); - hres = RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &hkey); - if (ERROR_SUCCESS == hres) + ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &hkey); + if (ERROR_SUCCESS == ret) { RegCloseKey(hkey); /* Skip Keyed entries */ @@ -538,7 +542,7 @@ static HRESULT WINAPI IEnumDMO_fnNext( } wsprintfW(szKey, szCat2Fmt, szDMORootKey, szNextKey); - hres = RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &hkey); + ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &hkey); if (This->pInTypes) { @@ -550,7 +554,7 @@ static HRESULT WINAPI IEnumDMO_fnNext( sizeof(szValue)/sizeof(DMO_PARTIAL_MEDIATYPE), (DMO_PARTIAL_MEDIATYPE*)szValue); - if (ERROR_SUCCESS != hres) + if (FAILED(hres)) { RegCloseKey(hkey); continue; @@ -587,7 +591,7 @@ static HRESULT WINAPI IEnumDMO_fnNext( sizeof(szValue)/sizeof(DMO_PARTIAL_MEDIATYPE), (DMO_PARTIAL_MEDIATYPE*)szValue); - if (ERROR_SUCCESS != hres) + if (FAILED(hres)) { RegCloseKey(hkey); continue; @@ -617,8 +621,8 @@ static HRESULT WINAPI IEnumDMO_fnNext( /* Media object wasn't filtered so add it to return list */ Names[count] = NULL; len = MAX_PATH * sizeof(WCHAR); - hres = RegQueryValueExW(hkey, NULL, NULL, NULL, (LPBYTE) szValue, &len); - if (ERROR_SUCCESS == hres) + ret = RegQueryValueExW(hkey, NULL, NULL, NULL, (LPBYTE)szValue, &len); + if (ERROR_SUCCESS == ret) { Names[count] = HeapAlloc(GetProcessHeap(), 0, (strlenW(szValue) + 1) * sizeof(WCHAR)); if (Names[count]) @@ -718,11 +722,16 @@ static const IEnumDMOVtbl edmovt = HRESULT read_types(HKEY root, LPCWSTR key, ULONG *supplied, ULONG requested, DMO_PARTIAL_MEDIATYPE* types ) { HRESULT ret = S_OK; + if (MSDMO_MAJOR_VERSION > 5) { DWORD len; + LONG rc; + len = requested * sizeof(DMO_PARTIAL_MEDIATYPE); - ret = RegQueryValueExW(root, key, NULL, NULL, (LPBYTE) types, &len); + rc = RegQueryValueExW(root, key, NULL, NULL, (LPBYTE) types, &len); + ret = HRESULT_FROM_WIN32(rc); + *supplied = len / sizeof(DMO_PARTIAL_MEDIATYPE); } else