[FORMATTING]

No code changes.

svn path=/trunk/; revision=47107
This commit is contained in:
Eric Kohl 2010-05-05 22:53:01 +00:00
parent 51e6829b67
commit ac293dd5d6

View file

@ -32,7 +32,7 @@
static BOOL
SetUserEnvironmentVariable (LPVOID *Environment,
SetUserEnvironmentVariable(LPVOID *Environment,
LPWSTR lpName,
LPWSTR lpValue,
BOOL bExpand)
@ -43,7 +43,7 @@ SetUserEnvironmentVariable (LPVOID *Environment,
UNICODE_STRING DstValue;
ULONG Length;
NTSTATUS Status;
PVOID Buffer=NULL;
PVOID Buffer = NULL;
if (bExpand)
{
@ -56,7 +56,6 @@ SetUserEnvironmentVariable (LPVOID *Environment,
DstValue.MaximumLength = Length;
DstValue.Buffer = Buffer = LocalAlloc(LPTR,
Length);
if (DstValue.Buffer == NULL)
{
DPRINT1("LocalAlloc() failed\n");
@ -71,7 +70,8 @@ SetUserEnvironmentVariable (LPVOID *Environment,
{
DPRINT1("RtlExpandEnvironmentStrings_U() failed (Status %lx)\n", Status);
DPRINT1("Length %lu\n", Length);
if (Buffer) LocalFree(Buffer);
if (Buffer)
LocalFree(Buffer);
return FALSE;
}
}
@ -81,12 +81,13 @@ SetUserEnvironmentVariable (LPVOID *Environment,
lpValue);
}
if (!_wcsicmp (lpName, L"temp") || !_wcsicmp (lpName, L"tmp"))
if (!_wcsicmp(lpName, L"temp") || !_wcsicmp(lpName, L"tmp"))
{
if (!GetShortPathNameW(DstValue.Buffer, ShortName, MAX_PATH))
{
DPRINT1("GetShortPathNameW() failed for %S (Error %lu)\n", DstValue.Buffer, GetLastError());
if (Buffer) LocalFree(Buffer);
if (Buffer)
LocalFree(Buffer);
return FALSE;
}
@ -104,7 +105,8 @@ SetUserEnvironmentVariable (LPVOID *Environment,
&Name,
&DstValue);
if (Buffer) LocalFree(Buffer);
if (Buffer)
LocalFree(Buffer);
if (!NT_SUCCESS(Status))
{
@ -117,7 +119,7 @@ SetUserEnvironmentVariable (LPVOID *Environment,
static BOOL
AppendUserEnvironmentVariable (LPVOID *Environment,
AppendUserEnvironmentVariable(LPVOID *Environment,
LPWSTR lpName,
LPWSTR lpValue)
{
@ -125,12 +127,12 @@ AppendUserEnvironmentVariable (LPVOID *Environment,
UNICODE_STRING Value;
NTSTATUS Status;
RtlInitUnicodeString (&Name,
RtlInitUnicodeString(&Name,
lpName);
Value.Length = 0;
Value.MaximumLength = 1024 * sizeof(WCHAR);
Value.Buffer = LocalAlloc (LPTR,
Value.Buffer = LocalAlloc(LPTR,
1024 * sizeof(WCHAR));
if (Value.Buffer == NULL)
{
@ -138,25 +140,25 @@ AppendUserEnvironmentVariable (LPVOID *Environment,
}
Value.Buffer[0] = UNICODE_NULL;
Status = RtlQueryEnvironmentVariable_U ((PWSTR)*Environment,
Status = RtlQueryEnvironmentVariable_U((PWSTR)*Environment,
&Name,
&Value);
if (NT_SUCCESS(Status))
{
RtlAppendUnicodeToString (&Value,
RtlAppendUnicodeToString(&Value,
L";");
}
RtlAppendUnicodeToString (&Value,
RtlAppendUnicodeToString(&Value,
lpValue);
Status = RtlSetEnvironmentVariable ((PWSTR*)Environment,
Status = RtlSetEnvironmentVariable((PWSTR*)Environment,
&Name,
&Value);
LocalFree (Value.Buffer);
LocalFree(Value.Buffer);
if (!NT_SUCCESS(Status))
{
DPRINT1 ("RtlSetEnvironmentVariable() failed (Status %lx)\n", Status);
DPRINT1("RtlSetEnvironmentVariable() failed (Status %lx)\n", Status);
return FALSE;
}
@ -165,40 +167,40 @@ AppendUserEnvironmentVariable (LPVOID *Environment,
static HKEY
GetCurrentUserKey (HANDLE hToken)
GetCurrentUserKey(HANDLE hToken)
{
UNICODE_STRING SidString;
HKEY hKey;
LONG Error;
if (!GetUserSidFromToken (hToken,
if (!GetUserSidFromToken(hToken,
&SidString))
{
DPRINT1 ("GetUserSidFromToken() failed\n");
DPRINT1("GetUserSidFromToken() failed\n");
return NULL;
}
Error = RegOpenKeyExW (HKEY_USERS,
Error = RegOpenKeyExW(HKEY_USERS,
SidString.Buffer,
0,
MAXIMUM_ALLOWED,
&hKey);
if (Error != ERROR_SUCCESS)
{
DPRINT1 ("RegOpenKeyExW() failed (Error %ld)\n", Error);
RtlFreeUnicodeString (&SidString);
DPRINT1("RegOpenKeyExW() failed (Error %ld)\n", Error);
RtlFreeUnicodeString(&SidString);
SetLastError((DWORD)Error);
return NULL;
}
RtlFreeUnicodeString (&SidString);
RtlFreeUnicodeString(&SidString);
return hKey;
}
static BOOL
SetUserEnvironment (LPVOID *lpEnvironment,
SetUserEnvironment(LPVOID *lpEnvironment,
HKEY hKey,
LPWSTR lpSubKeyName)
{
@ -214,19 +216,19 @@ SetUserEnvironment (LPVOID *lpEnvironment,
LPWSTR lpValueData;
LONG Error;
Error = RegOpenKeyExW (hKey,
Error = RegOpenKeyExW(hKey,
lpSubKeyName,
0,
KEY_QUERY_VALUE,
&hEnvKey);
if (Error != ERROR_SUCCESS)
{
DPRINT1 ("RegOpenKeyExW() failed (Error %ld)\n", Error);
DPRINT1("RegOpenKeyExW() failed (Error %ld)\n", Error);
SetLastError((DWORD)Error);
return FALSE;
}
Error = RegQueryInfoKey (hEnvKey,
Error = RegQueryInfoKey(hEnvKey,
NULL,
NULL,
NULL,
@ -240,33 +242,33 @@ SetUserEnvironment (LPVOID *lpEnvironment,
NULL);
if (Error != ERROR_SUCCESS)
{
DPRINT1 ("RegQueryInforKey() failed (Error %ld)\n", Error);
RegCloseKey (hEnvKey);
DPRINT1("RegQueryInforKey() failed (Error %ld)\n", Error);
RegCloseKey(hEnvKey);
SetLastError((DWORD)Error);
return FALSE;
}
if (dwValues == 0)
{
RegCloseKey (hEnvKey);
RegCloseKey(hEnvKey);
return TRUE;
}
/* Allocate buffers */
lpValueName = LocalAlloc (LPTR,
lpValueName = LocalAlloc(LPTR,
dwMaxValueNameLength * sizeof(WCHAR));
if (lpValueName == NULL)
{
RegCloseKey (hEnvKey);
RegCloseKey(hEnvKey);
return FALSE;
}
lpValueData = LocalAlloc (LPTR,
lpValueData = LocalAlloc(LPTR,
dwMaxValueDataLength);
if (lpValueData == NULL)
{
LocalFree (lpValueName);
RegCloseKey (hEnvKey);
LocalFree(lpValueName);
RegCloseKey(hEnvKey);
return FALSE;
}
@ -275,7 +277,7 @@ SetUserEnvironment (LPVOID *lpEnvironment,
{
dwValueNameLength = dwMaxValueNameLength;
dwValueDataLength = dwMaxValueDataLength;
RegEnumValueW (hEnvKey,
RegEnumValueW(hEnvKey,
i,
lpValueName,
&dwValueNameLength,
@ -287,30 +289,30 @@ SetUserEnvironment (LPVOID *lpEnvironment,
if (!_wcsicmp (lpValueName, L"path"))
{
/* Append 'Path' environment variable */
AppendUserEnvironmentVariable (lpEnvironment,
AppendUserEnvironmentVariable(lpEnvironment,
lpValueName,
lpValueData);
}
else
{
/* Set environment variable */
SetUserEnvironmentVariable (lpEnvironment,
SetUserEnvironmentVariable(lpEnvironment,
lpValueName,
lpValueData,
(dwType == REG_EXPAND_SZ));
}
}
LocalFree (lpValueData);
LocalFree (lpValueName);
RegCloseKey (hEnvKey);
LocalFree(lpValueData);
LocalFree(lpValueName);
RegCloseKey(hEnvKey);
return TRUE;
}
BOOL WINAPI
CreateEnvironmentBlock (LPVOID *lpEnvironment,
CreateEnvironmentBlock(LPVOID *lpEnvironment,
HANDLE hToken,
BOOL bInherit)
{
@ -327,18 +329,18 @@ CreateEnvironmentBlock (LPVOID *lpEnvironment,
return FALSE;
}
Status = RtlCreateEnvironment ((BOOLEAN)bInherit,
Status = RtlCreateEnvironment((BOOLEAN)bInherit,
(PWSTR*)lpEnvironment);
if (!NT_SUCCESS (Status))
{
DPRINT1 ("RtlCreateEnvironment() failed (Status %lx)\n", Status);
SetLastError (RtlNtStatusToDosError (Status));
DPRINT1("RtlCreateEnvironment() failed (Status %lx)\n", Status);
SetLastError(RtlNtStatusToDosError(Status));
return FALSE;
}
/* Set 'COMPUTERNAME' variable */
Length = MAX_PATH;
if (GetComputerNameW (Buffer,
if (GetComputerNameW(Buffer,
&Length))
{
SetUserEnvironmentVariable(lpEnvironment,
@ -350,17 +352,17 @@ CreateEnvironmentBlock (LPVOID *lpEnvironment,
if (hToken == NULL)
return TRUE;
hKeyUser = GetCurrentUserKey (hToken);
hKeyUser = GetCurrentUserKey(hToken);
if (hKeyUser == NULL)
{
DPRINT1 ("GetCurrentUserKey() failed\n");
RtlDestroyEnvironment (*lpEnvironment);
DPRINT1("GetCurrentUserKey() failed\n");
RtlDestroyEnvironment(*lpEnvironment);
return FALSE;
}
/* Set 'ALLUSERSPROFILE' variable */
Length = MAX_PATH;
if (GetAllUsersProfileDirectoryW (Buffer,
if (GetAllUsersProfileDirectoryW(Buffer,
&Length))
{
SetUserEnvironmentVariable(lpEnvironment,
@ -371,7 +373,7 @@ CreateEnvironmentBlock (LPVOID *lpEnvironment,
/* Set 'USERPROFILE' variable */
Length = MAX_PATH;
if (GetUserProfileDirectoryW (hToken,
if (GetUserProfileDirectoryW(hToken,
Buffer,
&Length))
{
@ -396,20 +398,20 @@ CreateEnvironmentBlock (LPVOID *lpEnvironment,
/* Set user environment variables */
SetUserEnvironment (lpEnvironment,
SetUserEnvironment(lpEnvironment,
hKeyUser,
L"Environment");
RegCloseKey (hKeyUser);
RegCloseKey(hKeyUser);
return TRUE;
}
BOOL WINAPI
DestroyEnvironmentBlock (LPVOID lpEnvironment)
DestroyEnvironmentBlock(LPVOID lpEnvironment)
{
DPRINT ("DestroyEnvironmentBlock() called\n");
DPRINT("DestroyEnvironmentBlock() called\n");
if (lpEnvironment == NULL)
{
@ -417,7 +419,7 @@ DestroyEnvironmentBlock (LPVOID lpEnvironment)
return FALSE;
}
RtlDestroyEnvironment (lpEnvironment);
RtlDestroyEnvironment(lpEnvironment);
return TRUE;
}