Fix code assuming that the Reg* functions set the last error code
Modified: trunk/reactos/lib/userenv/desktop.c
Modified: trunk/reactos/lib/userenv/environment.c
Modified: trunk/reactos/lib/userenv/misc.c
Modified: trunk/reactos/lib/userenv/precomp.h
Modified: trunk/reactos/lib/userenv/profile.c
Modified: trunk/reactos/lib/userenv/registry.c
Modified: trunk/reactos/lib/userenv/setup.c
Modified: trunk/reactos/lib/userenv/userenv.xml
_____
Modified: trunk/reactos/lib/userenv/desktop.c
--- trunk/reactos/lib/userenv/desktop.c 2006-01-11 23:54:44 UTC (rev
20794)
+++ trunk/reactos/lib/userenv/desktop.c 2006-01-12 00:11:14 UTC (rev
20795)
@@ -41,29 +41,34 @@
DWORD dwLength;
DWORD dwType;
HKEY hKey;
+ LONG Error;
DPRINT ("GetDesktopPath() called\n");
- if (RegOpenKeyExW (HKEY_CURRENT_USER,
-
L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell
Folders",
- 0,
- KEY_ALL_ACCESS,
- &hKey))
+ Error = RegOpenKeyExW (HKEY_CURRENT_USER,
+
L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell
Folders",
+ 0,
+ KEY_ALL_ACCESS,
+ &hKey);
+ if (Error != ERROR_SUCCESS)
{
DPRINT1 ("RegOpenKeyExW() failed\n");
+ SetLastError((DWORD)Error);
return FALSE;
}
dwLength = MAX_PATH * sizeof(WCHAR);
- if (RegQueryValueExW (hKey,
- bCommonPath ? L"Common Desktop" : L"Desktop",
- 0,
- &dwType,
- (LPBYTE)szPath,
- &dwLength))
+ Error = RegQueryValueExW (hKey,
+ bCommonPath ? L"Common Desktop" :
L"Desktop",
+ 0,
+ &dwType,
+ (LPBYTE)szPath,
+ &dwLength);
+ if (Error != ERROR_SUCCESS)
{
DPRINT1 ("RegQueryValueExW() failed\n");
RegCloseKey (hKey);
+ SetLastError((DWORD)Error);
return FALSE;
}
@@ -94,29 +99,34 @@
DWORD dwLength;
DWORD dwType;
HKEY hKey;
+ LONG Error;
DPRINT ("GetProgramsPath() called\n");
- if (RegOpenKeyExW (HKEY_CURRENT_USER,
-
L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell
Folders",
- 0,
- KEY_ALL_ACCESS,
- &hKey))
+ Error = RegOpenKeyExW (HKEY_CURRENT_USER,
+
L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell
Folders",
+ 0,
+ KEY_ALL_ACCESS,
+ &hKey);
+ if (Error != ERROR_SUCCESS)
{
DPRINT1 ("RegOpenKeyExW() failed\n");
+ SetLastError((DWORD)Error);
return FALSE;
}
dwLength = MAX_PATH * sizeof(WCHAR);
- if (RegQueryValueExW (hKey,
- bCommonPath ? L"Common Programs" : L"Programs",
- 0,
- &dwType,
- (LPBYTE)szPath,
- &dwLength))
+ Error = RegQueryValueExW (hKey,
+ bCommonPath ? L"Common Programs" :
L"Programs",
+ 0,
+ &dwType,
+ (LPBYTE)szPath,
+ &dwLength);
+ if (Error != ERROR_SUCCESS)
{
DPRINT1 ("RegQueryValueExW() failed\n");
RegCloseKey (hKey);
+ SetLastError((DWORD)Error);
return FALSE;
}
_____
Modified: trunk/reactos/lib/userenv/environment.c
--- trunk/reactos/lib/userenv/environment.c 2006-01-11 23:54:44 UTC
(rev 20794)
+++ trunk/reactos/lib/userenv/environment.c 2006-01-12 00:11:14 UTC
(rev 20795)
@@ -169,6 +169,7 @@
{
UNICODE_STRING SidString;
HKEY hKey;
+ LONG Error;
if (!GetUserSidFromToken (hToken,
&SidString))
@@ -177,14 +178,16 @@
return NULL;
}
- if (RegOpenKeyExW (HKEY_USERS,
- SidString.Buffer,
- 0,
- KEY_ALL_ACCESS,
- &hKey))
+ Error = RegOpenKeyExW (HKEY_USERS,
+ SidString.Buffer,
+ 0,
+ KEY_ALL_ACCESS,
+ &hKey);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1 ("RegOpenKeyExW() failed (Error %ld)\n", GetLastError());
+ DPRINT1 ("RegOpenKeyExW() failed (Error %ld)\n", Error);
RtlFreeUnicodeString (&SidString);
+ SetLastError((DWORD)Error);
return NULL;
}
@@ -209,32 +212,37 @@
DWORD i;
LPWSTR lpValueName;
LPWSTR lpValueData;
+ LONG Error;
- if (RegOpenKeyExW (hKey,
- lpSubKeyName,
- 0,
- KEY_ALL_ACCESS,
- &hEnvKey))
+ Error = RegOpenKeyExW (hKey,
+ lpSubKeyName,
+ 0,
+ KEY_ALL_ACCESS,
+ &hEnvKey);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1 ("RegOpenKeyExW() failed (Error %ld)\n", GetLastError());
+ DPRINT1 ("RegOpenKeyExW() failed (Error %ld)\n", Error);
+ SetLastError((DWORD)Error);
return FALSE;
}
- if (RegQueryInfoKey (hEnvKey,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- &dwValues,
- &dwMaxValueNameLength,
- &dwMaxValueDataLength,
- NULL,
- NULL))
+ Error = RegQueryInfoKey (hEnvKey,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ &dwValues,
+ &dwMaxValueNameLength,
+ &dwMaxValueDataLength,
+ NULL,
+ NULL);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1 ("RegQueryInforKey() failed (Error %ld)\n",
GetLastError());
+ DPRINT1 ("RegQueryInforKey() failed (Error %ld)\n", Error);
RegCloseKey (hEnvKey);
+ SetLastError((DWORD)Error);
return FALSE;
}
@@ -314,13 +322,17 @@
DPRINT("CreateEnvironmentBlock() called\n");
if (lpEnvironment == NULL)
- return FALSE;
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
Status = RtlCreateEnvironment ((BOOLEAN)bInherit,
(PWSTR*)lpEnvironment);
if (!NT_SUCCESS (Status))
{
DPRINT1 ("RtlCreateEnvironment() failed (Status %lx)\n", Status);
+ SetLastError (RtlNtStatusToDosError (Status));
return FALSE;
}
@@ -390,7 +402,10 @@
DPRINT ("DestroyEnvironmentBlock() called\n");
if (lpEnvironment == NULL)
- return FALSE;
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
RtlDestroyEnvironment (lpEnvironment);
_____
Modified: trunk/reactos/lib/userenv/misc.c
--- trunk/reactos/lib/userenv/misc.c 2006-01-11 23:54:44 UTC (rev
20794)
+++ trunk/reactos/lib/userenv/misc.c 2006-01-12 00:11:14 UTC (rev
20795)
@@ -91,6 +91,7 @@
if (!NT_SUCCESS (Status))
{
LocalFree ((HLOCAL)SidBuffer);
+ SetLastError (RtlNtStatusToDosError (Status));
return FALSE;
}
@@ -103,7 +104,10 @@
LocalFree ((HLOCAL)SidBuffer);
if (!NT_SUCCESS (Status))
- return FALSE;
+ {
+ SetLastError (RtlNtStatusToDosError (Status));
+ return FALSE;
+ }
DPRINT ("SidString.Length: %lu\n", SidString->Length);
DPRINT ("SidString.MaximumLength: %lu\n", SidString->MaximumLength);
_____
Modified: trunk/reactos/lib/userenv/precomp.h
--- trunk/reactos/lib/userenv/precomp.h 2006-01-11 23:54:44 UTC (rev
20794)
+++ trunk/reactos/lib/userenv/precomp.h 2006-01-12 00:11:14 UTC (rev
20795)
@@ -4,6 +4,7 @@
#define NTOS_MODE_USER
#include <ndk/ntndk.h>
#include <userenv.h>
+#include <sddl.h>
#include <shlobj.h>
#include "internal.h"
_____
Modified: trunk/reactos/lib/userenv/profile.c
--- trunk/reactos/lib/userenv/profile.c 2006-01-11 23:54:44 UTC (rev
20794)
+++ trunk/reactos/lib/userenv/profile.c 2006-01-12 00:11:14 UTC (rev
20795)
@@ -66,6 +66,7 @@
if (wcslen(lpName) + wcslen(lpszPostfix) >= dwMaxLength)
{
DPRINT1("Error: buffer overflow\n");
+ SetLastError(ERROR_BUFFER_OVERFLOW);
return FALSE;
}
@@ -109,35 +110,39 @@
WCHAR szUserProfilePath[MAX_PATH];
WCHAR szDefaultUserPath[MAX_PATH];
WCHAR szBuffer[MAX_PATH];
- UNICODE_STRING SidString;
+ LPWSTR SidString;
DWORD dwLength;
DWORD dwDisposition;
HKEY hKey;
- NTSTATUS Status;
+ LONG Error;
DPRINT("CreateUserProfileW() called\n");
- if (RegOpenKeyExW (HKEY_LOCAL_MACHINE,
- L"SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\ProfileList",
- 0,
- KEY_ALL_ACCESS,
- &hKey))
+ Error = RegOpenKeyExW (HKEY_LOCAL_MACHINE,
+ L"SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\ProfileList",
+ 0,
+ KEY_ALL_ACCESS,
+ &hKey);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1("Error: %lu\n", GetLastError());
+ DPRINT1("Error: %lu\n", Error);
+ SetLastError((DWORD)Error);
return FALSE;
}
/* Get profiles path */
dwLength = MAX_PATH * sizeof(WCHAR);
- if (RegQueryValueExW (hKey,
- L"ProfilesDirectory",
- NULL,
- NULL,
- (LPBYTE)szRawProfilesPath,
- &dwLength))
+ Error = RegQueryValueExW (hKey,
+ L"ProfilesDirectory",
+ NULL,
+ NULL,
+ (LPBYTE)szRawProfilesPath,
+ &dwLength);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1("Error: %lu\n", GetLastError());
+ DPRINT1("Error: %lu\n", Error);
RegCloseKey (hKey);
+ SetLastError((DWORD)Error);
return FALSE;
}
@@ -153,15 +158,17 @@
/* Get default user path */
dwLength = MAX_PATH * sizeof(WCHAR);
- if (RegQueryValueExW (hKey,
- L"DefaultUserProfile",
- NULL,
- NULL,
- (LPBYTE)szBuffer,
- &dwLength))
+ Error = RegQueryValueExW (hKey,
+ L"DefaultUserProfile",
+ NULL,
+ NULL,
+ (LPBYTE)szBuffer,
+ &dwLength);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1("Error: %lu\n", GetLastError());
+ DPRINT1("Error: %lu\n", Error);
RegCloseKey (hKey);
+ SetLastError((DWORD)Error);
return FALSE;
}
@@ -173,7 +180,7 @@
if (!AppendSystemPostfix (szUserProfilePath, MAX_PATH))
{
DPRINT1("AppendSystemPostfix() failed\n", GetLastError());
- RtlFreeUnicodeString (&SidString);
+ LocalFree ((HLOCAL)SidString);
RegCloseKey (hKey);
return FALSE;
}
@@ -200,30 +207,32 @@
}
/* Add profile to profile list */
- Status = RtlConvertSidToUnicodeString (&SidString, Sid, TRUE);
- if (!NT_SUCCESS(Status))
+ if (!ConvertSidToStringSidW (Sid,
+ &SidString))
{
- DPRINT1("Status: %lx\n", Status);
+ DPRINT1("Error: %lu\n", GetLastError());
return FALSE;
}
wcscpy (szBuffer,
L"SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\ProfileList\\");
- wcscat (szBuffer, SidString.Buffer);
+ wcscat (szBuffer, SidString);
/* Create user profile key */
- if (RegCreateKeyExW (HKEY_LOCAL_MACHINE,
- szBuffer,
- 0,
- NULL,
- REG_OPTION_NON_VOLATILE,
- KEY_ALL_ACCESS,
- NULL,
- &hKey,
- &dwDisposition))
+ Error = RegCreateKeyExW (HKEY_LOCAL_MACHINE,
+ szBuffer,
+ 0,
+ NULL,
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hKey,
+ &dwDisposition);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1("Error: %lu\n", GetLastError());
- RtlFreeUnicodeString (&SidString);
+ DPRINT1("Error: %lu\n", Error);
+ LocalFree ((HLOCAL)SidString);
+ SetLastError((DWORD)Error);
return FALSE;
}
@@ -234,36 +243,40 @@
if (!AppendSystemPostfix (szBuffer, MAX_PATH))
{
DPRINT1("AppendSystemPostfix() failed\n", GetLastError());
- RtlFreeUnicodeString (&SidString);
+ LocalFree ((HLOCAL)SidString);
RegCloseKey (hKey);
return FALSE;
}
/* Set 'ProfileImagePath' value (non-expanded) */
- if (RegSetValueExW (hKey,
- L"ProfileImagePath",
- 0,
- REG_EXPAND_SZ,
- (LPBYTE)szBuffer,
- (wcslen (szBuffer) + 1) * sizeof(WCHAR)))
+ Error = RegSetValueExW (hKey,
+ L"ProfileImagePath",
+ 0,
+ REG_EXPAND_SZ,
+ (LPBYTE)szBuffer,
+ (wcslen (szBuffer) + 1) * sizeof(WCHAR));
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1("Error: %lu\n", GetLastError());
- RtlFreeUnicodeString (&SidString);
+ DPRINT1("Error: %lu\n", Error);
+ LocalFree ((HLOCAL)SidString);
RegCloseKey (hKey);
+ SetLastError((DWORD)Error);
return FALSE;
}
/* Set 'Sid' value */
- if (RegSetValueExW (hKey,
- L"Sid",
- 0,
- REG_BINARY,
- Sid,
- RtlLengthSid (Sid)))
+ Error = RegSetValueExW (hKey,
+ L"Sid",
+ 0,
+ REG_BINARY,
+ Sid,
+ GetLengthSid (Sid));
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1("Error: %lu\n", GetLastError());
- RtlFreeUnicodeString (&SidString);
+ DPRINT1("Error: %lu\n", Error);
+ LocalFree ((HLOCAL)SidString);
RegCloseKey (hKey);
+ SetLastError((DWORD)Error);
return FALSE;
}
@@ -274,27 +287,29 @@
wcscat (szBuffer, L"\\ntuser.dat");
/* Create new user hive */
- if (RegLoadKeyW (HKEY_USERS,
- SidString.Buffer,
- szBuffer))
+ Error = RegLoadKeyW (HKEY_USERS,
+ SidString,
+ szBuffer);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1("Error: %lu\n", GetLastError());
- RtlFreeUnicodeString (&SidString);
+ DPRINT1("Error: %lu\n", Error);
+ LocalFree ((HLOCAL)SidString);
+ SetLastError((DWORD)Error);
return FALSE;
}
/* Initialize user hive */
- if (!CreateUserHive (SidString.Buffer, szUserProfilePath))
+ if (!CreateUserHive (SidString, szUserProfilePath))
{
DPRINT1("Error: %lu\n", GetLastError());
- RtlFreeUnicodeString (&SidString);
+ LocalFree ((HLOCAL)SidString);
return FALSE;
}
RegUnLoadKeyW (HKEY_USERS,
- SidString.Buffer);
+ SidString);
- RtlFreeUnicodeString (&SidString);
+ LocalFree ((HLOCAL)SidString);
DPRINT("CreateUserProfileW() done\n");
@@ -342,28 +357,33 @@
WCHAR szBuffer[MAX_PATH];
DWORD dwLength;
HKEY hKey;
+ LONG Error;
- if (RegOpenKeyExW (HKEY_LOCAL_MACHINE,
- L"SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\ProfileList",
- 0,
- KEY_READ,
- &hKey))
+ Error = RegOpenKeyExW (HKEY_LOCAL_MACHINE,
+ L"SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\ProfileList",
+ 0,
+ KEY_READ,
+ &hKey);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1("Error: %lu\n", GetLastError());
+ DPRINT1("Error: %lu\n", Error);
+ SetLastError((DWORD)Error);
return FALSE;
}
/* Get profiles path */
dwLength = sizeof(szBuffer);
- if (RegQueryValueExW (hKey,
- L"ProfilesDirectory",
- NULL,
- NULL,
- (LPBYTE)szBuffer,
- &dwLength))
+ Error = RegQueryValueExW (hKey,
+ L"ProfilesDirectory",
+ NULL,
+ NULL,
+ (LPBYTE)szBuffer,
+ &dwLength);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1("Error: %lu\n", GetLastError());
+ DPRINT1("Error: %lu\n", Error);
RegCloseKey (hKey);
+ SetLastError((DWORD)Error);
return FALSE;
}
@@ -379,15 +399,17 @@
/* Get 'AllUsersProfile' name */
dwLength = sizeof(szBuffer);
- if (RegQueryValueExW (hKey,
- L"AllUsersProfile",
- NULL,
- NULL,
- (LPBYTE)szBuffer,
- &dwLength))
+ Error = RegQueryValueExW (hKey,
+ L"AllUsersProfile",
+ NULL,
+ NULL,
+ (LPBYTE)szBuffer,
+ &dwLength);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1("Error: %lu\n", GetLastError());
+ DPRINT1("Error: %lu\n", Error);
RegCloseKey (hKey);
+ SetLastError((DWORD)Error);
return FALSE;
}
@@ -455,28 +477,33 @@
WCHAR szBuffer[MAX_PATH];
DWORD dwLength;
HKEY hKey;
+ LONG Error;
- if (RegOpenKeyExW (HKEY_LOCAL_MACHINE,
- L"SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\ProfileList",
- 0,
- KEY_READ,
- &hKey))
+ Error = RegOpenKeyExW (HKEY_LOCAL_MACHINE,
+ L"SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\ProfileList",
+ 0,
+ KEY_READ,
+ &hKey);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1("Error: %lu\n", GetLastError());
+ DPRINT1("Error: %lu\n", Error);
+ SetLastError((DWORD)Error);
return FALSE;
}
/* Get profiles path */
dwLength = sizeof(szBuffer);
- if (RegQueryValueExW (hKey,
- L"ProfilesDirectory",
- NULL,
- NULL,
- (LPBYTE)szBuffer,
- &dwLength))
+ Error = RegQueryValueExW (hKey,
+ L"ProfilesDirectory",
+ NULL,
+ NULL,
+ (LPBYTE)szBuffer,
+ &dwLength);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1("Error: %lu\n", GetLastError());
+ DPRINT1("Error: %lu\n", Error);
RegCloseKey (hKey);
+ SetLastError((DWORD)Error);
return FALSE;
}
@@ -492,15 +519,17 @@
/* Get 'DefaultUserProfile' name */
dwLength = sizeof(szBuffer);
- if (RegQueryValueExW (hKey,
- L"DefaultUserProfile",
- NULL,
- NULL,
- (LPBYTE)szBuffer,
- &dwLength))
+ Error = RegQueryValueExW (hKey,
+ L"DefaultUserProfile",
+ NULL,
+ NULL,
+ (LPBYTE)szBuffer,
+ &dwLength);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1("Error: %lu\n", GetLastError());
+ DPRINT1("Error: %lu\n", Error);
RegCloseKey (hKey);
+ SetLastError((DWORD)Error);
return FALSE;
}
@@ -568,28 +597,33 @@
WCHAR szBuffer[MAX_PATH];
DWORD dwLength;
HKEY hKey;
+ LONG Error;
- if (RegOpenKeyExW (HKEY_LOCAL_MACHINE,
- L"SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\ProfileList",
- 0,
- KEY_READ,
- &hKey))
+ Error = RegOpenKeyExW (HKEY_LOCAL_MACHINE,
+ L"SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\ProfileList",
+ 0,
+ KEY_READ,
+ &hKey);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1("Error: %lu\n", GetLastError());
+ DPRINT1("Error: %lu\n", Error);
+ SetLastError((DWORD)Error);
return FALSE;
}
/* Get profiles path */
dwLength = sizeof(szBuffer);
- if (RegQueryValueExW (hKey,
- L"ProfilesDirectory",
- NULL,
- NULL,
- (LPBYTE)szBuffer,
- &dwLength))
+ Error = RegQueryValueExW (hKey,
+ L"ProfilesDirectory",
+ NULL,
+ NULL,
+ (LPBYTE)szBuffer,
+ &dwLength);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1("Error: %lu\n", GetLastError());
+ DPRINT1("Error: %lu\n", Error);
RegCloseKey (hKey);
+ SetLastError((DWORD)Error);
return FALSE;
}
@@ -668,6 +702,7 @@
WCHAR szImagePath[MAX_PATH];
DWORD dwLength;
HKEY hKey;
+ LONG Error;
if (!GetUserSidFromToken (hToken,
&SidString))
@@ -687,26 +722,30 @@
DPRINT ("KeyName: '%S'\n", szKeyName);
- if (RegOpenKeyExW (HKEY_LOCAL_MACHINE,
- szKeyName,
- 0,
- KEY_ALL_ACCESS,
- &hKey))
+ Error = RegOpenKeyExW (HKEY_LOCAL_MACHINE,
+ szKeyName,
+ 0,
+ KEY_ALL_ACCESS,
+ &hKey);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1 ("Error: %lu\n", GetLastError());
+ DPRINT1 ("Error: %lu\n", Error);
+ SetLastError((DWORD)Error);
return FALSE;
}
dwLength = sizeof(szRawImagePath);
- if (RegQueryValueExW (hKey,
- L"ProfileImagePath",
- NULL,
- NULL,
- (LPBYTE)szRawImagePath,
- &dwLength))
+ Error = RegQueryValueExW (hKey,
+ L"ProfileImagePath",
+ NULL,
+ NULL,
+ (LPBYTE)szRawImagePath,
+ &dwLength);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1 ("Error: %lu\n", GetLastError());
+ DPRINT1 ("Error: %lu\n", Error);
RegCloseKey (hKey);
+ SetLastError((DWORD)Error);
return FALSE;
}
@@ -792,6 +831,7 @@
{
WCHAR szUserHivePath[MAX_PATH];
UNICODE_STRING SidString;
+ LONG Error;
DWORD dwLength = sizeof(szUserHivePath) / sizeof(szUserHivePath[0]);
DPRINT ("LoadUserProfileW() called\n");
@@ -842,23 +882,27 @@
DPRINT ("SidString: '%wZ'\n", &SidString);
- if (RegLoadKeyW (HKEY_USERS,
- SidString.Buffer,
- szUserHivePath))
+ Error = RegLoadKeyW (HKEY_USERS,
+ SidString.Buffer,
+ szUserHivePath);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1 ("RegLoadKeyW() failed (Error %ld)\n", GetLastError());
+ DPRINT1 ("RegLoadKeyW() failed (Error %ld)\n", Error);
RtlFreeUnicodeString (&SidString);
+ SetLastError((DWORD)Error);
return FALSE;
}
- if (RegOpenKeyExW (HKEY_USERS,
- SidString.Buffer,
- 0,
- KEY_ALL_ACCESS,
- (PHKEY)&lpProfileInfo->hProfile))
+ Error = RegOpenKeyExW (HKEY_USERS,
+ SidString.Buffer,
+ 0,
+ KEY_ALL_ACCESS,
+ (PHKEY)&lpProfileInfo->hProfile);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1 ("RegOpenKeyExW() failed (Error %ld)\n", GetLastError());
+ DPRINT1 ("RegOpenKeyExW() failed (Error %ld)\n", Error);
RtlFreeUnicodeString (&SidString);
+ SetLastError((DWORD)Error);
return FALSE;
}
@@ -875,6 +919,7 @@
HANDLE hProfile)
{
UNICODE_STRING SidString;
+ LONG Error;
DPRINT ("UnloadUserProfile() called\n");
@@ -896,11 +941,13 @@
DPRINT ("SidString: '%wZ'\n", &SidString);
- if (RegUnLoadKeyW (HKEY_USERS,
- SidString.Buffer))
+ Error = RegUnLoadKeyW (HKEY_USERS,
+ SidString.Buffer);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1 ("RegUnLoadKeyW() failed (Error %ld)\n", GetLastError());
+ DPRINT1 ("RegUnLoadKeyW() failed (Error %ld)\n", Error);
RtlFreeUnicodeString (&SidString);
+ SetLastError((DWORD)Error);
return FALSE;
}
_____
Modified: trunk/reactos/lib/userenv/registry.c
--- trunk/reactos/lib/userenv/registry.c 2006-01-11 23:54:44 UTC
(rev 20794)
+++ trunk/reactos/lib/userenv/registry.c 2006-01-12 00:11:14 UTC
(rev 20795)
@@ -37,6 +37,21 @@
CopyKey (HKEY hDstKey,
HKEY hSrcKey)
{
+ LONG Error;
+
+#if (_WIN32_WINNT >= 0x0600)
+ Error = RegCopyTreeW(hSrcKey,
+ NULL,
+ hDstKey);
+ if (Error != ERROR_SUCCESS)
+ {
+ SetLastError((DWORD)Error);
+ return FALSE;
+ }
+
+ return TRUE;
+
+#else
FILETIME LastWrite;
DWORD dwSubKeys;
DWORD dwValues;
@@ -56,20 +71,22 @@
DPRINT ("CopyKey() called \n");
- if (RegQueryInfoKey (hSrcKey,
- NULL,
- NULL,
- NULL,
- &dwSubKeys,
- &dwMaxSubKeyNameLength,
- NULL,
- &dwValues,
- &dwMaxValueNameLength,
- &dwMaxValueLength,
- NULL,
- NULL))
+ Error = RegQueryInfoKey (hSrcKey,
+ NULL,
+ NULL,
+ NULL,
+ &dwSubKeys,
+ &dwMaxSubKeyNameLength,
+ NULL,
+ &dwValues,
+ &dwMaxValueNameLength,
+ &dwMaxValueLength,
+ NULL,
+ NULL);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1 ("RegQueryInfoKey() failed (Error %lu)\n", GetLastError
());
+ DPRINT1 ("RegQueryInfoKey() failed (Error %lu)\n", Error);
+ SetLastError((DWORD)Error);
return FALSE;
}
@@ -88,56 +105,63 @@
if (lpNameBuffer == NULL)
{
DPRINT1("Buffer allocation failed\n");
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
for (i = 0; i < dwSubKeys; i++)
{
dwSubKeyNameLength = dwMaxSubKeyNameLength;
- if (RegEnumKeyExW (hSrcKey,
- i,
- lpNameBuffer,
- &dwSubKeyNameLength,
- NULL,
- NULL,
- NULL,
- &LastWrite))
+ Error = RegEnumKeyExW (hSrcKey,
+ i,
+ lpNameBuffer,
+ &dwSubKeyNameLength,
+ NULL,
+ NULL,
+ NULL,
+ &LastWrite);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1 ("Subkey enumeration failed (Error %lu)\n",
GetLastError());
+ DPRINT1 ("Subkey enumeration failed (Error %lu)\n",
Error);
HeapFree (GetProcessHeap (),
0,
lpNameBuffer);
+ SetLastError((DWORD)Error);
return FALSE;
}
- if (RegCreateKeyExW (hDstKey,
- lpNameBuffer,
- 0,
- NULL,
- REG_OPTION_NON_VOLATILE,
- KEY_WRITE,
- NULL,
- &hDstSubKey,
- &dwDisposition))
+ Error = RegCreateKeyExW (hDstKey,
+ lpNameBuffer,
+ 0,
+ NULL,
+ REG_OPTION_NON_VOLATILE,
+ KEY_WRITE,
+ NULL,
+ &hDstSubKey,
+ &dwDisposition);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1 ("Subkey creation failed (Error %lu)\n",
GetLastError());
+ DPRINT1 ("Subkey creation failed (Error %lu)\n", Error);
HeapFree (GetProcessHeap (),
0,
lpNameBuffer);
+ SetLastError((DWORD)Error);
return FALSE;
}
- if (RegOpenKeyExW (hSrcKey,
- lpNameBuffer,
- 0,
- KEY_READ,
- &hSrcSubKey))
+ Error = RegOpenKeyExW (hSrcKey,
+ lpNameBuffer,
+ 0,
+ KEY_READ,
+ &hSrcSubKey);
+ if (Error != ERROR_SUCCESS)
{
- DPRINT1 ("Error: %lu\n", GetLastError());
+ DPRINT1 ("Error: %lu\n", Error);
RegCloseKey (hDstSubKey);
HeapFree (GetProcessHeap (),
0,
lpNameBuffer);
+ SetLastError((DWORD)Error);
return FALSE;
}
@@ -171,6 +195,7 @@
if (lpNameBuffer == NULL)
{
DPRINT1 ("Buffer allocation failed\n");
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
@@ -183,6 +208,7 @@
HeapFree (GetProcessHeap (),
0,
lpNameBuffer);
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
@@ -190,39 +216,43 @@
{
dwValueNameLength = dwMaxValueNameLength;
dwValueLength = dwMaxValueLength;
- if (RegEnumValueW (hSrcKey,
- i,
- lpNameBuffer,
- &dwValueNameLength,
- NULL,
- &dwType,
- lpDataBuffer,
- &dwValueLength))
+ Error = RegEnumValueW (hSrcKey,
+ i,
+ lpNameBuffer,
+ &dwValueNameLength,
+ NULL,
+ &dwType,
[truncated at 1000 lines; 587 more skipped]