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
2025
January
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
February 2012
----- 2025 -----
January 2025
----- 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
22 participants
577 discussions
Start a n
N
ew thread
[dgorbachev] 55627: Add include paths
by dgorbachev@svn.reactos.org
Author: dgorbachev Date: Thu Feb 16 07:28:53 2012 New Revision: 55627 URL:
http://svn.reactos.org/svn/reactos?rev=55627&view=rev
Log: Add include paths Modified: trunk/reactos/dll/win32/shell32/shell32.rbuild trunk/reactos/drivers/network/tdi/tdi.rbuild trunk/reactos/lib/drivers/sound/mmebuddy/mmebuddy.rbuild Modified: trunk/reactos/dll/win32/shell32/shell32.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shell32.…
============================================================================== --- trunk/reactos/dll/win32/shell32/shell32.rbuild [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/shell32.rbuild [iso-8859-1] Thu Feb 16 07:28:53 2012 @@ -2,6 +2,7 @@ <module name="shell32" type="win32dll" baseaddress="${BASEADDRESS_SHELL32}" installbase="system32" installname="shell32.dll" allowwarnings="true" crt="msvcrt"> <autoregister infsection="OleControlDlls" type="Both" /> <importlibrary definition="shell32.spec" /> + <include base="shell32">.</include> <include base="recyclebin">.</include> <include base="ReactOS">include/reactos/wine</include> <include base="atlnew">.</include> Modified: trunk/reactos/drivers/network/tdi/tdi.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tdi/tdi.rb…
============================================================================== --- trunk/reactos/drivers/network/tdi/tdi.rbuild [iso-8859-1] (original) +++ trunk/reactos/drivers/network/tdi/tdi.rbuild [iso-8859-1] Thu Feb 16 07:28:53 2012 @@ -2,6 +2,7 @@ <!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd"> <module name="tdi" type="kernelmodedriver" installbase="system32/drivers" installname="tdi.sys"> <importlibrary definition="misc/tdi.spec"></importlibrary> + <include base="tdi">.</include> <library>ntoskrnl</library> <library>hal</library> <define name="_TDI_" /> Modified: trunk/reactos/lib/drivers/sound/mmebuddy/mmebuddy.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmebuddy…
============================================================================== --- trunk/reactos/lib/drivers/sound/mmebuddy/mmebuddy.rbuild [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/sound/mmebuddy/mmebuddy.rbuild [iso-8859-1] Thu Feb 16 07:28:53 2012 @@ -2,6 +2,7 @@ <!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd"> <module name="mmebuddy" type="staticlibrary" allowwarnings="false" unicode="yes"> <include base="ReactOS">include/reactos/libs/sound</include> + <include base="mmebuddy">.</include> <define name="NDEBUG">1</define> <file>capabilities.c</file> <file>devicelist.c</file>
12 years, 10 months
1
0
0
0
[ion] 55626: [CSRSRV]: Port the CsrWait* and CsrSession* APIs from CSRSRV2. Not yet used, so no real functional change. Fixup a few structures where needed. Initalize session support during CSRSRV ...
by ion@svn.reactos.org
Author: ion Date: Thu Feb 16 06:57:27 2012 New Revision: 55626 URL:
http://svn.reactos.org/svn/reactos?rev=55626&view=rev
Log: [CSRSRV]: Port the CsrWait* and CsrSession* APIs from CSRSRV2. Not yet used, so no real functional change. Fixup a few structures where needed. Initalize session support during CSRSRV initialization. We have a pretty good hybrid now, some few more changes here and there and we can perhaps start having the beginnings our own "basesrv.dll", Added: trunk/reactos/subsystems/win32/csrss/csrsrv/session.c - copied, changed from r55585, trunk/reactos/subsystems/csr/csrsrv/session.c trunk/reactos/subsystems/win32/csrss/csrsrv/wait.c - copied unchanged from r55585, trunk/reactos/subsystems/csr/csrsrv/wait.c Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/CMakeLists.txt trunk/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rbuild trunk/reactos/subsystems/win32/csrss/csrsrv/init.c trunk/reactos/subsystems/win32/csrss/csrsrv/procsup.c trunk/reactos/subsystems/win32/csrss/csrsrv/thredsup.c trunk/reactos/subsystems/win32/csrss/include/api.h Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/csrsrv/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/csrsrv/CMakeLists.txt [iso-8859-1] Thu Feb 16 06:57:27 2012 @@ -11,6 +11,8 @@ procsup.c thredsup.c init.c + wait.c + session.c ${CMAKE_CURRENT_BINARY_DIR}/csrsrv.def) add_library(csrsrv SHARED ${SOURCE}) Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c [iso-8859-1] Thu Feb 16 06:57:27 2012 @@ -986,6 +986,70 @@ RtlExitUserThread(STATUS_SUCCESS); } +/*++ + * @name CsrReleaseCapturedArguments + * @implemented NT5.1 + * + * The CsrReleaseCapturedArguments routine releases a Capture Buffer + * that was previously captured with CsrCaptureArguments. + * + * @param ApiMessage + * Pointer to the CSR API Message containing the Capture Buffer + * that needs to be released. + * + * @return None. + * + * @remarks None. + * + *--*/ +VOID +NTAPI +CsrReleaseCapturedArguments(IN PCSR_API_MESSAGE ApiMessage) +{ + PCSR_CAPTURE_BUFFER RemoteCaptureBuffer, LocalCaptureBuffer; + SIZE_T BufferDistance; + ULONG PointerCount; + ULONG_PTR **PointerOffsets, *CurrentPointer; + + /* Get the capture buffers */ + RemoteCaptureBuffer = ApiMessage->CsrCaptureData; + LocalCaptureBuffer = RemoteCaptureBuffer->PreviousCaptureBuffer; + + /* Free the previous one */ + RemoteCaptureBuffer->PreviousCaptureBuffer = NULL; + + /* Find out the difference between the two buffers */ + BufferDistance = (ULONG_PTR)LocalCaptureBuffer - (ULONG_PTR)RemoteCaptureBuffer; + + /* Save the pointer count and offset pointer */ + PointerCount = RemoteCaptureBuffer->PointerCount; + PointerOffsets = (ULONG_PTR**)(RemoteCaptureBuffer + 1); + + /* Start the loop */ + while (PointerCount) + { + /* Get the current pointer */ + CurrentPointer = *PointerOffsets++; + if (CurrentPointer) + { + /* Add it to the CSR Message structure */ + CurrentPointer += (ULONG_PTR)ApiMessage; + + /* Modify the pointer to take into account its new position */ + *CurrentPointer += BufferDistance; + } + + /* Move to the next Pointer */ + PointerCount--; + } + + /* Copy the data back */ + RtlMoveMemory(LocalCaptureBuffer, RemoteCaptureBuffer, RemoteCaptureBuffer->Size); + + /* Free our allocated buffer */ + RtlFreeHeap(CsrHeap, 0, RemoteCaptureBuffer); +} + /* SESSION MANAGER FUNCTIONS**************************************************/ /*++ Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rbuild [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rbuild [iso-8859-1] Thu Feb 16 06:57:27 2012 @@ -18,5 +18,7 @@ <file>procsup.c</file> <file>thredsup.c</file> <file>init.c</file> + <file>wait.c</file> + <file>session.c</file <pch>srv.h</pch> </module> Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/init.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/csrsrv/init.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/csrsrv/init.c [iso-8859-1] Thu Feb 16 06:57:27 2012 @@ -1116,6 +1116,15 @@ __FUNCTION__, Status); return Status; } + + /* Set up Session Support */ + Status = CsrInitializeNtSessionList(); + if (!NT_SUCCESS(Status)) + { + DPRINT1("CSRSRV:%s: CsrInitializeSessions failed (Status=%08lx)\n", + __FUNCTION__, Status); + return Status; + } /* Set up Process Support */ Status = CsrInitializeProcessStructure(); Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/procsup.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/csrsrv/procsup.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/csrsrv/procsup.c [iso-8859-1] Thu Feb 16 06:57:27 2012 @@ -16,7 +16,7 @@ /* GLOBALS ********************************************************************/ -RTL_CRITICAL_SECTION ProcessDataLock, CsrWaitListsLock; +RTL_CRITICAL_SECTION ProcessDataLock; PCSR_PROCESS CsrRootProcess; SECURITY_QUALITY_OF_SERVICE CsrSecurityQos = { Copied: trunk/reactos/subsystems/win32/csrss/csrsrv/session.c (from r55585, trunk/reactos/subsystems/csr/csrsrv/session.c) URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
============================================================================== --- trunk/reactos/subsystems/csr/csrsrv/session.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/csrsrv/session.c [iso-8859-1] Thu Feb 16 06:57:27 2012 @@ -17,25 +17,6 @@ RTL_CRITICAL_SECTION CsrNtSessionLock; LIST_ENTRY CsrNtSessionList; -HANDLE CsrSmApiPort; - -PSB_API_ROUTINE CsrServerSbApiDispatch[5] = -{ - CsrSbCreateSession, - CsrSbTerminateSession, - CsrSbForeignSessionComplete, - CsrSbCreateProcess, - NULL -}; - -PCHAR CsrServerSbApiName[5] = -{ - "SbCreateSession", - "SbTerminateSession", - "SbForeignSessionComplete", - "SbCreateProcess", - "Unknown Csr Sb Api Number" -}; /* PRIVATE FUNCTIONS *********************************************************/ @@ -191,217 +172,4 @@ } } - -/* SESSION MANAGER FUNCTIONS**************************************************/ - -/*++ - * @name CsrSbCreateSession - * - * The CsrSbCreateSession API is called by the Session Manager whenever a new - * session is created. - * - * @param ApiMessage - * Pointer to the Session Manager API Message. - * - * @return TRUE in case of success, FALSE othwerwise. - * - * @remarks The CsrSbCreateSession routine will initialize a new CSR NT - * Session and allocate a new CSR Process for the subsystem process. - * - *--*/ -BOOLEAN -NTAPI -CsrSbCreateSession(IN PSB_API_MSG ApiMessage) -{ - PSB_CREATE_SESSION_MSG CreateSession = &ApiMessage->CreateSession; - HANDLE hProcess, hThread; - PCSR_PROCESS CsrProcess; - NTSTATUS Status; - KERNEL_USER_TIMES KernelTimes; - PCSR_THREAD CsrThread; - PVOID ProcessData; - ULONG i; - - /* Save the Process and Thread Handles */ - hProcess = CreateSession->ProcessInfo.ProcessHandle; - hThread = CreateSession->ProcessInfo.ThreadHandle; - - /* Lock the Processes */ - CsrAcquireProcessLock(); - - /* Allocate a new process */ - CsrProcess = CsrAllocateProcess(); - if (!CsrProcess) - { - /* Fail */ - ApiMessage->ReturnValue = STATUS_NO_MEMORY; - CsrReleaseProcessLock(); - return TRUE; - } - - /* Set the exception port */ - Status = NtSetInformationProcess(hProcess, - ProcessExceptionPort, - &CsrApiPort, - sizeof(HANDLE)); - - /* Check for success */ - if (!NT_SUCCESS(Status)) - { - /* Fail the request */ - CsrDeallocateProcess(CsrProcess); - CsrReleaseProcessLock(); - - /* Strange as it seems, NTSTATUSes are actually returned */ - return (BOOLEAN)STATUS_NO_MEMORY; - } - - /* Get the Create Time */ - Status = NtQueryInformationThread(hThread, - ThreadTimes, - &KernelTimes, - sizeof(KERNEL_USER_TIMES), - NULL); - - /* Check for success */ - if (!NT_SUCCESS(Status)) - { - /* Fail the request */ - CsrDeallocateProcess(CsrProcess); - CsrReleaseProcessLock(); - - /* Strange as it seems, NTSTATUSes are actually returned */ - return (BOOLEAN)Status; - } - - /* Allocate a new Thread */ - CsrThread = CsrAllocateThread(CsrProcess); - if (!CsrThread) - { - /* Fail the request */ - CsrDeallocateProcess(CsrProcess); - ApiMessage->ReturnValue = STATUS_NO_MEMORY; - CsrReleaseProcessLock(); - return TRUE; - } - - /* Setup the Thread Object */ - CsrThread->CreateTime = KernelTimes.CreateTime; - CsrThread->ClientId = CreateSession->ProcessInfo.ClientId; - CsrThread->ThreadHandle = hThread; - ProtectHandle(hThread); - CsrThread->Flags = 0; - - /* Insert it into the Process List */ - CsrInsertThread(CsrProcess, CsrThread); - - /* Setup Process Data */ - CsrProcess->ClientId = CreateSession->ProcessInfo.ClientId; - CsrProcess->ProcessHandle = hProcess; - CsrProcess->NtSession = CsrAllocateNtSession(CreateSession->SessionId); - - /* Set the Process Priority */ - CsrSetBackgroundPriority(CsrProcess); - - /* Get the first data location */ - ProcessData = &CsrProcess->ServerData[CSR_SERVER_DLL_MAX]; - - /* Loop every DLL */ - for (i = 0; i < CSR_SERVER_DLL_MAX; i++) - { - /* Check if the DLL is loaded and has Process Data */ - if (CsrLoadedServerDll[i] && CsrLoadedServerDll[i]->SizeOfProcessData) - { - /* Write the pointer to the data */ - CsrProcess->ServerData[i] = ProcessData; - - /* Move to the next data location */ - ProcessData = (PVOID)((ULONG_PTR)ProcessData + - CsrLoadedServerDll[i]->SizeOfProcessData); - } - else - { - /* Nothing for this Process */ - CsrProcess->ServerData[i] = NULL; - } - } - - /* Insert the Process */ - CsrInsertProcess(NULL, NULL, CsrProcess); - - /* Activate the Thread */ - ApiMessage->ReturnValue = NtResumeThread(hThread, NULL); - - /* Release lock and return */ - CsrReleaseProcessLock(); - return TRUE; -} - -/*++ - * @name CsrSbForeignSessionComplete - * - * The CsrSbForeignSessionComplete API is called by the Session Manager - * whenever a foreign session is completed (ie: terminated). - * - * @param ApiMessage - * Pointer to the Session Manager API Message. - * - * @return TRUE in case of success, FALSE othwerwise. - * - * @remarks The CsrSbForeignSessionComplete API is not yet implemented. - * - *--*/ -BOOLEAN -NTAPI -CsrSbForeignSessionComplete(IN PSB_API_MSG ApiMessage) -{ - /* Deprecated/Unimplemented in NT */ - ApiMessage->ReturnValue = STATUS_NOT_IMPLEMENTED; - return TRUE; -} - -/*++ - * @name CsrSbTerminateSession - * - * The CsrSbTerminateSession API is called by the Session Manager - * whenever a foreign session should be destroyed. - * - * @param ApiMessage - * Pointer to the Session Manager API Message. - * - * @return TRUE in case of success, FALSE othwerwise. - * - * @remarks The CsrSbTerminateSession API is not yet implemented. - * - *--*/ -BOOLEAN -NTAPI -CsrSbTerminateSession(IN PSB_API_MSG ApiMessage) -{ - ApiMessage->ReturnValue = STATUS_NOT_IMPLEMENTED; - return TRUE; -} - -/*++ - * @name CsrSbCreateProcess - * - * The CsrSbCreateProcess API is called by the Session Manager - * whenever a foreign session is created and a new process should be started. - * - * @param ApiMessage - * Pointer to the Session Manager API Message. - * - * @return TRUE in case of success, FALSE othwerwise. - * - * @remarks The CsrSbCreateProcess API is not yet implemented. - * - *--*/ -BOOLEAN -NTAPI -CsrSbCreateProcess(IN PSB_API_MSG ApiMessage) -{ - ApiMessage->ReturnValue = STATUS_NOT_IMPLEMENTED; - return TRUE; -} - /* EOF */ Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/thredsup.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/csrsrv/thredsup.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/csrsrv/thredsup.c [iso-8859-1] Thu Feb 16 06:57:27 2012 @@ -407,4 +407,40 @@ return CsrThread; } +/*++ + * @name CsrDereferenceThread + * @implemented NT4 + * + * The CsrDereferenceThread routine removes a reference from a CSR Thread. + * + * @param CsrThread + * Pointer to the CSR Thread to dereference. + * + * @return None. + * + * @remarks If the reference count has reached zero (ie: the CSR Thread has + * no more active references), it will be deleted. + * + *--*/ +VOID +NTAPI +CsrDereferenceThread(IN PCSR_THREAD CsrThread) +{ + /* Acquire process lock */ + CsrAcquireProcessLock(); + + /* Decrease reference count */ + ASSERT(CsrThread->ReferenceCount > 0); + if (!(--CsrThread->ReferenceCount)) + { + /* Call the generic cleanup code */ + CsrThreadRefcountZero(CsrThread); + } + else + { + /* Just release the lock */ + CsrReleaseProcessLock(); + } +} + /* EOF */ Modified: trunk/reactos/subsystems/win32/csrss/include/api.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/inc…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/include/api.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/include/api.h [iso-8859-1] Thu Feb 16 06:57:27 2012 @@ -21,6 +21,18 @@ #define CsrReleaseProcessLock() UNLOCK #define ProcessStructureListLocked() \ (ProcessDataLock.OwningThread == NtCurrentTeb()->ClientId.UniqueThread) + +#define CsrAcquireWaitLock() \ + RtlEnterCriticalSection(&CsrWaitListsLock); + +#define CsrReleaseWaitLock() \ + RtlLeaveCriticalSection(&CsrWaitListsLock); + +#define CsrAcquireNtSessionLock() \ + RtlEnterCriticalSection(&CsrNtSessionLock); + +#define CsrReleaseNtSessionLock() \ + RtlLeaveCriticalSection(&CsrNtSessionLock); typedef enum _CSR_THREAD_FLAGS { @@ -65,6 +77,13 @@ PCONTROLDISPATCHER CtrlDispatcher; LIST_ENTRY ConsoleLink; } CSRSS_CON_PROCESS_DATA, *PCSRSS_CON_PROCESS_DATA; + +typedef struct _CSR_NT_SESSION +{ + ULONG ReferenceCount; + LIST_ENTRY SessionLink; + ULONG SessionId; +} CSR_NT_SESSION, *PCSR_NT_SESSION; typedef struct _CSR_PROCESS { @@ -102,12 +121,35 @@ LIST_ENTRY HashLinks; CLIENT_ID ClientId; PCSR_PROCESS Process; - //struct _CSR_WAIT_BLOCK *WaitBlock; + struct _CSR_WAIT_BLOCK *WaitBlock; HANDLE ThreadHandle; ULONG Flags; ULONG ReferenceCount; ULONG ImpersonationCount; } CSR_THREAD, *PCSR_THREAD; + +typedef +BOOLEAN +(*CSR_WAIT_FUNCTION)( + IN PLIST_ENTRY WaitList, + IN PCSR_THREAD WaitThread, + IN PCSR_API_MESSAGE WaitApiMessage, + IN PVOID WaitContext, + IN PVOID WaitArgument1, + IN PVOID WaitArgument2, + IN ULONG WaitFlags +); + +typedef struct _CSR_WAIT_BLOCK +{ + ULONG Size; + LIST_ENTRY WaitList; + LIST_ENTRY UserWaitList; + PVOID WaitContext; + PCSR_THREAD WaitThread; + CSR_WAIT_FUNCTION WaitFunction; + CSR_API_MESSAGE WaitApiMessage; +} CSR_WAIT_BLOCK, *PCSR_WAIT_BLOCK; typedef NTSTATUS (WINAPI *CSRSS_API_PROC)(PCSR_PROCESS ProcessData, PCSR_API_MESSAGE Request); @@ -167,6 +209,10 @@ VOID NTAPI +CsrDereferenceThread(IN PCSR_THREAD CsrThread); + +VOID +NTAPI CsrInsertProcess(IN PCSR_PROCESS Parent OPTIONAL, IN PCSR_PROCESS CurrentProcess OPTIONAL, IN PCSR_PROCESS CsrProcess); @@ -179,6 +225,11 @@ VOID WINAPI CsrSbApiRequestThread (PVOID PortHandle); VOID NTAPI ClientConnectionThread(HANDLE ServerPort); +VOID +NTAPI +CsrReleaseCapturedArguments(IN PCSR_API_MESSAGE ApiMessage); + +extern HANDLE CsrSmApiPort; extern HANDLE CsrSbApiPort; extern LIST_ENTRY CsrThreadHashTable[256]; extern PCSR_PROCESS CsrRootProcess; @@ -211,6 +262,10 @@ //hack VOID NTAPI CsrThreadRefcountZero(IN PCSR_THREAD CsrThread); +NTSTATUS +NTAPI +CsrInitializeNtSessionList(VOID); + /* api/user.c */ CSR_API(CsrRegisterServicesProcess);
12 years, 10 months
1
0
0
0
[ion] 55625: [CSRSRV]: Move the newly ported process APIs to procsup.c where they belong more. No functional change.
by ion@svn.reactos.org
Author: ion Date: Thu Feb 16 06:45:25 2012 New Revision: 55625 URL:
http://svn.reactos.org/svn/reactos?rev=55625&view=rev
Log: [CSRSRV]: Move the newly ported process APIs to procsup.c where they belong more. No functional change. Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c trunk/reactos/subsystems/win32/csrss/csrsrv/procsup.c trunk/reactos/subsystems/win32/csrss/csrsrv/thredsup.c trunk/reactos/subsystems/win32/csrss/include/api.h Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c [iso-8859-1] Thu Feb 16 06:45:25 2012 @@ -12,319 +12,13 @@ #define NDEBUG #include <debug.h> - -#define CSR_SERVER_DLL_MAX 4 -#define LOCK RtlEnterCriticalSection(&ProcessDataLock) -#define UNLOCK RtlLeaveCriticalSection(&ProcessDataLock) -#define CsrAcquireProcessLock() LOCK -#define CsrReleaseProcessLock() UNLOCK -#define ProcessStructureListLocked() \ - (ProcessDataLock.OwningThread == NtCurrentTeb()->ClientId.UniqueThread) extern NTSTATUS CallProcessInherit(PCSR_PROCESS, PCSR_PROCESS); extern NTSTATUS CallProcessDeleted(PCSR_PROCESS); /* GLOBALS *******************************************************************/ -RTL_CRITICAL_SECTION ProcessDataLock, CsrWaitListsLock; -extern PCSR_PROCESS CsrRootProcess; -extern LIST_ENTRY CsrThreadHashTable[256]; -extern ULONG CsrTotalPerProcessDataLength; -LONG CsrProcessSequenceCount = 5; - /* FUNCTIONS *****************************************************************/ - -/*++ - * @name CsrAllocateProcess - * @implemented NT4 - * - * The CsrAllocateProcess routine allocates a new CSR Process object. - * - * @return Pointer to the newly allocated CSR Process. - * - * @remarks None. - * - *--*/ -PCSR_PROCESS -NTAPI -CsrAllocateProcess(VOID) -{ - PCSR_PROCESS CsrProcess; - ULONG TotalSize; - - /* Calculate the amount of memory this should take */ - TotalSize = sizeof(CSR_PROCESS) + - (CSR_SERVER_DLL_MAX * sizeof(PVOID)) + - CsrTotalPerProcessDataLength; - - /* Allocate a Process */ - CsrProcess = RtlAllocateHeap(CsrHeap, HEAP_ZERO_MEMORY, TotalSize); - if (!CsrProcess) return NULL; - - /* Handle the Sequence Number and protect against overflow */ - CsrProcess->SequenceNumber = CsrProcessSequenceCount++; - if (CsrProcessSequenceCount < 5) CsrProcessSequenceCount = 5; - - /* Increase the reference count */ - CsrProcess->ReferenceCount++; - - /* Initialize the Thread List */ - InitializeListHead(&CsrProcess->ThreadList); - - /* Return the Process */ - return CsrProcess; -} - -/*++ - * @name CsrLockedReferenceProcess - * - * The CsrLockedReferenceProcess refences a CSR Process while the - * Process Lock is already being held. - * - * @param CsrProcess - * Pointer to the CSR Process to be referenced. - * - * @return None. - * - * @remarks This routine will return with the Process Lock held. - * - *--*/ -VOID -NTAPI -CsrLockedReferenceProcess(IN PCSR_PROCESS CsrProcess) -{ - /* Increment the reference count */ - ++CsrProcess->ReferenceCount; -} - -/*++ - * @name CsrServerInitialization - * @implemented NT4 - * - * The CsrInitializeProcessStructure routine sets up support for CSR Processes - * and CSR Threads. - * - * @param None. - * - * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL - * othwerwise. - * - * @remarks None. - * - *--*/ -NTSTATUS -NTAPI -CsrInitializeProcessStructure(VOID) -{ - NTSTATUS Status; - ULONG i; - - /* Initialize the Lock */ - Status = RtlInitializeCriticalSection(&ProcessDataLock); - if (!NT_SUCCESS(Status)) return Status; - - /* Set up the Root Process */ - CsrRootProcess = CsrAllocateProcess(); - if (!CsrRootProcess) return STATUS_NO_MEMORY; - - /* Set up the minimal information for it */ - InitializeListHead(&CsrRootProcess->ListLink); - CsrRootProcess->ProcessHandle = (HANDLE)-1; - CsrRootProcess->ClientId = NtCurrentTeb()->ClientId; - - /* Initialize the Thread Hash List */ - for (i = 0; i < 256; i++) InitializeListHead(&CsrThreadHashTable[i]); - - /* Initialize the Wait Lock */ - return RtlInitializeCriticalSection(&CsrWaitListsLock); -} - -/*++ - * @name CsrDeallocateProcess - * - * The CsrDeallocateProcess frees the memory associated with a CSR Process. - * - * @param CsrProcess - * Pointer to the CSR Process to be freed. - * - * @return None. - * - * @remarks Do not call this routine. It is reserved for the internal - * thread management routines when a CSR Process has been cleanly - * dereferenced and killed. - * - *--*/ -VOID -NTAPI -CsrDeallocateProcess(IN PCSR_PROCESS CsrProcess) -{ - /* Free the process object from the heap */ - RtlFreeHeap(CsrHeap, 0, CsrProcess); -} - -/*++ - * @name CsrRemoveProcess - * - * The CsrRemoveProcess function undoes a CsrInsertProcess operation and - * removes the CSR Process from the Process List and notifies Server DLLs - * of this removal. - * - * @param CsrProcess - * Pointer to the CSR Process to remove. - * - * @return None. - * - * @remarks None. - * - *--*/ -VOID -NTAPI -CsrRemoveProcess(IN PCSR_PROCESS CsrProcess) -{ -#if 0 - PCSR_SERVER_DLL ServerDll; - ULONG i; -#endif - ASSERT(ProcessStructureListLocked()); - - /* Remove us from the Process List */ - RemoveEntryList(&CsrProcess->ListLink); - - /* Release the lock */ - CsrReleaseProcessLock(); -#if 0 - /* Loop every Server DLL */ - for (i = 0; i < CSR_SERVER_DLL_MAX; i++) - { - /* Get the Server DLL */ - ServerDll = CsrLoadedServerDll[i]; - - /* Check if it's valid and if it has a Disconnect Callback */ - if (ServerDll && ServerDll->DisconnectCallback) - { - /* Call it */ - (ServerDll->DisconnectCallback)(CsrProcess); - } - } -#endif -} - -/*++ - * @name CsrInsertProcess - * - * The CsrInsertProcess routine inserts a CSR Process into the Process List - * and notifies Server DLLs of the creation of a new CSR Process. - * - * @param Parent - * Optional pointer to the CSR Process creating this CSR Process. - * - * @param CurrentProcess - * Optional pointer to the current CSR Process. - * - * @param CsrProcess - * Pointer to the CSR Process which is to be inserted. - * - * @return None. - * - * @remarks None. - * - *--*/ -VOID -NTAPI -CsrInsertProcess(IN PCSR_PROCESS Parent OPTIONAL, - IN PCSR_PROCESS CurrentProcess OPTIONAL, - IN PCSR_PROCESS CsrProcess) -{ -#if 0 - PCSR_SERVER_DLL ServerDll; - ULONG i; -#endif - ASSERT(ProcessStructureListLocked()); - - /* Set the parent */ - CsrProcess->Parent = Parent; - - /* Insert it into the Root List */ - InsertTailList(&CsrRootProcess->ListLink, &CsrProcess->ListLink); -#if 0 - /* 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->NewProcessCallback)) - { - ServerDll->NewProcessCallback(CurrentProcess, CsrProcess); - } - } -#endif -} - -/*++ - * @name CsrLockProcessByClientId - * @implemented NT4 - * - * The CsrLockProcessByClientId routine locks the CSR Process corresponding - * to the given Process ID and optionally returns it. - * - * @param Pid - * Process ID corresponding to the CSR Process which will be locked. - * - * @param CsrProcess - * Optional pointer to a CSR Process pointer which will hold the - * CSR Process corresponding to the given Process ID. - * - * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL - * othwerwise. - * - * @remarks Locking a CSR Process is defined as acquiring an extra - * reference to it and returning with the Process Lock held. - * - *--*/ -NTSTATUS -NTAPI -CsrLockProcessByClientId(IN HANDLE Pid, - OUT PCSR_PROCESS *CsrProcess) -{ - PLIST_ENTRY NextEntry; - PCSR_PROCESS CurrentProcess = NULL; - - /* Acquire the lock */ - CsrAcquireProcessLock(); - - /* Assume failure */ - ASSERT(CsrProcess != NULL); - *CsrProcess = NULL; - - /* Setup the List Pointers */ - NextEntry = CsrRootProcess->ListLink.Flink; - while (NextEntry != &CsrRootProcess->ListLink) - { - /* Get the Process */ - CurrentProcess = CONTAINING_RECORD(NextEntry, CSR_PROCESS, ListLink); - - /* Check for PID Match */ - if (CurrentProcess->ClientId.UniqueProcess == Pid) break; - - /* Next entry */ - NextEntry = NextEntry->Flink; - } - - /* Check if we didn't find it in the list */ - if (NextEntry == &CsrRootProcess->ListLink) - { - /* Nothing found, release the lock */ - CsrReleaseProcessLock(); - return STATUS_UNSUCCESSFUL; - } - - /* Lock the found process and return it */ - CsrLockedReferenceProcess(CurrentProcess); - *CsrProcess = CurrentProcess; - return STATUS_SUCCESS; -} PCSR_PROCESS WINAPI CsrGetProcessData(HANDLE ProcessId) { Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/procsup.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/csrsrv/procsup.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/csrsrv/procsup.c [iso-8859-1] Thu Feb 16 06:45:25 2012 @@ -14,15 +14,9 @@ #define NDEBUG #include <debug.h> -#define LOCK RtlEnterCriticalSection(&ProcessDataLock) -#define UNLOCK RtlLeaveCriticalSection(&ProcessDataLock) - -#define CsrAcquireProcessLock() LOCK -#define CsrReleaseProcessLock() UNLOCK - /* GLOBALS ********************************************************************/ -extern RTL_CRITICAL_SECTION ProcessDataLock; +RTL_CRITICAL_SECTION ProcessDataLock, CsrWaitListsLock; PCSR_PROCESS CsrRootProcess; SECURITY_QUALITY_OF_SERVICE CsrSecurityQos = { @@ -31,6 +25,8 @@ SECURITY_STATIC_TRACKING, FALSE }; +LONG CsrProcessSequenceCount = 5; +extern ULONG CsrTotalPerProcessDataLength; /* FUNCTIONS ******************************************************************/ @@ -398,4 +394,327 @@ return STATUS_SUCCESS; } +/*++ + * @name CsrSetBackgroundPriority + * @implemented NT4 + * + * The CsrSetBackgroundPriority routine sets the priority for the given CSR + * Process as a Background priority. + * + * @param CsrProcess + * Pointer to the CSR Process whose priority will be modified. + * + * @return None. + * + * @remarks None. + * + *--*/ +VOID +NTAPI +CsrSetBackgroundPriority(IN PCSR_PROCESS CsrProcess) +{ + PROCESS_PRIORITY_CLASS PriorityClass; + + /* Set the Foreground bit off */ + PriorityClass.Foreground = FALSE; + + /* Set the new Priority */ + NtSetInformationProcess(CsrProcess->ProcessHandle, + ProcessPriorityClass, + &PriorityClass, + sizeof(PriorityClass)); +} + +/*++ + * @name CsrAllocateProcess + * @implemented NT4 + * + * The CsrAllocateProcess routine allocates a new CSR Process object. + * + * @return Pointer to the newly allocated CSR Process. + * + * @remarks None. + * + *--*/ +PCSR_PROCESS +NTAPI +CsrAllocateProcess(VOID) +{ + PCSR_PROCESS CsrProcess; + ULONG TotalSize; + + /* Calculate the amount of memory this should take */ + TotalSize = sizeof(CSR_PROCESS) + + (CSR_SERVER_DLL_MAX * sizeof(PVOID)) + + CsrTotalPerProcessDataLength; + + /* Allocate a Process */ + CsrProcess = RtlAllocateHeap(CsrHeap, HEAP_ZERO_MEMORY, TotalSize); + if (!CsrProcess) return NULL; + + /* Handle the Sequence Number and protect against overflow */ + CsrProcess->SequenceNumber = CsrProcessSequenceCount++; + if (CsrProcessSequenceCount < 5) CsrProcessSequenceCount = 5; + + /* Increase the reference count */ + CsrProcess->ReferenceCount++; + + /* Initialize the Thread List */ + InitializeListHead(&CsrProcess->ThreadList); + + /* Return the Process */ + return CsrProcess; +} + +/*++ + * @name CsrLockedReferenceProcess + * + * The CsrLockedReferenceProcess refences a CSR Process while the + * Process Lock is already being held. + * + * @param CsrProcess + * Pointer to the CSR Process to be referenced. + * + * @return None. + * + * @remarks This routine will return with the Process Lock held. + * + *--*/ +VOID +NTAPI +CsrLockedReferenceProcess(IN PCSR_PROCESS CsrProcess) +{ + /* Increment the reference count */ + ++CsrProcess->ReferenceCount; +} + +/*++ + * @name CsrServerInitialization + * @implemented NT4 + * + * The CsrInitializeProcessStructure routine sets up support for CSR Processes + * and CSR Threads. + * + * @param None. + * + * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL + * othwerwise. + * + * @remarks None. + * + *--*/ +NTSTATUS +NTAPI +CsrInitializeProcessStructure(VOID) +{ + NTSTATUS Status; + ULONG i; + + /* Initialize the Lock */ + Status = RtlInitializeCriticalSection(&ProcessDataLock); + if (!NT_SUCCESS(Status)) return Status; + + /* Set up the Root Process */ + CsrRootProcess = CsrAllocateProcess(); + if (!CsrRootProcess) return STATUS_NO_MEMORY; + + /* Set up the minimal information for it */ + InitializeListHead(&CsrRootProcess->ListLink); + CsrRootProcess->ProcessHandle = (HANDLE)-1; + CsrRootProcess->ClientId = NtCurrentTeb()->ClientId; + + /* Initialize the Thread Hash List */ + for (i = 0; i < 256; i++) InitializeListHead(&CsrThreadHashTable[i]); + + /* Initialize the Wait Lock */ + return RtlInitializeCriticalSection(&CsrWaitListsLock); +} + +/*++ + * @name CsrDeallocateProcess + * + * The CsrDeallocateProcess frees the memory associated with a CSR Process. + * + * @param CsrProcess + * Pointer to the CSR Process to be freed. + * + * @return None. + * + * @remarks Do not call this routine. It is reserved for the internal + * thread management routines when a CSR Process has been cleanly + * dereferenced and killed. + * + *--*/ +VOID +NTAPI +CsrDeallocateProcess(IN PCSR_PROCESS CsrProcess) +{ + /* Free the process object from the heap */ + RtlFreeHeap(CsrHeap, 0, CsrProcess); +} + +/*++ + * @name CsrRemoveProcess + * + * The CsrRemoveProcess function undoes a CsrInsertProcess operation and + * removes the CSR Process from the Process List and notifies Server DLLs + * of this removal. + * + * @param CsrProcess + * Pointer to the CSR Process to remove. + * + * @return None. + * + * @remarks None. + * + *--*/ +VOID +NTAPI +CsrRemoveProcess(IN PCSR_PROCESS CsrProcess) +{ +#if 0 + PCSR_SERVER_DLL ServerDll; + ULONG i; +#endif + ASSERT(ProcessStructureListLocked()); + + /* Remove us from the Process List */ + RemoveEntryList(&CsrProcess->ListLink); + + /* Release the lock */ + CsrReleaseProcessLock(); +#if 0 + /* Loop every Server DLL */ + for (i = 0; i < CSR_SERVER_DLL_MAX; i++) + { + /* Get the Server DLL */ + ServerDll = CsrLoadedServerDll[i]; + + /* Check if it's valid and if it has a Disconnect Callback */ + if (ServerDll && ServerDll->DisconnectCallback) + { + /* Call it */ + (ServerDll->DisconnectCallback)(CsrProcess); + } + } +#endif +} + +/*++ + * @name CsrInsertProcess + * + * The CsrInsertProcess routine inserts a CSR Process into the Process List + * and notifies Server DLLs of the creation of a new CSR Process. + * + * @param Parent + * Optional pointer to the CSR Process creating this CSR Process. + * + * @param CurrentProcess + * Optional pointer to the current CSR Process. + * + * @param CsrProcess + * Pointer to the CSR Process which is to be inserted. + * + * @return None. + * + * @remarks None. + * + *--*/ +VOID +NTAPI +CsrInsertProcess(IN PCSR_PROCESS Parent OPTIONAL, + IN PCSR_PROCESS CurrentProcess OPTIONAL, + IN PCSR_PROCESS CsrProcess) +{ +#if 0 + PCSR_SERVER_DLL ServerDll; + ULONG i; +#endif + ASSERT(ProcessStructureListLocked()); + + /* Set the parent */ + CsrProcess->Parent = Parent; + + /* Insert it into the Root List */ + InsertTailList(&CsrRootProcess->ListLink, &CsrProcess->ListLink); +#if 0 + /* 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->NewProcessCallback)) + { + ServerDll->NewProcessCallback(CurrentProcess, CsrProcess); + } + } +#endif +} + +/*++ + * @name CsrLockProcessByClientId + * @implemented NT4 + * + * The CsrLockProcessByClientId routine locks the CSR Process corresponding + * to the given Process ID and optionally returns it. + * + * @param Pid + * Process ID corresponding to the CSR Process which will be locked. + * + * @param CsrProcess + * Optional pointer to a CSR Process pointer which will hold the + * CSR Process corresponding to the given Process ID. + * + * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL + * othwerwise. + * + * @remarks Locking a CSR Process is defined as acquiring an extra + * reference to it and returning with the Process Lock held. + * + *--*/ +NTSTATUS +NTAPI +CsrLockProcessByClientId(IN HANDLE Pid, + OUT PCSR_PROCESS *CsrProcess) +{ + PLIST_ENTRY NextEntry; + PCSR_PROCESS CurrentProcess = NULL; + + /* Acquire the lock */ + CsrAcquireProcessLock(); + + /* Assume failure */ + ASSERT(CsrProcess != NULL); + *CsrProcess = NULL; + + /* Setup the List Pointers */ + NextEntry = CsrRootProcess->ListLink.Flink; + while (NextEntry != &CsrRootProcess->ListLink) + { + /* Get the Process */ + CurrentProcess = CONTAINING_RECORD(NextEntry, CSR_PROCESS, ListLink); + + /* Check for PID Match */ + if (CurrentProcess->ClientId.UniqueProcess == Pid) break; + + /* Next entry */ + NextEntry = NextEntry->Flink; + } + + /* Check if we didn't find it in the list */ + if (NextEntry == &CsrRootProcess->ListLink) + { + /* Nothing found, release the lock */ + CsrReleaseProcessLock(); + return STATUS_UNSUCCESSFUL; + } + + /* Lock the found process and return it */ + CsrLockedReferenceProcess(CurrentProcess); + *CsrProcess = CurrentProcess; + return STATUS_SUCCESS; +} + /* EOF */ Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/thredsup.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/csrsrv/thredsup.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/csrsrv/thredsup.c [iso-8859-1] Thu Feb 16 06:45:25 2012 @@ -14,21 +14,12 @@ #define NDEBUG #include <debug.h> -#define LOCK RtlEnterCriticalSection(&ProcessDataLock) -#define UNLOCK RtlLeaveCriticalSection(&ProcessDataLock) -#define CsrHeap RtlGetProcessHeap() #define CsrHashThread(t) \ (HandleToUlong(t)&(256 - 1)) -#define CsrAcquireProcessLock() LOCK -#define CsrReleaseProcessLock() UNLOCK - /* GLOBALS ********************************************************************/ LIST_ENTRY CsrThreadHashTable[256]; -extern PCSR_PROCESS CsrRootProcess; -extern RTL_CRITICAL_SECTION ProcessDataLock; -extern PCSR_PROCESS ProcessData[256]; /* FUNCTIONS ******************************************************************/ Modified: trunk/reactos/subsystems/win32/csrss/include/api.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/inc…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/include/api.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/include/api.h [iso-8859-1] Thu Feb 16 06:45:25 2012 @@ -13,6 +13,14 @@ #include <ndk/rtlfuncs.h> #include <csrss/csrss.h> + +#define CSR_SERVER_DLL_MAX 4 +#define LOCK RtlEnterCriticalSection(&ProcessDataLock) +#define UNLOCK RtlLeaveCriticalSection(&ProcessDataLock) +#define CsrAcquireProcessLock() LOCK +#define CsrReleaseProcessLock() UNLOCK +#define ProcessStructureListLocked() \ + (ProcessDataLock.OwningThread == NtCurrentTeb()->ClientId.UniqueThread) typedef enum _CSR_THREAD_FLAGS { @@ -137,9 +145,32 @@ CSR_API(CsrGetShutdownParameters); CSR_API(CsrSetShutdownParameters); +VOID +NTAPI +CsrSetBackgroundPriority(IN PCSR_PROCESS CsrProcess); + PCSR_THREAD NTAPI CsrAllocateThread(IN PCSR_PROCESS CsrProcess); + +PCSR_PROCESS +NTAPI +CsrAllocateProcess(VOID); + +VOID +NTAPI +CsrDeallocateProcess(IN PCSR_PROCESS CsrProcess); + +VOID +NTAPI +CsrRemoveProcess(IN PCSR_PROCESS CsrProcess); + +VOID +NTAPI +CsrInsertProcess(IN PCSR_PROCESS Parent OPTIONAL, + IN PCSR_PROCESS CurrentProcess OPTIONAL, + IN PCSR_PROCESS CsrProcess); + /* api/wapi.c */ NTSTATUS FASTCALL CsrApiRegisterDefinitions(PCSRSS_API_DEFINITION NewDefinitions); @@ -149,6 +180,18 @@ VOID NTAPI ClientConnectionThread(HANDLE ServerPort); extern HANDLE CsrSbApiPort; +extern LIST_ENTRY CsrThreadHashTable[256]; +extern PCSR_PROCESS CsrRootProcess; +extern RTL_CRITICAL_SECTION ProcessDataLock, CsrWaitListsLock; + +BOOLEAN +NTAPI +ProtectHandle(IN HANDLE ObjectHandle); + +VOID +NTAPI +CsrInsertThread(IN PCSR_PROCESS Process, +IN PCSR_THREAD Thread); /* api/process.c */ typedef NTSTATUS (WINAPI *CSRSS_ENUM_PROCESS_PROC)(PCSR_PROCESS ProcessData,
12 years, 10 months
1
0
0
0
[ion] 55624: [CSRSRV]: Port the alloc/dealloc/insert/remove CsrProcess management functions from CSRSRV2. There is no longer a hash table being used but instead a linked list just like in real CSRS...
by ion@svn.reactos.org
Author: ion Date: Thu Feb 16 03:41:18 2012 New Revision: 55624 URL:
http://svn.reactos.org/svn/reactos?rev=55624&view=rev
Log: [CSRSRV]: Port the alloc/dealloc/insert/remove CsrProcess management functions from CSRSRV2. There is no longer a hash table being used but instead a linked list just like in real CSRSRV(2 for us). This brings us closer to the CSRSRV2 model and makes some of the older ported code cleaner too. Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c trunk/reactos/subsystems/win32/csrss/csrsrv/init.c trunk/reactos/subsystems/win32/csrss/csrsrv/procsup.c trunk/reactos/subsystems/win32/csrss/include/api.h Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c [iso-8859-1] Thu Feb 16 03:41:18 2012 @@ -13,191 +13,428 @@ #define NDEBUG #include <debug.h> +#define CSR_SERVER_DLL_MAX 4 #define LOCK RtlEnterCriticalSection(&ProcessDataLock) #define UNLOCK RtlLeaveCriticalSection(&ProcessDataLock) #define CsrAcquireProcessLock() LOCK #define CsrReleaseProcessLock() UNLOCK - +#define ProcessStructureListLocked() \ + (ProcessDataLock.OwningThread == NtCurrentTeb()->ClientId.UniqueThread) + extern NTSTATUS CallProcessInherit(PCSR_PROCESS, PCSR_PROCESS); extern NTSTATUS CallProcessDeleted(PCSR_PROCESS); /* GLOBALS *******************************************************************/ -static ULONG NrProcess; -PCSR_PROCESS ProcessData[256]; -RTL_CRITICAL_SECTION ProcessDataLock; +RTL_CRITICAL_SECTION ProcessDataLock, CsrWaitListsLock; extern PCSR_PROCESS CsrRootProcess; extern LIST_ENTRY CsrThreadHashTable[256]; +extern ULONG CsrTotalPerProcessDataLength; +LONG CsrProcessSequenceCount = 5; /* FUNCTIONS *****************************************************************/ -VOID WINAPI CsrInitProcessData(VOID) -{ +/*++ + * @name CsrAllocateProcess + * @implemented NT4 + * + * The CsrAllocateProcess routine allocates a new CSR Process object. + * + * @return Pointer to the newly allocated CSR Process. + * + * @remarks None. + * + *--*/ +PCSR_PROCESS +NTAPI +CsrAllocateProcess(VOID) +{ + PCSR_PROCESS CsrProcess; + ULONG TotalSize; + + /* Calculate the amount of memory this should take */ + TotalSize = sizeof(CSR_PROCESS) + + (CSR_SERVER_DLL_MAX * sizeof(PVOID)) + + CsrTotalPerProcessDataLength; + + /* Allocate a Process */ + CsrProcess = RtlAllocateHeap(CsrHeap, HEAP_ZERO_MEMORY, TotalSize); + if (!CsrProcess) return NULL; + + /* Handle the Sequence Number and protect against overflow */ + CsrProcess->SequenceNumber = CsrProcessSequenceCount++; + if (CsrProcessSequenceCount < 5) CsrProcessSequenceCount = 5; + + /* Increase the reference count */ + CsrProcess->ReferenceCount++; + + /* Initialize the Thread List */ + InitializeListHead(&CsrProcess->ThreadList); + + /* Return the Process */ + return CsrProcess; +} + +/*++ + * @name CsrLockedReferenceProcess + * + * The CsrLockedReferenceProcess refences a CSR Process while the + * Process Lock is already being held. + * + * @param CsrProcess + * Pointer to the CSR Process to be referenced. + * + * @return None. + * + * @remarks This routine will return with the Process Lock held. + * + *--*/ +VOID +NTAPI +CsrLockedReferenceProcess(IN PCSR_PROCESS CsrProcess) +{ + /* Increment the reference count */ + ++CsrProcess->ReferenceCount; +} + +/*++ + * @name CsrServerInitialization + * @implemented NT4 + * + * The CsrInitializeProcessStructure routine sets up support for CSR Processes + * and CSR Threads. + * + * @param None. + * + * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL + * othwerwise. + * + * @remarks None. + * + *--*/ +NTSTATUS +NTAPI +CsrInitializeProcessStructure(VOID) +{ + NTSTATUS Status; ULONG i; - RtlZeroMemory (ProcessData, sizeof ProcessData); - NrProcess = sizeof ProcessData / sizeof ProcessData[0]; - RtlInitializeCriticalSection( &ProcessDataLock ); + + /* Initialize the Lock */ + Status = RtlInitializeCriticalSection(&ProcessDataLock); + if (!NT_SUCCESS(Status)) return Status; + + /* Set up the Root Process */ + CsrRootProcess = CsrAllocateProcess(); + if (!CsrRootProcess) return STATUS_NO_MEMORY; + + /* Set up the minimal information for it */ + InitializeListHead(&CsrRootProcess->ListLink); + CsrRootProcess->ProcessHandle = (HANDLE)-1; + CsrRootProcess->ClientId = NtCurrentTeb()->ClientId; + + /* Initialize the Thread Hash List */ + for (i = 0; i < 256; i++) InitializeListHead(&CsrThreadHashTable[i]); + + /* Initialize the Wait Lock */ + return RtlInitializeCriticalSection(&CsrWaitListsLock); +} + +/*++ + * @name CsrDeallocateProcess + * + * The CsrDeallocateProcess frees the memory associated with a CSR Process. + * + * @param CsrProcess + * Pointer to the CSR Process to be freed. + * + * @return None. + * + * @remarks Do not call this routine. It is reserved for the internal + * thread management routines when a CSR Process has been cleanly + * dereferenced and killed. + * + *--*/ +VOID +NTAPI +CsrDeallocateProcess(IN PCSR_PROCESS CsrProcess) +{ + /* Free the process object from the heap */ + RtlFreeHeap(CsrHeap, 0, CsrProcess); +} + +/*++ + * @name CsrRemoveProcess + * + * The CsrRemoveProcess function undoes a CsrInsertProcess operation and + * removes the CSR Process from the Process List and notifies Server DLLs + * of this removal. + * + * @param CsrProcess + * Pointer to the CSR Process to remove. + * + * @return None. + * + * @remarks None. + * + *--*/ +VOID +NTAPI +CsrRemoveProcess(IN PCSR_PROCESS CsrProcess) +{ +#if 0 + PCSR_SERVER_DLL ServerDll; + ULONG i; +#endif + ASSERT(ProcessStructureListLocked()); + + /* Remove us from the Process List */ + RemoveEntryList(&CsrProcess->ListLink); + + /* Release the lock */ + CsrReleaseProcessLock(); +#if 0 + /* Loop every Server DLL */ + for (i = 0; i < CSR_SERVER_DLL_MAX; i++) + { + /* Get the Server DLL */ + ServerDll = CsrLoadedServerDll[i]; + + /* Check if it's valid and if it has a Disconnect Callback */ + if (ServerDll && ServerDll->DisconnectCallback) + { + /* Call it */ + (ServerDll->DisconnectCallback)(CsrProcess); + } + } +#endif +} + +/*++ + * @name CsrInsertProcess + * + * The CsrInsertProcess routine inserts a CSR Process into the Process List + * and notifies Server DLLs of the creation of a new CSR Process. + * + * @param Parent + * Optional pointer to the CSR Process creating this CSR Process. + * + * @param CurrentProcess + * Optional pointer to the current CSR Process. + * + * @param CsrProcess + * Pointer to the CSR Process which is to be inserted. + * + * @return None. + * + * @remarks None. + * + *--*/ +VOID +NTAPI +CsrInsertProcess(IN PCSR_PROCESS Parent OPTIONAL, + IN PCSR_PROCESS CurrentProcess OPTIONAL, + IN PCSR_PROCESS CsrProcess) +{ +#if 0 + PCSR_SERVER_DLL ServerDll; + ULONG i; +#endif + ASSERT(ProcessStructureListLocked()); + + /* Set the parent */ + CsrProcess->Parent = Parent; + + /* Insert it into the Root List */ + InsertTailList(&CsrRootProcess->ListLink, &CsrProcess->ListLink); +#if 0 + /* 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->NewProcessCallback)) + { + ServerDll->NewProcessCallback(CurrentProcess, CsrProcess); + } + } +#endif +} + +/*++ + * @name CsrLockProcessByClientId + * @implemented NT4 + * + * The CsrLockProcessByClientId routine locks the CSR Process corresponding + * to the given Process ID and optionally returns it. + * + * @param Pid + * Process ID corresponding to the CSR Process which will be locked. + * + * @param CsrProcess + * Optional pointer to a CSR Process pointer which will hold the + * CSR Process corresponding to the given Process ID. + * + * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL + * othwerwise. + * + * @remarks Locking a CSR Process is defined as acquiring an extra + * reference to it and returning with the Process Lock held. + * + *--*/ +NTSTATUS +NTAPI +CsrLockProcessByClientId(IN HANDLE Pid, + OUT PCSR_PROCESS *CsrProcess) +{ + PLIST_ENTRY NextEntry; + PCSR_PROCESS CurrentProcess = NULL; + + /* Acquire the lock */ + CsrAcquireProcessLock(); + + /* Assume failure */ + ASSERT(CsrProcess != NULL); + *CsrProcess = NULL; + + /* Setup the List Pointers */ + NextEntry = CsrRootProcess->ListLink.Flink; + while (NextEntry != &CsrRootProcess->ListLink) + { + /* Get the Process */ + CurrentProcess = CONTAINING_RECORD(NextEntry, CSR_PROCESS, ListLink); + + /* Check for PID Match */ + if (CurrentProcess->ClientId.UniqueProcess == Pid) break; + + /* Next entry */ + NextEntry = NextEntry->Flink; + } + + /* Check if we didn't find it in the list */ + if (NextEntry == &CsrRootProcess->ListLink) + { + /* Nothing found, release the lock */ + CsrReleaseProcessLock(); + return STATUS_UNSUCCESSFUL; + } + + /* Lock the found process and return it */ + CsrLockedReferenceProcess(CurrentProcess); + *CsrProcess = CurrentProcess; + return STATUS_SUCCESS; +} + +PCSR_PROCESS WINAPI CsrGetProcessData(HANDLE ProcessId) +{ + PCSR_PROCESS CsrProcess; + NTSTATUS Status; + + Status = CsrLockProcessByClientId(ProcessId, &CsrProcess); + if (!NT_SUCCESS(Status)) return NULL; + + UNLOCK; + return CsrProcess; +} + +PCSR_PROCESS WINAPI CsrCreateProcessData(HANDLE ProcessId) +{ + PCSR_PROCESS pProcessData; + OBJECT_ATTRIBUTES ObjectAttributes; + CLIENT_ID ClientId; + NTSTATUS Status; + + LOCK; - CsrRootProcess = CsrCreateProcessData(NtCurrentTeb()->ClientId.UniqueProcess); - - /* Initialize the Thread Hash List */ - for (i = 0; i < 256; i++) InitializeListHead(&CsrThreadHashTable[i]); -} - -PCSR_PROCESS WINAPI CsrGetProcessData(HANDLE ProcessId) -{ - ULONG hash; - PCSR_PROCESS pProcessData; - - hash = ((ULONG_PTR)ProcessId >> 2) % (sizeof(ProcessData) / sizeof(*ProcessData)); - - LOCK; - - pProcessData = ProcessData[hash]; - - while (pProcessData && pProcessData->ClientId.UniqueProcess != ProcessId) - { - pProcessData = pProcessData->next; - } - UNLOCK; - return pProcessData; -} - -PCSR_PROCESS WINAPI CsrCreateProcessData(HANDLE ProcessId) -{ - ULONG hash; - PCSR_PROCESS pProcessData; - OBJECT_ATTRIBUTES ObjectAttributes; - CLIENT_ID ClientId; - NTSTATUS Status; - - hash = ((ULONG_PTR)ProcessId >> 2) % (sizeof(ProcessData) / sizeof(*ProcessData)); - - LOCK; - - pProcessData = ProcessData[hash]; - - while (pProcessData && pProcessData->ClientId.UniqueProcess != ProcessId) - { - pProcessData = pProcessData->next; - } - if (pProcessData == NULL) - { - pProcessData = RtlAllocateHeap(CsrHeap, - HEAP_ZERO_MEMORY, - sizeof(CSR_PROCESS)); - if (pProcessData) - { - pProcessData->ClientId.UniqueProcess = ProcessId; - pProcessData->next = ProcessData[hash]; - ProcessData[hash] = pProcessData; - - ClientId.UniqueThread = NULL; - ClientId.UniqueProcess = pProcessData->ClientId.UniqueProcess; - InitializeObjectAttributes(&ObjectAttributes, - NULL, - 0, - NULL, - NULL); - - /* using OpenProcess is not optimal due to HANDLE vs. DWORD PIDs... */ - Status = NtOpenProcess(&pProcessData->ProcessHandle, - PROCESS_ALL_ACCESS, - &ObjectAttributes, - &ClientId); - DPRINT("CSR Process: %p Handle: %p\n", pProcessData, pProcessData->ProcessHandle); - if (!NT_SUCCESS(Status)) - { - ProcessData[hash] = pProcessData->next; - RtlFreeHeap(CsrHeap, 0, pProcessData); - pProcessData = NULL; - } - else - { - RtlInitializeCriticalSection(&pProcessData->HandleTableLock); - } - } - } - else - { - DPRINT1("Process data for pid %d already exist\n", ProcessId); - } - UNLOCK; - if (pProcessData == NULL) - { - DPRINT1("CsrCreateProcessData() failed\n"); - } - else - { - pProcessData->Flags = ~CsrProcessTerminated; - - /* Set default shutdown parameters */ - pProcessData->ShutdownLevel = 0x280; - pProcessData->ShutdownFlags = 0; - } - - pProcessData->ThreadCount = 0; - InitializeListHead(&pProcessData->ThreadList); - return pProcessData; + pProcessData = CsrAllocateProcess(); + ASSERT(pProcessData != NULL); + + pProcessData->ClientId.UniqueProcess = ProcessId; + + ClientId.UniqueThread = NULL; + ClientId.UniqueProcess = pProcessData->ClientId.UniqueProcess; + InitializeObjectAttributes(&ObjectAttributes, + NULL, + 0, + NULL, + NULL); + + /* using OpenProcess is not optimal due to HANDLE vs. DWORD PIDs... */ + Status = NtOpenProcess(&pProcessData->ProcessHandle, + PROCESS_ALL_ACCESS, + &ObjectAttributes, + &ClientId); + DPRINT("CSR Process: %p Handle: %p\n", pProcessData, pProcessData->ProcessHandle); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed\n"); + CsrDeallocateProcess(pProcessData); + CsrReleaseProcessLock(); + return NULL; + } + else + { + RtlInitializeCriticalSection(&pProcessData->HandleTableLock); + } + + /* Set default shutdown parameters */ + pProcessData->ShutdownLevel = 0x280; + pProcessData->ShutdownFlags = 0; + + /* Insert the Process */ + CsrInsertProcess(NULL, NULL, pProcessData); + + /* Release lock and return */ + CsrReleaseProcessLock(); + return pProcessData; } NTSTATUS WINAPI CsrFreeProcessData(HANDLE Pid) { - ULONG hash; - PCSR_PROCESS pProcessData, *pPrevLink; - HANDLE Process; - PLIST_ENTRY NextEntry; - PCSR_THREAD Thread; - - hash = ((ULONG_PTR)Pid >> 2) % (sizeof(ProcessData) / sizeof(*ProcessData)); - pPrevLink = &ProcessData[hash]; - - LOCK; - - while ((pProcessData = *pPrevLink) && pProcessData->ClientId.UniqueProcess != Pid) - { - pPrevLink = &pProcessData->next; - } - - if (pProcessData) - { - DPRINT("CsrFreeProcessData pid: %d\n", Pid); - Process = pProcessData->ProcessHandle; - CallProcessDeleted(pProcessData); - - /* Dereference all process threads */ - NextEntry = pProcessData->ThreadList.Flink; - while (NextEntry != &pProcessData->ThreadList) - { + PCSR_PROCESS pProcessData; + HANDLE Process; + PLIST_ENTRY NextEntry; + PCSR_THREAD Thread; + + pProcessData = CsrGetProcessData(Pid); + if (!pProcessData) return STATUS_INVALID_PARAMETER; + + LOCK; + + Process = pProcessData->ProcessHandle; + CallProcessDeleted(pProcessData); + + /* Dereference all process threads */ + NextEntry = pProcessData->ThreadList.Flink; + while (NextEntry != &pProcessData->ThreadList) + { Thread = CONTAINING_RECORD(NextEntry, CSR_THREAD, Link); NextEntry = NextEntry->Flink; CsrThreadRefcountZero(Thread); - } - - if (pProcessData->ClientViewBase) - { - NtUnmapViewOfSection(NtCurrentProcess(), (PVOID)pProcessData->ClientViewBase); - } - - if (pProcessData->ClientPort) - { - NtClose(pProcessData->ClientPort); - } - - *pPrevLink = pProcessData->next; - - RtlFreeHeap(CsrHeap, 0, pProcessData); - UNLOCK; - if (Process) - { - NtClose(Process); - } - return STATUS_SUCCESS; - } - - UNLOCK; - return STATUS_INVALID_PARAMETER; + } + + if (pProcessData->ClientViewBase) + { + NtUnmapViewOfSection(NtCurrentProcess(), (PVOID)pProcessData->ClientViewBase); + } + + if (pProcessData->ClientPort) + { + NtClose(pProcessData->ClientPort); + } + + CsrRemoveProcess(pProcessData); + + CsrDeallocateProcess(pProcessData); + + if (Process) + { + NtClose(Process); + } + + return STATUS_SUCCESS; } /********************************************************************** @@ -251,12 +488,7 @@ CurrentThread = NtCurrentTeb()->CsrClientThread; CsrProcess = CurrentThread->Process; -// DPRINT1("Current thread: %p %p\n", CurrentThread, CsrProcess); -// DPRINT1("Request CID: %lx %lx %lx\n", -// CsrProcess->ClientId.UniqueProcess, -// NtCurrentTeb()->ClientId.UniqueProcess, - // Request->Data.CreateThreadRequest.ClientId.UniqueProcess); - + if (CsrProcess->ClientId.UniqueProcess != Request->Data.CreateThreadRequest.ClientId.UniqueProcess) { if (Request->Data.CreateThreadRequest.ClientId.UniqueProcess == NtCurrentTeb()->ClientId.UniqueProcess) @@ -266,15 +498,9 @@ Status = CsrLockProcessByClientId(Request->Data.CreateThreadRequest.ClientId.UniqueProcess, &CsrProcess); - // DPRINT1("Found matching process: %p\n", CsrProcess); if (!NT_SUCCESS(Status)) return Status; } -// DPRINT1("PIDs: %lx %lx\n", CurrentThread->Process->ClientId.UniqueProcess, CsrProcess->ClientId.UniqueProcess); -// DPRINT1("Thread handle is: %lx Process Handle is: %lx %lx\n", - // Request->Data.CreateThreadRequest.ThreadHandle, - // CurrentThread->Process->ProcessHandle, - // CsrProcess->Process); Status = NtDuplicateObject(CsrProcess->ProcessHandle, Request->Data.CreateThreadRequest.ThreadHandle, NtCurrentProcess(), @@ -282,7 +508,6 @@ 0, 0, DUPLICATE_SAME_ACCESS); - //DPRINT1("Duplicate status: %lx\n", Status); if (!NT_SUCCESS(Status)) { Status = NtDuplicateObject(CurrentThread->Process->ProcessHandle, @@ -292,7 +517,6 @@ 0, 0, DUPLICATE_SAME_ACCESS); - // DPRINT1("Duplicate status: %lx\n", Status); } Status = STATUS_SUCCESS; // hack @@ -301,7 +525,6 @@ Status = CsrCreateThread(CsrProcess, ThreadHandle, &Request->Data.CreateThreadRequest.ClientId); - // DPRINT1("Create status: %lx\n", Status); } if (CsrProcess != CurrentThread->Process) CsrReleaseProcessLock(); Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/init.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/csrsrv/init.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/csrsrv/init.c [iso-8859-1] Thu Feb 16 03:41:18 2012 @@ -1117,6 +1117,15 @@ return Status; } + /* Set up Process Support */ + Status = CsrInitializeProcessStructure(); + if (!NT_SUCCESS(Status)) + { + DPRINT1("CSRSRV:%s: CsrInitializeProcessStructure failed (Status=%08lx)\n", + __FUNCTION__, Status); + return Status; + } + /* Parse the command line */ Status = CsrParseServerCommandLine(ArgumentCount, Arguments); if (!NT_SUCCESS(Status)) @@ -1125,8 +1134,6 @@ __FUNCTION__, Status); return Status; } - - CsrInitProcessData(); Status = CsrApiRegisterDefinitions(NativeDefinitions); if (!NT_SUCCESS(Status)) Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/procsup.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/csrsrv/procsup.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/csrsrv/procsup.c [iso-8859-1] Thu Feb 16 03:41:18 2012 @@ -23,7 +23,6 @@ /* GLOBALS ********************************************************************/ extern RTL_CRITICAL_SECTION ProcessDataLock; -extern PCSR_PROCESS ProcessData[256]; PCSR_PROCESS CsrRootProcess; SECURITY_QUALITY_OF_SERVICE CsrSecurityQos = { @@ -225,63 +224,63 @@ NTAPI FindProcessForShutdown(IN PLUID CallerLuid) { - ULONG Hash; PCSR_PROCESS CsrProcess, ReturnCsrProcess = NULL; NTSTATUS Status; ULONG Level = 0; LUID ProcessLuid; LUID SystemLuid = SYSTEM_LUID; BOOLEAN IsSystemLuid = FALSE, IsOurLuid = FALSE; - - for (Hash = 0; Hash < (sizeof(ProcessData) / sizeof(*ProcessData)); Hash++) - { - /* Get this process hash bucket */ - CsrProcess = ProcessData[Hash]; - while (CsrProcess) - { - /* Skip this process if it's already been processed*/ - if (CsrProcess->Flags & CsrProcessSkipShutdown) goto Next; + PLIST_ENTRY NextEntry; + + /* Set the List Pointers */ + NextEntry = CsrRootProcess->ListLink.Flink; + while (NextEntry != &CsrRootProcess->ListLink) + { + /* Get the process */ + CsrProcess = CONTAINING_RECORD(NextEntry, CSR_PROCESS, ListLink); + + /* Move to the next entry */ + NextEntry = NextEntry->Flink; - /* Get the LUID of this Process */ - Status = CsrGetProcessLuid(CsrProcess->ProcessHandle, &ProcessLuid); - - /* Check if we didn't get access to the LUID */ - if (Status == STATUS_ACCESS_DENIED) - { - /* FIXME:Check if we have any threads */ - } - - if (!NT_SUCCESS(Status)) - { - /* We didn't have access, so skip it */ - CsrProcess->Flags |= CsrProcessSkipShutdown; - goto Next; - } - - /* Check if this is the System LUID */ - if ((IsSystemLuid = RtlEqualLuid(&ProcessLuid, &SystemLuid))) - { - /* Mark this process */ - CsrProcess->ShutdownFlags |= CsrShutdownSystem; - } - else if (!(IsOurLuid = RtlEqualLuid(&ProcessLuid, CallerLuid))) - { - /* Our LUID doesn't match with the caller's */ - CsrProcess->ShutdownFlags |= CsrShutdownOther; - } - - /* Check if we're past the previous level */ - if (CsrProcess->ShutdownLevel > Level) - { - /* Update the level */ - Level = CsrProcess->ShutdownLevel; - - /* Set the final process */ - ReturnCsrProcess = CsrProcess; - } -Next: - /* Next process */ - CsrProcess = CsrProcess->next; + /* Skip this process if it's already been processed */ + if (CsrProcess->Flags & CsrProcessSkipShutdown) continue; + + /* Get the LUID of this Process */ + Status = CsrGetProcessLuid(CsrProcess->ProcessHandle, &ProcessLuid); + + /* Check if we didn't get access to the LUID */ + if (Status == STATUS_ACCESS_DENIED) + { + /* FIXME:Check if we have any threads */ + } + + if (!NT_SUCCESS(Status)) + { + /* We didn't have access, so skip it */ + CsrProcess->Flags |= CsrProcessSkipShutdown; + continue; + } + + /* Check if this is the System LUID */ + if ((IsSystemLuid = RtlEqualLuid(&ProcessLuid, &SystemLuid))) + { + /* Mark this process */ + CsrProcess->ShutdownFlags |= CsrShutdownSystem; + } + else if (!(IsOurLuid = RtlEqualLuid(&ProcessLuid, CallerLuid))) + { + /* Our LUID doesn't match with the caller's */ + CsrProcess->ShutdownFlags |= CsrShutdownOther; + } + + /* Check if we're past the previous level */ + if (CsrProcess->ShutdownLevel > Level) + { + /* Update the level */ + Level = CsrProcess->ShutdownLevel; + + /* Set the final process */ + ReturnCsrProcess = CsrProcess; } } @@ -306,28 +305,27 @@ PCSR_PROCESS CsrProcess = NULL; NTSTATUS Status = STATUS_UNSUCCESSFUL; BOOLEAN FirstTry; + PLIST_ENTRY NextEntry; ULONG Result = 0; - ULONG Hash; /* Acquire process lock */ CsrAcquireProcessLock(); - - /* Start the loop */ - for (Hash = 0; Hash < (sizeof(ProcessData) / sizeof(*ProcessData)); Hash++) + + /* Get the list pointers */ + NextEntry = CsrRootProcess->ListLink.Flink; + while (NextEntry != &CsrRootProcess->ListLink) { /* Get the Process */ - CsrProcess = ProcessData[Hash]; - while (CsrProcess) - { - /* Remove the skip flag, set shutdown flags to 0*/ - CsrProcess->Flags &= ~CsrProcessSkipShutdown; - CsrProcess->ShutdownFlags = 0; - - /* Move to the next */ - CsrProcess = CsrProcess->next; - } - } - + CsrProcess = CONTAINING_RECORD(NextEntry, CSR_PROCESS, ListLink); + + /* Remove the skip flag, set shutdown flags to 0*/ + CsrProcess->Flags &= ~CsrProcessSkipShutdown; + CsrProcess->ShutdownFlags = 0; + + /* Move to the next */ + NextEntry = NextEntry->Flink; + } + /* Set shudown Priority */ CsrSetToShutdownPriority(); @@ -390,48 +388,6 @@ NTSTATUS NTAPI -CsrLockProcessByClientId(IN HANDLE Pid, - OUT PCSR_PROCESS *CsrProcess OPTIONAL) -{ - ULONG Hash; - PCSR_PROCESS CurrentProcess = NULL; - NTSTATUS Status = STATUS_UNSUCCESSFUL; - - /* Acquire the lock */ - CsrAcquireProcessLock(); - - /* Start the loop */ - for (Hash = 0; Hash < (sizeof(ProcessData) / sizeof(*ProcessData)); Hash++) - { - /* Get the Process */ - CurrentProcess = ProcessData[Hash]; - while (CurrentProcess) - { - /* Check for PID match */ - if (CurrentProcess->ClientId.UniqueProcess == Pid) - { - /* Get out of here with success */ -// DPRINT1("Found %p for PID %lx\n", CurrentProcess, Pid); - Status = STATUS_SUCCESS; - goto Found; - } - - /* Move to the next */ - CurrentProcess = CurrentProcess->next; - } - } - - /* Nothing found, release the lock */ -Found: - if (!CurrentProcess) CsrReleaseProcessLock(); - - /* Return the status and process */ - if (CsrProcess) *CsrProcess = CurrentProcess; - return Status; -} - -NTSTATUS -NTAPI CsrUnlockProcess(IN PCSR_PROCESS CsrProcess) { /* Dereference the process */ Modified: trunk/reactos/subsystems/win32/csrss/include/api.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/inc…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/include/api.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/include/api.h [iso-8859-1] Thu Feb 16 03:41:18 2012 @@ -84,7 +84,6 @@ ULONG ShutdownLevel; ULONG ShutdownFlags; // PVOID ServerData[ANYSIZE_ARRAY]; - struct _CSR_PROCESS* next; CSRSS_CON_PROCESS_DATA; } CSR_PROCESS, *PCSR_PROCESS; @@ -154,7 +153,7 @@ /* api/process.c */ typedef NTSTATUS (WINAPI *CSRSS_ENUM_PROCESS_PROC)(PCSR_PROCESS ProcessData, PVOID Context); -VOID WINAPI CsrInitProcessData(VOID); +NTSTATUS WINAPI CsrInitializeProcessStructure(VOID); PCSR_PROCESS WINAPI CsrGetProcessData(HANDLE ProcessId); PCSR_PROCESS WINAPI CsrCreateProcessData(HANDLE ProcessId); NTSTATUS WINAPI CsrFreeProcessData( HANDLE Pid );
12 years, 10 months
1
0
0
0
[ion] 55623: [CSRSRV2]: Formatting fix.
by ion@svn.reactos.org
Author: ion Date: Thu Feb 16 03:38:21 2012 New Revision: 55623 URL:
http://svn.reactos.org/svn/reactos?rev=55623&view=rev
Log: [CSRSRV2]: Formatting fix. Modified: trunk/reactos/subsystems/csr/csrsrv/process.c Modified: trunk/reactos/subsystems/csr/csrsrv/process.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/csr/csrsrv/proc…
============================================================================== --- trunk/reactos/subsystems/csr/csrsrv/process.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/csr/csrsrv/process.c [iso-8859-1] Thu Feb 16 03:38:21 2012 @@ -249,9 +249,9 @@ ServerDll = CsrLoadedServerDll[i]; /* Make sure it's valid and that it has callback */ - if (ServerDll && ServerDll->NewProcessCallback) + if ((ServerDll) && (ServerDll->NewProcessCallback)) { - (*ServerDll->NewProcessCallback)(CurrentProcess, CsrProcess); + ServerDll->NewProcessCallback(CurrentProcess, CsrProcess); } } }
12 years, 10 months
1
0
0
0
[ion] 55622: [CSRSRV]: Fix \Local symbolic link. Thanks to vicmarcal (and the new awesome testman).
by ion@svn.reactos.org
Author: ion Date: Thu Feb 16 01:27:11 2012 New Revision: 55622 URL:
http://svn.reactos.org/svn/reactos?rev=55622&view=rev
Log: [CSRSRV]: Fix \Local symbolic link. Thanks to vicmarcal (and the new awesome testman). Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c [iso-8859-1] Thu Feb 16 01:27:11 2012 @@ -650,7 +650,7 @@ /* Make local point back to \Sessions\x\BNO */ RtlInitUnicodeString(&DirectoryName, L"Local"); - RtlInitUnicodeString(&SymlinkName, Buffer); + ASSERT(SessionId == 0); InitializeObjectAttributes(&ObjectAttributes, &DirectoryName, OBJ_OPENIF | OBJ_PERMANENT | OBJ_CASE_INSENSITIVE,
12 years, 10 months
1
0
0
0
[khornicek] 55621: [ROSAUTOTEST] Some bug fixing.
by khornicek@svn.reactos.org
Author: khornicek Date: Thu Feb 16 00:52:20 2012 New Revision: 55621 URL:
http://svn.reactos.org/svn/reactos?rev=55621&view=rev
Log: [ROSAUTOTEST] Some bug fixing. Modified: trunk/rostests/rosautotest/tools.cpp Modified: trunk/rostests/rosautotest/tools.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/rosautotest/tools.cpp?rev…
============================================================================== --- trunk/rostests/rosautotest/tools.cpp [iso-8859-1] (original) +++ trunk/rostests/rosautotest/tools.cpp [iso-8859-1] Thu Feb 16 00:52:20 2012 @@ -119,10 +119,10 @@ /* Try to print whole lines but obey the 512 bytes chunk size limit*/ if(NewString[curr_pos - 1] == '\n' || (curr_pos - start) == DBGPRINT_BUFSIZE) { - if((curr_pos - start) > DBGPRINT_BUFSIZE || NewString[curr_pos - 1] != '\n') + if((curr_pos - start) >= DBGPRINT_BUFSIZE) { - /* No newlines, print what we have and start over*/ - if(NewString[curr_pos - 1] != '\n') + /* No newlines so far, or the string just fits */ + if(last_newline <= start || (curr_pos - start) == DBGPRINT_BUFSIZE) { size = curr_pos - start; memcpy(DbgString, NewString.c_str() + start, size);
12 years, 10 months
1
0
0
0
[ion] 55620: [CSRSRV]: Add a new linked list for console processes, as ListLink is used for all CSR_PROCESSes.
by ion@svn.reactos.org
Author: ion Date: Wed Feb 15 22:15:33 2012 New Revision: 55620 URL:
http://svn.reactos.org/svn/reactos?rev=55620&view=rev
Log: [CSRSRV]: Add a new linked list for console processes, as ListLink is used for all CSR_PROCESSes. Modified: trunk/reactos/subsystems/win32/csrss/include/api.h trunk/reactos/subsystems/win32/csrss/win32csr/coninput.c trunk/reactos/subsystems/win32/csrss/win32csr/console.c trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c trunk/reactos/subsystems/win32/csrss/win32csr/handle.c Modified: trunk/reactos/subsystems/win32/csrss/include/api.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/inc…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/include/api.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/include/api.h [iso-8859-1] Wed Feb 15 22:15:33 2012 @@ -55,6 +55,7 @@ ULONG HandleTableSize; struct _CSRSS_HANDLE *HandleTable; PCONTROLDISPATCHER CtrlDispatcher; + LIST_ENTRY ConsoleLink; } CSRSS_CON_PROCESS_DATA, *PCSRSS_CON_PROCESS_DATA; typedef struct _CSR_PROCESS Modified: trunk/reactos/subsystems/win32/csrss/win32csr/coninput.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/win32csr/coninput.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/win32csr/coninput.c [iso-8859-1] Wed Feb 15 22:15:33 2012 @@ -373,7 +373,7 @@ current_entry = Console->ProcessList.Flink; while (current_entry != &Console->ProcessList) { - current = CONTAINING_RECORD(current_entry, CSR_PROCESS, ListLink); + current = CONTAINING_RECORD(current_entry, CSR_PROCESS, ConsoleLink); current_entry = current_entry->Flink; ConioConsoleCtrlEvent((DWORD)CTRL_C_EVENT, current); } Modified: trunk/reactos/subsystems/win32/csrss/win32csr/console.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/win32csr/console.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/win32csr/console.c [iso-8859-1] Wed Feb 15 22:15:33 2012 @@ -215,7 +215,7 @@ /* initialize list head */ InitializeListHead(&Console->ProcessList); /* insert process data required for GUI initialization */ - InsertHeadList(&Console->ProcessList, &ProcessData->ListLink); + InsertHeadList(&Console->ProcessList, &ProcessData->ConsoleLink); /* Initialize the Console */ Status = CsrInitConsole(Console, Request->Data.AllocConsoleRequest.ShowCmd); if (!NT_SUCCESS(Status)) @@ -307,7 +307,7 @@ if (!NewConsole) { /* Insert into the list if it has not been added */ - InsertHeadList(&ProcessData->Console->ProcessList, &ProcessData->ListLink); + InsertHeadList(&ProcessData->Console->ProcessList, &ProcessData->ConsoleLink); } RtlLeaveCriticalSection(&ProcessData->HandleTableLock); @@ -786,7 +786,7 @@ current_entry != &Console->ProcessList; current_entry = current_entry->Flink) { - current = CONTAINING_RECORD(current_entry, CSR_PROCESS, ListLink); + current = CONTAINING_RECORD(current_entry, CSR_PROCESS, ConsoleLink); if (++nItems <= Request->Data.GetProcessListRequest.nMaxIds) { *Buffer++ = HandleToUlong(current->ClientId.UniqueProcess); @@ -822,7 +822,7 @@ current_entry != &Console->ProcessList; current_entry = current_entry->Flink) { - current = CONTAINING_RECORD(current_entry, CSR_PROCESS, ListLink); + current = CONTAINING_RECORD(current_entry, CSR_PROCESS, ConsoleLink); if (Group == 0 || current->ProcessGroupId == Group) { ConioConsoleCtrlEvent(Request->Data.GenerateCtrlEvent.Event, current); Modified: trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c [iso-8859-1] Wed Feb 15 22:15:33 2012 @@ -400,7 +400,7 @@ DPRINT("GuiConsoleWriteUserSettings: No Process!!!\n"); return; } - ProcessData = CONTAINING_RECORD(Console->ProcessList.Flink, CSR_PROCESS, ListLink); + ProcessData = CONTAINING_RECORD(Console->ProcessList.Flink, CSR_PROCESS, ConsoleLink); if (!GuiConsoleOpenUserSettings(GuiData, PtrToUlong(ProcessData->ClientId.UniqueProcess), &hKey, KEY_READ | KEY_WRITE, TRUE)) { return; @@ -704,7 +704,7 @@ GuiConsoleUseDefaults(Console, GuiData, Console->ActiveBuffer); if (Console->ProcessList.Flink != &Console->ProcessList) { - ProcessData = CONTAINING_RECORD(Console->ProcessList.Flink, CSR_PROCESS, ListLink); + ProcessData = CONTAINING_RECORD(Console->ProcessList.Flink, CSR_PROCESS, ConsoleLink); if (GuiConsoleOpenUserSettings(GuiData, PtrToUlong(ProcessData->ClientId.UniqueProcess), &hKey, KEY_READ, FALSE)) { GuiConsoleReadUserSettings(hKey, Console, GuiData, Console->ActiveBuffer); @@ -1272,7 +1272,7 @@ current_entry = Console->ProcessList.Flink; while (current_entry != &Console->ProcessList) { - current = CONTAINING_RECORD(current_entry, CSR_PROCESS, ListLink); + current = CONTAINING_RECORD(current_entry, CSR_PROCESS, ConsoleLink); current_entry = current_entry->Flink; /* FIXME: Windows will wait up to 5 seconds for the thread to exit. Modified: trunk/reactos/subsystems/win32/csrss/win32csr/handle.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/win32csr/handle.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/win32csr/handle.c [iso-8859-1] Wed Feb 15 22:15:33 2012 @@ -154,7 +154,7 @@ { ProcessData->Console = NULL; EnterCriticalSection(&Console->Lock); - RemoveEntryList(&ProcessData->ListLink); + RemoveEntryList(&ProcessData->ConsoleLink); LeaveCriticalSection(&Console->Lock); if (_InterlockedDecrement(&Console->ReferenceCount) == 0) ConioDeleteConsole(&Console->Header);
12 years, 10 months
1
0
0
0
[tkreuzer] 55619: [COMDLG32] Really fix msvc build
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Wed Feb 15 21:57:13 2012 New Revision: 55619 URL:
http://svn.reactos.org/svn/reactos?rev=55619&view=rev
Log: [COMDLG32] Really fix msvc build Modified: trunk/reactos/dll/win32/comdlg32/cdlg_Ru.rc Modified: trunk/reactos/dll/win32/comdlg32/cdlg_Ru.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/comdlg32/cdlg_Ru…
============================================================================== --- trunk/reactos/dll/win32/comdlg32/cdlg_Ru.rc [iso-8859-1] (original) +++ trunk/reactos/dll/win32/comdlg32/cdlg_Ru.rc [iso-8859-1] Wed Feb 15 21:57:13 2012 @@ -55,7 +55,7 @@ PD32_VALUE_UREADABLE "ÐеÑиÑаемÑй ÑлеменÑ" PD32_INVALID_PAGE_RANGE "ÐÑо знаÑение не Ð»ÐµÐ¶Ð¸Ñ Ð²Ð½ÑÑÑи диапазона ÑÑÑаниÑ.\n\ ÐведиÑе знаÑение Ð¼ÐµÐ¶Ð´Ñ %1!%d! и %2!d!." - PD32_FROM_NOT_ABOVE_TO "ÐнаÑение \"оÑ\" не должно пÑевÑÑаÑÑ Ð·Ð½Ð°ÑÐµÐ½Ð¸Ñ \"до\"." + PD32_FROM_NOT_ABOVE_TO "ÐнаÑение 'оÑ' не должно пÑевÑÑаÑÑ Ð·Ð½Ð°ÑÐµÐ½Ð¸Ñ 'до'." PD32_MARGINS_OVERLAP "ÐÑаниÑÑ Ð¿ÐµÑекÑÑваÑÑ Ð¸Ð»Ð¸ пÑевÑÑаÑÑ ÑазмеÑÑ Ð±Ñмаги.\n\ ÐведиÑе Ð¸Ñ Ð·Ð°Ð½Ð¾Ð²Ð¾." PD32_NR_OF_COPIES_EMPTY "ЧиÑло копий не Ð¼Ð¾Ð¶ÐµÑ Ð±ÑÑÑ Ð¿ÑÑÑÑм."
12 years, 10 months
1
0
0
0
[khornicek] 55618: [ROSAUTOTEST] Try to print whole lines so the output from tests doesn't get mixed with debug output from other reactos components.
by khornicek@svn.reactos.org
Author: khornicek Date: Wed Feb 15 21:18:13 2012 New Revision: 55618 URL:
http://svn.reactos.org/svn/reactos?rev=55618&view=rev
Log: [ROSAUTOTEST] Try to print whole lines so the output from tests doesn't get mixed with debug output from other reactos components. Modified: trunk/rostests/rosautotest/tools.cpp Modified: trunk/rostests/rosautotest/tools.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/rosautotest/tools.cpp?rev…
============================================================================== --- trunk/rostests/rosautotest/tools.cpp [iso-8859-1] (original) +++ trunk/rostests/rosautotest/tools.cpp [iso-8859-1] Wed Feb 15 21:18:13 2012 @@ -96,7 +96,7 @@ StringOut(const string& String) { char DbgString[DBGPRINT_BUFSIZE + 1]; - size_t i; + size_t i, start = 0, last_newline = 0, size = 0, curr_pos = 0; string NewString; /* Unify the line endings (the piped output of the tests may use CRLF) */ @@ -113,26 +113,44 @@ /* Otherwise copy the string */ NewString += String[i]; } - } - - /* Output the string. - For DbgPrint, this must be done in chunks of 512 bytes. */ + + curr_pos = NewString.size(); + + /* Try to print whole lines but obey the 512 bytes chunk size limit*/ + if(NewString[curr_pos - 1] == '\n' || (curr_pos - start) == DBGPRINT_BUFSIZE) + { + if((curr_pos - start) > DBGPRINT_BUFSIZE || NewString[curr_pos - 1] != '\n') + { + /* No newlines, print what we have and start over*/ + if(NewString[curr_pos - 1] != '\n') + { + size = curr_pos - start; + memcpy(DbgString, NewString.c_str() + start, size); + start = curr_pos; + } + else + { + size = last_newline - start; + memcpy(DbgString, NewString.c_str() + start, size); + start = last_newline; + } + + DbgString[size] = 0; + DbgPrint(DbgString); + } + + last_newline = curr_pos; + } + } + + /* The rest of the string is <= DBGPRINT_BUFSIZE so just print it*/ + size = curr_pos - start; + memcpy(DbgString, NewString.c_str() + start, size); + DbgString[size] = 0; + DbgPrint(DbgString); + + /* Output the string */ cout << NewString; - - for(i = 0; i < NewString.size(); i += DBGPRINT_BUFSIZE) - { - size_t BytesToCopy; - - if(NewString.size() - i > DBGPRINT_BUFSIZE) - BytesToCopy = DBGPRINT_BUFSIZE; - else - BytesToCopy = NewString.size() - i; - - memcpy(DbgString, NewString.c_str() + i, BytesToCopy); - DbgString[BytesToCopy] = 0; - - DbgPrint(DbgString); - } } /**
12 years, 10 months
1
0
0
0
← Newer
1
...
29
30
31
32
33
34
35
...
58
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Results per page:
10
25
50
100
200