Commit in reactos/lib/userenv on MAIN
profile.c+99-21.6 -> 1.7
registry.c+10-101.2 -> 1.3
+109-12
2 modified files
Implement GetUserProfileDirectoryW().
Open user key in LoadUserProfileW() and close it in UnloadUserProfile().

reactos/lib/userenv
profile.c 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- profile.c	13 Mar 2004 20:49:07 -0000	1.6
+++ profile.c	14 Mar 2004 18:15:59 -0000	1.7
@@ -1,4 +1,4 @@
-/* $Id: profile.c,v 1.6 2004/03/13 20:49:07 ekohl Exp $
+/* $Id: profile.c,v 1.7 2004/03/14 18:15:59 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -506,8 +506,85 @@
 			  LPWSTR lpProfileDir,
 			  LPDWORD lpcchSize)
 {
-  /* FIXME */
+  UNICODE_STRING SidString;
+  WCHAR szKeyName[MAX_PATH];
+  WCHAR szRawImagePath[MAX_PATH];
+  WCHAR szImagePath[MAX_PATH];
+  DWORD dwLength;
+  HKEY hKey;
+
+  if (!GetUserSidFromToken (hToken,
+			    &SidString))
+    {
+      DPRINT1 ("GetUserSidFromToken() failed\n");
+      return FALSE;
+    }
+
+  DPRINT ("SidString: '%wZ'\n", &SidString);
+
+  wcscpy (szKeyName,
+	  L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\");
+  wcscat (szKeyName,
+	  SidString.Buffer);
+
+  RtlFreeUnicodeString (&SidString);
+
+  DPRINT ("KeyName: '%S'\n", szKeyName);
+
+  if (RegOpenKeyExW (HKEY_LOCAL_MACHINE,
+		     szKeyName,
+		     0,
+		     KEY_ALL_ACCESS,
+		     &hKey))
+    {
+      DPRINT1 ("Error: %lu\n", GetLastError());
+      return FALSE;
+    }
+
+  dwLength = MAX_PATH * sizeof(WCHAR);
+  if (RegQueryValueExW (hKey,
+			L"ProfileImagePath",
+			NULL,
+			NULL,
+			(LPBYTE)szRawImagePath,
+			&dwLength))
+    {
+      DPRINT1 ("Error: %lu\n", GetLastError());
+      RegCloseKey (hKey);
+      return FALSE;
+    }
+
+  RegCloseKey (hKey);
+
+  DPRINT ("RawImagePath: '%S'\n", szRawImagePath);
+
+  /* Expand it */
+  if (!ExpandEnvironmentStringsW (szRawImagePath,
+				  szImagePath,
+				  MAX_PATH))
+    {
+      DPRINT1 ("Error: %lu\n", GetLastError());
+      return FALSE;
+    }
+
+  DPRINT ("ImagePath: '%S'\n", szImagePath);
+
+  dwLength = wcslen (szImagePath);
+  if (dwLength > *lpcchSize)
+    {
+      DPRINT1 ("Buffer too small\n");
+      SetLastError (ERROR_INSUFFICIENT_BUFFER);
+      return FALSE;
+    }
+
+  *lpcchSize = dwLength;
+  wcscpy (lpProfileDir,
+	  szImagePath);
+
+  return TRUE;
+#if 0
   return GetDefaultUserProfileDirectoryW (lpProfileDir, lpcchSize);
+#endif
 }
 
 
@@ -601,6 +678,17 @@
       return FALSE;
     }
 
+  if (RegOpenKeyExW (HKEY_USERS,
+		     SidString.Buffer,
+		     0,
+		     KEY_ALL_ACCESS,
+		     (PHKEY)&lpProfileInfo->hProfile))
+    {
+      DPRINT1 ("RegOpenKeyExW() failed (Error %ld)\n", GetLastError());
+      RtlFreeUnicodeString (&SidString);
+      return FALSE;
+    }
+
   RtlFreeUnicodeString (&SidString);
 
   DPRINT ("LoadUserProfileW() done\n");
