ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
November 2012
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
11 participants
124 discussions
Start a n
N
ew thread
[ekohl] 57745: [LSASRV] LsarSetInformationPolicy: Add labels for unimplemented cases.
by ekohl@svn.reactos.org
Author: ekohl Date: Thu Nov 22 21:25:15 2012 New Revision: 57745 URL:
http://svn.reactos.org/svn/reactos?rev=57745&view=rev
Log: [LSASRV] LsarSetInformationPolicy: Add labels for unimplemented cases. Modified: trunk/reactos/dll/win32/lsasrv/lsarpc.c Modified: trunk/reactos/dll/win32/lsasrv/lsarpc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsarpc.c?…
============================================================================== --- trunk/reactos/dll/win32/lsasrv/lsarpc.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/lsasrv/lsarpc.c [iso-8859-1] Thu Nov 22 21:25:15 2012 @@ -462,26 +462,54 @@ switch (InformationClass) { - case PolicyAuditEventsInformation: + case PolicyAuditLogInformation: /* 1 */ Status = STATUS_NOT_IMPLEMENTED; break; - case PolicyPrimaryDomainInformation: + case PolicyAuditEventsInformation: /* 2 */ + Status = STATUS_NOT_IMPLEMENTED; + break; + + case PolicyPrimaryDomainInformation: /* 3 */ Status = LsarSetPrimaryDomain(PolicyHandle, (PLSAPR_POLICY_PRIMARY_DOM_INFO)PolicyInformation); break; - case PolicyAccountDomainInformation: + case PolicyAccountDomainInformation: /* 5 */ Status = LsarSetAccountDomain(PolicyHandle, (PLSAPR_POLICY_ACCOUNT_DOM_INFO)PolicyInformation); break; - case PolicyDnsDomainInformation: + case PolicyLsaServerRoleInformation: /* 6 */ + Status = STATUS_NOT_IMPLEMENTED; + break; + + case PolicyReplicaSourceInformation: /* 7 */ + Status = STATUS_NOT_IMPLEMENTED; + break; + + case PolicyDefaultQuotaInformation: /* 8 */ + Status = STATUS_NOT_IMPLEMENTED; + break; + + case PolicyModificationInformation: /* 9 */ + Status = STATUS_NOT_IMPLEMENTED; + break; + + case PolicyAuditFullSetInformation: /* 10 (0xA) */ + Status = STATUS_NOT_IMPLEMENTED; + break; + + case PolicyDnsDomainInformation: /* 12 (0xC) */ Status = LsarSetDnsDomain(PolicyHandle, (PLSAPR_POLICY_DNS_DOMAIN_INFO)PolicyInformation); break; - case PolicyLsaServerRoleInformation: + case PolicyDnsDomainInformationInt: /* 13 (0xD) */ + Status = STATUS_NOT_IMPLEMENTED; + break; + + case PolicyLocalAccountDomainInformation: /* 14 (0xE) */ Status = STATUS_NOT_IMPLEMENTED; break;
12 years, 1 month
1
0
0
0
[hbelusca] 57744: [CSRSRV] Remove the unneeded CsrpHandleConnectionRequest function since CsrApiHandleConnectionRequest does already the job.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Wed Nov 21 18:52:42 2012 New Revision: 57744 URL:
http://svn.reactos.org/svn/reactos?rev=57744&view=rev
Log: [CSRSRV] Remove the unneeded CsrpHandleConnectionRequest function since CsrApiHandleConnectionRequest does already the job. Modified: branches/ros-csrss/subsystems/win32/csrsrv/api.c Modified: branches/ros-csrss/subsystems/win32/csrsrv/api.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/subsystems/win32/csrs…
============================================================================== --- branches/ros-csrss/subsystems/win32/csrsrv/api.c [iso-8859-1] (original) +++ branches/ros-csrss/subsystems/win32/csrsrv/api.c [iso-8859-1] Wed Nov 21 18:52:42 2012 @@ -142,7 +142,7 @@ PCSR_CONNECTION_INFO ConnectInfo = &ApiMessage->ConnectionInfo; BOOLEAN AllowConnection = FALSE; REMOTE_PORT_VIEW RemotePortView; - HANDLE hPort; + HANDLE ServerPort; /* Acquire the Process Lock */ CsrAcquireProcessLock(); @@ -205,7 +205,7 @@ ConnectInfo->ProcessId = NtCurrentTeb()->ClientId.UniqueProcess; /* Accept the Connection */ - Status = NtAcceptConnectPort(&hPort, + Status = NtAcceptConnectPort(&ServerPort, AllowConnection ? UlongToPtr(CsrProcess->SequenceNumber) : 0, &ApiMessage->Header, AllowConnection, @@ -227,13 +227,13 @@ } /* Set some Port Data in the Process */ - CsrProcess->ClientPort = hPort; + CsrProcess->ClientPort = ServerPort; CsrProcess->ClientViewBase = (ULONG_PTR)RemotePortView.ViewBase; CsrProcess->ClientViewBounds = (ULONG_PTR)((ULONG_PTR)RemotePortView.ViewBase + (ULONG_PTR)RemotePortView.ViewSize); /* Complete the connection */ - Status = NtCompleteConnectPort(hPort); + Status = NtCompleteConnectPort(ServerPort); if (!NT_SUCCESS(Status)) { DPRINT1("CSRSS: NtCompleteConnectPort - failed. Status == %X\n", Status); @@ -247,107 +247,6 @@ } /* Return status to caller */ - return Status; -} - -// TODO: See CsrApiHandleConnectionRequest -NTSTATUS WINAPI -CsrpHandleConnectionRequest(PPORT_MESSAGE Request) -{ - NTSTATUS Status; - HANDLE ServerPort = NULL;//, ServerThread = NULL; - PCSR_PROCESS ProcessData = NULL; - REMOTE_PORT_VIEW RemotePortView; -// CLIENT_ID ClientId; - BOOLEAN AllowConnection = FALSE; - PCSR_CONNECTION_INFO ConnectInfo; - ServerPort = NULL; - - DPRINT1("CSR: %s: Handling: %p\n", __FUNCTION__, Request); - - ConnectInfo = (PCSR_CONNECTION_INFO)(Request + 1); - - /* Save the process ID */ - RtlZeroMemory(ConnectInfo, sizeof(CSR_CONNECTION_INFO)); - - CsrLockProcessByClientId(Request->ClientId.UniqueProcess, &ProcessData); - if (!ProcessData) - { - DPRINT1("CSRSRV: Unknown process: %lx. Will be rejecting connection\n", - Request->ClientId.UniqueProcess); - } - - if ((ProcessData) && (ProcessData != CsrRootProcess)) - { - /* Attach the Shared Section */ - Status = CsrSrvAttachSharedSection(ProcessData, ConnectInfo); - if (NT_SUCCESS(Status)) - { - DPRINT1("Connection ok\n"); - AllowConnection = TRUE; - } - else - { - DPRINT1("Shared section map failed: %lx\n", Status); - } - } - else if (ProcessData == CsrRootProcess) - { - AllowConnection = TRUE; - } - - /* Release the process */ - if (ProcessData) CsrUnlockProcess(ProcessData); - - /* Setup the Port View Structure */ - RemotePortView.Length = sizeof(REMOTE_PORT_VIEW); - RemotePortView.ViewSize = 0; - RemotePortView.ViewBase = NULL; - - /* Save the Process ID */ - ConnectInfo->ProcessId = NtCurrentTeb()->ClientId.UniqueProcess; - - Status = NtAcceptConnectPort(&ServerPort, - AllowConnection ? UlongToPtr(ProcessData->SequenceNumber) : 0, - Request, - AllowConnection, - NULL, - &RemotePortView); - if (!NT_SUCCESS(Status)) - { - DPRINT1("CSRSS: NtAcceptConnectPort - failed. Status == %X\n", Status); - } - else if (AllowConnection) - { - if (CsrDebug & 2) - { - DPRINT1("CSRSS: ClientId: %lx.%lx has ClientView: Base=%p, Size=%lx\n", - Request->ClientId.UniqueProcess, - Request->ClientId.UniqueThread, - RemotePortView.ViewBase, - RemotePortView.ViewSize); - } - - /* Set some Port Data in the Process */ - ProcessData->ClientPort = ServerPort; - ProcessData->ClientViewBase = (ULONG_PTR)RemotePortView.ViewBase; - ProcessData->ClientViewBounds = (ULONG_PTR)((ULONG_PTR)RemotePortView.ViewBase + - (ULONG_PTR)RemotePortView.ViewSize); - - /* Complete the connection */ - Status = NtCompleteConnectPort(ServerPort); - if (!NT_SUCCESS(Status)) - { - DPRINT1("CSRSS: NtCompleteConnectPort - failed. Status == %X\n", Status); - } - } - else - { - DPRINT1("CSRSS: Rejecting Connection Request from ClientId: %lx.%lx\n", - Request->ClientId.UniqueProcess, - Request->ClientId.UniqueThread); - } - return Status; }
12 years, 1 month
1
0
0
0
[hbelusca] 57743: [NTDLL] When calling CsrClientConnectToServer with a valid connection info user buffer, after capturing the buffer and calling CsrClientCallServer, do not forget to copy back to t...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Tue Nov 20 22:48:11 2012 New Revision: 57743 URL:
http://svn.reactos.org/svn/reactos?rev=57743&view=rev
Log: [NTDLL] When calling CsrClientConnectToServer with a valid connection info user buffer, after capturing the buffer and calling CsrClientCallServer, do not forget to copy back to the user buffer the updated connection info and to free the capture buffer ! Modified: branches/ros-csrss/dll/ntdll/csr/api.c branches/ros-csrss/dll/ntdll/csr/capture.c branches/ros-csrss/dll/ntdll/csr/connect.c Modified: branches/ros-csrss/dll/ntdll/csr/api.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/ntdll/csr/api.c?r…
============================================================================== --- branches/ros-csrss/dll/ntdll/csr/api.c [iso-8859-1] (original) +++ branches/ros-csrss/dll/ntdll/csr/api.c [iso-8859-1] Tue Nov 20 22:48:11 2012 @@ -13,6 +13,7 @@ #include <debug.h> /* GLOBALS ********************************************************************/ + extern HANDLE CsrApiPort; /* FUNCTIONS ******************************************************************/ Modified: branches/ros-csrss/dll/ntdll/csr/capture.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/ntdll/csr/capture…
============================================================================== --- branches/ros-csrss/dll/ntdll/csr/capture.c [iso-8859-1] (original) +++ branches/ros-csrss/dll/ntdll/csr/capture.c [iso-8859-1] Tue Nov 20 22:48:11 2012 @@ -13,6 +13,7 @@ #include <debug.h> /* GLOBALS ********************************************************************/ + extern HANDLE CsrPortHeap; /* FUNCTIONS ******************************************************************/ Modified: branches/ros-csrss/dll/ntdll/csr/connect.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/ntdll/csr/connect…
============================================================================== --- branches/ros-csrss/dll/ntdll/csr/connect.c [iso-8859-1] (original) +++ branches/ros-csrss/dll/ntdll/csr/connect.c [iso-8859-1] Tue Nov 20 22:48:11 2012 @@ -331,8 +331,9 @@ PCSR_CLIENT_CONNECT ClientConnect = &ApiMessage.Data.CsrClientConnect; PCSR_CAPTURE_BUFFER CaptureBuffer; + DPRINT("CsrClientConnectToServer: %lx %p\n", ServerId, ConnectionInfo); + /* Validate the Connection Info */ - DPRINT("CsrClientConnectToServer: %lx %p\n", ServerId, ConnectionInfo); if (ConnectionInfo && (!ConnectionInfoSize || !*ConnectionInfoSize)) { DPRINT1("Connection info given, but no length\n"); @@ -428,6 +429,14 @@ CaptureBuffer, CSR_CREATE_API_NUMBER(CSRSRV_SERVERDLL_INDEX, CsrpClientConnect), sizeof(CSR_CLIENT_CONNECT)); + + /* Copy the updated connection info data back into the user buffer */ + RtlMoveMemory(ConnectionInfo, + ClientConnect->ConnectionInfo, + *ConnectionInfoSize); + + /* Free the capture buffer */ + CsrFreeCaptureBuffer(CaptureBuffer); } else { @@ -438,6 +447,7 @@ /* Let the caller know if this was server to server */ DPRINT("Status was: 0x%lx. Are we in server: 0x%x\n", Status, InsideCsrProcess); if (ServerToServerCall) *ServerToServerCall = InsideCsrProcess; + return Status; }
12 years, 1 month
1
0
0
0
[ekohl] 57742: [LSASRV] - Create and set a security descriptor for newly created secrets.
by ekohl@svn.reactos.org
Author: ekohl Date: Tue Nov 20 22:34:00 2012 New Revision: 57742 URL:
http://svn.reactos.org/svn/reactos?rev=57742&view=rev
Log: [LSASRV] - Create and set a security descriptor for newly created secrets. Modified: trunk/reactos/dll/win32/lsasrv/lsarpc.c trunk/reactos/dll/win32/lsasrv/lsasrv.h trunk/reactos/dll/win32/lsasrv/security.c Modified: trunk/reactos/dll/win32/lsasrv/lsarpc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsarpc.c?…
============================================================================== --- trunk/reactos/dll/win32/lsasrv/lsarpc.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/lsasrv/lsarpc.c [iso-8859-1] Tue Nov 20 22:34:00 2012 @@ -767,6 +767,8 @@ PLSA_DB_OBJECT PolicyObject; PLSA_DB_OBJECT SecretObject = NULL; LARGE_INTEGER Time; + PSECURITY_DESCRIPTOR SecretSd = NULL; + ULONG SecretSdSize; NTSTATUS Status = STATUS_SUCCESS; /* Validate the PolicyHandle */ @@ -786,6 +788,15 @@ { ERR("NtQuerySystemTime failed (Status 0x%08lx)\n", Status); goto done; + } + + /* Create a security descriptor for the secret */ + Status = LsapCreateSecretSd(&SecretSd, + &SecretSdSize); + if (!NT_SUCCESS(Status)) + { + ERR("LsapCreateAccountSd returned 0x%08lx\n", Status); + return Status; } /* Create the Secret object */ @@ -817,8 +828,22 @@ L"OldTime", (PVOID)&Time, sizeof(LARGE_INTEGER)); + if (!NT_SUCCESS(Status)) + { + ERR("LsapSetObjectAttribute (OldTime) failed (Status 0x%08lx)\n", Status); + goto done; + } + + /* Set the SecDesc attribute */ + Status = LsapSetObjectAttribute(SecretObject, + L"SecDesc", + SecretSd, + SecretSdSize); done: + if (SecretSd != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, SecretSd); + if (!NT_SUCCESS(Status)) { if (SecretObject != NULL) Modified: trunk/reactos/dll/win32/lsasrv/lsasrv.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsasrv.h?…
============================================================================== --- trunk/reactos/dll/win32/lsasrv/lsasrv.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/lsasrv/lsasrv.h [iso-8859-1] Tue Nov 20 22:34:00 2012 @@ -236,4 +236,8 @@ LsapCreateAccountSd(PSECURITY_DESCRIPTOR *AccountSd, PULONG AccountSdSize); +NTSTATUS +LsapCreateSecretSd(PSECURITY_DESCRIPTOR *SecretSd, + PULONG SecretSdSize); + /* EOF */ Modified: trunk/reactos/dll/win32/lsasrv/security.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/security.…
============================================================================== --- trunk/reactos/dll/win32/lsasrv/security.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/lsasrv/security.c [iso-8859-1] Tue Nov 20 22:34:00 2012 @@ -436,4 +436,172 @@ return Status; } + +NTSTATUS +LsapCreateSecretSd(PSECURITY_DESCRIPTOR *SecretSd, + PULONG SecretSdSize) +{ + SECURITY_DESCRIPTOR AbsoluteSd; + PSECURITY_DESCRIPTOR RelativeSd = NULL; + ULONG RelativeSdSize = 0; + PSID AdministratorsSid = NULL; + PSID EveryoneSid = NULL; + PSID LocalSystemSid = NULL; + PACL Dacl = NULL; + ULONG DaclSize; + NTSTATUS Status; + + if (SecretSd == NULL || SecretSdSize == NULL) + return STATUS_INVALID_PARAMETER; + + *SecretSd = NULL; + *SecretSdSize = 0; + + /* Initialize the SD */ + Status = RtlCreateSecurityDescriptor(&AbsoluteSd, + SECURITY_DESCRIPTOR_REVISION); + if (!NT_SUCCESS(Status)) + return Status; + + Status = RtlAllocateAndInitializeSid(&NtAuthority, + 2, + SECURITY_BUILTIN_DOMAIN_RID, + DOMAIN_ALIAS_RID_ADMINS, + 0, + 0, + 0, + 0, + 0, + 0, + &AdministratorsSid); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlAllocateAndInitializeSid(&WorldSidAuthority, + 1, + SECURITY_WORLD_RID, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + &EveryoneSid); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlAllocateAndInitializeSid(&NtAuthority, + 1, + SECURITY_LOCAL_SYSTEM_RID, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + &LocalSystemSid); + if (!NT_SUCCESS(Status)) + goto done; + + /* Allocate and initialize the DACL */ + DaclSize = sizeof(ACL) + + sizeof(ACCESS_ALLOWED_ACE) - sizeof(ULONG) + RtlLengthSid(AdministratorsSid) + + sizeof(ACCESS_ALLOWED_ACE) - sizeof(ULONG) + RtlLengthSid(EveryoneSid); + + Dacl = RtlAllocateHeap(RtlGetProcessHeap(), + HEAP_ZERO_MEMORY, + DaclSize); + if (Dacl == NULL) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + goto done; + } + + Status = RtlCreateAcl(Dacl, + DaclSize, + ACL_REVISION); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlAddAccessAllowedAce(Dacl, + ACL_REVISION, + SECRET_ALL_ACCESS, + AdministratorsSid); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlAddAccessAllowedAce(Dacl, + ACL_REVISION, + SECRET_EXECUTE, + EveryoneSid); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlSetDaclSecurityDescriptor(&AbsoluteSd, + TRUE, + Dacl, + FALSE); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlSetGroupSecurityDescriptor(&AbsoluteSd, + LocalSystemSid, + FALSE); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlSetOwnerSecurityDescriptor(&AbsoluteSd, + AdministratorsSid, + FALSE); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlAbsoluteToSelfRelativeSD(&AbsoluteSd, + RelativeSd, + &RelativeSdSize); + if (Status != STATUS_BUFFER_TOO_SMALL) + goto done; + + RelativeSd = RtlAllocateHeap(RtlGetProcessHeap(), + HEAP_ZERO_MEMORY, + RelativeSdSize); + if (RelativeSd == NULL) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + goto done; + } + + Status = RtlAbsoluteToSelfRelativeSD(&AbsoluteSd, + RelativeSd, + &RelativeSdSize); + if (!NT_SUCCESS(Status)) + goto done; + + *SecretSd = RelativeSd; + *SecretSdSize = RelativeSdSize; + +done: + if (Dacl != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, Dacl); + + if (AdministratorsSid != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, AdministratorsSid); + + if (EveryoneSid != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, EveryoneSid); + + if (LocalSystemSid != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, LocalSystemSid); + + if (!NT_SUCCESS(Status)) + { + if (RelativeSd != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, RelativeSd); + } + + return Status; +} + /* EOF */
12 years, 1 month
1
0
0
0
[hbelusca] 57741: [CSRSRV] - Remove unused functions CallHardError and CsrHandleHardError (in fact calling the hard error callback is already done in the listening thread). - Add an annotation and ...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Tue Nov 20 19:34:03 2012 New Revision: 57741 URL:
http://svn.reactos.org/svn/reactos?rev=57741&view=rev
Log: [CSRSRV] - Remove unused functions CallHardError and CsrHandleHardError (in fact calling the hard error callback is already done in the listening thread). - Add an annotation and correct a typographical error; remove old comments. - Remove the now unneeded csrplugin.h header (a relic of the old callback system of the old csrss/csrsrv). Removed: branches/ros-csrss/subsystems/win32/csrsrv/include/csrplugin.h Modified: branches/ros-csrss/subsystems/win32/csrsrv/api.c branches/ros-csrss/subsystems/win32/csrsrv/init.c branches/ros-csrss/subsystems/win32/csrsrv/procsup.c branches/ros-csrss/subsystems/win32/csrsrv/wait.c Modified: branches/ros-csrss/subsystems/win32/csrsrv/api.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/subsystems/win32/csrs…
============================================================================== --- branches/ros-csrss/subsystems/win32/csrsrv/api.c [iso-8859-1] (original) +++ branches/ros-csrss/subsystems/win32/csrsrv/api.c [iso-8859-1] Tue Nov 20 19:34:03 2012 @@ -23,24 +23,6 @@ extern ULONG CsrMaxApiRequestThreads; /* FUNCTIONS ******************************************************************/ - -VOID -CallHardError(IN PCSR_THREAD ThreadData, - IN PHARDERROR_MSG HardErrorMessage); - -#if 0 -static -VOID -NTAPI -CsrHandleHardError(IN PCSR_THREAD ThreadData, - IN OUT PHARDERROR_MSG Message) -{ - DPRINT1("CSR: received hard error %lx\n", Message->Status); - - /* Call the hard error handler in win32csr */ - CallHardError(ThreadData, Message); -} -#endif /*++ * @name CsrCallServerFromServer @@ -626,7 +608,7 @@ if ((ServerDll) && (ServerDll->HardErrorCallback)) { /* Call it */ - ServerDll->HardErrorCallback(NULL /* CsrThread */, HardErrorMsg); + ServerDll->HardErrorCallback(NULL /* CsrThread == NULL */, HardErrorMsg); /* If it's handled, get out of here */ if (HardErrorMsg->Response != ResponseNotHandled) break; @@ -1141,7 +1123,7 @@ &hUser32); RtlFreeUnicodeString(&TempName); - /* If we got teh handle, get the Client Thread Startup Entrypoint */ + /* If we got the handle, get the Client Thread Startup Entrypoint */ if (NT_SUCCESS(Status)) { RtlInitAnsiString(&StartupName,"ClientThreadSetup"); Removed: branches/ros-csrss/subsystems/win32/csrsrv/include/csrplugin.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/subsystems/win32/csrs…
============================================================================== --- branches/ros-csrss/subsystems/win32/csrsrv/include/csrplugin.h [iso-8859-1] (original) +++ branches/ros-csrss/subsystems/win32/csrsrv/include/csrplugin.h (removed) @@ -1,58 +1,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS system libraries - * FILE: subsys/csrss/include/csrplugin.h - * PURPOSE: CSRSS plugin interface - */ - -/* - * CSRSS is a native application and can only implicitly link against native - * DLLs. Since e.g. user32.dll and gdi32.dll are win32 DLLs and not native - * DLLs it is not possible to call functions in those DLLs directly from - * CSRSS. - * However, it is possible to explicitly load a non-native DLL. Such a DLL - * can then in turn be implicitly linked against other DLLs in its own - * subsystem. - */ - -#pragma once - -#include <windows.h> - -#include <csr/csr.h> -//#include "api.h" - -/* -typedef NTSTATUS (WINAPI *CSRSS_ENUM_PROCESSES_PROC)(CSRSS_ENUM_PROCESS_PROC EnumProc, - PVOID Context); -typedef NTSTATUS (WINAPI *CSRSS_ENUM_PROCESS_PROC)(PCSR_PROCESS ProcessData, - PVOID Context); - -typedef struct tagCSRSS_EXPORTED_FUNCS -{ - CSRSS_ENUM_PROCESSES_PROC CsrEnumProcessesProc; -} CSRSS_EXPORTED_FUNCS, *PCSRSS_EXPORTED_FUNCS; -*/ - -typedef BOOL (WINAPI *CSRPLUGIN_INIT_COMPLETE_PROC)(void); - -typedef VOID (WINAPI *CSRPLUGIN_HARDERROR_PROC)(IN PCSR_THREAD ThreadData, - IN PHARDERROR_MSG HardErrorMessage); - -typedef NTSTATUS (WINAPI *CSRPLUGIN_PROCESS_INHERIT_PROC)(IN PCSR_PROCESS SourceProcessData, - IN PCSR_PROCESS TargetProcessData); - -typedef ULONG (WINAPI *CSRPLUGIN_PROCESS_DELETED_PROC)(IN PCSR_PROCESS ProcessData, IN ULONG Unused, IN BOOLEAN Flag); - -typedef struct tagCSRSS_SERVER_PROCS -{ - CSRPLUGIN_INIT_COMPLETE_PROC InitCompleteProc; - CSRPLUGIN_HARDERROR_PROC HardErrorProc; - CSRPLUGIN_PROCESS_INHERIT_PROC ProcessInheritProc; - CSRPLUGIN_PROCESS_DELETED_PROC ProcessDeletedProc; -} CSRPLUGIN_SERVER_PROCS, *PCSRPLUGIN_SERVER_PROCS; - -typedef BOOL (WINAPI *CSRPLUGIN_INITIALIZE_PROC)(PCSRSS_API_DEFINITION *ApiDefinitions, - PCSRPLUGIN_SERVER_PROCS ServerProcs); - -/* EOF */ Modified: branches/ros-csrss/subsystems/win32/csrsrv/init.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/subsystems/win32/csrs…
============================================================================== --- branches/ros-csrss/subsystems/win32/csrsrv/init.c [iso-8859-1] (original) +++ branches/ros-csrss/subsystems/win32/csrsrv/init.c [iso-8859-1] Tue Nov 20 19:34:03 2012 @@ -37,29 +37,6 @@ /* PRIVATE FUNCTIONS **********************************************************/ - -VOID -CallHardError(IN PCSR_THREAD ThreadData, - IN PHARDERROR_MSG HardErrorMessage) -{ - ULONG i; - PCSR_SERVER_DLL ServerDll; - - DPRINT("CSR: %s called\n", __FUNCTION__); - - /* Notify the Server DLLs */ - for (i = 0; i < CSR_SERVER_DLL_MAX; i++) - { - /* Get the current Server DLL */ - ServerDll = CsrLoadedServerDll[i]; - - /* Make sure it's valid and that it has callback */ - if (ServerDll && ServerDll->HardErrorCallback) - { - ServerDll->HardErrorCallback(ThreadData, HardErrorMessage); - } - } -} /* === INIT ROUTINES === */ Modified: branches/ros-csrss/subsystems/win32/csrsrv/procsup.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/subsystems/win32/csrs…
============================================================================== --- branches/ros-csrss/subsystems/win32/csrsrv/procsup.c [iso-8859-1] (original) +++ branches/ros-csrss/subsystems/win32/csrsrv/procsup.c [iso-8859-1] Tue Nov 20 19:34:03 2012 @@ -32,9 +32,9 @@ /* PRIVATE FUNCTIONS **********************************************************/ /*++ - * @name CsrpSetToNormalPriority - * - * The CsrpSetToNormalPriority routine sets the current NT Process' + * @name CsrSetToNormalPriority + * + * The CsrSetToNormalPriority routine sets the current NT Process' * priority to the normal priority for CSR Processes. * * @param None. @@ -47,7 +47,7 @@ *--*/ VOID NTAPI -CsrSetToNormalPriority(VOID) // CsrpSetToNormalPriority +CsrSetToNormalPriority(VOID) { KPRIORITY BasePriority = (8 + 1) + 4; @@ -59,9 +59,9 @@ } /*++ - * @name CsrpSetToShutdownPriority - * - * The CsrpSetToShutdownPriority routine sets the current NT Process' + * @name CsrSetToShutdownPriority + * + * The CsrSetToShutdownPriority routine sets the current NT Process' * priority to the boosted priority for CSR Processes doing shutdown. * Additonally, it acquires the Shutdown Privilege required for shutdown. * @@ -75,7 +75,7 @@ *--*/ VOID NTAPI -CsrSetToShutdownPriority(VOID) // CsrpSetToShutdownPriority +CsrSetToShutdownPriority(VOID) { KPRIORITY SetBasePriority = (8 + 1) + 6; BOOLEAN Old; @@ -1288,7 +1288,6 @@ } /* Set shudown Priority */ - // CsrpSetToShutdownPriority(); CsrSetToShutdownPriority(); /* Start looping */ @@ -1365,7 +1364,6 @@ Quickie: /* Return to normal priority */ - // CsrpSetToNormalPriority(); CsrSetToNormalPriority(); return Status; Modified: branches/ros-csrss/subsystems/win32/csrsrv/wait.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/subsystems/win32/csrs…
============================================================================== --- branches/ros-csrss/subsystems/win32/csrsrv/wait.c [iso-8859-1] (original) +++ branches/ros-csrss/subsystems/win32/csrsrv/wait.c [iso-8859-1] Tue Nov 20 19:34:03 2012 @@ -163,7 +163,7 @@ RemoveEntryList(&WaitBlock->UserWaitList); } - /* Dereference teh thread */ + /* Dereference the thread */ CsrDereferenceThread(WaitBlock->WaitThread); /* Free the wait block */
12 years, 1 month
1
0
0
0
[hbelusca] 57740: [KERNEL32/CONSRV] - Merge IntWriteConsoleOutputCharacter and WriteConsoleOutputAttribute functions into IntWriteConsoleOutputCode helper functions, which is used inside WriteConso...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Mon Nov 19 23:26:36 2012 New Revision: 57740 URL:
http://svn.reactos.org/svn/reactos?rev=57740&view=rev
Log: [KERNEL32/CONSRV] - Merge IntWriteConsoleOutputCharacter and WriteConsoleOutputAttribute functions into IntWriteConsoleOutputCode helper functions, which is used inside WriteConsoleOutputAttribute and WriteConsoleOutputCharacterW/A. - In server-side, merge CsrWriteConsoleOutputChar and CsrWriteConsoleOutputAttrib into the server API SrvWriteConsoleOutputString. - The structures CSRSS_WRITE_CONSOLE_OUTPUT_CHAR and CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB are merged into CSRSS_WRITE_CONSOLE_OUTPUT_CODE. [CONSRV] - Add a CsrValidateMessageBuffer usage. Modified: branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c branches/ros-csrss/include/reactos/subsys/win/conmsg.h branches/ros-csrss/win32ss/user/consrv/conoutput.c Modified: branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/cl…
============================================================================== --- branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c [iso-8859-1] (original) +++ branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c [iso-8859-1] Mon Nov 19 23:26:36 2012 @@ -436,6 +436,7 @@ ULONG /* SizeBytes, */ CharSize; // DWORD Written = 0; + /* Determine the needed size */ CharSize = (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); WriteConsoleRequest->BufferSize = nNumberOfCharsToWrite * CharSize; @@ -654,75 +655,109 @@ static BOOL -IntWriteConsoleOutputCharacter(HANDLE hConsoleOutput, - PVOID lpCharacter, - DWORD nLength, - COORD dwWriteCoord, - LPDWORD lpNumberOfCharsWritten, - BOOL bUnicode) -{ - PCSR_API_MESSAGE Request; - ULONG CsrRequest; +IntWriteConsoleOutputCode(HANDLE hConsoleOutput, + CODE_TYPE CodeType, + CONST VOID *pCode, + DWORD nLength, + COORD dwWriteCoord, + LPDWORD lpNumberOfCodesWritten) +{ NTSTATUS Status; - ULONG CharSize, nChars; - //ULONG SizeBytes; - DWORD Written = 0; - - CharSize = (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); - - nChars = min(nLength, CSRSS_MAX_WRITE_CONSOLE_OUTPUT_CHAR / CharSize); - //SizeBytes = nChars * CharSize; - - Request = RtlAllocateHeap(RtlGetProcessHeap(), 0, - max(sizeof(CSR_API_MESSAGE), - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE_OUTPUT_CHAR) - + min (nChars, CSRSS_MAX_WRITE_CONSOLE_OUTPUT_CHAR / CharSize) * CharSize)); - if (Request == NULL) - { + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_WRITE_CONSOLE_OUTPUT_CODE WriteConsoleOutputCodeRequest = &ApiMessage.Data.WriteConsoleOutputCodeRequest; + PCSR_CAPTURE_BUFFER CaptureBuffer; + ULONG CodeSize; //, nChars; + // ULONG SizeBytes; + // DWORD Written = 0; + + /* Determine the needed size */ +/* + CodeSize = (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); + nChars = min(nLength, CSRSS_MAX_WRITE_CONSOLE_OUTPUT_CHAR / CodeSize); + SizeBytes = nChars * CodeSize; +*/ + switch (CodeType) + { + case CODE_ASCII: + CodeSize = sizeof(CHAR); + break; + + case CODE_UNICODE: + CodeSize = sizeof(WCHAR); + break; + + case CODE_ATTRIBUTE: + CodeSize = sizeof(WORD); + break; + + default: + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + WriteConsoleOutputCodeRequest->BufferSize = nLength * CodeSize; + + /* Allocate a Capture Buffer */ + CaptureBuffer = CsrAllocateCaptureBuffer(1, WriteConsoleOutputCodeRequest->BufferSize); + if (CaptureBuffer == NULL) + { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } - CsrRequest = CSR_CREATE_API_NUMBER(CSR_CONSOLE, WRITE_CONSOLE_OUTPUT_CHAR); - Request->Data.WriteConsoleOutputCharRequest.Coord = dwWriteCoord; - - while (nLength > 0) - { - DWORD BytesWrite; - - Request->Data.WriteConsoleOutputCharRequest.ConsoleHandle = hConsoleOutput; - Request->Data.WriteConsoleOutputCharRequest.Unicode = bUnicode; - Request->Data.WriteConsoleOutputCharRequest.Length = (WORD)min(nLength, nChars); - BytesWrite = Request->Data.WriteConsoleOutputCharRequest.Length * CharSize; - - memcpy(Request->Data.WriteConsoleOutputCharRequest.String, lpCharacter, BytesWrite); - - Status = CsrClientCallServer(Request, - NULL, - CsrRequest, - max(sizeof(CSR_API_MESSAGE), - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE_OUTPUT_CHAR) + BytesWrite)); - - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request->Status)) +/* + /\* Allocate space in the Buffer *\/ + CsrAllocateMessagePointer(CaptureBuffer, + SizeBytes, + (PVOID*)&WriteConsoleOutputCodeRequest->pCode.pCode); +*/ + /* Capture the buffer to write */ + CsrCaptureMessageBuffer(CaptureBuffer, + (PVOID)pCode, + WriteConsoleOutputCodeRequest->BufferSize, + (PVOID*)&WriteConsoleOutputCodeRequest->pCode.pCode); + + /* Start writing */ + WriteConsoleOutputCodeRequest->ConsoleHandle = hConsoleOutput; + WriteConsoleOutputCodeRequest->CodeType = CodeType; + WriteConsoleOutputCodeRequest->Coord = dwWriteCoord; + + /** + ** TODO: HACK: Surely it has to go into CONSRV !! + **/ + // while (nLength > 0) + { + // DWORD BytesWrite; + + WriteConsoleOutputCodeRequest->Length = nLength; // (WORD)min(nLength, nChars); + // BytesWrite = WriteConsoleOutputCodeRequest->Length * CodeSize; + + // memcpy(WriteConsoleOutputCodeRequest->pCode.pCode, pCode, BytesWrite); + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + CaptureBuffer, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepWriteConsoleOutputString), + sizeof(CSRSS_WRITE_CONSOLE_OUTPUT_CODE)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) { - RtlFreeHeap(RtlGetProcessHeap(), 0, Request); + CsrFreeCaptureBuffer(CaptureBuffer); BaseSetLastNTError(Status); return FALSE; } - nLength -= Request->Data.WriteConsoleOutputCharRequest.NrCharactersWritten; - lpCharacter = (PVOID)((ULONG_PTR)lpCharacter + (ULONG_PTR)(Request->Data.WriteConsoleOutputCharRequest.NrCharactersWritten * CharSize)); - Written += Request->Data.WriteConsoleOutputCharRequest.NrCharactersWritten; - - Request->Data.WriteConsoleOutputCharRequest.Coord = Request->Data.WriteConsoleOutputCharRequest.EndCoord; - } - - if (lpNumberOfCharsWritten != NULL) - { - *lpNumberOfCharsWritten = Written; - } - - RtlFreeHeap(RtlGetProcessHeap(), 0, Request); + // nLength -= WriteConsoleOutputCodeRequest->NrCharactersWritten; + // pCode = (PVOID)((ULONG_PTR)pCode + /*(ULONG_PTR)(*/WriteConsoleOutputCodeRequest->NrCharactersWritten * CodeSize/*)*/); + // Written += WriteConsoleOutputCodeRequest->NrCharactersWritten; + + WriteConsoleOutputCodeRequest->Coord = WriteConsoleOutputCodeRequest->EndCoord; + } + + if (lpNumberOfCodesWritten != NULL) + // *lpNumberOfCodesWritten = Written; + // *lpNumberOfCodesWritten = WriteConsoleOutputCodeRequest->NrCharactersWritten; + *lpNumberOfCodesWritten = WriteConsoleOutputCodeRequest->Length; + + CsrFreeCaptureBuffer(CaptureBuffer); return TRUE; } @@ -778,7 +813,7 @@ if (lpNumberOfCodesWritten) *lpNumberOfCodesWritten = FillOutputRequest->Length; - // *lpNumberOfCharsWritten = Request.Data.FillOutputRequest.NrCharactersWritten; + // *lpNumberOfCodesWritten = Request.Data.FillOutputRequest.NrCharactersWritten; return TRUE; } @@ -1191,12 +1226,12 @@ COORD dwWriteCoord, LPDWORD lpNumberOfCharsWritten) { - return IntWriteConsoleOutputCharacter(hConsoleOutput, - (PVOID)lpCharacter, - nLength, - dwWriteCoord, - lpNumberOfCharsWritten, - TRUE); + return IntWriteConsoleOutputCode(hConsoleOutput, + CODE_UNICODE, + lpCharacter, + nLength, + dwWriteCoord, + lpNumberOfCharsWritten); } @@ -1213,12 +1248,12 @@ COORD dwWriteCoord, LPDWORD lpNumberOfCharsWritten) { - return IntWriteConsoleOutputCharacter(hConsoleOutput, - (PVOID)lpCharacter, - nLength, - dwWriteCoord, - lpNumberOfCharsWritten, - FALSE); + return IntWriteConsoleOutputCode(hConsoleOutput, + CODE_ASCII, + lpCharacter, + nLength, + dwWriteCoord, + lpNumberOfCharsWritten); } @@ -1235,54 +1270,12 @@ COORD dwWriteCoord, LPDWORD lpNumberOfAttrsWritten) { - PCSR_API_MESSAGE Request; - ULONG CsrRequest; - NTSTATUS Status; - WORD Size; - - Request = RtlAllocateHeap(RtlGetProcessHeap(), - 0, - max(sizeof(CSR_API_MESSAGE), - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB) - + min(nLength, CSRSS_MAX_WRITE_CONSOLE_OUTPUT_ATTRIB / sizeof(WORD)) * sizeof(WORD))); - if (Request == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - CsrRequest = CSR_CREATE_API_NUMBER(CSR_CONSOLE, WRITE_CONSOLE_OUTPUT_ATTRIB); - Request->Data.WriteConsoleOutputAttribRequest.Coord = dwWriteCoord; - - if (lpNumberOfAttrsWritten) - *lpNumberOfAttrsWritten = nLength; - while (nLength) - { - Size = (WORD)min(nLength, CSRSS_MAX_WRITE_CONSOLE_OUTPUT_ATTRIB / sizeof(WORD)); - Request->Data.WriteConsoleOutputAttribRequest.ConsoleHandle = hConsoleOutput; - Request->Data.WriteConsoleOutputAttribRequest.Length = Size; - memcpy(Request->Data.WriteConsoleOutputAttribRequest.Attribute, lpAttribute, Size * sizeof(WORD)); - - Status = CsrClientCallServer(Request, - NULL, - CsrRequest, - max(sizeof(CSR_API_MESSAGE), - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB) + Size * sizeof(WORD))); - - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request->Status)) - { - RtlFreeHeap(RtlGetProcessHeap(), 0, Request); - BaseSetLastNTError (Status); - return FALSE; - } - nLength -= Size; - lpAttribute += Size; - Request->Data.WriteConsoleOutputAttribRequest.Coord = Request->Data.WriteConsoleOutputAttribRequest.EndCoord; - } - - RtlFreeHeap(RtlGetProcessHeap(), 0, Request); - - return TRUE; + return IntWriteConsoleOutputCode(hConsoleOutput, + CODE_ATTRIBUTE, + lpAttribute, + nLength, + dwWriteCoord, + lpNumberOfAttrsWritten); } Modified: branches/ros-csrss/include/reactos/subsys/win/conmsg.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/include/reactos/subsy…
============================================================================== --- branches/ros-csrss/include/reactos/subsys/win/conmsg.h [iso-8859-1] (original) +++ branches/ros-csrss/include/reactos/subsys/win/conmsg.h [iso-8859-1] Mon Nov 19 23:26:36 2012 @@ -26,7 +26,7 @@ ConsolepReadConsoleOutput, ConsolepWriteConsoleOutput, ConsolepReadConsoleOutputString, - // ConsolepWriteConsoleOutputString, + ConsolepWriteConsoleOutputString, ConsolepFillConsoleOutput, ConsolepGetMode, // ConsolepGetNumberOfFonts, @@ -112,13 +112,6 @@ } CONSRV_API_NUMBER, *PCONSRV_API_NUMBER; -#define CSR_API_MESSAGE_HEADER_SIZE(Type) (FIELD_OFFSET(CSR_API_MESSAGE, Data) + sizeof(Type)) -#define CSRSS_MAX_WRITE_CONSOLE (LPC_MAX_DATA_LENGTH - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE)) -#define CSRSS_MAX_WRITE_CONSOLE_OUTPUT_CHAR (LPC_MAX_DATA_LENGTH - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE_OUTPUT_CHAR)) -#define CSRSS_MAX_WRITE_CONSOLE_OUTPUT_ATTRIB (LPC_MAX_DATA_LENGTH - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB)) -#define CSRSS_MAX_READ_CONSOLE_OUTPUT_CHAR (LPC_MAX_DATA_LENGTH - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_READ_CONSOLE_OUTPUT_CHAR)) -#define CSRSS_MAX_READ_CONSOLE_OUTPUT_ATTRIB (LPC_MAX_DATA_LENGTH - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_READ_CONSOLE_OUTPUT_ATTRIB)) - #define CONSOLE_INPUT_MODE_VALID (0x0f) #define CONSOLE_OUTPUT_MODE_VALID (0x03) @@ -150,12 +143,12 @@ WORD NrCharactersRead; HANDLE EventHandle; - PVOID Buffer; - ULONG BufferSize; - UNICODE_STRING ExeName; DWORD CtrlWakeupMask; DWORD ControlKeyState; + + ULONG BufferSize; + PVOID Buffer; } CSRSS_READ_CONSOLE, *PCSRSS_READ_CONSOLE; typedef struct @@ -184,26 +177,6 @@ HANDLE ConsoleHandle; COORD Position; } CSRSS_SET_CURSOR_POSITION, *PCSRSS_SET_CURSOR_POSITION; - -typedef struct -{ - HANDLE ConsoleHandle; - BOOL Unicode; - WORD Length; - COORD Coord; - COORD EndCoord; - ULONG NrCharactersWritten; - CHAR String[0]; -} CSRSS_WRITE_CONSOLE_OUTPUT_CHAR, *PCSRSS_WRITE_CONSOLE_OUTPUT_CHAR; - -typedef struct -{ - HANDLE ConsoleHandle; - WORD Length; - COORD Coord; - COORD EndCoord; - WORD Attribute[0]; -} CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB, *PCSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB; typedef struct { @@ -304,6 +277,28 @@ typedef struct { HANDLE ConsoleHandle; + USHORT CodeType; + + ULONG BufferSize; + WORD Length; + COORD Coord; + COORD EndCoord; + + ULONG NrCharactersWritten; + + union + { + // PVOID String; + PVOID pCode; + PCHAR AsciiChar; + PWCHAR UnicodeChar; + PWORD Attribute; + } pCode; // Either a pointer to a character or to an attribute. +} CSRSS_WRITE_CONSOLE_OUTPUT_CODE, *PCSRSS_WRITE_CONSOLE_OUTPUT_CODE; + +typedef struct +{ + HANDLE ConsoleHandle; CODE_TYPE CodeType; union @@ -588,8 +583,7 @@ CSRSS_WRITE_CONSOLE WriteConsoleRequest; // SrvWriteConsole / WriteConsole CSRSS_WRITE_CONSOLE_INPUT WriteConsoleInputRequest; CSRSS_WRITE_CONSOLE_OUTPUT WriteConsoleOutputRequest; - CSRSS_WRITE_CONSOLE_OUTPUT_CHAR WriteConsoleOutputCharRequest; - CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB WriteConsoleOutputAttribRequest; + CSRSS_WRITE_CONSOLE_OUTPUT_CODE WriteConsoleOutputCodeRequest; CSRSS_FILL_OUTPUT FillOutputRequest; CSRSS_SET_ATTRIB SetAttribRequest; Modified: branches/ros-csrss/win32ss/user/consrv/conoutput.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/conoutput.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/conoutput.c [iso-8859-1] Mon Nov 19 23:26:36 2012 @@ -469,6 +469,11 @@ DPRINT("SrvReadConsoleOutput\n"); + CharInfo = ReadConsoleOutputRequest->CharInfo; + ReadRegion = ReadConsoleOutputRequest->ReadRegion; + BufferSize = ReadConsoleOutputRequest->BufferSize; + BufferCoord = ReadConsoleOutputRequest->BufferCoord; + if (!CsrValidateMessageBuffer(ApiMessage, (PVOID*)&ReadConsoleOutputRequest->CharInfo, BufferSize.X * BufferSize.Y, @@ -479,11 +484,6 @@ Status = ConioLockScreenBuffer(ProcessData, ReadConsoleOutputRequest->ConsoleHandle, &Buff, GENERIC_READ); if (!NT_SUCCESS(Status)) return Status; - - CharInfo = ReadConsoleOutputRequest->CharInfo; - ReadRegion = ReadConsoleOutputRequest->ReadRegion; - BufferSize = ReadConsoleOutputRequest->BufferSize; - BufferCoord = ReadConsoleOutputRequest->BufferCoord; /* if (!Win32CsrValidateBuffer(ProcessData->Process, CharInfo, @@ -648,6 +648,10 @@ DPRINT("SrvWriteConsoleOutput\n"); + BufferSize = WriteConsoleOutputRequest->BufferSize; + BufferCoord = WriteConsoleOutputRequest->BufferCoord; + CharInfo = WriteConsoleOutputRequest->CharInfo; + if (!CsrValidateMessageBuffer(ApiMessage, (PVOID*)&WriteConsoleOutputRequest->CharInfo, BufferSize.X * BufferSize.Y, @@ -663,10 +667,6 @@ if (!NT_SUCCESS(Status)) return Status; Console = Buff->Header.Console; - - BufferSize = WriteConsoleOutputRequest->BufferSize; - BufferCoord = WriteConsoleOutputRequest->BufferCoord; - CharInfo = WriteConsoleOutputRequest->CharInfo; /* if (!Win32CsrValidateBuffer(ProcessData->Process, CharInfo, @@ -743,8 +743,6 @@ DPRINT("SrvReadConsoleOutputString\n"); - ReadBuffer = ReadConsoleOutputCodeRequest->pCode.pCode; - CodeType = ReadConsoleOutputCodeRequest->CodeType; switch (CodeType) { @@ -764,11 +762,20 @@ return STATUS_INVALID_PARAMETER; } + if (!CsrValidateMessageBuffer(ApiMessage, + (PVOID*)&ReadConsoleOutputCodeRequest->pCode.pCode, + ReadConsoleOutputCodeRequest->NumCodesToRead, + CodeSize)) + { + return STATUS_INVALID_PARAMETER; + } + Status = ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process), ReadConsoleOutputCodeRequest->ConsoleHandle, &Buff, GENERIC_READ); if (!NT_SUCCESS(Status)) return Status; Console = Buff->Header.Console; + ReadBuffer = ReadConsoleOutputCodeRequest->pCode.pCode; Xpos = ReadConsoleOutputCodeRequest->ReadCoord.X; Ypos = (ReadConsoleOutputCodeRequest->ReadCoord.Y + Buff->VirtualY) % Buff->MaxY; @@ -845,169 +852,136 @@ return STATUS_SUCCESS; } -CSR_API(CsrWriteConsoleOutputChar) +CSR_API(SrvWriteConsoleOutputString) { NTSTATUS Status; - PCSRSS_WRITE_CONSOLE_OUTPUT_CHAR WriteConsoleOutputCharRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteConsoleOutputCharRequest; - PCHAR String, tmpString = NULL; - PBYTE Buffer; + PCSRSS_WRITE_CONSOLE_OUTPUT_CODE WriteConsoleOutputCodeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteConsoleOutputCodeRequest; PCSRSS_CONSOLE Console; PCSRSS_SCREEN_BUFFER Buff; - DWORD X, Y, Length, CharSize, Written = 0; + USHORT CodeType; + PBYTE Buffer; // PUCHAR + PCHAR String, tmpString = NULL; + DWORD X, Y, Length; // , Written = 0; + ULONG CodeSize; SMALL_RECT UpdateRect; - DPRINT("CsrWriteConsoleOutputChar\n"); - - CharSize = (WriteConsoleOutputCharRequest->Unicode ? sizeof(WCHAR) : sizeof(CHAR)); - - if (ApiMessage->Header.u1.s1.TotalLength - < CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE_OUTPUT_CHAR) - + (WriteConsoleOutputCharRequest->Length * CharSize)) - { - DPRINT1("Invalid ApiMessage size\n"); + DPRINT("SrvWriteConsoleOutputString\n"); + + CodeType = WriteConsoleOutputCodeRequest->CodeType; + switch (CodeType) + { + case CODE_ASCII: + CodeSize = sizeof(CHAR); + break; + + case CODE_UNICODE: + CodeSize = sizeof(WCHAR); + break; + + case CODE_ATTRIBUTE: + CodeSize = sizeof(WORD); + break; + + default: + return STATUS_INVALID_PARAMETER; + } + + if (!CsrValidateMessageBuffer(ApiMessage, + (PVOID*)&WriteConsoleOutputCodeRequest->pCode.pCode, + WriteConsoleOutputCodeRequest->Length, + CodeSize)) + { return STATUS_INVALID_PARAMETER; } - Status = ConioLockScreenBuffer(CsrGetClientThread()->Process, - WriteConsoleOutputCharRequest->ConsoleHandle, + Status = ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process), + WriteConsoleOutputCodeRequest->ConsoleHandle, &Buff, GENERIC_WRITE); - if (NT_SUCCESS(Status)) - { - Console = Buff->Header.Console; - if(WriteConsoleOutputCharRequest->Unicode) + if (!NT_SUCCESS(Status)) return Status; + + Console = Buff->Header.Console; + + switch (CodeType) + { + case CODE_UNICODE: { Length = WideCharToMultiByte(Console->OutputCodePage, 0, - (PWCHAR)WriteConsoleOutputCharRequest->String, - WriteConsoleOutputCharRequest->Length, + (PWCHAR)WriteConsoleOutputCodeRequest->pCode.UnicodeChar, + WriteConsoleOutputCodeRequest->Length, NULL, 0, NULL, NULL); tmpString = String = RtlAllocateHeap(GetProcessHeap(), 0, Length); if (String) { WideCharToMultiByte(Console->OutputCodePage, 0, - (PWCHAR)WriteConsoleOutputCharRequest->String, - WriteConsoleOutputCharRequest->Length, + (PWCHAR)WriteConsoleOutputCodeRequest->pCode.UnicodeChar, + WriteConsoleOutputCodeRequest->Length, String, Length, NULL, NULL); } else { Status = STATUS_NO_MEMORY; } - } - else - { - String = (PCHAR)WriteConsoleOutputCharRequest->String; - } - - if (String) - { - if (NT_SUCCESS(Status)) - { - X = WriteConsoleOutputCharRequest->Coord.X; - Y = (WriteConsoleOutputCharRequest->Coord.Y + Buff->VirtualY) % Buff->MaxY; - Length = WriteConsoleOutputCharRequest->Length; - Buffer = &Buff->Buffer[2 * (Y * Buff->MaxX + X)]; - while (Length--) + + break; + } + + case CODE_ASCII: + String = (PCHAR)WriteConsoleOutputCodeRequest->pCode.AsciiChar; + break; + + case CODE_ATTRIBUTE: + default: + // *(ReadBuffer++) = Code; + String = (PCHAR)WriteConsoleOutputCodeRequest->pCode.Attribute; + break; + } + + if (String && NT_SUCCESS(Status)) + { + X = WriteConsoleOutputCodeRequest->Coord.X; + Y = (WriteConsoleOutputCodeRequest->Coord.Y + Buff->VirtualY) % Buff->MaxY; + Length = WriteConsoleOutputCodeRequest->Length; + Buffer = &Buff->Buffer[2 * (Y * Buff->MaxX + X) + (CodeType == CODE_ATTRIBUTE ? 1 : 0)]; + + while (Length--) + { + *Buffer = *String++; + // ReadBuffer = (PVOID)((ULONG_PTR)ReadBuffer + CodeSize); + String = (PCHAR)((ULONG_PTR)String + CodeSize); + // Written++; + Buffer += 2; + if (++X == Buff->MaxX) + { + if (++Y == Buff->MaxY) { - *Buffer = *String++; - Written++; - Buffer += 2; - if (++X == Buff->MaxX) - { - if (++Y == Buff->MaxY) - { - Y = 0; - Buffer = Buff->Buffer; - } - X = 0; - } + Y = 0; + Buffer = Buff->Buffer + (CodeType == CODE_ATTRIBUTE ? 1 : 0); } - if (Buff == Console->ActiveBuffer) - { - ConioComputeUpdateRect(Buff, &UpdateRect, &WriteConsoleOutputCharRequest->Coord, - WriteConsoleOutputCharRequest->Length); - ConioDrawRegion(Console, &UpdateRect); - } - - WriteConsoleOutputCharRequest->EndCoord.X = X; - WriteConsoleOutputCharRequest->EndCoord.Y = (Y + Buff->MaxY - Buff->VirtualY) % Buff->MaxY; - - } - if (WriteConsoleOutputCharRequest->Unicode) - { - RtlFreeHeap(GetProcessHeap(), 0, tmpString); - } - } - ConioUnlockScreenBuffer(Buff); - } - WriteConsoleOutputCharRequest->NrCharactersWritten = Written; + X = 0; + } + } + + if (Buff == Console->ActiveBuffer) + { + ConioComputeUpdateRect(Buff, &UpdateRect, &WriteConsoleOutputCodeRequest->Coord, + WriteConsoleOutputCodeRequest->Length); + ConioDrawRegion(Console, &UpdateRect); + } + + WriteConsoleOutputCodeRequest->EndCoord.X = X; + WriteConsoleOutputCodeRequest->EndCoord.Y = (Y + Buff->MaxY - Buff->VirtualY) % Buff->MaxY; + } + + if (tmpString) + { + RtlFreeHeap(GetProcessHeap(), 0, tmpString); + } + + ConioUnlockScreenBuffer(Buff); + + // WriteConsoleOutputCodeRequest->NrCharactersWritten = Written; return Status; -} - -CSR_API(CsrWriteConsoleOutputAttrib) -{ - PCSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB WriteConsoleOutputAttribRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteConsoleOutputAttribRequest; - PCSRSS_CONSOLE Console; - PCSRSS_SCREEN_BUFFER Buff; - PUCHAR Buffer; - PWORD Attribute; - int X, Y, Length; - NTSTATUS Status; - SMALL_RECT UpdateRect; - - DPRINT("CsrWriteConsoleOutputAttrib\n"); - - if (ApiMessage->Header.u1.s1.TotalLength - < CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB) - + WriteConsoleOutputAttribRequest->Length * sizeof(WORD)) - { - DPRINT1("Invalid ApiMessage size\n"); - return STATUS_INVALID_PARAMETER; - } - - Status = ConioLockScreenBuffer(CsrGetClientThread()->Process, - WriteConsoleOutputAttribRequest->ConsoleHandle, - &Buff, - GENERIC_WRITE); - if (! NT_SUCCESS(Status)) - { - return Status; - } - Console = Buff->Header.Console; - - X = WriteConsoleOutputAttribRequest->Coord.X; - Y = (WriteConsoleOutputAttribRequest->Coord.Y + Buff->VirtualY) % Buff->MaxY; - Length = WriteConsoleOutputAttribRequest->Length; - Buffer = &Buff->Buffer[2 * (Y * Buff->MaxX + X) + 1]; - Attribute = WriteConsoleOutputAttribRequest->Attribute; - while (Length--) - { - *Buffer = (UCHAR)(*Attribute++); - Buffer += 2; - if (++X == Buff->MaxX) - { - if (++Y == Buff->MaxY) - { - Y = 0; - Buffer = Buff->Buffer + 1; - } - X = 0; - } - } - - if (Buff == Console->ActiveBuffer) - { - ConioComputeUpdateRect(Buff, &UpdateRect, &WriteConsoleOutputAttribRequest->Coord, - WriteConsoleOutputAttribRequest->Length); - ConioDrawRegion(Console, &UpdateRect); - } - - WriteConsoleOutputAttribRequest->EndCoord.X = X; - WriteConsoleOutputAttribRequest->EndCoord.Y = (Y + Buff->MaxY - Buff->VirtualY) % Buff->MaxY; - - ConioUnlockScreenBuffer(Buff); - - return STATUS_SUCCESS; } CSR_API(SrvFillConsoleOutput) @@ -1016,7 +990,7 @@ PCSRSS_FILL_OUTPUT FillOutputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.FillOutputRequest; PCSRSS_CONSOLE Console; PCSRSS_SCREEN_BUFFER Buff; - DWORD X, Y, Length, Start; // , Written = 0; + DWORD X, Y, Length; // , Written = 0; USHORT CodeType; BYTE Code; PBYTE Buffer; @@ -1034,8 +1008,7 @@ X = FillOutputRequest->Coord.X; Y = (FillOutputRequest->Coord.Y + Buff->VirtualY) % Buff->MaxY; Length = FillOutputRequest->Length; - Start = 2 * (Y * Buff->MaxX + X) + (CodeType == CODE_ATTRIBUTE ? 1 : 0); - Buffer = &Buff->Buffer[Start]; + Buffer = &Buff->Buffer[2 * (Y * Buff->MaxX + X) + (CodeType == CODE_ATTRIBUTE ? 1 : 0)]; switch (CodeType) { @@ -1296,7 +1269,7 @@ PCSRSS_SCREEN_BUFFER_INFO ScreenBufferInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ScreenBufferInfoRequest; PCSRSS_CONSOLE Console; PCSRSS_SCREEN_BUFFER Buff; - PCONSOLE_SCREEN_BUFFER_INFO pInfo; + PCONSOLE_SCREEN_BUFFER_INFO pInfo = &ScreenBufferInfoRequest->Info; DPRINT("SrvGetConsoleScreenBufferInfo\n"); @@ -1304,7 +1277,7 @@ if (!NT_SUCCESS(Status)) return Status; Console = Buff->Header.Console; - pInfo = &ScreenBufferInfoRequest->Info; + pInfo->dwSize.X = Buff->MaxX; pInfo->dwSize.Y = Buff->MaxY; pInfo->dwCursorPosition.X = Buff->CurrentX; @@ -1316,6 +1289,7 @@ pInfo->srWindow.Bottom = Buff->ShowY + Console->Size.Y - 1; pInfo->dwMaximumWindowSize.X = Buff->MaxX; pInfo->dwMaximumWindowSize.Y = Buff->MaxY; + ConioUnlockScreenBuffer(Buff); return STATUS_SUCCESS;
12 years, 1 month
1
0
0
0
[hbelusca] 57739: Forgot this part.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Mon Nov 19 21:52:59 2012 New Revision: 57739 URL:
http://svn.reactos.org/svn/reactos?rev=57739&view=rev
Log: Forgot this part. Modified: branches/ros-csrss/include/reactos/subsys/win/conmsg.h Modified: branches/ros-csrss/include/reactos/subsys/win/conmsg.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/include/reactos/subsy…
============================================================================== --- branches/ros-csrss/include/reactos/subsys/win/conmsg.h [iso-8859-1] (original) +++ branches/ros-csrss/include/reactos/subsys/win/conmsg.h [iso-8859-1] Mon Nov 19 21:52:59 2012 @@ -136,8 +136,10 @@ BOOL Unicode; ULONG NrCharactersToWrite; ULONG NrCharactersWritten; - HANDLE UnpauseEvent; - BYTE Buffer[0]; + // HANDLE UnpauseEvent; + + ULONG BufferSize; + PVOID Buffer; } CSRSS_WRITE_CONSOLE, *PCSRSS_WRITE_CONSOLE; typedef struct @@ -583,7 +585,7 @@ CSRSS_READ_CONSOLE_OUTPUT_CODE ReadConsoleOutputCodeRequest; // SrvReadConsoleOutputString / ReadConsoleOutputAttribute & ReadConsoleOutputCharacter /* Write */ - CSRSS_WRITE_CONSOLE WriteConsoleRequest; + CSRSS_WRITE_CONSOLE WriteConsoleRequest; // SrvWriteConsole / WriteConsole CSRSS_WRITE_CONSOLE_INPUT WriteConsoleInputRequest; CSRSS_WRITE_CONSOLE_OUTPUT WriteConsoleOutputRequest; CSRSS_WRITE_CONSOLE_OUTPUT_CHAR WriteConsoleOutputCharRequest;
12 years, 1 month
1
0
0
0
[hbelusca] 57738: [KERNEL32/CONSRV] - Modify the helper function IntWriteConsole to make it use of capture buffers for passing things to write. - Now, the loop disappears. - I moved the pause-event...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Mon Nov 19 21:48:22 2012 New Revision: 57738 URL:
http://svn.reactos.org/svn/reactos?rev=57738&view=rev
Log: [KERNEL32/CONSRV] - Modify the helper function IntWriteConsole to make it use of capture buffers for passing things to write. - Now, the loop disappears. - I moved the pause-event wait (introduced in revision r47359) inside consrv, and (concerning the server-api-part SrvWriteConsole), especially in the ConioWriteConsole function, to be sure that all functions calling ConioWriteConsole become sensible to pause event. This REALLY NEEDS testing (and of course the code needs cleaning of the introduced comments, when I'm sure it works). Modified: branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c branches/ros-csrss/win32ss/user/consrv/conoutput.c Modified: branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/cl…
============================================================================== --- branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c [iso-8859-1] (original) +++ branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c [iso-8859-1] Mon Nov 19 21:48:22 2012 @@ -428,68 +428,77 @@ LPVOID lpReserved, BOOL bUnicode) { - PCSR_API_MESSAGE Request; - ULONG CsrRequest; NTSTATUS Status; - USHORT nChars; - ULONG SizeBytes, CharSize; - DWORD Written = 0; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_WRITE_CONSOLE WriteConsoleRequest = &ApiMessage.Data.WriteConsoleRequest; + PCSR_CAPTURE_BUFFER CaptureBuffer; + // USHORT nChars; + ULONG /* SizeBytes, */ CharSize; + // DWORD Written = 0; CharSize = (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); - Request = RtlAllocateHeap(RtlGetProcessHeap(), - 0, - max(sizeof(CSR_API_MESSAGE), - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE) + min(nNumberOfCharsToWrite, - CSRSS_MAX_WRITE_CONSOLE / CharSize) * CharSize)); - if (Request == NULL) - { + WriteConsoleRequest->BufferSize = nNumberOfCharsToWrite * CharSize; + + /* Allocate a Capture Buffer */ + CaptureBuffer = CsrAllocateCaptureBuffer(1, WriteConsoleRequest->BufferSize); + if (CaptureBuffer == NULL) + { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } - CsrRequest = CSR_CREATE_API_NUMBER(CSR_CONSOLE, WRITE_CONSOLE); - - while (nNumberOfCharsToWrite > 0) - { - Request->Data.WriteConsoleRequest.ConsoleHandle = hConsoleOutput; - Request->Data.WriteConsoleRequest.Unicode = bUnicode; - - nChars = (USHORT)min(nNumberOfCharsToWrite, CSRSS_MAX_WRITE_CONSOLE / CharSize); - Request->Data.WriteConsoleRequest.NrCharactersToWrite = nChars; - - SizeBytes = nChars * CharSize; - - memcpy(Request->Data.WriteConsoleRequest.Buffer, lpBuffer, SizeBytes); - - Status = CsrClientCallServer(Request, - NULL, - CsrRequest, - max(sizeof(CSR_API_MESSAGE), - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE) + SizeBytes)); + /* Capture the buffer to write */ + CsrCaptureMessageBuffer(CaptureBuffer, + (PVOID)lpBuffer, + WriteConsoleRequest->BufferSize, + (PVOID*)&WriteConsoleRequest->Buffer); + + /* Start writing */ + WriteConsoleRequest->NrCharactersToWrite = nNumberOfCharsToWrite; + WriteConsoleRequest->ConsoleHandle = hConsoleOutput; + WriteConsoleRequest->Unicode = bUnicode; + + // while (nNumberOfCharsToWrite > 0) + { + //// nChars = (USHORT)min(nNumberOfCharsToWrite, CSRSS_MAX_WRITE_CONSOLE / CharSize); + // nChars = nNumberOfCharsToWrite; + // WriteConsoleRequest->NrCharactersToWrite = nChars; + + // SizeBytes = nChars * CharSize; + + // memcpy(WriteConsoleRequest->Buffer, lpBuffer, SizeBytes); + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + CaptureBuffer, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepWriteConsole), + sizeof(CSRSS_WRITE_CONSOLE)); +/** FIXME: Added in 47359 for pausing if (Status == STATUS_PENDING) { - WaitForSingleObject(Request->Data.WriteConsoleRequest.UnpauseEvent, INFINITE); - CloseHandle(Request->Data.WriteConsoleRequest.UnpauseEvent); + WaitForSingleObject(WriteConsoleRequest->UnpauseEvent, INFINITE); + CloseHandle(WriteConsoleRequest->UnpauseEvent); continue; } - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request->Status)) +**/ + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) { - RtlFreeHeap(RtlGetProcessHeap(), 0, Request); + CsrFreeCaptureBuffer(CaptureBuffer); BaseSetLastNTError(Status); return FALSE; } - nNumberOfCharsToWrite -= nChars; - lpBuffer = (PVOID)((ULONG_PTR)lpBuffer + (ULONG_PTR)SizeBytes); - Written += Request->Data.WriteConsoleRequest.NrCharactersWritten; + // nNumberOfCharsToWrite -= nChars; + // lpBuffer = (PVOID)((ULONG_PTR)lpBuffer + (ULONG_PTR)SizeBytes); + // Written += WriteConsoleRequest->NrCharactersWritten; } if (lpNumberOfCharsWritten != NULL) - { - *lpNumberOfCharsWritten = Written; - } - RtlFreeHeap(RtlGetProcessHeap(), 0, Request); + // *lpNumberOfCharsWritten = Written; + *lpNumberOfCharsWritten = WriteConsoleRequest->NrCharactersWritten; + + CsrFreeCaptureBuffer(CaptureBuffer); return TRUE; } Modified: branches/ros-csrss/win32ss/user/consrv/conoutput.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/conoutput.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/conoutput.c [iso-8859-1] Mon Nov 19 21:48:22 2012 @@ -131,6 +131,22 @@ for (i = 0; i < Length; i++) { + if (Console->UnpauseEvent) + { +/** FIXME: Added in 47359 for pausing + Status = NtDuplicateObject(NtCurrentProcess(), + Console->UnpauseEvent, + Process->ProcessHandle, + &WriteConsoleRequest->UnpauseEvent, + SYNCHRONIZE, 0, 0); + ConioUnlockScreenBuffer(Buff); + return (NT_SUCCESS(Status) ? STATUS_PENDING : Status); +**/ + + /* Wait on the console unpause event till it becomes signaled */ + WaitForSingleObject(Console->UnpauseEvent, INFINITE); + } + if (Buff->Mode & ENABLE_PROCESSED_OUTPUT) { /* --- LF --- */ @@ -230,7 +246,7 @@ } } - if (! ConioIsRectEmpty(&UpdateRect) && Buff == Console->ActiveBuffer) + if (!ConioIsRectEmpty(&UpdateRect) && Buff == Console->ActiveBuffer) { ConioWriteStream(Console, &UpdateRect, CursorStartX, CursorStartY, ScrolledLines, Buffer, Length); @@ -532,37 +548,39 @@ PCSRSS_WRITE_CONSOLE WriteConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteConsoleRequest; PCHAR Buffer; PCSRSS_SCREEN_BUFFER Buff; - PCSR_PROCESS ProcessData = CsrGetClientThread()->Process; + // PCSR_PROCESS Process = CsrGetClientThread()->Process; PCSRSS_CONSOLE Console; DWORD Written = 0; ULONG Length; - ULONG CharSize = (WriteConsoleRequest->Unicode ? sizeof(WCHAR) : sizeof(CHAR)); + // ULONG CharSize = (WriteConsoleRequest->Unicode ? sizeof(WCHAR) : sizeof(CHAR)); DPRINT("SrvWriteConsole\n"); - if (ApiMessage->Header.u1.s1.TotalLength - < CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE) - + (WriteConsoleRequest->NrCharactersToWrite * CharSize)) - { - DPRINT1("Invalid ApiMessage size\n"); + if (!CsrValidateMessageBuffer(ApiMessage, + (PVOID)&WriteConsoleRequest->Buffer, + WriteConsoleRequest->BufferSize, + sizeof(BYTE))) + { return STATUS_INVALID_PARAMETER; } - Status = ConioLockScreenBuffer(ProcessData, WriteConsoleRequest->ConsoleHandle, &Buff, GENERIC_WRITE); - if (! NT_SUCCESS(Status)) - { - return Status; - } + Status = ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process), WriteConsoleRequest->ConsoleHandle, &Buff, GENERIC_WRITE); + if (!NT_SUCCESS(Status)) return Status; + Console = Buff->Header.Console; +/** FIXME: Added in 47359 for pausing if (Console->UnpauseEvent) { - Status = NtDuplicateObject(NtCurrentProcess(), Console->UnpauseEvent, - ProcessData->ProcessHandle, &WriteConsoleRequest->UnpauseEvent, + Status = NtDuplicateObject(NtCurrentProcess(), + Console->UnpauseEvent, + Process->ProcessHandle, + &WriteConsoleRequest->UnpauseEvent, SYNCHRONIZE, 0, 0); ConioUnlockScreenBuffer(Buff); - return NT_SUCCESS(Status) ? STATUS_PENDING : Status; - } + return (NT_SUCCESS(Status) ? STATUS_PENDING : Status); + } +**/ if(WriteConsoleRequest->Unicode) { @@ -604,6 +622,7 @@ RtlFreeHeap(GetProcessHeap(), 0, Buffer); } } + ConioUnlockScreenBuffer(Buff); WriteConsoleRequest->NrCharactersWritten = Written;
12 years, 1 month
1
0
0
0
[ekohl] 57737: [LSASRV] - Move LsapCreatePolicySd into a separate file. - Create and set a security descriptor to newly created accounts.
by ekohl@svn.reactos.org
Author: ekohl Date: Mon Nov 19 21:33:07 2012 New Revision: 57737 URL:
http://svn.reactos.org/svn/reactos?rev=57737&view=rev
Log: [LSASRV] - Move LsapCreatePolicySd into a separate file. - Create and set a security descriptor to newly created accounts. Added: trunk/reactos/dll/win32/lsasrv/security.c (with props) Modified: trunk/reactos/dll/win32/lsasrv/CMakeLists.txt trunk/reactos/dll/win32/lsasrv/database.c trunk/reactos/dll/win32/lsasrv/lsarpc.c trunk/reactos/dll/win32/lsasrv/lsasrv.h Modified: trunk/reactos/dll/win32/lsasrv/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/CMakeList…
============================================================================== --- trunk/reactos/dll/win32/lsasrv/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/dll/win32/lsasrv/CMakeLists.txt [iso-8859-1] Mon Nov 19 21:33:07 2012 @@ -18,6 +18,7 @@ lsasrv.c policy.c privileges.c + security.c lsasrv.rc ${CMAKE_CURRENT_BINARY_DIR}/lsasrv_stubs.c ${CMAKE_CURRENT_BINARY_DIR}/lsasrv.def Modified: trunk/reactos/dll/win32/lsasrv/database.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/database.…
============================================================================== --- trunk/reactos/dll/win32/lsasrv/database.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/lsasrv/database.c [iso-8859-1] Mon Nov 19 21:33:07 2012 @@ -230,260 +230,6 @@ SECURITY_NULL_RID, SECURITY_NULL_RID, Sid); -} - - -static NTSTATUS -LsapCreatePolicySd(PSECURITY_DESCRIPTOR *PolicySd, - PULONG PolicySdSize) -{ - SECURITY_DESCRIPTOR AbsoluteSd; - PSECURITY_DESCRIPTOR RelativeSd = NULL; - ULONG RelativeSdSize = 0; - PSID AnonymousSid = NULL; - PSID AdministratorsSid = NULL; - PSID EveryoneSid = NULL; - PSID LocalServiceSid = NULL; - PSID NetworkServiceSid = NULL; - PSID LocalSystemSid = NULL; - PACL Dacl = NULL; - ULONG DaclSize; - NTSTATUS Status; - - if (PolicySd == NULL || PolicySdSize == NULL) - return STATUS_INVALID_PARAMETER; - - *PolicySd = NULL; - *PolicySdSize = 0; - - /* Initialize the SD */ - Status = RtlCreateSecurityDescriptor(&AbsoluteSd, - SECURITY_DESCRIPTOR_REVISION); - if (!NT_SUCCESS(Status)) - return Status; - - Status = RtlAllocateAndInitializeSid(&NtAuthority, - 1, - SECURITY_ANONYMOUS_LOGON_RID, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - &AnonymousSid); - if (!NT_SUCCESS(Status)) - goto done; - - Status = RtlAllocateAndInitializeSid(&NtAuthority, - 2, - SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_ADMINS, - 0, - 0, - 0, - 0, - 0, - 0, - &AdministratorsSid); - if (!NT_SUCCESS(Status)) - goto done; - - Status = RtlAllocateAndInitializeSid(&WorldSidAuthority, - 1, - SECURITY_WORLD_RID, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - &EveryoneSid); - if (!NT_SUCCESS(Status)) - goto done; - - Status = RtlAllocateAndInitializeSid(&NtAuthority, - 1, - SECURITY_LOCAL_SERVICE_RID, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - &LocalServiceSid); - if (!NT_SUCCESS(Status)) - goto done; - - Status = RtlAllocateAndInitializeSid(&NtAuthority, - 1, - SECURITY_NETWORK_SERVICE_RID, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - &NetworkServiceSid); - if (!NT_SUCCESS(Status)) - goto done; - - Status = RtlAllocateAndInitializeSid(&NtAuthority, - 1, - SECURITY_LOCAL_SYSTEM_RID, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - &LocalSystemSid); - if (!NT_SUCCESS(Status)) - goto done; - - /* Allocate and initialize the DACL */ - DaclSize = sizeof(ACL) + - sizeof(ACCESS_DENIED_ACE) - sizeof(ULONG) + RtlLengthSid(AnonymousSid) + - sizeof(ACCESS_ALLOWED_ACE) - sizeof(ULONG) + RtlLengthSid(AdministratorsSid) + - sizeof(ACCESS_ALLOWED_ACE) - sizeof(ULONG) + RtlLengthSid(EveryoneSid) + - sizeof(ACCESS_ALLOWED_ACE) - sizeof(ULONG) + RtlLengthSid(AnonymousSid) + - sizeof(ACCESS_ALLOWED_ACE) - sizeof(ULONG) + RtlLengthSid(LocalServiceSid) + - sizeof(ACCESS_ALLOWED_ACE) - sizeof(ULONG) + RtlLengthSid(NetworkServiceSid); - - Dacl = RtlAllocateHeap(RtlGetProcessHeap(), - HEAP_ZERO_MEMORY, - DaclSize); - if (Dacl == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - Status = RtlCreateAcl(Dacl, - DaclSize, - ACL_REVISION); - if (!NT_SUCCESS(Status)) - goto done; - - Status = RtlAddAccessDeniedAce(Dacl, - ACL_REVISION, - POLICY_LOOKUP_NAMES, - AnonymousSid); - if (!NT_SUCCESS(Status)) - goto done; - - Status = RtlAddAccessAllowedAce(Dacl, - ACL_REVISION, - POLICY_ALL_ACCESS | POLICY_NOTIFICATION, - AdministratorsSid); - if (!NT_SUCCESS(Status)) - goto done; - - Status = RtlAddAccessAllowedAce(Dacl, - ACL_REVISION, - POLICY_EXECUTE, - EveryoneSid); - if (!NT_SUCCESS(Status)) - goto done; - - Status = RtlAddAccessAllowedAce(Dacl, - ACL_REVISION, - POLICY_LOOKUP_NAMES | POLICY_VIEW_LOCAL_INFORMATION, - AnonymousSid); - if (!NT_SUCCESS(Status)) - goto done; - - Status = RtlAddAccessAllowedAce(Dacl, - ACL_REVISION, - POLICY_NOTIFICATION, - LocalServiceSid); - if (!NT_SUCCESS(Status)) - goto done; - - Status = RtlAddAccessAllowedAce(Dacl, - ACL_REVISION, - POLICY_NOTIFICATION, - NetworkServiceSid); - if (!NT_SUCCESS(Status)) - goto done; - - Status = RtlSetDaclSecurityDescriptor(&AbsoluteSd, - TRUE, - Dacl, - FALSE); - if (!NT_SUCCESS(Status)) - goto done; - - Status = RtlSetGroupSecurityDescriptor(&AbsoluteSd, - LocalSystemSid, - FALSE); - if (!NT_SUCCESS(Status)) - goto done; - - Status = RtlSetOwnerSecurityDescriptor(&AbsoluteSd, - AdministratorsSid, - FALSE); - if (!NT_SUCCESS(Status)) - goto done; - - Status = RtlAbsoluteToSelfRelativeSD(&AbsoluteSd, - RelativeSd, - &RelativeSdSize); - if (Status != STATUS_BUFFER_TOO_SMALL) - goto done; - - RelativeSd = RtlAllocateHeap(RtlGetProcessHeap(), - HEAP_ZERO_MEMORY, - RelativeSdSize); - if (RelativeSd == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - Status = RtlAbsoluteToSelfRelativeSD(&AbsoluteSd, - RelativeSd, - &RelativeSdSize); - if (!NT_SUCCESS(Status)) - goto done; - - *PolicySd = RelativeSd; - *PolicySdSize = RelativeSdSize; - -done: - if (Dacl != NULL) - RtlFreeHeap(RtlGetProcessHeap(), 0, Dacl); - - if (AnonymousSid != NULL) - RtlFreeHeap(RtlGetProcessHeap(), 0, AnonymousSid); - - if (AdministratorsSid != NULL) - RtlFreeHeap(RtlGetProcessHeap(), 0, AdministratorsSid); - - if (EveryoneSid != NULL) - RtlFreeHeap(RtlGetProcessHeap(), 0, EveryoneSid); - - if (LocalServiceSid != NULL) - RtlFreeHeap(RtlGetProcessHeap(), 0, LocalServiceSid); - - if (NetworkServiceSid != NULL) - RtlFreeHeap(RtlGetProcessHeap(), 0, NetworkServiceSid); - - if (LocalSystemSid != NULL) - RtlFreeHeap(RtlGetProcessHeap(), 0, LocalSystemSid); - - if (!NT_SUCCESS(Status)) - { - if (RelativeSd != NULL) - RtlFreeHeap(RtlGetProcessHeap(), 0, RelativeSd); - } - - return Status; } Modified: trunk/reactos/dll/win32/lsasrv/lsarpc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsarpc.c?…
============================================================================== --- trunk/reactos/dll/win32/lsasrv/lsarpc.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/lsasrv/lsarpc.c [iso-8859-1] Mon Nov 19 21:33:07 2012 @@ -513,6 +513,8 @@ PLSA_DB_OBJECT PolicyObject; PLSA_DB_OBJECT AccountObject = NULL; LPWSTR SidString = NULL; + PSECURITY_DESCRIPTOR AccountSd = NULL; + ULONG AccountSdSize; NTSTATUS Status = STATUS_SUCCESS; /* Validate the AccountSid */ @@ -537,6 +539,15 @@ ERR("ConvertSidToStringSid failed\n"); Status = STATUS_INVALID_PARAMETER; goto done; + } + + /* Create a security descriptor for the account */ + Status = LsapCreateAccountSd(&AccountSd, + &AccountSdSize); + if (!NT_SUCCESS(Status)) + { + ERR("LsapCreateAccountSd returned 0x%08lx\n", Status); + return Status; } /* Create the Account object */ @@ -557,10 +568,21 @@ L"Sid", (PVOID)AccountSid, GetLengthSid(AccountSid)); + if (!NT_SUCCESS(Status)) + goto done; + + /* Set the SecDesc attribute */ + Status = LsapSetObjectAttribute(AccountObject, + L"SecDesc", + AccountSd, + AccountSdSize); done: if (SidString != NULL) LocalFree(SidString); + + if (AccountSd != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, AccountSd); if (!NT_SUCCESS(Status)) { Modified: trunk/reactos/dll/win32/lsasrv/lsasrv.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsasrv.h?…
============================================================================== --- trunk/reactos/dll/win32/lsasrv/lsasrv.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/lsasrv/lsasrv.h [iso-8859-1] Mon Nov 19 21:33:07 2012 @@ -227,4 +227,13 @@ PLSAPR_PRIVILEGE_ENUM_BUFFER EnumerationBuffer, DWORD PreferedMaximumLength); +/* security.c */ +NTSTATUS +LsapCreatePolicySd(PSECURITY_DESCRIPTOR *PolicySd, + PULONG PolicySdSize); + +NTSTATUS +LsapCreateAccountSd(PSECURITY_DESCRIPTOR *AccountSd, + PULONG AccountSdSize); + /* EOF */ Added: trunk/reactos/dll/win32/lsasrv/security.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/security.…
============================================================================== --- trunk/reactos/dll/win32/lsasrv/security.c (added) +++ trunk/reactos/dll/win32/lsasrv/security.c [iso-8859-1] Mon Nov 19 21:33:07 2012 @@ -1,0 +1,439 @@ +/* + * PROJECT: Local Security Authority Server DLL + * LICENSE: GPL - See COPYING in the top level directory + * FILE: dll/win32/lsasrv/security.c + * PURPOSE: LSA object security functions + * COPYRIGHT: Copyright 2012 Eric Kohl + */ + +/* INCLUDES ****************************************************************/ + +#include "lsasrv.h" + +WINE_DEFAULT_DEBUG_CHANNEL(lsasrv); + + +/* FUNCTIONS ***************************************************************/ + +NTSTATUS +LsapCreatePolicySd(PSECURITY_DESCRIPTOR *PolicySd, + PULONG PolicySdSize) +{ + SECURITY_DESCRIPTOR AbsoluteSd; + PSECURITY_DESCRIPTOR RelativeSd = NULL; + ULONG RelativeSdSize = 0; + PSID AnonymousSid = NULL; + PSID AdministratorsSid = NULL; + PSID EveryoneSid = NULL; + PSID LocalServiceSid = NULL; + PSID NetworkServiceSid = NULL; + PSID LocalSystemSid = NULL; + PACL Dacl = NULL; + ULONG DaclSize; + NTSTATUS Status; + + if (PolicySd == NULL || PolicySdSize == NULL) + return STATUS_INVALID_PARAMETER; + + *PolicySd = NULL; + *PolicySdSize = 0; + + /* Initialize the SD */ + Status = RtlCreateSecurityDescriptor(&AbsoluteSd, + SECURITY_DESCRIPTOR_REVISION); + if (!NT_SUCCESS(Status)) + return Status; + + Status = RtlAllocateAndInitializeSid(&NtAuthority, + 1, + SECURITY_ANONYMOUS_LOGON_RID, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + &AnonymousSid); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlAllocateAndInitializeSid(&NtAuthority, + 2, + SECURITY_BUILTIN_DOMAIN_RID, + DOMAIN_ALIAS_RID_ADMINS, + 0, + 0, + 0, + 0, + 0, + 0, + &AdministratorsSid); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlAllocateAndInitializeSid(&WorldSidAuthority, + 1, + SECURITY_WORLD_RID, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + &EveryoneSid); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlAllocateAndInitializeSid(&NtAuthority, + 1, + SECURITY_LOCAL_SERVICE_RID, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + &LocalServiceSid); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlAllocateAndInitializeSid(&NtAuthority, + 1, + SECURITY_NETWORK_SERVICE_RID, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + &NetworkServiceSid); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlAllocateAndInitializeSid(&NtAuthority, + 1, + SECURITY_LOCAL_SYSTEM_RID, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + &LocalSystemSid); + if (!NT_SUCCESS(Status)) + goto done; + + /* Allocate and initialize the DACL */ + DaclSize = sizeof(ACL) + + sizeof(ACCESS_DENIED_ACE) - sizeof(ULONG) + RtlLengthSid(AnonymousSid) + + sizeof(ACCESS_ALLOWED_ACE) - sizeof(ULONG) + RtlLengthSid(AdministratorsSid) + + sizeof(ACCESS_ALLOWED_ACE) - sizeof(ULONG) + RtlLengthSid(EveryoneSid) + + sizeof(ACCESS_ALLOWED_ACE) - sizeof(ULONG) + RtlLengthSid(AnonymousSid) + + sizeof(ACCESS_ALLOWED_ACE) - sizeof(ULONG) + RtlLengthSid(LocalServiceSid) + + sizeof(ACCESS_ALLOWED_ACE) - sizeof(ULONG) + RtlLengthSid(NetworkServiceSid); + + Dacl = RtlAllocateHeap(RtlGetProcessHeap(), + HEAP_ZERO_MEMORY, + DaclSize); + if (Dacl == NULL) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + goto done; + } + + Status = RtlCreateAcl(Dacl, + DaclSize, + ACL_REVISION); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlAddAccessDeniedAce(Dacl, + ACL_REVISION, + POLICY_LOOKUP_NAMES, + AnonymousSid); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlAddAccessAllowedAce(Dacl, + ACL_REVISION, + POLICY_ALL_ACCESS | POLICY_NOTIFICATION, + AdministratorsSid); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlAddAccessAllowedAce(Dacl, + ACL_REVISION, + POLICY_EXECUTE, + EveryoneSid); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlAddAccessAllowedAce(Dacl, + ACL_REVISION, + POLICY_LOOKUP_NAMES | POLICY_VIEW_LOCAL_INFORMATION, + AnonymousSid); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlAddAccessAllowedAce(Dacl, + ACL_REVISION, + POLICY_NOTIFICATION, + LocalServiceSid); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlAddAccessAllowedAce(Dacl, + ACL_REVISION, + POLICY_NOTIFICATION, + NetworkServiceSid); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlSetDaclSecurityDescriptor(&AbsoluteSd, + TRUE, + Dacl, + FALSE); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlSetGroupSecurityDescriptor(&AbsoluteSd, + LocalSystemSid, + FALSE); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlSetOwnerSecurityDescriptor(&AbsoluteSd, + AdministratorsSid, + FALSE); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlAbsoluteToSelfRelativeSD(&AbsoluteSd, + RelativeSd, + &RelativeSdSize); + if (Status != STATUS_BUFFER_TOO_SMALL) + goto done; + + RelativeSd = RtlAllocateHeap(RtlGetProcessHeap(), + HEAP_ZERO_MEMORY, + RelativeSdSize); + if (RelativeSd == NULL) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + goto done; + } + + Status = RtlAbsoluteToSelfRelativeSD(&AbsoluteSd, + RelativeSd, + &RelativeSdSize); + if (!NT_SUCCESS(Status)) + goto done; + + *PolicySd = RelativeSd; + *PolicySdSize = RelativeSdSize; + +done: + if (Dacl != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, Dacl); + + if (AnonymousSid != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, AnonymousSid); + + if (AdministratorsSid != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, AdministratorsSid); + + if (EveryoneSid != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, EveryoneSid); + + if (LocalServiceSid != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, LocalServiceSid); + + if (NetworkServiceSid != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, NetworkServiceSid); + + if (LocalSystemSid != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, LocalSystemSid); + + if (!NT_SUCCESS(Status)) + { + if (RelativeSd != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, RelativeSd); + } + + return Status; +} + + +NTSTATUS +LsapCreateAccountSd(PSECURITY_DESCRIPTOR *AccountSd, + PULONG AccountSdSize) +{ + SECURITY_DESCRIPTOR AbsoluteSd; + PSECURITY_DESCRIPTOR RelativeSd = NULL; + ULONG RelativeSdSize = 0; + PSID AdministratorsSid = NULL; + PSID EveryoneSid = NULL; + PSID LocalSystemSid = NULL; + PACL Dacl = NULL; + ULONG DaclSize; + NTSTATUS Status; + + if (AccountSd == NULL || AccountSdSize == NULL) + return STATUS_INVALID_PARAMETER; + + *AccountSd = NULL; + *AccountSdSize = 0; + + /* Initialize the SD */ + Status = RtlCreateSecurityDescriptor(&AbsoluteSd, + SECURITY_DESCRIPTOR_REVISION); + if (!NT_SUCCESS(Status)) + return Status; + + Status = RtlAllocateAndInitializeSid(&NtAuthority, + 2, + SECURITY_BUILTIN_DOMAIN_RID, + DOMAIN_ALIAS_RID_ADMINS, + 0, + 0, + 0, + 0, + 0, + 0, + &AdministratorsSid); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlAllocateAndInitializeSid(&WorldSidAuthority, + 1, + SECURITY_WORLD_RID, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + &EveryoneSid); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlAllocateAndInitializeSid(&NtAuthority, + 1, + SECURITY_LOCAL_SYSTEM_RID, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + &LocalSystemSid); + if (!NT_SUCCESS(Status)) + goto done; + + /* Allocate and initialize the DACL */ + DaclSize = sizeof(ACL) + + sizeof(ACCESS_ALLOWED_ACE) - sizeof(ULONG) + RtlLengthSid(AdministratorsSid) + + sizeof(ACCESS_ALLOWED_ACE) - sizeof(ULONG) + RtlLengthSid(EveryoneSid); + + Dacl = RtlAllocateHeap(RtlGetProcessHeap(), + HEAP_ZERO_MEMORY, + DaclSize); + if (Dacl == NULL) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + goto done; + } + + Status = RtlCreateAcl(Dacl, + DaclSize, + ACL_REVISION); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlAddAccessAllowedAce(Dacl, + ACL_REVISION, + ACCOUNT_ALL_ACCESS, + AdministratorsSid); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlAddAccessAllowedAce(Dacl, + ACL_REVISION, + ACCOUNT_EXECUTE, + EveryoneSid); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlSetDaclSecurityDescriptor(&AbsoluteSd, + TRUE, + Dacl, + FALSE); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlSetGroupSecurityDescriptor(&AbsoluteSd, + LocalSystemSid, + FALSE); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlSetOwnerSecurityDescriptor(&AbsoluteSd, + AdministratorsSid, + FALSE); + if (!NT_SUCCESS(Status)) + goto done; + + Status = RtlAbsoluteToSelfRelativeSD(&AbsoluteSd, + RelativeSd, + &RelativeSdSize); + if (Status != STATUS_BUFFER_TOO_SMALL) + goto done; + + RelativeSd = RtlAllocateHeap(RtlGetProcessHeap(), + HEAP_ZERO_MEMORY, + RelativeSdSize); + if (RelativeSd == NULL) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + goto done; + } + + Status = RtlAbsoluteToSelfRelativeSD(&AbsoluteSd, + RelativeSd, + &RelativeSdSize); + if (!NT_SUCCESS(Status)) + goto done; + + *AccountSd = RelativeSd; + *AccountSdSize = RelativeSdSize; + +done: + if (Dacl != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, Dacl); + + if (AdministratorsSid != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, AdministratorsSid); + + if (EveryoneSid != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, EveryoneSid); + + if (LocalSystemSid != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, LocalSystemSid); + + if (!NT_SUCCESS(Status)) + { + if (RelativeSd != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, RelativeSd); + } + + return Status; +} + +/* EOF */ Propchange: trunk/reactos/dll/win32/lsasrv/security.c ------------------------------------------------------------------------------ svn:eol-style = native Propchange: trunk/reactos/dll/win32/lsasrv/security.c ------------------------------------------------------------------------------ svn:keywords = author date id revision
12 years, 1 month
1
0
0
0
[ekohl] 57736: [INCLUDE] Add generic rights for account and secret objects.
by ekohl@svn.reactos.org
Author: ekohl Date: Mon Nov 19 17:28:36 2012 New Revision: 57736 URL:
http://svn.reactos.org/svn/reactos?rev=57736&view=rev
Log: [INCLUDE] Add generic rights for account and secret objects. Modified: trunk/reactos/include/psdk/ntlsa.h Modified: trunk/reactos/include/psdk/ntlsa.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/ntlsa.h?rev=5…
============================================================================== --- trunk/reactos/include/psdk/ntlsa.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/ntlsa.h [iso-8859-1] Mon Nov 19 17:28:36 2012 @@ -30,8 +30,19 @@ #define ACCOUNT_ADJUST_QUOTAS 4 #define ACCOUNT_ADJUST_SYSTEM_ACCESS 8 +#define ACCOUNT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 15) +#define ACCOUNT_READ (STANDARD_RIGHTS_READ | 1) +#define ACCOUNT_WRITE (STANDARD_RIGHTS_WRITE | 14) +#define ACCOUNT_EXECUTE (STANDARD_RIGHTS_EXECUTE) + #define SECRET_SET_VALUE 1 #define SECRET_QUERY_VALUE 2 + +#define SECRET_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 3) +#define SECRET_READ (STANDARD_RIGHTS_READ | 2) +#define SECRET_WRITE (STANDARD_RIGHTS_WRITE | 1) +#define SECRET_EXECUTE (STANDARD_RIGHTS_EXECUTE) + /* System Access Flags */ #define SECURITY_ACCESS_INTERACTIVE_LOGON 0x00000001
12 years, 1 month
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
...
13
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
Results per page:
10
25
50
100
200