From 33527f2f1c71f8a0dcc2bbae67e4e3922860f506 Mon Sep 17 00:00:00 2001 From: wj32 Date: Fri, 30 Nov 2012 12:44:53 +0000 Subject: [PATCH] fixed PhSetDesktopWinStaAccess on Windows 8 - create a DACL instead of setting it to NULL git-svn-id: svn://svn.code.sf.net/p/processhacker/code@5114 21ef857c-d57f-4fe0-8362-d861dc6d29cd --- 2.x/trunk/CHANGELOG.txt | 1 + 2.x/trunk/ProcessHacker/runas.c | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/2.x/trunk/CHANGELOG.txt b/2.x/trunk/CHANGELOG.txt index 434ab4c6f..4508cfda0 100644 --- a/2.x/trunk/CHANGELOG.txt +++ b/2.x/trunk/CHANGELOG.txt @@ -18,6 +18,7 @@ Process Hacker * Fixed task scheduler information on Windows 8 * Fixed drag bug in tree list * Fixed KProcessHacker bug affecting TmTx objects + * Fixed Run As feature on Windows 8 2.28 * NEW/IMPROVED: diff --git a/2.x/trunk/ProcessHacker/runas.c b/2.x/trunk/ProcessHacker/runas.c index 3aca23cff..79abebdbd 100644 --- a/2.x/trunk/ProcessHacker/runas.c +++ b/2.x/trunk/ProcessHacker/runas.c @@ -740,13 +740,25 @@ VOID PhSetDesktopWinStaAccess( { HWINSTA wsHandle; HDESK desktopHandle; - SECURITY_DESCRIPTOR securityDescriptor; + ULONG allocationLength; + PSECURITY_DESCRIPTOR securityDescriptor; + PACL dacl; // TODO: Set security on the correct window station and desktop. - // Create a security descriptor with a NULL DACL, - // thereby allowing everyone to access the object. - RtlCreateSecurityDescriptor(&securityDescriptor, SECURITY_DESCRIPTOR_REVISION); + // We create a DACL that allows everyone to access everything. + + allocationLength = SECURITY_DESCRIPTOR_MIN_LENGTH + + (ULONG)sizeof(ACL) + + (ULONG)sizeof(ACCESS_ALLOWED_ACE) + + RtlLengthSid(&PhSeEveryoneSid); + securityDescriptor = PhAllocate(allocationLength); + dacl = (PACL)((PCHAR)securityDescriptor + SECURITY_DESCRIPTOR_MIN_LENGTH); + + RtlCreateSecurityDescriptor(securityDescriptor, SECURITY_DESCRIPTOR_REVISION); + RtlCreateAcl(dacl, allocationLength - SECURITY_DESCRIPTOR_MIN_LENGTH, ACL_REVISION); + RtlAddAccessAllowedAce(dacl, ACL_REVISION, GENERIC_ALL, &PhSeEveryoneSid); + RtlSetDaclSecurityDescriptor(securityDescriptor, TRUE, dacl, FALSE); if (wsHandle = OpenWindowStation( L"WinSta0", @@ -754,7 +766,7 @@ VOID PhSetDesktopWinStaAccess( WRITE_DAC )) { - PhSetObjectSecurity(wsHandle, DACL_SECURITY_INFORMATION, &securityDescriptor); + PhSetObjectSecurity(wsHandle, DACL_SECURITY_INFORMATION, securityDescriptor); CloseWindowStation(wsHandle); } @@ -765,9 +777,11 @@ VOID PhSetDesktopWinStaAccess( WRITE_DAC | DESKTOP_READOBJECTS | DESKTOP_WRITEOBJECTS )) { - PhSetObjectSecurity(desktopHandle, DACL_SECURITY_INFORMATION, &securityDescriptor); + PhSetObjectSecurity(desktopHandle, DACL_SECURITY_INFORMATION, securityDescriptor); CloseDesktop(desktopHandle); } + + PhFree(securityDescriptor); } /**