user32: Implement GetUserObjectInformation with index=UOI_USER_SID

Dmitry Timoshkov dmitry at codeweavers.com
Thu Jul 22 20:47:30 CDT 2010


Wolfgang Schwotzer <wolfgang.schwotzer at gmx.net> wrote:

> +            size = 0;
> +            GetUserNameW( NULL, &size );
> +
> +            user_name = HeapAlloc( GetProcessHeap(), 0, (size + 1) * sizeof(WCHAR) );
> +            if (!user_name) {
> +                SetLastError(ERROR_OUTOFMEMORY);
> +                return FALSE;
> +            }
> +
> +            if (!GetUserNameW( user_name, &size ))
> +            {
> +                HeapFree( GetProcessHeap(), 0, user_name );
> +                return FALSE;
> +            }
> +
> +            size = 0;
> +            dom_size = 0;
> +            LookupAccountNameW( NULL, user_name, NULL, &size, NULL, &dom_size, &use );
> +
> +            *needed = size;
> +            if (info == NULL)
> +            {
> +                HeapFree( GetProcessHeap(), 0, user_name );
> +                return TRUE;
> +            }
> +
> +            if (len < size)
> +            {
> +                SetLastError( ERROR_NOT_ENOUGH_MEMORY );
> +                HeapFree( GetProcessHeap(), 0, user_name );
> +                return FALSE;
> +            }
> +
> +            dom_size = 0;
> +            ret = LookupAccountNameW( NULL, user_name, (PSID)info, &size, NULL, &dom_size, &use );
> +            HeapFree( GetProcessHeap(), 0, user_name );
> +            return ret;
> +        }

You need to test return value of every 1st call as well as you do for
every next one.

-- 
Dmitry.



More information about the wine-devel mailing list