[PATCH 1/2] advapi32: HKCR merge: foundation

Alexandre Julliard julliard at winehq.org
Fri Sep 27 04:13:19 CDT 2013


George Stephanos <gaf.stephanos at gmail.com> writes:

> @@ -224,13 +248,138 @@ static NTSTATUS open_key( HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES *a
>  
>  }
>  
> +static LSTATUS create_hkcr_struct( HKEY *hkey, opened_hkcr_t **hkcr )
> +{
> +    UINT_PTR handle = nb_hkcr_handles, i;
> +    LSTATUS ret = ERROR_SUCCESS;
> +
> +    EnterCriticalSection( &hkcr_handles_cs );
> +
> +    for (i = 0; i < nb_hkcr_handles; i++)
> +    {
> +        if (!hkcr_handles[i])
> +        {
> +            handle = i;
> +            break;
> +        }
> +    }

You need some sort of free list instead of a linear search. Also you can
probably avoid one level of pointers and store objects directly.

Returning a pointer to the object outside of the critical section is not
a good idea.

> +static HKEY resolve_hkcr( HKEY hkey )
> +{
> +    HKEY ret;
> +    UINT_PTR idx = (UINT_PTR)hkey >> 2;
> +    opened_hkcr_t *hkcr;
> +    if (idx <= nb_hkcr_handles)
> +    {
> +        EnterCriticalSection( &hkcr_handles_cs );

The count needs to be protected by the critical section too.

Also please write a better subject line for the commit.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list