Ge is looking for feedback on this patch, could somebody familiar with the innards of SHGetFolderPath() comment?
http://bugs.winehq.org/show_bug.cgi?id=10905#c6 / http://www.winehq.org/pipermail/wine-patches/2007-December/048437.html
Thanks, Dan
Hi Ge, sorry I missed this. I have some stylistic quibbles with your patch:
+static PSID GetUserFromToken(HANDLE Token)
shellpath.c uses the _ prefix for static functions. It's not pretty, perhaps, but please be consistent.
@@ -1371,6 +1417,9 @@ static HRESULT _SHGetUserProfilePath(HANDLE hToken, DWORD dwFlags, BYTE folder, LPWSTR pszPath) { HRESULT hr; + PSID UserFromToken; + HANDLE ProcessToken; + PSID CurrentUser;
These have the wrong scope, as they're only used...
@@ -1391,6 +1441,37 @@ static HRESULT _SHGetUserProfilePath(HANDLE hToken, DWORD dwFlags, BYTE folder, */ if (hToken != NULL && hToken != (HANDLE)-1) { + UserFromToken = GetUserFromToken(hToken);
within this block.
But even fixing this, I think it'd be clearer to do something like the following:
- if (hToken != NULL && hToken != (HANDLE)-1) + if (hToken != NULL && hToken != (HANDLE)-1 && !_IsCurrentUserToken(hToken))
That is, make a function that checks whether the token represents the current user, and returns TRUE if so/FALSE if not.
--Juan