7 modified files
reactos/lib/userenv
diff -u -r1.4 -r1.5
--- internal.h 16 Jan 2004 15:31:53 -0000 1.4
+++ internal.h 13 Mar 2004 20:49:07 -0000 1.5
@@ -1,4 +1,4 @@
-/* $Id: internal.h,v 1.4 2004/01/16 15:31:53 ekohl Exp $
+/* $Id: internal.h,v 1.5 2004/03/13 20:49:07 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@@ -24,21 +24,25 @@
#endif /* __GNUC__ */
#define CHECKPOINT
-/* directory.h */
+/* directory.c */
BOOL
CopyDirectory (LPCWSTR lpDestinationPath,
LPCWSTR lpSourcePath);
-/* misc.h */
+/* misc.c */
LPWSTR
AppendBackslash (LPWSTR String);
BOOL
+GetUserSidFromToken (HANDLE hToken,
+ PUNICODE_STRING SidString);
+
+/* profile.c */
+BOOL
AppendSystemPostfix (LPWSTR lpName,
DWORD dwMaxLength);
-
-/* registry.h */
+/* registry.c */
BOOL
CreateUserHive (LPCWSTR lpKeyName);
reactos/lib/userenv
diff -u -r1.1 -r1.2
--- misc.c 16 Jan 2004 15:31:53 -0000 1.1
+++ misc.c 13 Mar 2004 20:49:07 -0000 1.2
@@ -1,4 +1,4 @@
-/* $Id: misc.c,v 1.1 2004/01/16 15:31:53 ekohl Exp $
+/* $Id: misc.c,v 1.2 2004/03/13 20:49:07 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@@ -32,4 +32,63 @@
return &String[Length];
}
+
+BOOL
+GetUserSidFromToken (HANDLE hToken,
+ PUNICODE_STRING SidString)
+{
+ PSID_AND_ATTRIBUTES SidBuffer;
+ ULONG Length;
+ NTSTATUS Status;
+
+ Length = 256;
+ SidBuffer = LocalAlloc (0,
+ Length);
+ if (SidBuffer == NULL)
+ return FALSE;
+
+ Status = NtQueryInformationToken (hToken,
+ TokenUser,
+ (PVOID)SidBuffer,
+ Length,
+ &Length);
+ if (Status == STATUS_BUFFER_TOO_SMALL)
+ {
+ SidBuffer = LocalReAlloc (SidBuffer,
+ Length,
+ 0);
+ if (SidBuffer == NULL)
+ return FALSE;
+
+ Status = NtQueryInformationToken (hToken,
+ TokenUser,
+ (PVOID)SidBuffer,
+ Length,
+ &Length);
+ }
+
+ if (!NT_SUCCESS (Status))
+ {
+ LocalFree (SidBuffer);
+ return FALSE;
+ }
+
+ DPRINT ("SidLength: %lu\n", RtlLengthSid (SidBuffer[0].Sid));
+
+ Status = RtlConvertSidToUnicodeString (SidString,
+ SidBuffer[0].Sid,
+ TRUE);
+
+ LocalFree (SidBuffer);
+
+ if (!NT_SUCCESS (Status))
+ return FALSE;
+
+ DPRINT ("SidString.Length: %lu\n", SidString->Length);
+ DPRINT ("SidString.MaximumLength: %lu\n", SidString->MaximumLength);
+ DPRINT ("SidString: '%wZ'\n", SidString);
+
+ return TRUE;
+}
+
/* EOF */
reactos/lib/userenv
diff -u -r1.5 -r1.6
--- profile.c 28 Feb 2004 11:30:59 -0000 1.5
+++ profile.c 13 Mar 2004 20:49:07 -0000 1.6
@@ -1,4 +1,4 @@
-/* $Id: profile.c,v 1.5 2004/02/28 11:30:59 ekohl Exp $
+/* $Id: profile.c,v 1.6 2004/03/13 20:49:07 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@@ -515,6 +515,14 @@
LoadUserProfileW (HANDLE hToken,
LPPROFILEINFOW lpProfileInfo)
{
+ WCHAR szRawProfilesPath[MAX_PATH];
+ WCHAR szProfilesPath[MAX_PATH];
+ WCHAR szUserHivePath[MAX_PATH];
+ UNICODE_STRING SidString;
+ DWORD dwLength;
+ HKEY hKey;
+
+ DPRINT ("LoadUserProfileW() called\n");
/* Check profile info */
if (lpProfileInfo->dwSize != sizeof(PROFILEINFOW) ||
@@ -525,7 +533,110 @@
return FALSE;
}
- /* FIXME: load the profile */
+ if (RegOpenKeyExW (HKEY_LOCAL_MACHINE,
+ L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList",
+ 0,
+ KEY_ALL_ACCESS,
+ &hKey))
+ {
+ DPRINT1("Error: %lu\n", GetLastError());
+ return FALSE;
+ }
+
+ /* Get profiles path */
+ dwLength = MAX_PATH * sizeof(WCHAR);
+ if (RegQueryValueExW (hKey,
+ L"ProfilesDirectory",
+ NULL,
+ NULL,
+ (LPBYTE)szRawProfilesPath,
+ &dwLength))
+ {
+ DPRINT1("Error: %lu\n", GetLastError());
+ RegCloseKey (hKey);
+ return FALSE;
+ }
+
+ /* Expand it */
+ if (!ExpandEnvironmentStringsW (szRawProfilesPath,
+ szProfilesPath,
+ MAX_PATH))
+ {
+ DPRINT1("Error: %lu\n", GetLastError());
+ RegCloseKey (hKey);
+ return FALSE;
+ }
+
+ RegCloseKey (hKey);
+
+ wcscpy (szUserHivePath, szProfilesPath);
+ wcscat (szUserHivePath, L"\\");
+ wcscat (szUserHivePath, lpProfileInfo->lpUserName);
+ if (!AppendSystemPostfix (szUserHivePath, MAX_PATH))
+ {
+ DPRINT1("AppendSystemPostfix() failed\n", GetLastError());
+ return FALSE;
+ }
+
+ /* Create user hive name */
+ wcscat (szUserHivePath, L"\\ntuser.dat");
+
+ DPRINT ("szUserHivePath: %S\n", szUserHivePath);
+
+ if (!GetUserSidFromToken (hToken,
+ &SidString))
+ {
+ DPRINT1 ("GetUserSidFromToken() failed\n");
+ return FALSE;
+ }
+
+ DPRINT ("SidString: '%wZ'\n", &SidString);
+
+ if (RegLoadKeyW (HKEY_USERS,
+ SidString.Buffer,
+ szUserHivePath))
+ {
+ DPRINT1 ("RegLoadKeyW() failed (Error %ld)\n", GetLastError());
+ RtlFreeUnicodeString (&SidString);
+ return FALSE;
+ }
+
+ RtlFreeUnicodeString (&SidString);
+
+ DPRINT ("LoadUserProfileW() done\n");
+
+ return TRUE;
+}
+
+
+BOOL WINAPI
+UnloadUserProfile (HANDLE hToken,
+ HANDLE hProfile)
+{
+ UNICODE_STRING SidString;
+
+ DPRINT ("UnloadUserProfile() called\n");
+
+ if (!GetUserSidFromToken (hToken,
+ &SidString))
+ {
+ DPRINT1 ("GetUserSidFromToken() failed\n");
+ return FALSE;
+ }
+
+ DPRINT ("SidString: '%wZ'\n", &SidString);
+
+ if (RegUnLoadKeyW (HKEY_USERS,
+ SidString.Buffer))
+ {
+ DPRINT1 ("RegUnLoadKeyW() failed (Error %ld)\n", GetLastError());
+ RtlFreeUnicodeString (&SidString);
+ return FALSE;
+ }
+
+ RtlFreeUnicodeString (&SidString);
+
+ DPRINT ("UnloadUserProfile() done\n");
return TRUE;
}
reactos/lib/userenv
diff -u -r1.3 -r1.4
--- setup.c 16 Jan 2004 15:31:53 -0000 1.3
+++ setup.c 13 Mar 2004 20:49:07 -0000 1.4
@@ -1,4 +1,4 @@
-/* $Id: setup.c,v 1.3 2004/01/16 15:31:53 ekohl Exp $
+/* $Id: setup.c,v 1.4 2004/03/13 20:49:07 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@@ -7,6 +7,7 @@
* PROGRAMMER: Eric Kohl
*/
+#include <ntos.h>
#include <windows.h>
#include <string.h>
#include <stdarg.h>
reactos/lib/userenv
diff -u -r1.1 -r1.2
--- userenv.c 9 Jan 2004 19:52:01 -0000 1.1
+++ userenv.c 13 Mar 2004 20:49:07 -0000 1.2
@@ -1,4 +1,4 @@
-/* $Id: userenv.c,v 1.1 2004/01/09 19:52:01 ekohl Exp $
+/* $Id: userenv.c,v 1.2 2004/03/13 20:49:07 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@@ -7,6 +7,7 @@
* PROGRAMMER: Eric Kohl
*/
+#include <ntos.h>
#include <windows.h>
#include <userenv.h>
reactos/lib/userenv
diff -u -r1.3 -r1.4
--- userenv.def 28 Feb 2004 11:30:59 -0000 1.3
+++ userenv.def 13 Mar 2004 20:49:07 -0000 1.4
@@ -7,4 +7,5 @@
GetUserProfileDirectoryW@12
CreateUserProfileW@8
LoadUserProfileW@8
+UnloadUserProfile@8
;EOF
reactos/lib/userenv
diff -u -r1.3 -r1.4
--- userenv.edf 28 Feb 2004 11:30:59 -0000 1.3
+++ userenv.edf 13 Mar 2004 20:49:07 -0000 1.4
@@ -7,4 +7,5 @@
GetUserProfileDirectoryW=GetUserProfileDirectoryW@12
CreateUserProfileW=CreateUserProfileW@8
LoadUserProfileW=LoadUserProfileW@8
+UnloadUserProfile=UnloadUserProfile@8
;EOF
CVSspam 0.2.8