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 TOKEN_PRIVILEGES TokenPriv
;
111 DPRINT("AcquireRemoveRestorePrivilege(%d)\n", bAcquire
);
113 if (OpenProcessToken(GetCurrentProcess(),
114 TOKEN_ADJUST_PRIVILEGES
,
117 TokenPriv
.PrivilegeCount
= 1;
118 TokenPriv
.Privileges
[0].Attributes
= (bAcquire
? SE_PRIVILEGE_ENABLED
: 0);
120 if (LookupPrivilegeValue(NULL
, SE_RESTORE_NAME
, &TokenPriv
.Privileges
[0].Luid
))
122 bRet
= AdjustTokenPrivileges(Token
, FALSE
, &TokenPriv
, 0, NULL
, NULL
);
126 DPRINT1("AdjustTokenPrivileges() failed with error %lu\n", GetLastError());
128 else if (GetLastError() == ERROR_NOT_ALL_ASSIGNED
)
130 DPRINT1("AdjustTokenPrivileges() succeeded, but with not all privileges assigned\n");
136 DPRINT1("LookupPrivilegeValue() failed with error %lu\n", GetLastError());
143 DPRINT1("OpenProcessToken() failed with error %lu\n", GetLastError());
152 CreateUserProfileW(PSID Sid
,
155 WCHAR szRawProfilesPath
[MAX_PATH
];
156 WCHAR szProfilesPath
[MAX_PATH
];
157 WCHAR szUserProfilePath
[MAX_PATH
];
158 WCHAR szDefaultUserPath
[MAX_PATH
];
159 WCHAR szUserProfileName
[MAX_PATH
];
160 WCHAR szBuffer
[MAX_PATH
];
169 DPRINT("CreateUserProfileW() called\n");
171 Error
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
172 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList",
176 if (Error
!= ERROR_SUCCESS
)
178 DPRINT1("Error: %lu\n", Error
);
179 SetLastError((DWORD
)Error
);
183 /* Get profiles path */
184 dwLength
= MAX_PATH
* sizeof(WCHAR
);
185 Error
= RegQueryValueExW(hKey
,
186 L
"ProfilesDirectory",
189 (LPBYTE
)szRawProfilesPath
,
191 if (Error
!= ERROR_SUCCESS
)
193 DPRINT1("Error: %lu\n", Error
);
195 SetLastError((DWORD
)Error
);
200 if (!ExpandEnvironmentStringsW(szRawProfilesPath
,
204 DPRINT1("Error: %lu\n", GetLastError());
209 /* create the profiles directory if it does not yet exist */
210 if (!CreateDirectoryW(szProfilesPath
, NULL
))
212 if (GetLastError() != ERROR_ALREADY_EXISTS
)
214 DPRINT1("Error: %lu\n", GetLastError());
219 /* Get default user path */
220 dwLength
= MAX_PATH
* sizeof(WCHAR
);
221 Error
= RegQueryValueExW(hKey
,
222 L
"DefaultUserProfile",
227 if (Error
!= ERROR_SUCCESS
)
229 DPRINT1("Error: %lu\n", Error
);
231 SetLastError((DWORD
)Error
);
237 wcscpy(szUserProfileName
, lpUserName
);
239 wcscpy(szUserProfilePath
, szProfilesPath
);
240 wcscat(szUserProfilePath
, L
"\\");
241 wcscat(szUserProfilePath
, szUserProfileName
);
243 wcscpy(szDefaultUserPath
, szProfilesPath
);
244 wcscat(szDefaultUserPath
, L
"\\");
245 wcscat(szDefaultUserPath
, szBuffer
);
247 /* Create user profile directory */
248 if (!CreateDirectoryW(szUserProfilePath
, NULL
))
250 if (GetLastError() != ERROR_ALREADY_EXISTS
)
252 DPRINT1("Error: %lu\n", GetLastError());
256 for (i
= 0; i
< 1000; i
++)
258 swprintf(szUserProfileName
, L
"%s.%03u", lpUserName
, i
);
260 wcscpy(szUserProfilePath
, szProfilesPath
);
261 wcscat(szUserProfilePath
, L
"\\");
262 wcscat(szUserProfilePath
, szUserProfileName
);
264 if (CreateDirectoryW(szUserProfilePath
, NULL
))
267 if (GetLastError() != ERROR_ALREADY_EXISTS
)
269 DPRINT1("Error: %lu\n", GetLastError());
275 /* Copy default user directory */
276 if (!CopyDirectory(szUserProfilePath
, szDefaultUserPath
))
278 DPRINT1("Error: %lu\n", GetLastError());
282 /* Add profile to profile list */
283 if (!ConvertSidToStringSidW(Sid
,
286 DPRINT1("Error: %lu\n", GetLastError());
291 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\");
292 wcscat(szBuffer
, SidString
);
294 /* Create user profile key */
295 Error
= RegCreateKeyExW(HKEY_LOCAL_MACHINE
,
299 REG_OPTION_NON_VOLATILE
,
304 if (Error
!= ERROR_SUCCESS
)
306 DPRINT1("Error: %lu\n", Error
);
311 /* Create non-expanded user profile path */
312 wcscpy(szBuffer
, szRawProfilesPath
);
313 wcscat(szBuffer
, L
"\\");
314 wcscat(szBuffer
, szUserProfileName
);
316 /* Set 'ProfileImagePath' value (non-expanded) */
317 Error
= RegSetValueExW(hKey
,
322 (wcslen (szBuffer
) + 1) * sizeof(WCHAR
));
323 if (Error
!= ERROR_SUCCESS
)
325 DPRINT1("Error: %lu\n", Error
);
331 /* Set 'Sid' value */
332 Error
= RegSetValueExW(hKey
,
338 if (Error
!= ERROR_SUCCESS
)
340 DPRINT1("Error: %lu\n", Error
);
348 /* Create user hive name */
349 wcscpy(szBuffer
, szUserProfilePath
);
350 wcscat(szBuffer
, L
"\\ntuser.dat");
352 /* Acquire restore privilege */
353 if (!AcquireRemoveRestorePrivilege(TRUE
))
355 Error
= GetLastError();
356 DPRINT1("Error: %lu\n", Error
);
361 /* Create new user hive */
362 Error
= RegLoadKeyW(HKEY_USERS
,
365 AcquireRemoveRestorePrivilege(FALSE
);
366 if (Error
!= ERROR_SUCCESS
)
368 DPRINT1("Error: %lu\n", Error
);
373 /* Initialize user hive */
374 if (!CreateUserHive(SidString
, szUserProfilePath
))
376 Error
= GetLastError();
377 DPRINT1("Error: %lu\n", Error
);
381 /* Unload the hive */
382 AcquireRemoveRestorePrivilege(TRUE
);
383 RegUnLoadKeyW(HKEY_USERS
, SidString
);
384 AcquireRemoveRestorePrivilege(FALSE
);
387 LocalFree((HLOCAL
)SidString
);
388 SetLastError((DWORD
)Error
);
390 DPRINT("CreateUserProfileW() done\n");
398 GetAllUsersProfileDirectoryA(LPSTR lpProfileDir
,
404 lpBuffer
= GlobalAlloc(GMEM_FIXED
,
405 *lpcchSize
* sizeof(WCHAR
));
406 if (lpBuffer
== NULL
)
409 bResult
= GetAllUsersProfileDirectoryW(lpBuffer
,
413 WideCharToMultiByte(CP_ACP
,
423 GlobalFree(lpBuffer
);
431 GetAllUsersProfileDirectoryW(LPWSTR lpProfileDir
,
434 WCHAR szProfilePath
[MAX_PATH
];
435 WCHAR szBuffer
[MAX_PATH
];
440 Error
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
441 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList",
445 if (Error
!= ERROR_SUCCESS
)
447 DPRINT1("Error: %lu\n", Error
);
448 SetLastError((DWORD
)Error
);
452 /* Get profiles path */
453 dwLength
= sizeof(szBuffer
);
454 Error
= RegQueryValueExW(hKey
,
455 L
"ProfilesDirectory",
460 if (Error
!= ERROR_SUCCESS
)
462 DPRINT1("Error: %lu\n", Error
);
464 SetLastError((DWORD
)Error
);
469 if (!ExpandEnvironmentStringsW(szBuffer
,
473 DPRINT1("Error: %lu\n", GetLastError());
478 /* Get 'AllUsersProfile' name */
479 dwLength
= sizeof(szBuffer
);
480 Error
= RegQueryValueExW(hKey
,
486 if (Error
!= ERROR_SUCCESS
)
488 DPRINT1("Error: %lu\n", Error
);
490 SetLastError((DWORD
)Error
);
496 wcscat(szProfilePath
, L
"\\");
497 wcscat(szProfilePath
, szBuffer
);
499 dwLength
= wcslen(szProfilePath
) + 1;
500 if (lpProfileDir
!= NULL
)
502 if (*lpcchSize
< dwLength
)
504 *lpcchSize
= dwLength
;
505 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
509 wcscpy(lpProfileDir
, szProfilePath
);
512 *lpcchSize
= dwLength
;
520 GetDefaultUserProfileDirectoryA(LPSTR lpProfileDir
,
526 lpBuffer
= GlobalAlloc(GMEM_FIXED
,
527 *lpcchSize
* sizeof(WCHAR
));
528 if (lpBuffer
== NULL
)
531 bResult
= GetDefaultUserProfileDirectoryW(lpBuffer
,
535 WideCharToMultiByte(CP_ACP
,
545 GlobalFree(lpBuffer
);
553 GetDefaultUserProfileDirectoryW(LPWSTR lpProfileDir
,
556 WCHAR szProfilePath
[MAX_PATH
];
557 WCHAR szBuffer
[MAX_PATH
];
562 Error
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
563 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList",
567 if (Error
!= ERROR_SUCCESS
)
569 DPRINT1("Error: %lu\n", Error
);
570 SetLastError((DWORD
)Error
);
574 /* Get profiles path */
575 dwLength
= sizeof(szBuffer
);
576 Error
= RegQueryValueExW(hKey
,
577 L
"ProfilesDirectory",
582 if (Error
!= ERROR_SUCCESS
)
584 DPRINT1("Error: %lu\n", Error
);
586 SetLastError((DWORD
)Error
);
591 if (!ExpandEnvironmentStringsW(szBuffer
,
595 DPRINT1("Error: %lu\n", GetLastError());
600 /* Get 'DefaultUserProfile' name */
601 dwLength
= sizeof(szBuffer
);
602 Error
= RegQueryValueExW(hKey
,
603 L
"DefaultUserProfile",
608 if (Error
!= ERROR_SUCCESS
)
610 DPRINT1("Error: %lu\n", Error
);
612 SetLastError((DWORD
)Error
);
618 wcscat(szProfilePath
, L
"\\");
619 wcscat(szProfilePath
, szBuffer
);
621 dwLength
= wcslen(szProfilePath
) + 1;
622 if (lpProfileDir
!= NULL
)
624 if (*lpcchSize
< dwLength
)
626 *lpcchSize
= dwLength
;
627 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
631 wcscpy(lpProfileDir
, szProfilePath
);
634 *lpcchSize
= dwLength
;
642 GetProfilesDirectoryA(LPSTR lpProfileDir
,
648 lpBuffer
= GlobalAlloc(GMEM_FIXED
,
649 *lpcchSize
* sizeof(WCHAR
));
650 if (lpBuffer
== NULL
)
653 bResult
= GetProfilesDirectoryW(lpBuffer
,
657 WideCharToMultiByte(CP_ACP
,
667 GlobalFree(lpBuffer
);
675 GetProfilesDirectoryW(LPWSTR lpProfilesDir
,
678 WCHAR szProfilesPath
[MAX_PATH
];
679 WCHAR szBuffer
[MAX_PATH
];
684 Error
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
685 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList",
689 if (Error
!= ERROR_SUCCESS
)
691 DPRINT1("Error: %lu\n", Error
);
692 SetLastError((DWORD
)Error
);
696 /* Get profiles path */
697 dwLength
= sizeof(szBuffer
);
698 Error
= RegQueryValueExW(hKey
,
699 L
"ProfilesDirectory",
704 if (Error
!= ERROR_SUCCESS
)
706 DPRINT1("Error: %lu\n", Error
);
708 SetLastError((DWORD
)Error
);
715 if (!ExpandEnvironmentStringsW(szBuffer
,
719 DPRINT1("Error: %lu\n", GetLastError());
723 dwLength
= wcslen (szProfilesPath
) + 1;
724 if (lpProfilesDir
!= NULL
)
726 if (*lpcchSize
< dwLength
)
728 *lpcchSize
= dwLength
;
729 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
733 wcscpy(lpProfilesDir
, szProfilesPath
);
736 *lpcchSize
= dwLength
;
744 GetUserProfileDirectoryA(HANDLE hToken
,
751 lpBuffer
= GlobalAlloc(GMEM_FIXED
,
752 *lpcchSize
* sizeof(WCHAR
));
753 if (lpBuffer
== NULL
)
756 bResult
= GetUserProfileDirectoryW(hToken
,
761 WideCharToMultiByte(CP_ACP
,
771 GlobalFree(lpBuffer
);
779 GetUserProfileDirectoryW(HANDLE hToken
,
783 UNICODE_STRING SidString
;
784 WCHAR szKeyName
[MAX_PATH
];
785 WCHAR szRawImagePath
[MAX_PATH
];
786 WCHAR szImagePath
[MAX_PATH
];
791 if (!GetUserSidFromToken(hToken
,
794 DPRINT1("GetUserSidFromToken() failed\n");
798 DPRINT("SidString: '%wZ'\n", &SidString
);
801 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\");
805 RtlFreeUnicodeString(&SidString
);
807 DPRINT("KeyName: '%S'\n", szKeyName
);
809 Error
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
814 if (Error
!= ERROR_SUCCESS
)
816 DPRINT1("Error: %lu\n", Error
);
817 SetLastError((DWORD
)Error
);
821 dwLength
= sizeof(szRawImagePath
);
822 Error
= RegQueryValueExW(hKey
,
826 (LPBYTE
)szRawImagePath
,
828 if (Error
!= ERROR_SUCCESS
)
830 DPRINT1("Error: %lu\n", Error
);
832 SetLastError((DWORD
)Error
);
838 DPRINT("RawImagePath: '%S'\n", szRawImagePath
);
841 if (!ExpandEnvironmentStringsW(szRawImagePath
,
845 DPRINT1 ("Error: %lu\n", GetLastError());
849 DPRINT("ImagePath: '%S'\n", szImagePath
);
851 dwLength
= wcslen (szImagePath
) + 1;
852 if (*lpcchSize
< dwLength
)
854 *lpcchSize
= dwLength
;
855 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
859 *lpcchSize
= dwLength
;
860 wcscpy(lpProfileDir
, szImagePath
);
868 CheckForLoadedProfile(HANDLE hToken
)
870 UNICODE_STRING SidString
;
873 DPRINT("CheckForLoadedProfile() called\n");
875 if (!GetUserSidFromToken(hToken
,
878 DPRINT1("GetUserSidFromToken() failed\n");
882 if (RegOpenKeyExW(HKEY_USERS
,
888 DPRINT("Profile not loaded\n");
889 RtlFreeUnicodeString(&SidString
);
895 RtlFreeUnicodeString(&SidString
);
897 DPRINT("Profile already loaded\n");
905 LoadUserProfileA(HANDLE hToken
,
906 LPPROFILEINFOA lpProfileInfo
)
908 DPRINT ("LoadUserProfileA() not implemented\n");
915 LoadUserProfileW(IN HANDLE hToken
,
916 IN OUT LPPROFILEINFOW lpProfileInfo
)
918 WCHAR szUserHivePath
[MAX_PATH
];
919 LPWSTR UserName
= NULL
, Domain
= NULL
;
920 DWORD UserNameLength
= 0, DomainLength
= 0;
921 PTOKEN_USER UserSid
= NULL
;
922 SID_NAME_USE AccountType
;
923 UNICODE_STRING SidString
= { 0, 0, NULL
};
926 DWORD dwLength
= sizeof(szUserHivePath
) / sizeof(szUserHivePath
[0]);
928 DPRINT("LoadUserProfileW() called\n");
930 /* Check profile info */
931 if (!lpProfileInfo
|| (lpProfileInfo
->dwSize
!= sizeof(PROFILEINFOW
)) ||
932 (lpProfileInfo
->lpUserName
== NULL
) || (lpProfileInfo
->lpUserName
[0] == 0))
934 SetLastError(ERROR_INVALID_PARAMETER
);
938 /* Don't load a profile twice */
939 if (CheckForLoadedProfile(hToken
))
941 DPRINT ("Profile already loaded\n");
942 lpProfileInfo
->hProfile
= NULL
;
946 if (lpProfileInfo
->lpProfilePath
)
948 wcscpy(szUserHivePath
, lpProfileInfo
->lpProfilePath
);
952 /* FIXME: check if MS Windows allows lpProfileInfo->lpProfilePath to be NULL */
953 if (!GetProfilesDirectoryW(szUserHivePath
, &dwLength
))
955 DPRINT1("GetProfilesDirectoryW() failed (error %ld)\n", GetLastError());
960 /* Create user hive name */
961 wcscat(szUserHivePath
, L
"\\");
962 wcscat(szUserHivePath
, lpProfileInfo
->lpUserName
);
963 wcscat(szUserHivePath
, L
"\\ntuser.dat");
964 DPRINT("szUserHivePath: %S\n", szUserHivePath
);
966 /* Create user profile directory if needed */
967 if (GetFileAttributesW(szUserHivePath
) == INVALID_FILE_ATTRIBUTES
)
970 if (GetTokenInformation(hToken
, TokenUser
, NULL
, 0, &dwLength
) ||
971 GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
973 DPRINT1 ("GetTokenInformation() failed\n");
977 UserSid
= (PTOKEN_USER
)HeapAlloc(GetProcessHeap(), 0, dwLength
);
980 DPRINT1("HeapAlloc() failed\n");
981 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
985 if (!GetTokenInformation(hToken
, TokenUser
, UserSid
, dwLength
, &dwLength
))
987 DPRINT1("GetTokenInformation() failed\n");
994 if (UserNameLength
> 0)
996 HeapFree(GetProcessHeap(), 0, UserName
);
997 UserName
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, UserNameLength
* sizeof(WCHAR
));
1000 DPRINT1("HeapAlloc() failed\n");
1001 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1005 if (DomainLength
> 0)
1007 HeapFree(GetProcessHeap(), 0, Domain
);
1008 Domain
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, DomainLength
* sizeof(WCHAR
));
1011 DPRINT1("HeapAlloc() failed\n");
1012 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1016 ret
= LookupAccountSidW(NULL
,
1023 } while (!ret
&& GetLastError() == ERROR_INSUFFICIENT_BUFFER
);
1027 DPRINT1("LookupAccountSidW() failed\n");
1031 /* Create profile */
1032 /* FIXME: ignore Domain? */
1033 DPRINT("UserName %S, Domain %S\n", UserName
, Domain
);
1034 ret
= CreateUserProfileW(UserSid
->User
.Sid
, UserName
);
1037 DPRINT1("CreateUserProfileW() failed\n");
1042 /* Get user SID string */
1043 ret
= GetUserSidFromToken(hToken
, &SidString
);
1046 DPRINT1("GetUserSidFromToken() failed\n");
1051 /* Acquire restore privilege */
1052 if (!AcquireRemoveRestorePrivilege(TRUE
))
1054 DPRINT1("AcquireRemoveRestorePrivilege() failed (Error %ld)\n", GetLastError());
1058 /* Load user registry hive */
1059 Error
= RegLoadKeyW(HKEY_USERS
,
1062 AcquireRemoveRestorePrivilege(FALSE
);
1063 if (Error
!= ERROR_SUCCESS
)
1065 DPRINT1("RegLoadKeyW() failed (Error %ld)\n", Error
);
1066 SetLastError((DWORD
)Error
);
1070 /* Open future HKEY_CURRENT_USER */
1071 Error
= RegOpenKeyExW(HKEY_USERS
,
1075 (PHKEY
)&lpProfileInfo
->hProfile
);
1076 if (Error
!= ERROR_SUCCESS
)
1078 DPRINT1("RegOpenKeyExW() failed (Error %ld)\n", Error
);
1079 SetLastError((DWORD
)Error
);
1086 HeapFree(GetProcessHeap(), 0, UserSid
);
1087 HeapFree(GetProcessHeap(), 0, UserName
);
1088 HeapFree(GetProcessHeap(), 0, Domain
);
1089 RtlFreeUnicodeString(&SidString
);
1091 DPRINT("LoadUserProfileW() done\n");
1098 UnloadUserProfile(HANDLE hToken
,
1101 UNICODE_STRING SidString
;
1104 DPRINT("UnloadUserProfile() called\n");
1106 if (hProfile
== NULL
)
1108 DPRINT1("Invalide profile handle\n");
1109 SetLastError(ERROR_INVALID_PARAMETER
);
1113 RegCloseKey(hProfile
);
1115 if (!GetUserSidFromToken(hToken
,
1118 DPRINT1("GetUserSidFromToken() failed\n");
1122 DPRINT("SidString: '%wZ'\n", &SidString
);
1124 /* Acquire restore privilege */
1125 if (!AcquireRemoveRestorePrivilege(TRUE
))
1127 DPRINT1("AcquireRemoveRestorePrivilege() failed (Error %ld)\n", GetLastError());
1128 RtlFreeUnicodeString(&SidString
);
1132 /* Unload the hive */
1133 Error
= RegUnLoadKeyW(HKEY_USERS
,
1136 /* Remove restore privilege */
1137 AcquireRemoveRestorePrivilege(FALSE
);
1139 if (Error
!= ERROR_SUCCESS
)
1141 DPRINT1("RegUnLoadKeyW() failed (Error %ld)\n", Error
);
1142 RtlFreeUnicodeString(&SidString
);
1143 SetLastError((DWORD
)Error
);
1147 RtlFreeUnicodeString(&SidString
);
1149 DPRINT("UnloadUserProfile() done\n");
1156 DeleteProfileW(LPCWSTR lpSidString
,
1157 LPCWSTR lpProfilePath
,
1158 LPCWSTR lpComputerName
)
1160 DPRINT1("DeleteProfileW() not implemented!\n");
1166 DeleteProfileA(LPCSTR lpSidString
,
1167 LPCSTR lpProfilePath
,
1168 LPCSTR lpComputerName
)
1170 DPRINT1("DeleteProfileA() not implemented!\n");