shell32: Support getting the shell folder path for users other than the current user and the default user [resend]

Alexandre Julliard julliard at winehq.org
Thu Jan 24 04:46:05 CST 2008


"Ge van Geldorp" <ge at thinstall.com> writes:

> +static PSID _GetUserFromToken(HANDLE Token)
> +{
> +    char InfoBuffer[64];
> +    PTOKEN_USER UserInfo;
> +    DWORD InfoSize;
> +    PSID Sid;
> +    DWORD SidSize;
> +
> +    UserInfo = (PTOKEN_USER) InfoBuffer;
> +    if (! GetTokenInformation(Token, TokenUser, InfoBuffer, sizeof(InfoBuffer),
> +                              &InfoSize))
> +    {
> +        if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
> +            return NULL;
> +        UserInfo = HeapAlloc(GetProcessHeap(), 0, InfoSize);
> +        if (UserInfo == NULL)
> +            return NULL;
> +        if (! GetTokenInformation(Token, TokenUser, UserInfo, InfoSize,
> +                                  &InfoSize))
> +        {
> +            HeapFree(GetProcessHeap(), 0, UserInfo);
> +            return NULL;
> +        }
> +    }
> +
> +    SidSize = GetLengthSid(UserInfo->User.Sid);
> +    Sid = HeapAlloc(GetProcessHeap(), 0, SidSize);
> +    if (Sid == NULL)
> +    {
> +        if (UserInfo != (PTOKEN_USER) InfoBuffer)
> +            HeapFree(GetProcessHeap(), 0, UserInfo);
> +        return NULL;
> +    }
> +
> +    if (! CopySid(SidSize, Sid, UserInfo->User.Sid))
> +    {
> +        HeapFree(GetProcessHeap(), 0, Sid);
> +        Sid = NULL;
> +    }

You should return a string directly, there's no reason to make a copy of
the SID.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list