[FORMATTING] No code changes!

svn path=/trunk/; revision=36357
This commit is contained in:
Eric Kohl 2008-09-20 20:28:23 +00:00
parent 8c33fab48b
commit aa46f44e50
3 changed files with 635 additions and 614 deletions

View file

@ -18,7 +18,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(advapi);
* @implemented
*/
BOOL STDCALL
CreateProcessAsUserA (HANDLE hToken,
CreateProcessAsUserA(HANDLE hToken,
LPCSTR lpApplicationName,
LPSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
@ -34,7 +34,7 @@ CreateProcessAsUserA (HANDLE hToken,
NTSTATUS Status;
/* Create the process with a suspended main thread */
if (!CreateProcessA (lpApplicationName,
if (!CreateProcessA(lpApplicationName,
lpCommandLine,
lpProcessAttributes,
lpThreadAttributes,
@ -52,20 +52,20 @@ CreateProcessAsUserA (HANDLE hToken,
AccessToken.Thread = NULL;
/* Set the new process token */
Status = NtSetInformationProcess (lpProcessInformation->hProcess,
Status = NtSetInformationProcess(lpProcessInformation->hProcess,
ProcessAccessToken,
(PVOID)&AccessToken,
sizeof (AccessToken));
sizeof(AccessToken));
if (!NT_SUCCESS (Status))
{
SetLastError (RtlNtStatusToDosError (Status));
SetLastError(RtlNtStatusToDosError(Status));
return FALSE;
}
/* Resume the main thread */
if (!(dwCreationFlags & CREATE_SUSPENDED))
{
ResumeThread (lpProcessInformation->hThread);
ResumeThread(lpProcessInformation->hThread);
}
return TRUE;
@ -76,7 +76,7 @@ CreateProcessAsUserA (HANDLE hToken,
* @implemented
*/
BOOL STDCALL
CreateProcessAsUserW (HANDLE hToken,
CreateProcessAsUserW(HANDLE hToken,
LPCWSTR lpApplicationName,
LPWSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
@ -92,7 +92,7 @@ CreateProcessAsUserW (HANDLE hToken,
NTSTATUS Status;
/* Create the process with a suspended main thread */
if (!CreateProcessW (lpApplicationName,
if (!CreateProcessW(lpApplicationName,
lpCommandLine,
lpProcessAttributes,
lpThreadAttributes,
@ -110,20 +110,20 @@ CreateProcessAsUserW (HANDLE hToken,
AccessToken.Thread = NULL;
/* Set the new process token */
Status = NtSetInformationProcess (lpProcessInformation->hProcess,
Status = NtSetInformationProcess(lpProcessInformation->hProcess,
ProcessAccessToken,
(PVOID)&AccessToken,
sizeof (AccessToken));
sizeof(AccessToken));
if (!NT_SUCCESS (Status))
{
SetLastError (RtlNtStatusToDosError (Status));
SetLastError(RtlNtStatusToDosError(Status));
return FALSE;
}
/* Resume the main thread */
if (!(dwCreationFlags & CREATE_SUSPENDED))
{
ResumeThread (lpProcessInformation->hThread);
ResumeThread(lpProcessInformation->hThread);
}
return TRUE;
@ -199,7 +199,7 @@ UsernameDone:
static BOOL STDCALL
SamGetUserSid (LPCWSTR UserName,
SamGetUserSid(LPCWSTR UserName,
PSID *Sid)
{
PSID lpSid;
@ -211,7 +211,7 @@ SamGetUserSid (LPCWSTR UserName,
*Sid = NULL;
/* Open the Users key */
if (RegOpenKeyExW (HKEY_LOCAL_MACHINE,
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"SAM\\SAM\\Domains\\Account\\Users",
0,
KEY_READ,
@ -222,23 +222,23 @@ SamGetUserSid (LPCWSTR UserName,
}
/* Open the user key */
if (RegOpenKeyExW (hUsersKey,
if (RegOpenKeyExW(hUsersKey,
UserName,
0,
KEY_READ,
&hUserKey))
{
if (GetLastError () == ERROR_FILE_NOT_FOUND)
if (GetLastError() == ERROR_FILE_NOT_FOUND)
{
ERR("Invalid user name!\n");
SetLastError (ERROR_NO_SUCH_USER);
SetLastError(ERROR_NO_SUCH_USER);
}
else
{
ERR("Failed to open user key! (Error %lu)\n", GetLastError());
}
RegCloseKey (hUsersKey);
RegCloseKey(hUsersKey);
return FALSE;
}
@ -246,7 +246,7 @@ SamGetUserSid (LPCWSTR UserName,
/* Get SID size */
dwLength = 0;
if (RegQueryValueExW (hUserKey,
if (RegQueryValueExW(hUserKey,
L"Sid",
NULL,
NULL,
@ -254,24 +254,24 @@ SamGetUserSid (LPCWSTR UserName,
&dwLength))
{
ERR("Failed to read the SID size! (Error %lu)\n", GetLastError());
RegCloseKey (hUserKey);
RegCloseKey(hUserKey);
return FALSE;
}
/* Allocate sid buffer */
TRACE("Required SID buffer size: %lu\n", dwLength);
lpSid = (PSID)RtlAllocateHeap (RtlGetProcessHeap (),
lpSid = (PSID)RtlAllocateHeap(RtlGetProcessHeap(),
0,
dwLength);
if (lpSid == NULL)
{
ERR("Failed to allocate SID buffer!\n");
RegCloseKey (hUserKey);
RegCloseKey(hUserKey);
return FALSE;
}
/* Read sid */
if (RegQueryValueExW (hUserKey,
if (RegQueryValueExW(hUserKey,
L"Sid",
NULL,
NULL,
@ -279,14 +279,14 @@ SamGetUserSid (LPCWSTR UserName,
&dwLength))
{
ERR("Failed to read the SID! (Error %lu)\n", GetLastError());
RtlFreeHeap (RtlGetProcessHeap (),
RtlFreeHeap(RtlGetProcessHeap(),
0,
lpSid);
RegCloseKey (hUserKey);
RegCloseKey(hUserKey);
return FALSE;
}
RegCloseKey (hUserKey);
RegCloseKey(hUserKey);
*Sid = lpSid;
@ -405,8 +405,7 @@ AppendRidToSid(PSID SrcSid,
static PTOKEN_GROUPS
AllocateGroupSids(
OUT PSID *PrimaryGroupSid,
AllocateGroupSids(OUT PSID *PrimaryGroupSid,
OUT PSID *OwnerSid)
{
SID_IDENTIFIER_AUTHORITY WorldAuthority = {SECURITY_WORLD_SID_AUTHORITY};
@ -442,13 +441,13 @@ AllocateGroupSids(
/* Member of the domain */
TokenGroups->Groups[GroupCount].Sid = Sid;
TokenGroups->Groups[GroupCount].Attributes = SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
TokenGroups->Groups[GroupCount].Attributes =
SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
*PrimaryGroupSid = Sid;
GroupCount++;
/* Member of 'Everyone' */
RtlAllocateAndInitializeSid(
&WorldAuthority,
RtlAllocateAndInitializeSid(&WorldAuthority,
1,
SECURITY_WORLD_RID,
SECURITY_NULL_RID,
@ -460,13 +459,13 @@ AllocateGroupSids(
SECURITY_NULL_RID,
&Sid);
TokenGroups->Groups[GroupCount].Sid = Sid;
TokenGroups->Groups[GroupCount].Attributes = SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
TokenGroups->Groups[GroupCount].Attributes =
SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
GroupCount++;
#if 1
/* Member of 'Administrators' */
RtlAllocateAndInitializeSid(
&SystemAuthority,
RtlAllocateAndInitializeSid(&SystemAuthority,
2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
@ -478,15 +477,15 @@ AllocateGroupSids(
SECURITY_NULL_RID,
&Sid);
TokenGroups->Groups[GroupCount].Sid = Sid;
TokenGroups->Groups[GroupCount].Attributes = SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
TokenGroups->Groups[GroupCount].Attributes =
SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
GroupCount++;
#else
TRACE("Not adding user to Administrators group\n");
#endif
/* Member of 'Users' */
RtlAllocateAndInitializeSid(
&SystemAuthority,
RtlAllocateAndInitializeSid(&SystemAuthority,
2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_USERS,
@ -498,12 +497,12 @@ AllocateGroupSids(
SECURITY_NULL_RID,
&Sid);
TokenGroups->Groups[GroupCount].Sid = Sid;
TokenGroups->Groups[GroupCount].Attributes = SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
TokenGroups->Groups[GroupCount].Attributes =
SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
GroupCount++;
/* Logon SID */
RtlAllocateAndInitializeSid(
&SystemAuthority,
RtlAllocateAndInitializeSid(&SystemAuthority,
SECURITY_LOGON_IDS_RID_COUNT,
SECURITY_LOGON_IDS_RID,
Luid.HighPart,
@ -515,13 +514,13 @@ AllocateGroupSids(
SECURITY_NULL_RID,
&Sid);
TokenGroups->Groups[GroupCount].Sid = Sid;
TokenGroups->Groups[GroupCount].Attributes = SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY | SE_GROUP_LOGON_ID;
TokenGroups->Groups[GroupCount].Attributes =
SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY | SE_GROUP_LOGON_ID;
GroupCount++;
*OwnerSid = Sid;
/* Member of 'Local users */
RtlAllocateAndInitializeSid(
&LocalAuthority,
RtlAllocateAndInitializeSid(&LocalAuthority,
1,
SECURITY_LOCAL_RID,
SECURITY_NULL_RID,
@ -533,12 +532,12 @@ AllocateGroupSids(
SECURITY_NULL_RID,
&Sid);
TokenGroups->Groups[GroupCount].Sid = Sid;
TokenGroups->Groups[GroupCount].Attributes = SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
TokenGroups->Groups[GroupCount].Attributes =
SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
GroupCount++;
/* Member of 'Interactive users' */
RtlAllocateAndInitializeSid(
&SystemAuthority,
RtlAllocateAndInitializeSid(&SystemAuthority,
1,
SECURITY_INTERACTIVE_RID,
SECURITY_NULL_RID,
@ -550,12 +549,12 @@ AllocateGroupSids(
SECURITY_NULL_RID,
&Sid);
TokenGroups->Groups[GroupCount].Sid = Sid;
TokenGroups->Groups[GroupCount].Attributes = SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
TokenGroups->Groups[GroupCount].Attributes =
SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
GroupCount++;
/* Member of 'Authenticated users' */
RtlAllocateAndInitializeSid(
&SystemAuthority,
RtlAllocateAndInitializeSid(&SystemAuthority,
1,
SECURITY_AUTHENTICATED_USER_RID,
SECURITY_NULL_RID,
@ -567,7 +566,8 @@ AllocateGroupSids(
SECURITY_NULL_RID,
&Sid);
TokenGroups->Groups[GroupCount].Sid = Sid;
TokenGroups->Groups[GroupCount].Attributes = SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
TokenGroups->Groups[GroupCount].Attributes =
SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
GroupCount++;
TokenGroups->GroupCount = GroupCount;
@ -596,7 +596,7 @@ FreeGroupSids(PTOKEN_GROUPS TokenGroups)
* @unimplemented
*/
BOOL STDCALL
LogonUserW (LPWSTR lpszUsername,
LogonUserW(LPWSTR lpszUsername,
LPWSTR lpszDomain,
LPWSTR lpszPassword,
DWORD dwLogonType,
@ -670,6 +670,7 @@ LogonUserW (LPWSTR lpszUsername,
{
return FALSE;
}
ExpirationTime.QuadPart = -1;
/* Get the user SID from the registry */
@ -708,7 +709,8 @@ LogonUserW (LPWSTR lpszUsername,
TokenPrivileges->PrivilegeCount = 0;
for (i = 0; i < sizeof(DefaultPrivs) / sizeof(DefaultPrivs[0]); i++)
{
if (! LookupPrivilegeValueW(NULL, DefaultPrivs[i].PrivName,
if (! LookupPrivilegeValueW(NULL,
DefaultPrivs[i].PrivName,
&TokenPrivileges->Privileges[TokenPrivileges->PrivilegeCount].Luid))
{
WARN("Can't set privilege %S\n", DefaultPrivs[i].PrivName);
@ -723,7 +725,6 @@ LogonUserW (LPWSTR lpszUsername,
TokenOwner.Owner = OwnerSid;
TokenPrimaryGroup.PrimaryGroup = PrimaryGroupSid;
Dacl = RtlAllocateHeap(GetProcessHeap(), 0, 1024);
if (Dacl == NULL)
{
@ -773,6 +774,7 @@ LogonUserW (LPWSTR lpszUsername,
memcpy(TokenSource.SourceName,
"User32 ",
8);
Status = NtAllocateLocallyUniqueId(&TokenSource.SourceIdentifier);
if (!NT_SUCCESS(Status))
{

View file

@ -43,10 +43,12 @@ AbortSystemShutdownA(LPCSTR lpMachineName)
RtlInitAnsiString(&MachineNameA, (LPSTR)lpMachineName);
Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
if (STATUS_SUCCESS != Status) {
if (STATUS_SUCCESS != Status)
{
SetLastError(RtlNtStatusToDosError(Status));
return FALSE;
}
rv = AbortSystemShutdownW(MachineNameW.Buffer);
RtlFreeUnicodeString(&MachineNameW);
SetLastError(ERROR_SUCCESS);
@ -60,8 +62,7 @@ AbortSystemShutdownA(LPCSTR lpMachineName)
* @unimplemented
*/
BOOL STDCALL
InitiateSystemShutdownW(
LPWSTR lpMachineName,
InitiateSystemShutdownW(LPWSTR lpMachineName,
LPWSTR lpMessage,
DWORD dwTimeout,
BOOL bForceAppsClosed,
@ -70,13 +71,17 @@ InitiateSystemShutdownW(
SHUTDOWN_ACTION Action = ShutdownNoReboot;
NTSTATUS Status;
if (lpMachineName) {
if (lpMachineName)
{
/* FIXME: remote machine shutdown not supported yet */
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
if (dwTimeout) {
if (dwTimeout)
{
}
Status = NtShutdownSystem(Action);
SetLastError(RtlNtStatusToDosError(Status));
return FALSE;
@ -90,8 +95,7 @@ InitiateSystemShutdownW(
*/
BOOL
STDCALL
InitiateSystemShutdownA(
LPSTR lpMachineName,
InitiateSystemShutdownA(LPSTR lpMachineName,
LPSTR lpMessage,
DWORD dwTimeout,
BOOL bForceAppsClosed,
@ -105,38 +109,49 @@ InitiateSystemShutdownA(
INT LastError;
BOOL rv;
if (lpMachineName) {
if (lpMachineName)
{
RtlInitAnsiString(&MachineNameA, lpMachineName);
Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
if (STATUS_SUCCESS != Status) {
if (STATUS_SUCCESS != Status)
{
SetLastError(RtlNtStatusToDosError(Status));
return FALSE;
}
}
if (lpMessage) {
if (lpMessage)
{
RtlInitAnsiString(&MessageA, lpMessage);
Status = RtlAnsiStringToUnicodeString(&MessageW, &MessageA, TRUE);
if (STATUS_SUCCESS != Status) {
if (MachineNameW.Length) {
if (STATUS_SUCCESS != Status)
{
if (MachineNameW.Length)
{
RtlFreeUnicodeString(&MachineNameW);
}
SetLastError(RtlNtStatusToDosError(Status));
return FALSE;
}
}
rv = InitiateSystemShutdownW(
MachineNameW.Buffer,
rv = InitiateSystemShutdownW(MachineNameW.Buffer,
MessageW.Buffer,
dwTimeout,
bForceAppsClosed,
bRebootAfterShutdown);
LastError = GetLastError();
if (lpMachineName) {
if (lpMachineName)
{
RtlFreeUnicodeString(&MachineNameW);
}
if (lpMessage) {
if (lpMessage)
{
RtlFreeUnicodeString(&MessageW);
}
SetLastError(LastError);
return rv;
}
@ -146,8 +161,12 @@ InitiateSystemShutdownA(
*
* see InitiateSystemShutdownExA
*/
BOOL WINAPI InitiateSystemShutdownExW( LPWSTR lpMachineName, LPWSTR lpMessage,
DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown,
BOOL WINAPI
InitiateSystemShutdownExW(LPWSTR lpMachineName,
LPWSTR lpMessage,
DWORD dwTimeout,
BOOL bForceAppsClosed,
BOOL bRebootAfterShutdown,
DWORD dwReason)
{
UNIMPLEMENTED;