Re: shell32: Support getting the shell folder path for users other than the current user and the default user [resend]
"Ge van Geldorp" <ge(a)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(a)winehq.org
From: Alexandre Julliard [mailto:julliard(a)winehq.org]
"Ge van Geldorp" <ge(a)thinstall.com> writes:
+ 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.
There's no way for the caller to free the memory if I return UserInfo->User.Sid directly. Ge van Geldorp.
"Ge van Geldorp" <ge(a)thinstall.com> writes:
From: Alexandre Julliard [mailto:julliard(a)winehq.org] You should return a string directly, there's no reason to make a copy of the SID.
There's no way for the caller to free the memory if I return UserInfo->User.Sid directly.
Of course, that's why I said you should return the string, not the SID. There's no reason to split that functionality into two separate functions. -- Alexandre Julliard julliard(a)winehq.org
participants (2)
-
Alexandre Julliard -
Ge van Geldorp