[USERENV]

Fix coding style and indentation. No code changes!

svn path=/trunk/; revision=60744
This commit is contained in:
Eric Kohl 2013-10-24 20:16:20 +00:00
parent 5bb77216c8
commit 480ce3de05
11 changed files with 1254 additions and 1213 deletions

File diff suppressed because it is too large Load diff

View file

@ -19,7 +19,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/userenv/directory.c
* FILE: dll/win32/userenv/directory.c
* PURPOSE: User profile code
* PROGRAMMER: Eric Kohl
*/
@ -32,7 +32,8 @@
/* FUNCTIONS ***************************************************************/
BOOL WINAPI
BOOL
WINAPI
CopyProfileDirectoryA(LPCSTR lpSourcePath,
LPCSTR lpDestinationPath,
DWORD dwFlags)
@ -67,7 +68,8 @@ CopyProfileDirectoryA(LPCSTR lpSourcePath,
}
BOOL WINAPI
BOOL
WINAPI
CopyProfileDirectoryW(LPCWSTR lpSourcePath,
LPCWSTR lpDestinationPath,
DWORD dwFlags)
@ -78,8 +80,8 @@ CopyProfileDirectoryW(LPCWSTR lpSourcePath,
BOOL
CopyDirectory (LPCWSTR lpDestinationPath,
LPCWSTR lpSourcePath)
CopyDirectory(LPCWSTR lpDestinationPath,
LPCWSTR lpSourcePath)
{
WCHAR szFileName[MAX_PATH];
WCHAR szFullSrcName[MAX_PATH];
@ -89,110 +91,110 @@ CopyDirectory (LPCWSTR lpDestinationPath,
LPWSTR lpDstPtr;
HANDLE hFind;
DPRINT ("CopyDirectory (%S, %S) called\n",
DPRINT("CopyDirectory (%S, %S) called\n",
lpDestinationPath, lpSourcePath);
wcscpy (szFileName, lpSourcePath);
wcscat (szFileName, L"\\*.*");
wcscpy(szFileName, lpSourcePath);
wcscat(szFileName, L"\\*.*");
hFind = FindFirstFileW (szFileName,
&FindFileData);
hFind = FindFirstFileW(szFileName,
&FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
{
DPRINT1 ("Error: %lu\n", GetLastError());
DPRINT1("Error: %lu\n", GetLastError());
return FALSE;
}
wcscpy (szFullSrcName, lpSourcePath);
lpSrcPtr = AppendBackslash (szFullSrcName);
wcscpy(szFullSrcName, lpSourcePath);
lpSrcPtr = AppendBackslash(szFullSrcName);
wcscpy (szFullDstName, lpDestinationPath);
lpDstPtr = AppendBackslash (szFullDstName);
wcscpy(szFullDstName, lpDestinationPath);
lpDstPtr = AppendBackslash(szFullDstName);
for (;;)
{
if (wcscmp (FindFileData.cFileName, L".") &&
wcscmp (FindFileData.cFileName, L".."))
if (wcscmp(FindFileData.cFileName, L".") &&
wcscmp(FindFileData.cFileName, L".."))
{
wcscpy (lpSrcPtr, FindFileData.cFileName);
wcscpy (lpDstPtr, FindFileData.cFileName);
wcscpy(lpSrcPtr, FindFileData.cFileName);
wcscpy(lpDstPtr, FindFileData.cFileName);
if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
DPRINT ("Create directory: %S\n", szFullDstName);
if (!CreateDirectoryExW (szFullSrcName, szFullDstName, NULL))
DPRINT("Create directory: %S\n", szFullDstName);
if (!CreateDirectoryExW(szFullSrcName, szFullDstName, NULL))
{
if (GetLastError () != ERROR_ALREADY_EXISTS)
if (GetLastError() != ERROR_ALREADY_EXISTS)
{
DPRINT1 ("Error: %lu\n", GetLastError());
DPRINT1("Error: %lu\n", GetLastError());
FindClose (hFind);
FindClose(hFind);
return FALSE;
}
}
if (!CopyDirectory (szFullDstName, szFullSrcName))
if (!CopyDirectory(szFullDstName, szFullSrcName))
{
DPRINT1 ("Error: %lu\n", GetLastError());
DPRINT1("Error: %lu\n", GetLastError());
FindClose (hFind);
FindClose(hFind);
return FALSE;
}
}
else
{
DPRINT ("Copy file: %S -> %S\n", szFullSrcName, szFullDstName);
if (!CopyFileW (szFullSrcName, szFullDstName, FALSE))
DPRINT("Copy file: %S -> %S\n", szFullSrcName, szFullDstName);
if (!CopyFileW(szFullSrcName, szFullDstName, FALSE))
{
DPRINT1 ("Error: %lu\n", GetLastError());
DPRINT1("Error: %lu\n", GetLastError());
FindClose (hFind);
FindClose(hFind);
return FALSE;
}
}
}
if (!FindNextFileW (hFind, &FindFileData))
if (!FindNextFileW(hFind, &FindFileData))
{
if (GetLastError () != ERROR_NO_MORE_FILES)
if (GetLastError() != ERROR_NO_MORE_FILES)
{
DPRINT1 ("Error: %lu\n", GetLastError());
DPRINT1("Error: %lu\n", GetLastError());
}
break;
}
}
FindClose (hFind);
FindClose(hFind);
DPRINT ("CopyDirectory() done\n");
DPRINT("CopyDirectory() done\n");
return TRUE;
}
BOOL
CreateDirectoryPath (LPCWSTR lpPathName,
LPSECURITY_ATTRIBUTES lpSecurityAttributes)
CreateDirectoryPath(LPCWSTR lpPathName,
LPSECURITY_ATTRIBUTES lpSecurityAttributes)
{
WCHAR szPath[MAX_PATH];
LPWSTR Ptr;
DWORD dwError;
DPRINT ("CreateDirectoryPath() called\n");
DPRINT("CreateDirectoryPath() called\n");
if (lpPathName == NULL || *lpPathName == 0)
return TRUE;
if (CreateDirectoryW (lpPathName,
lpSecurityAttributes))
if (CreateDirectoryW(lpPathName,
lpSecurityAttributes))
return TRUE;
dwError = GetLastError ();
dwError = GetLastError();
if (dwError == ERROR_ALREADY_EXISTS)
return TRUE;
wcscpy (szPath, lpPathName);
wcscpy(szPath, lpPathName);
if (wcslen(szPath) > 3 && szPath[1] == ':' && szPath[2] == '\\')
{
@ -205,15 +207,15 @@ CreateDirectoryPath (LPCWSTR lpPathName,
while (Ptr != NULL)
{
Ptr = wcschr (Ptr, L'\\');
Ptr = wcschr(Ptr, L'\\');
if (Ptr != NULL)
*Ptr = 0;
DPRINT ("CreateDirectory(%S)\n", szPath);
if (!CreateDirectoryW (szPath,
lpSecurityAttributes))
DPRINT("CreateDirectory(%S)\n", szPath);
if (!CreateDirectoryW(szPath,
lpSecurityAttributes))
{
dwError = GetLastError ();
dwError = GetLastError();
if (dwError != ERROR_ALREADY_EXISTS)
return FALSE;
}
@ -225,45 +227,46 @@ CreateDirectoryPath (LPCWSTR lpPathName,
}
}
DPRINT ("CreateDirectoryPath() done\n");
DPRINT("CreateDirectoryPath() done\n");
return TRUE;
}
static BOOL
RecursiveRemoveDir (LPCWSTR lpPath)
static
BOOL
RecursiveRemoveDir(LPCWSTR lpPath)
{
WCHAR szPath[MAX_PATH];
WIN32_FIND_DATAW FindData;
HANDLE hFind;
BOOL bResult;
wcscpy (szPath, lpPath);
wcscat (szPath, L"\\*.*");
DPRINT ("Search path: '%S'\n", szPath);
wcscpy(szPath, lpPath);
wcscat(szPath, L"\\*.*");
DPRINT("Search path: '%S'\n", szPath);
hFind = FindFirstFileW (szPath,
&FindData);
hFind = FindFirstFileW(szPath,
&FindData);
if (hFind == INVALID_HANDLE_VALUE)
return FALSE;
bResult = TRUE;
while (TRUE)
{
if (wcscmp (FindData.cFileName, L".") &&
wcscmp (FindData.cFileName, L".."))
if (wcscmp(FindData.cFileName, L".") &&
wcscmp(FindData.cFileName, L".."))
{
wcscpy (szPath, lpPath);
wcscat (szPath, L"\\");
wcscat (szPath, FindData.cFileName);
DPRINT ("File name: '%S'\n", szPath);
wcscpy(szPath, lpPath);
wcscat(szPath, L"\\");
wcscat(szPath, FindData.cFileName);
DPRINT("File name: '%S'\n", szPath);
if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
DPRINT ("Delete directory: '%S'\n", szPath);
DPRINT("Delete directory: '%S'\n", szPath);
if (!RecursiveRemoveDir (szPath))
if (!RecursiveRemoveDir(szPath))
{
bResult = FALSE;
break;
@ -271,11 +274,11 @@ RecursiveRemoveDir (LPCWSTR lpPath)
if (FindData.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
{
SetFileAttributesW (szPath,
FindData.dwFileAttributes & ~FILE_ATTRIBUTE_READONLY);
SetFileAttributesW(szPath,
FindData.dwFileAttributes & ~FILE_ATTRIBUTE_READONLY);
}
if (!RemoveDirectoryW (szPath))
if (!RemoveDirectoryW(szPath))
{
bResult = FALSE;
break;
@ -283,15 +286,15 @@ RecursiveRemoveDir (LPCWSTR lpPath)
}
else
{
DPRINT ("Delete file: '%S'\n", szPath);
DPRINT("Delete file: '%S'\n", szPath);
if (FindData.dwFileAttributes & (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM))
{
SetFileAttributesW (szPath,
FILE_ATTRIBUTE_NORMAL);
SetFileAttributesW(szPath,
FILE_ATTRIBUTE_NORMAL);
}
if (!DeleteFileW (szPath))
if (!DeleteFileW(szPath))
{
bResult = FALSE;
break;
@ -299,11 +302,11 @@ RecursiveRemoveDir (LPCWSTR lpPath)
}
}
if (!FindNextFileW (hFind, &FindData))
if (!FindNextFileW(hFind, &FindData))
{
if (GetLastError () != ERROR_NO_MORE_FILES)
if (GetLastError() != ERROR_NO_MORE_FILES)
{
DPRINT1 ("Error: %lu\n", GetLastError());
DPRINT1("Error: %lu\n", GetLastError());
bResult = FALSE;
break;
}
@ -312,20 +315,20 @@ RecursiveRemoveDir (LPCWSTR lpPath)
}
}
FindClose (hFind);
FindClose(hFind);
return bResult;
}
BOOL
RemoveDirectoryPath (LPCWSTR lpPathName)
RemoveDirectoryPath(LPCWSTR lpPathName)
{
if (!RecursiveRemoveDir (lpPathName))
if (!RecursiveRemoveDir(lpPathName))
return FALSE;
DPRINT ("Delete directory: '%S'\n", lpPathName);
return RemoveDirectoryW (lpPathName);
DPRINT("Delete directory: '%S'\n", lpPathName);
return RemoveDirectoryW(lpPathName);
}
/* EOF */

View file

@ -19,7 +19,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/userenv/environment.c
* FILE: dll/win32/userenv/environment.c
* PURPOSE: User environment functions
* PROGRAMMER: Eric Kohl
*/
@ -30,7 +30,8 @@
#include <debug.h>
static BOOL
static
BOOL
SetUserEnvironmentVariable(LPVOID *Environment,
LPWSTR lpName,
LPWSTR lpValue,
@ -117,7 +118,8 @@ SetUserEnvironmentVariable(LPVOID *Environment,
}
static BOOL
static
BOOL
AppendUserEnvironmentVariable(LPVOID *Environment,
LPWSTR lpName,
LPWSTR lpValue)
@ -165,7 +167,8 @@ AppendUserEnvironmentVariable(LPVOID *Environment,
}
static HKEY
static
HKEY
GetCurrentUserKey(HANDLE hToken)
{
UNICODE_STRING SidString;
@ -198,7 +201,8 @@ GetCurrentUserKey(HANDLE hToken)
}
static BOOL
static
BOOL
SetUserEnvironment(LPVOID *lpEnvironment,
HKEY hKey,
LPWSTR lpSubKeyName)
@ -310,7 +314,8 @@ SetUserEnvironment(LPVOID *lpEnvironment,
}
BOOL WINAPI
BOOL
WINAPI
CreateEnvironmentBlock(LPVOID *lpEnvironment,
HANDLE hToken,
BOOL bInherit)
@ -454,7 +459,8 @@ CreateEnvironmentBlock(LPVOID *lpEnvironment,
}
BOOL WINAPI
BOOL
WINAPI
DestroyEnvironmentBlock(LPVOID lpEnvironment)
{
DPRINT("DestroyEnvironmentBlock() called\n");
@ -471,7 +477,8 @@ DestroyEnvironmentBlock(LPVOID lpEnvironment)
}
BOOL WINAPI
BOOL
WINAPI
ExpandEnvironmentStringsForUserW(IN HANDLE hToken,
IN LPCWSTR lpSrc,
OUT LPWSTR lpDest,
@ -522,7 +529,8 @@ ExpandEnvironmentStringsForUserW(IN HANDLE hToken,
}
BOOL WINAPI
BOOL
WINAPI
ExpandEnvironmentStringsForUserA(IN HANDLE hToken,
IN LPCSTR lpSrc,
OUT LPSTR lpDest,

View file

@ -19,7 +19,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/userenv/gpolicy.c
* FILE: dll/win32/userenv/gpolicy.c
* PURPOSE: Group policy functions
* PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.com>
*/
@ -110,7 +110,8 @@ UninitializeGPNotifications(VOID)
DeleteCriticalSection(&GPNotifyLock);
}
static VOID
static
VOID
NotifyGPEvents(IN BOOL bMachine)
{
PGP_NOTIFY Notify = NotificationList;
@ -126,7 +127,9 @@ NotifyGPEvents(IN BOOL bMachine)
}
}
static DWORD WINAPI
static
DWORD
WINAPI
GPNotificationThreadProc(IN LPVOID lpParameter)
{
HMODULE hModule;
@ -255,7 +258,8 @@ GPNotificationThreadProc(IN LPVOID lpParameter)
return 1;
}
static HANDLE
static
HANDLE
CreateGPEvent(IN BOOL bMachine,
IN PSECURITY_DESCRIPTOR lpSecurityDescriptor)
{
@ -274,7 +278,8 @@ CreateGPEvent(IN BOOL bMachine,
return hEvent;
}
BOOL WINAPI
BOOL
WINAPI
RegisterGPNotification(IN HANDLE hEvent,
IN BOOL bMachine)
{
@ -378,7 +383,8 @@ Cleanup:
return Ret;
}
BOOL WINAPI
BOOL
WINAPI
UnregisterGPNotification(IN HANDLE hEvent)
{
PGP_NOTIFY Notify = NULL, *NotifyLink;
@ -418,7 +424,8 @@ UnregisterGPNotification(IN HANDLE hEvent)
return Ret;
}
BOOL WINAPI
BOOL
WINAPI
RefreshPolicy(IN BOOL bMachine)
{
HANDLE hEvent;
@ -437,7 +444,8 @@ RefreshPolicy(IN BOOL bMachine)
return Ret;
}
BOOL WINAPI
BOOL
WINAPI
RefreshPolicyEx(IN BOOL bMachine,
IN DWORD dwOptions)
{
@ -470,7 +478,8 @@ RefreshPolicyEx(IN BOOL bMachine,
}
}
HANDLE WINAPI
HANDLE
WINAPI
EnterCriticalPolicySection(IN BOOL bMachine)
{
SECURITY_ATTRIBUTES SecurityAttributes;
@ -507,7 +516,8 @@ EnterCriticalPolicySection(IN BOOL bMachine)
return NULL;
}
BOOL WINAPI
BOOL
WINAPI
LeaveCriticalPolicySection(IN HANDLE hSection)
{
BOOL Ret;
@ -524,7 +534,8 @@ LeaveCriticalPolicySection(IN HANDLE hSection)
return Ret;
}
BOOL WINAPI
BOOL
WINAPI
WaitForUserPolicyForegroundProcessing(VOID)
{
HANDLE hEvent;
@ -543,7 +554,8 @@ WaitForUserPolicyForegroundProcessing(VOID)
return Ret;
}
BOOL WINAPI
BOOL
WINAPI
WaitForMachinePolicyForegroundProcessing(VOID)
{
HANDLE hEvent;

View file

@ -19,7 +19,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/userenv/internal.h
* FILE: dll/win32/userenv/internal.h
* PURPOSE: internal stuff
* PROGRAMMER: Eric Kohl
*/
@ -29,15 +29,15 @@
/* directory.c */
BOOL
CopyDirectory (LPCWSTR lpDestinationPath,
LPCWSTR lpSourcePath);
CopyDirectory(LPCWSTR lpDestinationPath,
LPCWSTR lpSourcePath);
BOOL
CreateDirectoryPath (LPCWSTR lpPathName,
LPSECURITY_ATTRIBUTES lpSecurityAttributes);
CreateDirectoryPath(LPCWSTR lpPathName,
LPSECURITY_ATTRIBUTES lpSecurityAttributes);
BOOL
RemoveDirectoryPath (LPCWSTR lpPathName);
RemoveDirectoryPath(LPCWSTR lpPathName);
/* misc.c */
typedef struct _DYN_FUNCS
@ -64,35 +64,36 @@ typedef struct _DYN_MODULE
extern DYN_MODULE DynOle32;
BOOL
LoadDynamicImports(PDYN_MODULE Module, PDYN_FUNCS DynFuncs);
LoadDynamicImports(PDYN_MODULE Module,
PDYN_FUNCS DynFuncs);
VOID
UnloadDynamicImports(PDYN_FUNCS DynFuncs);
LPWSTR
AppendBackslash (LPWSTR String);
AppendBackslash(LPWSTR String);
BOOL
GetUserSidFromToken (HANDLE hToken,
PUNICODE_STRING SidString);
GetUserSidFromToken(HANDLE hToken,
PUNICODE_STRING SidString);
PSECURITY_DESCRIPTOR
CreateDefaultSecurityDescriptor(VOID);
/* profile.c */
BOOL
AppendSystemPostfix (LPWSTR lpName,
DWORD dwMaxLength);
AppendSystemPostfix(LPWSTR lpName,
DWORD dwMaxLength);
/* registry.c */
BOOL
CreateUserHive (LPCWSTR lpKeyName,
LPCWSTR lpProfilePath);
CreateUserHive(LPCWSTR lpKeyName,
LPCWSTR lpProfilePath);
/* setup.c */
BOOL
UpdateUsersShellFolderSettings(LPCWSTR lpUserProfilePath,
HKEY hUserKey);
HKEY hUserKey);
/* userenv.c */
extern HINSTANCE hInstance;

View file

@ -19,7 +19,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/userenv/misc.c
* FILE: dll/win32/userenv/misc.c
* PURPOSE: User profile code
* PROGRAMMER: Eric Kohl
*/
@ -35,86 +35,86 @@ static SID_IDENTIFIER_AUTHORITY WorldAuthority = {SECURITY_WORLD_SID_AUTHORITY};
/* FUNCTIONS ***************************************************************/
LPWSTR
AppendBackslash (LPWSTR String)
AppendBackslash(LPWSTR String)
{
ULONG Length;
ULONG Length;
Length = lstrlenW (String);
if (String[Length - 1] != L'\\')
Length = lstrlenW(String);
if (String[Length - 1] != L'\\')
{
String[Length] = L'\\';
Length++;
String[Length] = (WCHAR)0;
String[Length] = L'\\';
Length++;
String[Length] = (WCHAR)0;
}
return &String[Length];
return &String[Length];
}
BOOL
GetUserSidFromToken (HANDLE hToken,
PUNICODE_STRING SidString)
GetUserSidFromToken(HANDLE hToken,
PUNICODE_STRING SidString)
{
PSID_AND_ATTRIBUTES SidBuffer, nsb;
ULONG Length;
NTSTATUS Status;
PSID_AND_ATTRIBUTES SidBuffer, nsb;
ULONG Length;
NTSTATUS Status;
Length = 256;
SidBuffer = LocalAlloc (LMEM_FIXED,
Length);
if (SidBuffer == NULL)
return FALSE;
Length = 256;
SidBuffer = LocalAlloc(LMEM_FIXED,
Length);
if (SidBuffer == NULL)
return FALSE;
Status = NtQueryInformationToken (hToken,
TokenUser,
(PVOID)SidBuffer,
Length,
&Length);
if (Status == STATUS_BUFFER_TOO_SMALL)
Status = NtQueryInformationToken(hToken,
TokenUser,
(PVOID)SidBuffer,
Length,
&Length);
if (Status == STATUS_BUFFER_TOO_SMALL)
{
nsb = LocalReAlloc (SidBuffer,
Length,
LMEM_MOVEABLE);
if (nsb == NULL)
nsb = LocalReAlloc(SidBuffer,
Length,
LMEM_MOVEABLE);
if (nsb == NULL)
{
LocalFree((HLOCAL)SidBuffer);
return FALSE;
LocalFree((HLOCAL)SidBuffer);
return FALSE;
}
SidBuffer = nsb;
Status = NtQueryInformationToken (hToken,
TokenUser,
(PVOID)SidBuffer,
Length,
&Length);
SidBuffer = nsb;
Status = NtQueryInformationToken(hToken,
TokenUser,
(PVOID)SidBuffer,
Length,
&Length);
}
if (!NT_SUCCESS (Status))
if (!NT_SUCCESS (Status))
{
LocalFree ((HLOCAL)SidBuffer);
SetLastError (RtlNtStatusToDosError (Status));
return FALSE;
LocalFree((HLOCAL)SidBuffer);
SetLastError(RtlNtStatusToDosError(Status));
return FALSE;
}
DPRINT ("SidLength: %lu\n", RtlLengthSid (SidBuffer[0].Sid));
DPRINT("SidLength: %lu\n", RtlLengthSid (SidBuffer[0].Sid));
Status = RtlConvertSidToUnicodeString (SidString,
SidBuffer[0].Sid,
TRUE);
Status = RtlConvertSidToUnicodeString(SidString,
SidBuffer[0].Sid,
TRUE);
LocalFree ((HLOCAL)SidBuffer);
LocalFree((HLOCAL)SidBuffer);
if (!NT_SUCCESS (Status))
if (!NT_SUCCESS(Status))
{
SetLastError (RtlNtStatusToDosError (Status));
return FALSE;
SetLastError(RtlNtStatusToDosError(Status));
return FALSE;
}
DPRINT ("SidString.Length: %lu\n", SidString->Length);
DPRINT ("SidString.MaximumLength: %lu\n", SidString->MaximumLength);
DPRINT ("SidString: '%wZ'\n", SidString);
DPRINT("SidString.Length: %lu\n", SidString->Length);
DPRINT("SidString.MaximumLength: %lu\n", SidString->MaximumLength);
DPRINT("SidString: '%wZ'\n", SidString);
return TRUE;
return TRUE;
}
PSECURITY_DESCRIPTOR
@ -284,47 +284,48 @@ DYN_MODULE DynOle32 =
* has been created!
*/
BOOL
LoadDynamicImports(PDYN_MODULE Module, PDYN_FUNCS DynFuncs)
LoadDynamicImports(PDYN_MODULE Module,
PDYN_FUNCS DynFuncs)
{
LPSTR *fname;
PVOID *fn;
LPSTR *fname;
PVOID *fn;
ZeroMemory(DynFuncs, sizeof(DYN_FUNCS));
ZeroMemory(DynFuncs, sizeof(DYN_FUNCS));
DynFuncs->hModule = LoadLibraryW(Module->Library);
if (!DynFuncs->hModule)
DynFuncs->hModule = LoadLibraryW(Module->Library);
if (!DynFuncs->hModule)
{
return FALSE;
return FALSE;
}
fn = &DynFuncs->fn.foo;
fn = &DynFuncs->fn.foo;
/* load the imports */
for (fname = Module->Functions; *fname != NULL; fname++)
/* load the imports */
for (fname = Module->Functions; *fname != NULL; fname++)
{
*fn = GetProcAddress(DynFuncs->hModule, *fname);
if (*fn == NULL)
*fn = GetProcAddress(DynFuncs->hModule, *fname);
if (*fn == NULL)
{
FreeLibrary(DynFuncs->hModule);
DynFuncs->hModule = (HMODULE)0;
FreeLibrary(DynFuncs->hModule);
DynFuncs->hModule = (HMODULE)0;
return FALSE;
return FALSE;
}
fn++;
fn++;
}
return TRUE;
return TRUE;
}
VOID
UnloadDynamicImports(PDYN_FUNCS DynFuncs)
{
if (DynFuncs->hModule)
if (DynFuncs->hModule)
{
FreeLibrary(DynFuncs->hModule);
DynFuncs->hModule = (HMODULE)0;
FreeLibrary(DynFuncs->hModule);
DynFuncs->hModule = (HMODULE)0;
}
}

View file

@ -18,7 +18,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/userenv/profile.c
* FILE: dll/win32/userenv/profile.c
* PURPOSE: User profile code
* PROGRAMMERS: Eric Kohl
* Hervé Poussineau

View file

@ -19,7 +19,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/userenv/registry.c
* FILE: dll/win32/userenv/registry.c
* PURPOSE: User profile code
* PROGRAMMER: Eric Kohl
*/
@ -32,301 +32,302 @@
/* FUNCTIONS ***************************************************************/
static BOOL
CopyKey (HKEY hDstKey,
HKEY hSrcKey)
static
BOOL
CopyKey(HKEY hDstKey,
HKEY hSrcKey)
{
LONG Error;
LONG Error;
#if (_WIN32_WINNT >= 0x0600)
Error = RegCopyTreeW(hSrcKey,
NULL,
hDstKey);
if (Error != ERROR_SUCCESS)
{
SetLastError((DWORD)Error);
return FALSE;
}
Error = RegCopyTreeW(hSrcKey,
NULL,
hDstKey);
if (Error != ERROR_SUCCESS)
{
SetLastError((DWORD)Error);
return FALSE;
}
return TRUE;
return TRUE;
#else
FILETIME LastWrite;
DWORD dwSubKeys;
DWORD dwValues;
DWORD dwType;
DWORD dwMaxSubKeyNameLength;
DWORD dwSubKeyNameLength;
DWORD dwMaxValueNameLength;
DWORD dwValueNameLength;
DWORD dwMaxValueLength;
DWORD dwValueLength;
DWORD dwDisposition;
DWORD i;
LPWSTR lpNameBuffer;
LPBYTE lpDataBuffer;
HKEY hDstSubKey;
HKEY hSrcSubKey;
FILETIME LastWrite;
DWORD dwSubKeys;
DWORD dwValues;
DWORD dwType;
DWORD dwMaxSubKeyNameLength;
DWORD dwSubKeyNameLength;
DWORD dwMaxValueNameLength;
DWORD dwValueNameLength;
DWORD dwMaxValueLength;
DWORD dwValueLength;
DWORD dwDisposition;
DWORD i;
LPWSTR lpNameBuffer;
LPBYTE lpDataBuffer;
HKEY hDstSubKey;
HKEY hSrcSubKey;
DPRINT ("CopyKey() called \n");
DPRINT ("CopyKey() called \n");
Error = RegQueryInfoKey (hSrcKey,
NULL,
NULL,
NULL,
&dwSubKeys,
&dwMaxSubKeyNameLength,
NULL,
&dwValues,
&dwMaxValueNameLength,
&dwMaxValueLength,
NULL,
NULL);
if (Error != ERROR_SUCCESS)
Error = RegQueryInfoKey(hSrcKey,
NULL,
NULL,
NULL,
&dwSubKeys,
&dwMaxSubKeyNameLength,
NULL,
&dwValues,
&dwMaxValueNameLength,
&dwMaxValueLength,
NULL,
NULL);
if (Error != ERROR_SUCCESS)
{
DPRINT1 ("RegQueryInfoKey() failed (Error %lu)\n", Error);
SetLastError((DWORD)Error);
return FALSE;
DPRINT1("RegQueryInfoKey() failed (Error %lu)\n", Error);
SetLastError((DWORD)Error);
return FALSE;
}
DPRINT ("dwSubKeys %lu\n", dwSubKeys);
DPRINT ("dwMaxSubKeyNameLength %lu\n", dwMaxSubKeyNameLength);
DPRINT ("dwValues %lu\n", dwValues);
DPRINT ("dwMaxValueNameLength %lu\n", dwMaxValueNameLength);
DPRINT ("dwMaxValueLength %lu\n", dwMaxValueLength);
DPRINT("dwSubKeys %lu\n", dwSubKeys);
DPRINT("dwMaxSubKeyNameLength %lu\n", dwMaxSubKeyNameLength);
DPRINT("dwValues %lu\n", dwValues);
DPRINT("dwMaxValueNameLength %lu\n", dwMaxValueNameLength);
DPRINT("dwMaxValueLength %lu\n", dwMaxValueLength);
/* Copy subkeys */
if (dwSubKeys != 0)
/* Copy subkeys */
if (dwSubKeys != 0)
{
lpNameBuffer = HeapAlloc (GetProcessHeap (),
0,
dwMaxSubKeyNameLength * sizeof(WCHAR));
if (lpNameBuffer == NULL)
{
DPRINT1("Buffer allocation failed\n");
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
lpNameBuffer = HeapAlloc(GetProcessHeap(),
0,
dwMaxSubKeyNameLength * sizeof(WCHAR));
if (lpNameBuffer == NULL)
{
DPRINT1("Buffer allocation failed\n");
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
for (i = 0; i < dwSubKeys; i++)
{
dwSubKeyNameLength = dwMaxSubKeyNameLength;
Error = RegEnumKeyExW (hSrcKey,
i,
lpNameBuffer,
&dwSubKeyNameLength,
NULL,
NULL,
NULL,
&LastWrite);
if (Error != ERROR_SUCCESS)
{
DPRINT1 ("Subkey enumeration failed (Error %lu)\n", Error);
HeapFree (GetProcessHeap (),
0,
lpNameBuffer);
SetLastError((DWORD)Error);
return FALSE;
}
for (i = 0; i < dwSubKeys; i++)
{
dwSubKeyNameLength = dwMaxSubKeyNameLength;
Error = RegEnumKeyExW(hSrcKey,
i,
lpNameBuffer,
&dwSubKeyNameLength,
NULL,
NULL,
NULL,
&LastWrite);
if (Error != ERROR_SUCCESS)
{
DPRINT1("Subkey enumeration failed (Error %lu)\n", Error);
HeapFree(GetProcessHeap(),
0,
lpNameBuffer);
SetLastError((DWORD)Error);
return FALSE;
}
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", Error);
HeapFree (GetProcessHeap (),
0,
lpNameBuffer);
SetLastError((DWORD)Error);
return FALSE;
}
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", Error);
HeapFree(GetProcessHeap(),
0,
lpNameBuffer);
SetLastError((DWORD)Error);
return FALSE;
}
Error = RegOpenKeyExW (hSrcKey,
lpNameBuffer,
0,
KEY_READ,
&hSrcSubKey);
if (Error != ERROR_SUCCESS)
{
DPRINT1 ("Error: %lu\n", Error);
RegCloseKey (hDstSubKey);
HeapFree (GetProcessHeap (),
0,
lpNameBuffer);
SetLastError((DWORD)Error);
return FALSE;
}
Error = RegOpenKeyExW(hSrcKey,
lpNameBuffer,
0,
KEY_READ,
&hSrcSubKey);
if (Error != ERROR_SUCCESS)
{
DPRINT1("Error: %lu\n", Error);
RegCloseKey(hDstSubKey);
HeapFree(GetProcessHeap(),
0,
lpNameBuffer);
SetLastError((DWORD)Error);
return FALSE;
}
if (!CopyKey (hDstSubKey,
hSrcSubKey))
{
DPRINT1 ("Error: %lu\n", GetLastError());
RegCloseKey (hSrcSubKey);
RegCloseKey (hDstSubKey);
HeapFree (GetProcessHeap (),
0,
lpNameBuffer);
return FALSE;
}
if (!CopyKey(hDstSubKey,
hSrcSubKey))
{
DPRINT1("Error: %lu\n", GetLastError());
RegCloseKey (hSrcSubKey);
RegCloseKey (hDstSubKey);
HeapFree(GetProcessHeap(),
0,
lpNameBuffer);
return FALSE;
}
RegCloseKey (hSrcSubKey);
RegCloseKey (hDstSubKey);
}
RegCloseKey(hSrcSubKey);
RegCloseKey(hDstSubKey);
}
HeapFree (GetProcessHeap (),
0,
lpNameBuffer);
HeapFree(GetProcessHeap(),
0,
lpNameBuffer);
}
/* Copy values */
if (dwValues != 0)
/* Copy values */
if (dwValues != 0)
{
lpNameBuffer = HeapAlloc (GetProcessHeap (),
0,
dwMaxValueNameLength * sizeof(WCHAR));
if (lpNameBuffer == NULL)
{
DPRINT1 ("Buffer allocation failed\n");
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
lpNameBuffer = HeapAlloc(GetProcessHeap(),
0,
dwMaxValueNameLength * sizeof(WCHAR));
if (lpNameBuffer == NULL)
{
DPRINT1("Buffer allocation failed\n");
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
lpDataBuffer = HeapAlloc (GetProcessHeap (),
0,
dwMaxValueLength);
if (lpDataBuffer == NULL)
{
DPRINT1 ("Buffer allocation failed\n");
HeapFree (GetProcessHeap (),
0,
lpNameBuffer);
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
lpDataBuffer = HeapAlloc(GetProcessHeap(),
0,
dwMaxValueLength);
if (lpDataBuffer == NULL)
{
DPRINT1("Buffer allocation failed\n");
HeapFree(GetProcessHeap(),
0,
lpNameBuffer);
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
for (i = 0; i < dwValues; i++)
{
dwValueNameLength = dwMaxValueNameLength;
dwValueLength = dwMaxValueLength;
Error = RegEnumValueW (hSrcKey,
i,
lpNameBuffer,
&dwValueNameLength,
NULL,
&dwType,
lpDataBuffer,
&dwValueLength);
if (Error != ERROR_SUCCESS)
{
DPRINT1("Error: %lu\n", Error);
HeapFree (GetProcessHeap (),
0,
lpDataBuffer);
HeapFree (GetProcessHeap (),
0,
lpNameBuffer);
SetLastError((DWORD)Error);
return FALSE;
}
for (i = 0; i < dwValues; i++)
{
dwValueNameLength = dwMaxValueNameLength;
dwValueLength = dwMaxValueLength;
Error = RegEnumValueW(hSrcKey,
i,
lpNameBuffer,
&dwValueNameLength,
NULL,
&dwType,
lpDataBuffer,
&dwValueLength);
if (Error != ERROR_SUCCESS)
{
DPRINT1("Error: %lu\n", Error);
HeapFree(GetProcessHeap(),
0,
lpDataBuffer);
HeapFree(GetProcessHeap(),
0,
lpNameBuffer);
SetLastError((DWORD)Error);
return FALSE;
}
Error = RegSetValueExW (hDstKey,
lpNameBuffer,
0,
dwType,
lpDataBuffer,
dwValueLength);
if (Error != ERROR_SUCCESS)
{
DPRINT1("Error: %lu\n", Error);
HeapFree (GetProcessHeap (),
0,
lpDataBuffer);
HeapFree (GetProcessHeap (),
0,
lpNameBuffer);
SetLastError((DWORD)Error);
return FALSE;
}
}
Error = RegSetValueExW(hDstKey,
lpNameBuffer,
0,
dwType,
lpDataBuffer,
dwValueLength);
if (Error != ERROR_SUCCESS)
{
DPRINT1("Error: %lu\n", Error);
HeapFree(GetProcessHeap(),
0,
lpDataBuffer);
HeapFree(GetProcessHeap(),
0,
lpNameBuffer);
SetLastError((DWORD)Error);
return FALSE;
}
}
HeapFree (GetProcessHeap (),
0,
lpDataBuffer);
HeapFree(GetProcessHeap(),
0,
lpDataBuffer);
HeapFree (GetProcessHeap (),
0,
lpNameBuffer);
HeapFree(GetProcessHeap(),
0,
lpNameBuffer);
}
DPRINT ("CopyKey() done \n");
DPRINT("CopyKey() done \n");
return TRUE;
return TRUE;
#endif
}
BOOL
CreateUserHive (LPCWSTR lpKeyName,
LPCWSTR lpProfilePath)
CreateUserHive(LPCWSTR lpKeyName,
LPCWSTR lpProfilePath)
{
HKEY hDefaultKey = NULL;
HKEY hUserKey = NULL;
LONG Error;
BOOL Ret = FALSE;
HKEY hDefaultKey = NULL;
HKEY hUserKey = NULL;
LONG Error;
BOOL Ret = FALSE;
DPRINT ("CreateUserHive(%S) called\n", lpKeyName);
DPRINT("CreateUserHive(%S) called\n", lpKeyName);
Error = RegOpenKeyExW (HKEY_USERS,
L".Default",
0,
KEY_READ,
&hDefaultKey);
if (Error != ERROR_SUCCESS)
Error = RegOpenKeyExW(HKEY_USERS,
L".Default",
0,
KEY_READ,
&hDefaultKey);
if (Error != ERROR_SUCCESS)
{
SetLastError((DWORD)Error);
goto Cleanup;
SetLastError((DWORD)Error);
goto Cleanup;
}
Error = RegOpenKeyExW (HKEY_USERS,
lpKeyName,
0,
KEY_ALL_ACCESS,
&hUserKey);
if (Error != ERROR_SUCCESS)
Error = RegOpenKeyExW(HKEY_USERS,
lpKeyName,
0,
KEY_ALL_ACCESS,
&hUserKey);
if (Error != ERROR_SUCCESS)
{
SetLastError((DWORD)Error);
goto Cleanup;
SetLastError((DWORD)Error);
goto Cleanup;
}
if (!CopyKey(hUserKey, hDefaultKey))
if (!CopyKey(hUserKey, hDefaultKey))
{
goto Cleanup;
goto Cleanup;
}
if (!UpdateUsersShellFolderSettings(lpProfilePath,
hUserKey))
if (!UpdateUsersShellFolderSettings(lpProfilePath,
hUserKey))
{
goto Cleanup;
goto Cleanup;
}
RegFlushKey (hUserKey);
Ret = TRUE;
RegFlushKey(hUserKey);
Ret = TRUE;
Cleanup:
if (hUserKey != NULL)
RegCloseKey (hUserKey);
if (hUserKey != NULL)
RegCloseKey (hUserKey);
if (hDefaultKey != NULL)
RegCloseKey (hDefaultKey);
if (hDefaultKey != NULL)
RegCloseKey (hDefaultKey);
return Ret;
return Ret;
}
/* EOF */

View file

@ -19,7 +19,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/userenv/resource.h
* FILE: dll/win32/userenv/resource.h
* PURPOSE: Resource IDs
* PROGRAMMER: Eric Kohl
*/

View file

@ -19,7 +19,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/userenv/setup.c
* FILE: dll/win32/userenv/setup.c
* PURPOSE: Profile setup functions
* PROGRAMMER: Eric Kohl
*/

View file

@ -19,7 +19,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/userenv/userenv.c
* FILE: dll/win32/userenv/userenv.c
* PURPOSE: DLL initialization code
* PROGRAMMER: Eric Kohl
*/
@ -31,20 +31,21 @@
HINSTANCE hInstance = NULL;
BOOL WINAPI
DllMain (HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved)
BOOL
WINAPI
DllMain(HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH)
if (fdwReason == DLL_PROCESS_ATTACH)
{
hInstance = hinstDLL;
InitializeGPNotifications();
hInstance = hinstDLL;
InitializeGPNotifications();
}
else if (fdwReason == DLL_PROCESS_DETACH)
else if (fdwReason == DLL_PROCESS_DETACH)
{
UninitializeGPNotifications();
}
return TRUE;
return TRUE;
}