mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
Fix code assuming that the Reg* functions set the last error code
svn path=/trunk/; revision=20795
This commit is contained in:
parent
d46b22a834
commit
ff7d975c7d
8 changed files with 542 additions and 396 deletions
|
@ -41,29 +41,34 @@ GetDesktopPath (BOOL bCommonPath,
|
|||
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 @@ GetProgramsPath (BOOL bCommonPath,
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -169,6 +169,7 @@ GetCurrentUserKey (HANDLE hToken)
|
|||
{
|
||||
UNICODE_STRING SidString;
|
||||
HKEY hKey;
|
||||
LONG Error;
|
||||
|
||||
if (!GetUserSidFromToken (hToken,
|
||||
&SidString))
|
||||
|
@ -177,14 +178,16 @@ GetCurrentUserKey (HANDLE hToken)
|
|||
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 @@ SetUserEnvironment (LPVOID *lpEnvironment,
|
|||
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 @@ CreateEnvironmentBlock (LPVOID *lpEnvironment,
|
|||
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 @@ DestroyEnvironmentBlock (LPVOID lpEnvironment)
|
|||
DPRINT ("DestroyEnvironmentBlock() called\n");
|
||||
|
||||
if (lpEnvironment == NULL)
|
||||
return FALSE;
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
RtlDestroyEnvironment (lpEnvironment);
|
||||
|
||||
|
|
|
@ -91,6 +91,7 @@ GetUserSidFromToken (HANDLE hToken,
|
|||
if (!NT_SUCCESS (Status))
|
||||
{
|
||||
LocalFree ((HLOCAL)SidBuffer);
|
||||
SetLastError (RtlNtStatusToDosError (Status));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -103,7 +104,10 @@ GetUserSidFromToken (HANDLE hToken,
|
|||
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);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#define NTOS_MODE_USER
|
||||
#include <ndk/ntndk.h>
|
||||
#include <userenv.h>
|
||||
#include <sddl.h>
|
||||
#include <shlobj.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
|
|
@ -66,6 +66,7 @@ AppendSystemPostfix (LPWSTR lpName,
|
|||
if (wcslen(lpName) + wcslen(lpszPostfix) >= dwMaxLength)
|
||||
{
|
||||
DPRINT1("Error: buffer overflow\n");
|
||||
SetLastError(ERROR_BUFFER_OVERFLOW);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -109,35 +110,39 @@ CreateUserProfileW (PSID Sid,
|
|||
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 @@ CreateUserProfileW (PSID Sid,
|
|||
|
||||
/* 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 @@ CreateUserProfileW (PSID Sid,
|
|||
if (!AppendSystemPostfix (szUserProfilePath, MAX_PATH))
|
||||
{
|
||||
DPRINT1("AppendSystemPostfix() failed\n", GetLastError());
|
||||
RtlFreeUnicodeString (&SidString);
|
||||
LocalFree ((HLOCAL)SidString);
|
||||
RegCloseKey (hKey);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -200,30 +207,32 @@ CreateUserProfileW (PSID Sid,
|
|||
}
|
||||
|
||||
/* 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 @@ CreateUserProfileW (PSID Sid,
|
|||
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 @@ CreateUserProfileW (PSID Sid,
|
|||
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 @@ GetAllUsersProfileDirectoryW (LPWSTR lpProfileDir,
|
|||
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 @@ GetAllUsersProfileDirectoryW (LPWSTR lpProfileDir,
|
|||
|
||||
/* 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 @@ GetDefaultUserProfileDirectoryW (LPWSTR lpProfileDir,
|
|||
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 @@ GetDefaultUserProfileDirectoryW (LPWSTR lpProfileDir,
|
|||
|
||||
/* 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 @@ GetProfilesDirectoryW (LPWSTR lpProfilesDir,
|
|||
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 @@ GetUserProfileDirectoryW (HANDLE hToken,
|
|||
WCHAR szImagePath[MAX_PATH];
|
||||
DWORD dwLength;
|
||||
HKEY hKey;
|
||||
LONG Error;
|
||||
|
||||
if (!GetUserSidFromToken (hToken,
|
||||
&SidString))
|
||||
|
@ -687,26 +722,30 @@ GetUserProfileDirectoryW (HANDLE hToken,
|
|||
|
||||
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 @@ LoadUserProfileW (HANDLE hToken,
|
|||
{
|
||||
WCHAR szUserHivePath[MAX_PATH];
|
||||
UNICODE_STRING SidString;
|
||||
LONG Error;
|
||||
DWORD dwLength = sizeof(szUserHivePath) / sizeof(szUserHivePath[0]);
|
||||
|
||||
DPRINT ("LoadUserProfileW() called\n");
|
||||
|
@ -842,23 +882,27 @@ LoadUserProfileW (HANDLE hToken,
|
|||
|
||||
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 @@ UnloadUserProfile (HANDLE hToken,
|
|||
HANDLE hProfile)
|
||||
{
|
||||
UNICODE_STRING SidString;
|
||||
LONG Error;
|
||||
|
||||
DPRINT ("UnloadUserProfile() called\n");
|
||||
|
||||
|
@ -896,11 +941,13 @@ UnloadUserProfile (HANDLE hToken,
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,21 @@ static BOOL
|
|||
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 @@ CopyKey (HKEY hDstKey,
|
|||
|
||||
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 @@ CopyKey (HKEY hDstKey,
|
|||
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 @@ CopyKey (HKEY hDstKey,
|
|||
if (lpNameBuffer == NULL)
|
||||
{
|
||||
DPRINT1 ("Buffer allocation failed\n");
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -183,6 +208,7 @@ CopyKey (HKEY hDstKey,
|
|||
HeapFree (GetProcessHeap (),
|
||||
0,
|
||||
lpNameBuffer);
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -190,39 +216,43 @@ CopyKey (HKEY hDstKey,
|
|||
{
|
||||
dwValueNameLength = dwMaxValueNameLength;
|
||||
dwValueLength = dwMaxValueLength;
|
||||
if (RegEnumValueW (hSrcKey,
|
||||
i,
|
||||
lpNameBuffer,
|
||||
&dwValueNameLength,
|
||||
NULL,
|
||||
&dwType,
|
||||
lpDataBuffer,
|
||||
&dwValueLength))
|
||||
Error = RegEnumValueW (hSrcKey,
|
||||
i,
|
||||
lpNameBuffer,
|
||||
&dwValueNameLength,
|
||||
NULL,
|
||||
&dwType,
|
||||
lpDataBuffer,
|
||||
&dwValueLength);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT1("Error: %lu\n", GetLastError());
|
||||
DPRINT1("Error: %lu\n", Error);
|
||||
HeapFree (GetProcessHeap (),
|
||||
0,
|
||||
lpDataBuffer);
|
||||
HeapFree (GetProcessHeap (),
|
||||
0,
|
||||
lpNameBuffer);
|
||||
SetLastError((DWORD)Error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (RegSetValueExW (hDstKey,
|
||||
lpNameBuffer,
|
||||
0,
|
||||
dwType,
|
||||
lpDataBuffer,
|
||||
dwValueLength))
|
||||
Error = RegSetValueExW (hDstKey,
|
||||
lpNameBuffer,
|
||||
0,
|
||||
dwType,
|
||||
lpDataBuffer,
|
||||
dwValueLength);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT1("Error: %lu\n", GetLastError());
|
||||
DPRINT1("Error: %lu\n", Error);
|
||||
HeapFree (GetProcessHeap (),
|
||||
0,
|
||||
lpDataBuffer);
|
||||
HeapFree (GetProcessHeap (),
|
||||
0,
|
||||
lpNameBuffer);
|
||||
SetLastError((DWORD)Error);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -239,6 +269,7 @@ CopyKey (HKEY hDstKey,
|
|||
DPRINT ("CopyKey() done \n");
|
||||
|
||||
return TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -246,57 +277,57 @@ BOOL
|
|||
CreateUserHive (LPCWSTR lpKeyName,
|
||||
LPCWSTR lpProfilePath)
|
||||
{
|
||||
HKEY hDefaultKey;
|
||||
HKEY hUserKey;
|
||||
HKEY hDefaultKey = NULL;
|
||||
HKEY hUserKey = NULL;
|
||||
LONG Error;
|
||||
BOOL Ret = FALSE;
|
||||
|
||||
DPRINT ("CreateUserHive(%S) called\n", lpKeyName);
|
||||
|
||||
if (RegOpenKeyExW (HKEY_USERS,
|
||||
L".Default",
|
||||
0,
|
||||
KEY_READ,
|
||||
&hDefaultKey))
|
||||
Error = RegOpenKeyExW (HKEY_USERS,
|
||||
L".Default",
|
||||
0,
|
||||
KEY_READ,
|
||||
&hDefaultKey);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT1 ("Error: %lu\n", GetLastError());
|
||||
return FALSE;
|
||||
SetLastError((DWORD)Error);
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
if (RegOpenKeyExW (HKEY_USERS,
|
||||
lpKeyName,
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
&hUserKey))
|
||||
Error = RegOpenKeyExW (HKEY_USERS,
|
||||
lpKeyName,
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
&hUserKey);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT1 ("Error: %lu\n", GetLastError());
|
||||
RegCloseKey (hDefaultKey);
|
||||
return FALSE;
|
||||
SetLastError((DWORD)Error);
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
if (!CopyKey(hUserKey, hDefaultKey))
|
||||
{
|
||||
DPRINT1 ("Error: %lu\n", GetLastError());
|
||||
RegCloseKey (hUserKey);
|
||||
RegCloseKey (hDefaultKey);
|
||||
return FALSE;
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
if (!UpdateUsersShellFolderSettings(lpProfilePath,
|
||||
hUserKey))
|
||||
{
|
||||
DPRINT1("Error: %lu\n", GetLastError());
|
||||
RegCloseKey (hUserKey);
|
||||
RegCloseKey (hDefaultKey);
|
||||
return FALSE;
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
RegFlushKey (hUserKey);
|
||||
Ret = TRUE;
|
||||
|
||||
RegCloseKey (hUserKey);
|
||||
RegCloseKey (hDefaultKey);
|
||||
Cleanup:
|
||||
if (hUserKey != NULL)
|
||||
RegCloseKey (hUserKey);
|
||||
|
||||
DPRINT ("CreateUserHive() done\n");
|
||||
if (hDefaultKey != NULL)
|
||||
RegCloseKey (hDefaultKey);
|
||||
|
||||
return TRUE;
|
||||
return Ret;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -112,6 +112,7 @@ InitializeProfiles (VOID)
|
|||
DWORD dwLength;
|
||||
PFOLDERDATA lpFolderData;
|
||||
HKEY hKey;
|
||||
LONG Error;
|
||||
|
||||
/* Load profiles directory path */
|
||||
if (!LoadStringW(hInstance,
|
||||
|
@ -123,27 +124,31 @@ InitializeProfiles (VOID)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/* Store profiles directory path */
|
||||
dwLength = (wcslen (szBuffer) + 1) * sizeof(WCHAR);
|
||||
if (RegSetValueExW (hKey,
|
||||
L"ProfilesDirectory",
|
||||
0,
|
||||
REG_EXPAND_SZ,
|
||||
(LPBYTE)szBuffer,
|
||||
dwLength))
|
||||
Error = RegSetValueExW (hKey,
|
||||
L"ProfilesDirectory",
|
||||
0,
|
||||
REG_EXPAND_SZ,
|
||||
(LPBYTE)szBuffer,
|
||||
dwLength);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT1("Error: %lu\n", GetLastError());
|
||||
DPRINT1("Error: %lu\n", Error);
|
||||
RegCloseKey (hKey);
|
||||
SetLastError((DWORD)Error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -178,15 +183,17 @@ InitializeProfiles (VOID)
|
|||
}
|
||||
|
||||
dwLength = (wcslen (szBuffer) + 1) * sizeof(WCHAR);
|
||||
if (RegSetValueExW (hKey,
|
||||
L"DefaultUserProfile",
|
||||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)szBuffer,
|
||||
dwLength))
|
||||
Error = RegSetValueExW (hKey,
|
||||
L"DefaultUserProfile",
|
||||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)szBuffer,
|
||||
dwLength);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT1("Error: %lu\n", GetLastError());
|
||||
DPRINT1("Error: %lu\n", Error);
|
||||
RegCloseKey (hKey);
|
||||
SetLastError((DWORD)Error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -246,13 +253,15 @@ InitializeProfiles (VOID)
|
|||
}
|
||||
|
||||
/* Set default 'Shell Folders' values */
|
||||
if (RegOpenKeyExW(HKEY_USERS,
|
||||
L".Default\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
&hKey))
|
||||
Error = RegOpenKeyExW(HKEY_USERS,
|
||||
L".Default\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
&hKey);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT1("Error: %lu\n", GetLastError());
|
||||
DPRINT1("Error: %lu\n", Error);
|
||||
SetLastError((DWORD)Error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -276,15 +285,17 @@ InitializeProfiles (VOID)
|
|||
}
|
||||
|
||||
dwLength = (wcslen(szBuffer) + 1) * sizeof(WCHAR);
|
||||
if (RegSetValueExW(hKey,
|
||||
lpFolderData->lpValueName,
|
||||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)szBuffer,
|
||||
dwLength))
|
||||
Error = RegSetValueExW(hKey,
|
||||
lpFolderData->lpValueName,
|
||||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)szBuffer,
|
||||
dwLength);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT1("Error: %lu\n", GetLastError());
|
||||
DPRINT1("Error: %lu\n", Error);
|
||||
RegCloseKey(hKey);
|
||||
SetLastError((DWORD)Error);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -297,28 +308,32 @@ InitializeProfiles (VOID)
|
|||
wcscat(szBuffer, L"\\media\\fonts");
|
||||
|
||||
dwLength = (wcslen(szBuffer) + 1) * sizeof(WCHAR);
|
||||
if (RegSetValueExW(hKey,
|
||||
L"Fonts",
|
||||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)szBuffer,
|
||||
dwLength))
|
||||
Error = RegSetValueExW(hKey,
|
||||
L"Fonts",
|
||||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)szBuffer,
|
||||
dwLength);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT1("Error: %lu\n", GetLastError());
|
||||
DPRINT1("Error: %lu\n", Error);
|
||||
RegCloseKey(hKey);
|
||||
SetLastError((DWORD)Error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
|
||||
/* Set default 'User Shell Folders' values */
|
||||
if (RegOpenKeyExW(HKEY_USERS,
|
||||
L".Default\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders",
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
&hKey))
|
||||
Error = RegOpenKeyExW(HKEY_USERS,
|
||||
L".Default\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders",
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
&hKey);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT1("Error: %lu\n", GetLastError());
|
||||
DPRINT1("Error: %lu\n", Error);
|
||||
SetLastError((DWORD)Error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -341,15 +356,17 @@ InitializeProfiles (VOID)
|
|||
}
|
||||
|
||||
dwLength = (wcslen(szBuffer) + 1) * sizeof(WCHAR);
|
||||
if (RegSetValueExW(hKey,
|
||||
lpFolderData->lpValueName,
|
||||
0,
|
||||
REG_EXPAND_SZ,
|
||||
(LPBYTE)szBuffer,
|
||||
dwLength))
|
||||
Error = RegSetValueExW(hKey,
|
||||
lpFolderData->lpValueName,
|
||||
0,
|
||||
REG_EXPAND_SZ,
|
||||
(LPBYTE)szBuffer,
|
||||
dwLength);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT1("Error: %lu\n", GetLastError());
|
||||
DPRINT1("Error: %lu\n", Error);
|
||||
RegCloseKey(hKey);
|
||||
SetLastError((DWORD)Error);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -368,26 +385,30 @@ InitializeProfiles (VOID)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
dwLength = (wcslen(szBuffer) + 1) * sizeof(WCHAR);
|
||||
if (RegSetValueExW(hKey,
|
||||
L"AllUsersProfile",
|
||||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)szBuffer,
|
||||
dwLength))
|
||||
Error = RegSetValueExW(hKey,
|
||||
L"AllUsersProfile",
|
||||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)szBuffer,
|
||||
dwLength);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT1("Error: %lu\n", GetLastError());
|
||||
DPRINT1("Error: %lu\n", Error);
|
||||
RegCloseKey (hKey);
|
||||
SetLastError((DWORD)Error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -448,13 +469,15 @@ InitializeProfiles (VOID)
|
|||
}
|
||||
|
||||
/* Set common 'Shell Folders' values */
|
||||
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
&hKey))
|
||||
Error = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
&hKey);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT1("Error: %lu\n", GetLastError());
|
||||
DPRINT1("Error: %lu\n", Error);
|
||||
SetLastError((DWORD)Error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -478,15 +501,17 @@ InitializeProfiles (VOID)
|
|||
}
|
||||
|
||||
dwLength = (wcslen(szBuffer) + 1) * sizeof(WCHAR);
|
||||
if (RegSetValueExW(hKey,
|
||||
lpFolderData->lpValueName,
|
||||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)szBuffer,
|
||||
dwLength))
|
||||
Error = RegSetValueExW(hKey,
|
||||
lpFolderData->lpValueName,
|
||||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)szBuffer,
|
||||
dwLength);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT1("Error: %lu\n", GetLastError());
|
||||
DPRINT1("Error: %lu\n", Error);
|
||||
RegCloseKey(hKey);
|
||||
SetLastError((DWORD)Error);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -497,13 +522,15 @@ InitializeProfiles (VOID)
|
|||
RegCloseKey(hKey);
|
||||
|
||||
/* Set common 'User Shell Folders' values */
|
||||
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders",
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
&hKey))
|
||||
Error = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders",
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
&hKey);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT1("Error: %lu\n", GetLastError());
|
||||
DPRINT1("Error: %lu\n", Error);
|
||||
SetLastError((DWORD)Error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -526,15 +553,17 @@ InitializeProfiles (VOID)
|
|||
}
|
||||
|
||||
dwLength = (wcslen(szBuffer) + 1) * sizeof(WCHAR);
|
||||
if (RegSetValueExW(hKey,
|
||||
lpFolderData->lpValueName,
|
||||
0,
|
||||
REG_EXPAND_SZ,
|
||||
(LPBYTE)szBuffer,
|
||||
dwLength))
|
||||
Error = RegSetValueExW(hKey,
|
||||
lpFolderData->lpValueName,
|
||||
0,
|
||||
REG_EXPAND_SZ,
|
||||
(LPBYTE)szBuffer,
|
||||
dwLength);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT1("Error: %lu\n", GetLastError());
|
||||
DPRINT1("Error: %lu\n", Error);
|
||||
RegCloseKey(hKey);
|
||||
SetLastError((DWORD)Error);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -565,26 +594,30 @@ InitializeProfiles (VOID)
|
|||
}
|
||||
|
||||
/* Store it */
|
||||
if (RegOpenKeyExW (HKEY_LOCAL_MACHINE,
|
||||
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion",
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
&hKey))
|
||||
Error = RegOpenKeyExW (HKEY_LOCAL_MACHINE,
|
||||
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion",
|
||||
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 = (wcslen (szProfilesPath) + 1) * sizeof(WCHAR);
|
||||
if (RegSetValueExW (hKey,
|
||||
L"ProgramFilesDir",
|
||||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)szProfilesPath,
|
||||
dwLength))
|
||||
Error = RegSetValueExW (hKey,
|
||||
L"ProgramFilesDir",
|
||||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)szProfilesPath,
|
||||
dwLength);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT1("Error: %lu\n", GetLastError());
|
||||
DPRINT1("Error: %lu\n", Error);
|
||||
RegCloseKey (hKey);
|
||||
SetLastError((DWORD)Error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -615,18 +648,21 @@ UpdateUsersShellFolderSettings(LPCWSTR lpUserProfilePath,
|
|||
DWORD dwLength;
|
||||
PFOLDERDATA lpFolderData;
|
||||
HKEY hFoldersKey;
|
||||
LONG Error;
|
||||
|
||||
DPRINT("UpdateUsersShellFolderSettings() called\n");
|
||||
|
||||
DPRINT("User profile path: %S\n", lpUserProfilePath);
|
||||
|
||||
if (RegOpenKeyExW(hUserKey,
|
||||
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
&hFoldersKey))
|
||||
Error = RegOpenKeyExW(hUserKey,
|
||||
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
&hFoldersKey);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT1("Error: %lu\n", GetLastError());
|
||||
DPRINT1("Error: %lu\n", Error);
|
||||
SetLastError((DWORD)Error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -652,15 +688,17 @@ UpdateUsersShellFolderSettings(LPCWSTR lpUserProfilePath,
|
|||
DPRINT("%S: %S\n", lpFolderData->lpValueName, szBuffer);
|
||||
|
||||
dwLength = (wcslen(szBuffer) + 1) * sizeof(WCHAR);
|
||||
if (RegSetValueExW(hFoldersKey,
|
||||
lpFolderData->lpValueName,
|
||||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)szBuffer,
|
||||
dwLength))
|
||||
Error = RegSetValueExW(hFoldersKey,
|
||||
lpFolderData->lpValueName,
|
||||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)szBuffer,
|
||||
dwLength);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT1("Error: %lu\n", GetLastError());
|
||||
DPRINT1("Error: %lu\n", Error);
|
||||
RegCloseKey(hFoldersKey);
|
||||
SetLastError((DWORD)Error);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
<importlibrary definition="userenv.def" />
|
||||
<include base="userenv">.</include>
|
||||
<define name="__USE_W32API" />
|
||||
<define name="_WIN32_IE">0x0400</define>
|
||||
<define name="_WIN32_WINNT">0x0501</define>
|
||||
<define name="_WIN32_IE">0x0500</define>
|
||||
<define name="_WIN32_WINNT">0x0600</define>
|
||||
<library>uuid</library>
|
||||
<library>ntdll</library>
|
||||
<library>kernel32</library>
|
||||
|
|
Loading…
Reference in a new issue