[PATCH 2/5] ole32: Simplify enumeration cloning using duplicated key

Alexandre Julliard julliard at winehq.org
Fri Dec 6 04:36:26 CST 2013


Nikolay Sivov <nsivov at codeweavers.com> writes:

> -    new_this->IEnumCATEGORYINFO_iface = This->IEnumCATEGORYINFO_iface;
> -    new_this->ref = 1;
> -    new_this->lcid = This->lcid;
> -    /* FIXME: could we more efficiently use DuplicateHandle? */
> -    open_classes_key(HKEY_CLASSES_ROOT, keyname, KEY_READ, &new_this->key);
> -    new_this->next_index = This->next_index;
> +    cloned->IEnumCATEGORYINFO_iface = This->IEnumCATEGORYINFO_iface;
> +    cloned->ref = 1;
> +    cloned->lcid = This->lcid;
>  
> -    *ppenum = &new_this->IEnumCATEGORYINFO_iface;
> +    if (!DuplicateHandle(GetCurrentProcess(), This->key, GetCurrentProcess(), (HANDLE*)&cloned->key, 0, FALSE, DUPLICATE_SAME_ACCESS))
> +    {
> +        IEnumCATEGORYINFO_Release(&cloned->IEnumCATEGORYINFO_iface);
> +        return E_FAIL;
> +    }

Using DuplicateHandle is not a good idea on registry keys, particularly
for HKEY_CLASSES_ROOT keys.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list