Skip to content

Commit b1322d4

Browse files
committed
[USERENV] LoadUserProfileW(): Improve handling of lpProfileInfo->lpProfilePath (reactos#8321)
- As mentioned in the previous MSGINA commit aa67222, `lpProfilePath` specifies the path to a *roaming* user profile, for example on a domain server, if any. It is then used to create a local image (copy) of the profile on the local computer. HOWEVER (ReactOS HACK): We currently don't implement this in ReactOS; instead, we use it directly as *the* user's profile path, without doing any copy... - Yes, MS Windows allows `lpProfileInfo->lpProfilePath` to be NULL :)
1 parent aa67222 commit b1322d4

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

dll/win32/userenv/profile.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,7 +2007,7 @@ LoadUserProfileW(
20072007
_Inout_ LPPROFILEINFOW lpProfileInfo)
20082008
{
20092009
WCHAR szUserHivePath[MAX_PATH];
2010-
DWORD dwLength = _countof(szUserHivePath);
2010+
DWORD dwLength;
20112011
PTOKEN_USER UserSid = NULL;
20122012
UNICODE_STRING SidString = { 0, 0, NULL };
20132013
HANDLE hProfileMutex = NULL;
@@ -2055,24 +2055,33 @@ LoadUserProfileW(
20552055
{
20562056
DPRINT1("Loading profile %S\n", SidString.Buffer);
20572057

2058+
/*
2059+
* NOTE: lpProfilePath specifies the path to a *roaming* user profile,
2060+
* for example on a domain server, if any. It is then used to create
2061+
* a local image (copy) of the profile on the local computer.
2062+
*
2063+
* FIXME: We currently don't implement this in ReactOS; instead, we use
2064+
* it directly as *the* user's profile path, without doing any copy...
2065+
*/
20582066
if (lpProfileInfo->lpProfilePath)
20592067
{
20602068
/* Use the caller's specified roaming user profile path */
20612069
StringCbCopyW(szUserHivePath, sizeof(szUserHivePath), lpProfileInfo->lpProfilePath);
20622070
}
20632071
else
20642072
{
2065-
/* FIXME: check if MS Windows allows lpProfileInfo->lpProfilePath to be NULL */
2073+
/* Build a default user profile path */
2074+
dwLength = _countof(szUserHivePath);
20662075
if (!GetProfilesDirectoryW(szUserHivePath, &dwLength))
20672076
{
2068-
DPRINT1("GetProfilesDirectoryW() failed (error %ld)\n", GetLastError());
2077+
DPRINT1("GetProfilesDirectoryW() failed (Error %ld)\n", GetLastError());
20692078
goto cleanup;
20702079
}
2080+
StringCbCatW(szUserHivePath, sizeof(szUserHivePath), L"\\");
2081+
StringCbCatW(szUserHivePath, sizeof(szUserHivePath), lpProfileInfo->lpUserName);
20712082
}
20722083

20732084
/* Create user hive name */
2074-
StringCbCatW(szUserHivePath, sizeof(szUserHivePath), L"\\");
2075-
StringCbCatW(szUserHivePath, sizeof(szUserHivePath), lpProfileInfo->lpUserName);
20762085
StringCbCatW(szUserHivePath, sizeof(szUserHivePath), L"\\ntuser.dat");
20772086
DPRINT("szUserHivePath: %S\n", szUserHivePath);
20782087

0 commit comments

Comments
 (0)