4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 * COPYRIGHT: See COPYING in the top level directory
20 * PROJECT: ReactOS system libraries
21 * FILE: lib/userenv/profile.c
22 * PURPOSE: User profile code
23 * PROGRAMMERS: Eric Kohl
33 /* FUNCTIONS ***************************************************************/
36 AppendSystemPostfix(LPWSTR lpName
,
39 WCHAR szSystemRoot
[MAX_PATH
];
43 /* Build profile name postfix */
44 if (!ExpandEnvironmentStringsW(L
"%SystemRoot%",
48 DPRINT1("Error: %lu\n", GetLastError());
52 _wcsupr(szSystemRoot
);
54 /* Get name postfix */
55 szSystemRoot
[2] = L
'.';
56 lpszPostfix
= &szSystemRoot
[2];
57 lpszPtr
= lpszPostfix
;
58 while (*lpszPtr
!= (WCHAR
)0)
60 if (*lpszPtr
== L
'\\')
65 if (wcslen(lpName
) + wcslen(lpszPostfix
) + 1 >= dwMaxLength
)
67 DPRINT1("Error: buffer overflow\n");
68 SetLastError(ERROR_BUFFER_OVERFLOW
);
72 wcscat(lpName
, lpszPostfix
);
80 CreateUserProfileA(PSID Sid
,
83 UNICODE_STRING UserName
;
87 Status
= RtlCreateUnicodeStringFromAsciiz(&UserName
,
89 if (!NT_SUCCESS(Status
))
91 SetLastError(RtlNtStatusToDosError(Status
));
95 bResult
= CreateUserProfileW(Sid
, UserName
.Buffer
);
97 RtlFreeUnicodeString(&UserName
);
105 AcquireRemoveRestorePrivilege(IN BOOL bAcquire
)
109 PTOKEN_PRIVILEGES TokenPriv
;
112 DPRINT("AcquireRemoveRestorePrivilege(%d)\n", bAcquire
);
114 Process
= OpenProcess(PROCESS_QUERY_INFORMATION
, FALSE
, GetCurrentProcessId());
117 DPRINT1("OpenProcess() failed with error %lu\n", GetLastError());
120 bRet
= OpenProcessToken(Process
, TOKEN_ADJUST_PRIVILEGES
, &Token
);
121 CloseHandle(Process
);
124 DPRINT1("OpenProcessToken() failed with error %lu\n", GetLastError());
127 TokenPriv
= HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(TOKEN_PRIVILEGES
, Privileges
) + sizeof(LUID_AND_ATTRIBUTES
));
130 DPRINT1("Failed to allocate mem for token privileges\n");
132 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
135 TokenPriv
->PrivilegeCount
= 1;
136 TokenPriv
->Privileges
[0].Attributes
= bAcquire
? SE_PRIVILEGE_ENABLED
: 0;
137 if (!LookupPrivilegeValue(NULL
, SE_RESTORE_NAME
, &TokenPriv
->Privileges
[0].Luid
))
139 DPRINT1("LookupPrivilegeValue() failed with error %lu\n", GetLastError());
140 HeapFree(GetProcessHeap(), 0, TokenPriv
);
144 bRet
= AdjustTokenPrivileges(
151 HeapFree(GetProcessHeap(), 0, TokenPriv
);
156 DPRINT1("AdjustTokenPrivileges() failed with error %lu\n", GetLastError());
166 CreateUserProfileW(PSID Sid
,
169 WCHAR szRawProfilesPath
[MAX_PATH
];
170 WCHAR szProfilesPath
[MAX_PATH
];
171 WCHAR szUserProfilePath
[MAX_PATH
];
172 WCHAR szDefaultUserPath
[MAX_PATH
];
173 WCHAR szBuffer
[MAX_PATH
];
180 DPRINT("CreateUserProfileW() called\n");
182 Error
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
183 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList",
187 if (Error
!= ERROR_SUCCESS
)
189 DPRINT1("Error: %lu\n", Error
);
190 SetLastError((DWORD
)Error
);
194 /* Get profiles path */
195 dwLength
= MAX_PATH
* sizeof(WCHAR
);
196 Error
= RegQueryValueExW(hKey
,
197 L
"ProfilesDirectory",
200 (LPBYTE
)szRawProfilesPath
,
202 if (Error
!= ERROR_SUCCESS
)
204 DPRINT1("Error: %lu\n", Error
);
206 SetLastError((DWORD
)Error
);
211 if (!ExpandEnvironmentStringsW(szRawProfilesPath
,
215 DPRINT1("Error: %lu\n", GetLastError());
220 /* create the profiles directory if it does not yet exist */
221 if (!CreateDirectoryW(szProfilesPath
, NULL
))
223 if (GetLastError() != ERROR_ALREADY_EXISTS
)
225 DPRINT1("Error: %lu\n", GetLastError());
230 /* Get default user path */
231 dwLength
= MAX_PATH
* sizeof(WCHAR
);
232 Error
= RegQueryValueExW(hKey
,
233 L
"DefaultUserProfile",
238 if (Error
!= ERROR_SUCCESS
)
240 DPRINT1("Error: %lu\n", Error
);
242 SetLastError((DWORD
)Error
);
248 wcscpy(szUserProfilePath
, szProfilesPath
);
249 wcscat(szUserProfilePath
, L
"\\");
250 wcscat(szUserProfilePath
, lpUserName
);
251 if (!AppendSystemPostfix(szUserProfilePath
, MAX_PATH
))
253 DPRINT1("AppendSystemPostfix() failed\n", GetLastError());
257 wcscpy(szDefaultUserPath
, szProfilesPath
);
258 wcscat(szDefaultUserPath
, L
"\\");
259 wcscat(szDefaultUserPath
, szBuffer
);
261 /* Create user profile directory */
262 if (!CreateDirectoryW(szUserProfilePath
, NULL
))
264 if (GetLastError() != ERROR_ALREADY_EXISTS
)
266 DPRINT1("Error: %lu\n", GetLastError());
271 /* Copy default user directory */
272 if (!CopyDirectory(szUserProfilePath
, szDefaultUserPath
))
274 DPRINT1("Error: %lu\n", GetLastError());
278 /* Add profile to profile list */
279 if (!ConvertSidToStringSidW(Sid
,
282 DPRINT1("Error: %lu\n", GetLastError());
287 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\");
288 wcscat(szBuffer
, SidString
);
290 /* Create user profile key */
291 Error
= RegCreateKeyExW(HKEY_LOCAL_MACHINE
,
295 REG_OPTION_NON_VOLATILE
,
300 if (Error
!= ERROR_SUCCESS
)
302 DPRINT1("Error: %lu\n", Error
);
303 LocalFree((HLOCAL
)SidString
);
304 SetLastError((DWORD
)Error
);
308 /* Create non-expanded user profile path */
309 wcscpy(szBuffer
, szRawProfilesPath
);
310 wcscat(szBuffer
, L
"\\");
311 wcscat(szBuffer
, lpUserName
);
312 if (!AppendSystemPostfix(szBuffer
, MAX_PATH
))
314 DPRINT1("AppendSystemPostfix() failed\n", GetLastError());
315 LocalFree((HLOCAL
)SidString
);
320 /* Set 'ProfileImagePath' value (non-expanded) */
321 Error
= RegSetValueExW(hKey
,
326 (wcslen (szBuffer
) + 1) * sizeof(WCHAR
));
327 if (Error
!= ERROR_SUCCESS
)
329 DPRINT1("Error: %lu\n", Error
);
330 LocalFree((HLOCAL
)SidString
);
332 SetLastError((DWORD
)Error
);
336 /* Set 'Sid' value */
337 Error
= RegSetValueExW(hKey
,
343 if (Error
!= ERROR_SUCCESS
)
345 DPRINT1("Error: %lu\n", Error
);
346 LocalFree((HLOCAL
)SidString
);
348 SetLastError((DWORD
)Error
);
354 /* Create user hive name */
355 wcscpy(szBuffer
, szUserProfilePath
);
356 wcscat(szBuffer
, L
"\\ntuser.dat");
358 /* Acquire restore privilege */
359 if (!AcquireRemoveRestorePrivilege(TRUE
))
361 DPRINT1("Error: %lu\n", Error
);
362 LocalFree((HLOCAL
)SidString
);
366 /* Create new user hive */
367 Error
= RegLoadKeyW(HKEY_USERS
,
370 AcquireRemoveRestorePrivilege(FALSE
);
371 if (Error
!= ERROR_SUCCESS
)
373 DPRINT1("Error: %lu\n", Error
);
374 LocalFree((HLOCAL
)SidString
);
375 SetLastError((DWORD
)Error
);
379 /* Initialize user hive */
380 if (!CreateUserHive(SidString
, szUserProfilePath
))
382 DPRINT1("Error: %lu\n", GetLastError());
383 LocalFree((HLOCAL
)SidString
);
387 RegUnLoadKeyW(HKEY_USERS
, SidString
);
389 LocalFree((HLOCAL
)SidString
);
391 DPRINT("CreateUserProfileW() done\n");
399 GetAllUsersProfileDirectoryA(LPSTR lpProfileDir
,
405 lpBuffer
= GlobalAlloc(GMEM_FIXED
,
406 *lpcchSize
* sizeof(WCHAR
));
407 if (lpBuffer
== NULL
)
410 bResult
= GetAllUsersProfileDirectoryW(lpBuffer
,
414 WideCharToMultiByte(CP_ACP
,
424 GlobalFree(lpBuffer
);
432 GetAllUsersProfileDirectoryW(LPWSTR lpProfileDir
,
435 WCHAR szProfilePath
[MAX_PATH
];
436 WCHAR szBuffer
[MAX_PATH
];
441 Error
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
442 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList",
446 if (Error
!= ERROR_SUCCESS
)
448 DPRINT1("Error: %lu\n", Error
);
449 SetLastError((DWORD
)Error
);
453 /* Get profiles path */
454 dwLength
= sizeof(szBuffer
);
455 Error
= RegQueryValueExW(hKey
,
456 L
"ProfilesDirectory",
461 if (Error
!= ERROR_SUCCESS
)
463 DPRINT1("Error: %lu\n", Error
);
465 SetLastError((DWORD
)Error
);
470 if (!ExpandEnvironmentStringsW(szBuffer
,
474 DPRINT1("Error: %lu\n", GetLastError());
479 /* Get 'AllUsersProfile' name */
480 dwLength
= sizeof(szBuffer
);
481 Error
= RegQueryValueExW(hKey
,
487 if (Error
!= ERROR_SUCCESS
)
489 DPRINT1("Error: %lu\n", Error
);
491 SetLastError((DWORD
)Error
);
497 wcscat(szProfilePath
, L
"\\");
498 wcscat(szProfilePath
, szBuffer
);
500 dwLength
= wcslen(szProfilePath
) + 1;
501 if (lpProfileDir
!= NULL
)
503 if (*lpcchSize
< dwLength
)
505 *lpcchSize
= dwLength
;
506 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
510 wcscpy(lpProfileDir
, szProfilePath
);
513 *lpcchSize
= dwLength
;
521 GetDefaultUserProfileDirectoryA(LPSTR lpProfileDir
,
527 lpBuffer
= GlobalAlloc(GMEM_FIXED
,
528 *lpcchSize
* sizeof(WCHAR
));
529 if (lpBuffer
== NULL
)
532 bResult
= GetDefaultUserProfileDirectoryW(lpBuffer
,
536 WideCharToMultiByte(CP_ACP
,
546 GlobalFree(lpBuffer
);
554 GetDefaultUserProfileDirectoryW(LPWSTR lpProfileDir
,
557 WCHAR szProfilePath
[MAX_PATH
];
558 WCHAR szBuffer
[MAX_PATH
];
563 Error
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
564 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList",
568 if (Error
!= ERROR_SUCCESS
)
570 DPRINT1("Error: %lu\n", Error
);
571 SetLastError((DWORD
)Error
);
575 /* Get profiles path */
576 dwLength
= sizeof(szBuffer
);
577 Error
= RegQueryValueExW(hKey
,
578 L
"ProfilesDirectory",
583 if (Error
!= ERROR_SUCCESS
)
585 DPRINT1("Error: %lu\n", Error
);
587 SetLastError((DWORD
)Error
);
592 if (!ExpandEnvironmentStringsW(szBuffer
,
596 DPRINT1("Error: %lu\n", GetLastError());
601 /* Get 'DefaultUserProfile' name */
602 dwLength
= sizeof(szBuffer
);
603 Error
= RegQueryValueExW(hKey
,
604 L
"DefaultUserProfile",
609 if (Error
!= ERROR_SUCCESS
)
611 DPRINT1("Error: %lu\n", Error
);
613 SetLastError((DWORD
)Error
);
619 wcscat(szProfilePath
, L
"\\");
620 wcscat(szProfilePath
, szBuffer
);
622 dwLength
= wcslen(szProfilePath
) + 1;
623 if (lpProfileDir
!= NULL
)
625 if (*lpcchSize
< dwLength
)
627 *lpcchSize
= dwLength
;
628 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
632 wcscpy(lpProfileDir
, szProfilePath
);
635 *lpcchSize
= dwLength
;
643 GetProfilesDirectoryA(LPSTR lpProfileDir
,
649 lpBuffer
= GlobalAlloc(GMEM_FIXED
,
650 *lpcchSize
* sizeof(WCHAR
));
651 if (lpBuffer
== NULL
)
654 bResult
= GetProfilesDirectoryW(lpBuffer
,
658 WideCharToMultiByte(CP_ACP
,
668 GlobalFree(lpBuffer
);
676 GetProfilesDirectoryW(LPWSTR lpProfilesDir
,
679 WCHAR szProfilesPath
[MAX_PATH
];
680 WCHAR szBuffer
[MAX_PATH
];
685 Error
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
686 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList",
690 if (Error
!= ERROR_SUCCESS
)
692 DPRINT1("Error: %lu\n", Error
);
693 SetLastError((DWORD
)Error
);
697 /* Get profiles path */
698 dwLength
= sizeof(szBuffer
);
699 Error
= RegQueryValueExW(hKey
,
700 L
"ProfilesDirectory",
705 if (Error
!= ERROR_SUCCESS
)
707 DPRINT1("Error: %lu\n", Error
);
709 SetLastError((DWORD
)Error
);
716 if (!ExpandEnvironmentStringsW(szBuffer
,
720 DPRINT1("Error: %lu\n", GetLastError());
724 dwLength
= wcslen (szProfilesPath
) + 1;
725 if (lpProfilesDir
!= NULL
)
727 if (*lpcchSize
< dwLength
)
729 *lpcchSize
= dwLength
;
730 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
734 wcscpy(lpProfilesDir
, szProfilesPath
);
737 *lpcchSize
= dwLength
;
745 GetUserProfileDirectoryA(HANDLE hToken
,
752 lpBuffer
= GlobalAlloc(GMEM_FIXED
,
753 *lpcchSize
* sizeof(WCHAR
));
754 if (lpBuffer
== NULL
)
757 bResult
= GetUserProfileDirectoryW(hToken
,
762 WideCharToMultiByte(CP_ACP
,
772 GlobalFree(lpBuffer
);
780 GetUserProfileDirectoryW(HANDLE hToken
,
784 UNICODE_STRING SidString
;
785 WCHAR szKeyName
[MAX_PATH
];
786 WCHAR szRawImagePath
[MAX_PATH
];
787 WCHAR szImagePath
[MAX_PATH
];
792 if (!GetUserSidFromToken(hToken
,
795 DPRINT1("GetUserSidFromToken() failed\n");
799 DPRINT("SidString: '%wZ'\n", &SidString
);
802 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\");
806 RtlFreeUnicodeString(&SidString
);
808 DPRINT("KeyName: '%S'\n", szKeyName
);
810 Error
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
815 if (Error
!= ERROR_SUCCESS
)
817 DPRINT1("Error: %lu\n", Error
);
818 SetLastError((DWORD
)Error
);
822 dwLength
= sizeof(szRawImagePath
);
823 Error
= RegQueryValueExW(hKey
,
827 (LPBYTE
)szRawImagePath
,
829 if (Error
!= ERROR_SUCCESS
)
831 DPRINT1("Error: %lu\n", Error
);
833 SetLastError((DWORD
)Error
);
839 DPRINT("RawImagePath: '%S'\n", szRawImagePath
);
842 if (!ExpandEnvironmentStringsW(szRawImagePath
,
846 DPRINT1 ("Error: %lu\n", GetLastError());
850 DPRINT("ImagePath: '%S'\n", szImagePath
);
852 dwLength
= wcslen (szImagePath
) + 1;
853 if (*lpcchSize
< dwLength
)
855 *lpcchSize
= dwLength
;
856 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
860 *lpcchSize
= dwLength
;
861 wcscpy(lpProfileDir
, szImagePath
);
869 CheckForLoadedProfile(HANDLE hToken
)
871 UNICODE_STRING SidString
;
874 DPRINT("CheckForLoadedProfile() called\n");
876 if (!GetUserSidFromToken(hToken
,
879 DPRINT1("GetUserSidFromToken() failed\n");
883 if (RegOpenKeyExW(HKEY_USERS
,
889 DPRINT("Profile not loaded\n");
890 RtlFreeUnicodeString(&SidString
);
896 RtlFreeUnicodeString(&SidString
);
898 DPRINT("Profile already loaded\n");
906 LoadUserProfileA(HANDLE hToken
,
907 LPPROFILEINFOA lpProfileInfo
)
909 DPRINT ("LoadUserProfileA() not implemented\n");
916 LoadUserProfileW(IN HANDLE hToken
,
917 IN OUT LPPROFILEINFOW lpProfileInfo
)
919 WCHAR szUserHivePath
[MAX_PATH
];
920 LPWSTR UserName
= NULL
, Domain
= NULL
;
921 DWORD UserNameLength
= 0, DomainLength
= 0;
922 PTOKEN_USER UserSid
= NULL
;
923 SID_NAME_USE AccountType
;
924 UNICODE_STRING SidString
= { 0, 0, NULL
};
927 DWORD dwLength
= sizeof(szUserHivePath
) / sizeof(szUserHivePath
[0]);
929 DPRINT("LoadUserProfileW() called\n");
931 /* Check profile info */
932 if (!lpProfileInfo
|| (lpProfileInfo
->dwSize
!= sizeof(PROFILEINFOW
)) ||
933 (lpProfileInfo
->lpUserName
== NULL
) || (lpProfileInfo
->lpUserName
[0] == 0))
935 SetLastError(ERROR_INVALID_PARAMETER
);
939 /* Don't load a profile twice */
940 if (CheckForLoadedProfile(hToken
))
942 DPRINT ("Profile already loaded\n");
943 lpProfileInfo
->hProfile
= NULL
;
947 if (lpProfileInfo
->lpProfilePath
)
949 wcscpy(szUserHivePath
, lpProfileInfo
->lpProfilePath
);
953 /* FIXME: check if MS Windows allows lpProfileInfo->lpProfilePath to be NULL */
954 if (!GetProfilesDirectoryW(szUserHivePath
, &dwLength
))
956 DPRINT1("GetProfilesDirectoryW() failed (error %ld)\n", GetLastError());
961 wcscat(szUserHivePath
, L
"\\");
962 wcscat(szUserHivePath
, lpProfileInfo
->lpUserName
);
963 dwLength
= sizeof(szUserHivePath
) / sizeof(szUserHivePath
[0]);
964 if (!AppendSystemPostfix(szUserHivePath
, dwLength
))
966 DPRINT1("AppendSystemPostfix() failed\n", GetLastError());
970 /* Create user hive name */
971 wcscat(szUserHivePath
, L
"\\ntuser.dat");
972 DPRINT("szUserHivePath: %S\n", szUserHivePath
);
974 /* Create user profile directory if needed */
975 if (GetFileAttributesW(szUserHivePath
) == INVALID_FILE_ATTRIBUTES
)
978 if (GetTokenInformation(hToken
, TokenUser
, NULL
, 0, &dwLength
) ||
979 GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
981 DPRINT1 ("GetTokenInformation() failed\n");
985 UserSid
= (PTOKEN_USER
)HeapAlloc(GetProcessHeap(), 0, dwLength
);
988 DPRINT1("HeapAlloc() failed\n");
989 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
993 if (!GetTokenInformation(hToken
, TokenUser
, UserSid
, dwLength
, &dwLength
))
995 DPRINT1("GetTokenInformation() failed\n");
1002 if (UserNameLength
> 0)
1004 HeapFree(GetProcessHeap(), 0, UserName
);
1005 UserName
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, UserNameLength
* sizeof(WCHAR
));
1008 DPRINT1("HeapAlloc() failed\n");
1009 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1013 if (DomainLength
> 0)
1015 HeapFree(GetProcessHeap(), 0, Domain
);
1016 Domain
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, DomainLength
* sizeof(WCHAR
));
1019 DPRINT1("HeapAlloc() failed\n");
1020 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1024 ret
= LookupAccountSidW(NULL
,
1031 } while (!ret
&& GetLastError() == ERROR_INSUFFICIENT_BUFFER
);
1035 DPRINT1("LookupAccountSidW() failed\n");
1039 /* Create profile */
1040 /* FIXME: ignore Domain? */
1041 DPRINT("UserName %S, Domain %S\n", UserName
, Domain
);
1042 ret
= CreateUserProfileW(UserSid
->User
.Sid
, UserName
);
1045 DPRINT1("CreateUserProfileW() failed\n");
1050 /* Get user SID string */
1051 ret
= GetUserSidFromToken(hToken
, &SidString
);
1054 DPRINT1("GetUserSidFromToken() failed\n");
1059 /* Acquire restore privilege */
1060 if (!AcquireRemoveRestorePrivilege(TRUE
))
1062 DPRINT1("AcquireRemoveRestorePrivilege() failed (Error %ld)\n", GetLastError());
1066 /* Load user registry hive */
1067 Error
= RegLoadKeyW(HKEY_USERS
,
1070 AcquireRemoveRestorePrivilege(FALSE
);
1071 if (Error
!= ERROR_SUCCESS
)
1073 DPRINT1("RegLoadKeyW() failed (Error %ld)\n", Error
);
1074 SetLastError((DWORD
)Error
);
1078 /* Open future HKEY_CURRENT_USER */
1079 Error
= RegOpenKeyExW(HKEY_USERS
,
1083 (PHKEY
)&lpProfileInfo
->hProfile
);
1084 if (Error
!= ERROR_SUCCESS
)
1086 DPRINT1("RegOpenKeyExW() failed (Error %ld)\n", Error
);
1087 SetLastError((DWORD
)Error
);
1094 HeapFree(GetProcessHeap(), 0, UserSid
);
1095 HeapFree(GetProcessHeap(), 0, UserName
);
1096 HeapFree(GetProcessHeap(), 0, Domain
);
1097 RtlFreeUnicodeString(&SidString
);
1099 DPRINT("LoadUserProfileW() done\n");
1106 UnloadUserProfile(HANDLE hToken
,
1109 UNICODE_STRING SidString
;
1112 DPRINT("UnloadUserProfile() called\n");
1114 if (hProfile
== NULL
)
1116 DPRINT1("Invalide profile handle\n");
1117 SetLastError(ERROR_INVALID_PARAMETER
);
1121 RegCloseKey(hProfile
);
1123 if (!GetUserSidFromToken(hToken
,
1126 DPRINT1("GetUserSidFromToken() failed\n");
1130 DPRINT("SidString: '%wZ'\n", &SidString
);
1132 Error
= RegUnLoadKeyW(HKEY_USERS
,
1134 if (Error
!= ERROR_SUCCESS
)
1136 DPRINT1("RegUnLoadKeyW() failed (Error %ld)\n", Error
);
1137 RtlFreeUnicodeString(&SidString
);
1138 SetLastError((DWORD
)Error
);
1142 RtlFreeUnicodeString(&SidString
);
1144 DPRINT("UnloadUserProfile() done\n");
1151 DeleteProfileW(LPCWSTR lpSidString
,
1152 LPCWSTR lpProfilePath
,
1153 LPCWSTR lpComputerName
)
1155 DPRINT1("DeleteProfileW() not implemented!\n");
1161 DeleteProfileA(LPCSTR lpSidString
,
1162 LPCSTR lpProfilePath
,
1163 LPCSTR lpComputerName
)
1165 DPRINT1("DeleteProfileA() not implemented!\n");