@@ -617,6 +705,15 @@
 
   DPRINT ("UnloadUserProfile() called\n");
 
+  if (hProfile == NULL)
+    {
+      DPRINT1 ("Invalide profile handle\n");
+      SetLastError (ERROR_INVALID_PARAMETER);
+      return FALSE;
+    }
+
+  RegCloseKey (hProfile);
+
   if (!GetUserSidFromToken (hToken,
 			    &SidString))
     {

reactos/lib/userenv
registry.c 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- registry.c	28 Feb 2004 11:30:59 -0000	1.2
+++ registry.c	14 Mar 2004 18:15:59 -0000	1.3
@@ -1,4 +1,4 @@
-/* $Id: registry.c,v 1.2 2004/02/28 11:30:59 ekohl Exp $
+/* $Id: registry.c,v 1.3 2004/03/14 18:15:59 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -52,7 +52,7 @@
 		       NULL,
 		       NULL))
     {
-      DPRINT1("Error: %lu\n", GetLastError ());
+      DPRINT1 ("RegQueryInfoKey() failed (Error %lu)\n", GetLastError ());
       return FALSE;
     }
 
@@ -86,7 +86,7 @@
 			     NULL,
 			     &LastWrite))
 	    {
-	      DPRINT1("Subkey enumeration failed (Error %lu)\n", GetLastError());
+	      DPRINT ("Subkey enumeration failed (Error %lu)\n", GetLastError());
 	      HeapFree (GetProcessHeap (),
 			0,
 			lpNameBuffer);
@@ -103,7 +103,7 @@
 			       &hDstSubKey,
 			       &dwDisposition))
 	    {
-	      DPRINT1("Subkey creation failed (Error %lu)\n", GetLastError());
+	      DPRINT ("Subkey creation failed (Error %lu)\n", GetLastError());
 	      HeapFree (GetProcessHeap (),
 			0,
 			lpNameBuffer);
@@ -116,7 +116,7 @@
 			     KEY_READ,
 			     &hSrcSubKey))
 	    {
-	      DPRINT1("Error: %lu\n", GetLastError());
+	      DPRINT ("Error: %lu\n", GetLastError());
 	      RegCloseKey (hDstSubKey);
 	      HeapFree (GetProcessHeap (),
 			0,
@@ -127,7 +127,7 @@
 	  if (!CopyKey (hDstSubKey,
 			hSrcSubKey))
 	    {
-	      DPRINT1("Error: %lu\n", GetLastError());
+	      DPRINT ("Error: %lu\n", GetLastError());
 	      RegCloseKey (hSrcSubKey);
 	      RegCloseKey (hDstSubKey);
 	      HeapFree (GetProcessHeap (),
@@ -153,7 +153,7 @@
 				dwMaxValueNameLength * sizeof(WCHAR));
       if (lpNameBuffer == NULL)
 	{
-	  DPRINT1("Buffer allocation failed\n");
+	  DPRINT ("Buffer allocation failed\n");
 	  return FALSE;
 	}
 
@@ -162,7 +162,7 @@
 				dwMaxValueLength);
       if (lpDataBuffer == NULL)
 	{
-	  DPRINT1("Buffer allocation failed\n");
+	  DPRINT ("Buffer allocation failed\n");
 	  HeapFree (GetProcessHeap (),
 		    0,
 		    lpNameBuffer);
@@ -241,7 +241,7 @@
 		     KEY_READ,
 		     &hDefaultKey))
     {
-      DPRINT1("Error: %lu\n", GetLastError());
+      DPRINT1 ("Error: %lu\n", GetLastError());
       return FALSE;
     }
 
@@ -251,7 +251,7 @@
 		     KEY_ALL_ACCESS,
 		     &hUserKey))
     {
-      DPRINT1("Error: %lu\n", GetLastError());
+      DPRINT1 ("Error: %lu\n", GetLastError());
       RegCloseKey (hDefaultKey);
       return FALSE;
     }
CVSspam 0.2.8