Clarify few parts of code; remove unneeded comments and DPRINTs; start documentation of the CsrCreateProcess routine.

[BASESRV-CONSRV-WINSRV]
Correct the sizes of the API tables.

[SM]
Correct the API names.

svn path=/branches/ros-csrss/; revision=58464
This commit is contained in:
Hermès Bélusca-Maïto 2013-03-10 19:37:33 +00:00
parent 0a679dbf86
commit e2d2cb40e2
17 changed files with 136 additions and 225 deletions

View file

@ -166,7 +166,7 @@ SmpStopCsr(IN PSM_API_MSG SmApiMsg,
return STATUS_NOT_IMPLEMENTED; return STATUS_NOT_IMPLEMENTED;
} }
PSM_API_HANDLER SmpApiDispatch[SmMaxApiNumber] = PSM_API_HANDLER SmpApiDispatch[SmpMaxApiNumber - SmpCreateForeignSessionApi] =
{ {
SmpCreateForeignSession, SmpCreateForeignSession,
SmpSessionComplete, SmpSessionComplete,
@ -401,13 +401,13 @@ SmpApiLoop(IN PVOID Parameter)
RequestMsg.ReturnValue = STATUS_PENDING; RequestMsg.ReturnValue = STATUS_PENDING;
/* Check if the API is valid */ /* Check if the API is valid */
if (RequestMsg.ApiNumber >= SmMaxApiNumber) if (RequestMsg.ApiNumber >= SmpMaxApiNumber)
{ {
/* It isn't, fail */ /* It isn't, fail */
DPRINT1("Invalid API: %lx\n", RequestMsg.ApiNumber); DPRINT1("Invalid API: %lx\n", RequestMsg.ApiNumber);
Status = STATUS_NOT_IMPLEMENTED; Status = STATUS_NOT_IMPLEMENTED;
} }
else if ((RequestMsg.ApiNumber <= SmTerminateForeignSessionApi) && else if ((RequestMsg.ApiNumber <= SmpTerminateForeignSessionApi) &&
!(ClientContext->Subsystem)) !(ClientContext->Subsystem))
{ {
/* It's valid, but doesn't have a subsystem with it */ /* It's valid, but doesn't have a subsystem with it */

View file

@ -12,17 +12,6 @@
#include "csrmsg.h" #include "csrmsg.h"
/*
BOOLEAN
NTAPI
CsrCaptureArguments(IN PCSR_THREAD CsrThread,
IN PCSR_API_MESSAGE ApiMessage);
VOID
NTAPI
CsrReleaseCapturedArguments(IN PCSR_API_MESSAGE ApiMessage);
*/
NTSTATUS NTSTATUS
NTAPI NTAPI
CsrClientConnectToServer(IN PWSTR ObjectDirectory, CsrClientConnectToServer(IN PWSTR ObjectDirectory,

View file

@ -107,7 +107,7 @@ typedef struct _CSR_API_MESSAGE
PORT_MESSAGE Header; PORT_MESSAGE Header;
union union
{ {
CSR_CONNECTION_INFO ConnectionInfo; // Uniquely used in csrss/csrsrv for internal signaling (opening a new connection). CSR_CONNECTION_INFO ConnectionInfo; // Uniquely used in CSRSRV for internal signaling (opening a new connection).
struct struct
{ {
PCSR_CAPTURE_BUFFER CsrCaptureData; PCSR_CAPTURE_BUFFER CsrCaptureData;

View file

@ -247,19 +247,6 @@ NTSTATUS
/* PROTOTYPES ****************************************************************/ /* PROTOTYPES ****************************************************************/
///////////
BOOLEAN
NTAPI
CsrCaptureArguments(IN PCSR_THREAD CsrThread,
IN PCSR_API_MESSAGE ApiMessage);
VOID
NTAPI
CsrReleaseCapturedArguments(IN PCSR_API_MESSAGE ApiMessage);
//////////
NTSTATUS NTSTATUS
NTAPI NTAPI
CsrServerInitialization(IN ULONG ArgumentCount, CsrServerInitialization(IN ULONG ArgumentCount,

View file

@ -18,17 +18,21 @@
// in the checked build of SMSS, which is probably a close approximation. We add // in the checked build of SMSS, which is probably a close approximation. We add
// "p" to use the similar nomenclature seen/leaked out in the Base CSRSS APIs. // "p" to use the similar nomenclature seen/leaked out in the Base CSRSS APIs.
// //
// The enumeration finishes with an enumeratee holding the maximum API number.
// Its name is based on BasepMaxApiNumber, UserpMaxApiNumber...
//
// //
typedef enum _SMSRV_API_NUMBER typedef enum _SMSRV_API_NUMBER
{ {
SmCreateForeignSessionApi, SmpCreateForeignSessionApi,
SmSessionCompleteApi, SmpSessionCompleteApi,
SmTerminateForeignSessionApi, SmpTerminateForeignSessionApi,
SmExecPgmApi, SmpExecPgmApi,
SmLoadDeferedSubsystemApi, SmpLoadDeferedSubsystemApi,
SmStartCsrApi, SmpStartCsrApi,
SmStopCsrApi, SmpStopCsrApi,
SmMaxApiNumber // Based on BasepMaxApiNumber, UserpMaxApiNumber...
SmpMaxApiNumber
} SMSRV_API_NUMBER; } SMSRV_API_NUMBER;
// //
@ -108,7 +112,7 @@ C_ASSERT(sizeof(SM_API_MSG) == 0x130);
#endif #endif
// //
// There are the APIs that the SMSS Serve can send to a client (such as CSRSS) // There are the APIs that the SMSS Server can send to a client (such as CSRSS).
// //
// These are called "SB" APIs. // These are called "SB" APIs.
// //
@ -117,6 +121,9 @@ C_ASSERT(sizeof(SM_API_MSG) == 0x130);
// We add "p" to use the similar nomenclature seen/leaked out in the Base CSRSS // We add "p" to use the similar nomenclature seen/leaked out in the Base CSRSS
// APIs. // APIs.
// //
// The enumeration finishes with an enumeratee holding the maximum API number.
// Its name is based on BasepMaxApiNumber, UserpMaxApiNumber...
//
// //
typedef enum _SB_API_NUMBER typedef enum _SB_API_NUMBER
{ {
@ -124,7 +131,8 @@ typedef enum _SB_API_NUMBER
SbpTerminateSession, SbpTerminateSession,
SbpForeignSessionComplete, SbpForeignSessionComplete,
SbpCreateProcess, SbpCreateProcess,
SbpMaxApiNumber // Based on BasepMaxApiNumber, UserpMaxApiNumber...
SbpMaxApiNumber
} SB_API_NUMBER; } SB_API_NUMBER;
// //

View file

@ -38,7 +38,7 @@ SmExecPgm(IN HANDLE SmApiPort,
SmApiMsg.h.u1.s1.TotalLength = sizeof(SmApiMsg); SmApiMsg.h.u1.s1.TotalLength = sizeof(SmApiMsg);
/* Initalize this specific API's parameters */ /* Initalize this specific API's parameters */
SmApiMsg.ApiNumber = SmExecPgmApi; SmApiMsg.ApiNumber = SmpExecPgmApi;
RtlCopyMemory(&SmApiMsg.u.ExecPgm.ProcessInformation, RtlCopyMemory(&SmApiMsg.u.ExecPgm.ProcessInformation,
ProcessInformation, ProcessInformation,
sizeof(SmApiMsg.u.ExecPgm.ProcessInformation)); sizeof(SmApiMsg.u.ExecPgm.ProcessInformation));
@ -144,7 +144,7 @@ SmSessionComplete(IN HANDLE SmApiPort,
SessionComplete->SessionStatus = SessionStatus; SessionComplete->SessionStatus = SessionStatus;
/* Set the API Message Port Message header */ /* Set the API Message Port Message header */
ApiMessage.ApiNumber = SmSessionCompleteApi; ApiMessage.ApiNumber = SmpSessionCompleteApi;
ApiMessage.h.u1.s1.DataLength = sizeof(SM_SESSION_COMPLETE_MSG) + 8; ApiMessage.h.u1.s1.DataLength = sizeof(SM_SESSION_COMPLETE_MSG) + 8;
ApiMessage.h.u1.s1.TotalLength = sizeof(SM_API_MSG); ApiMessage.h.u1.s1.TotalLength = sizeof(SM_API_MSG);
ApiMessage.h.u2.ZeroInit = 0; ApiMessage.h.u2.ZeroInit = 0;

View file

@ -23,7 +23,7 @@ HANDLE BaseSrvSharedHeap = NULL; // Shared heap with CSR. (CsrSrvSharedSectio
PBASE_STATIC_SERVER_DATA BaseStaticServerData = NULL; // Data that we can share amongst processes. Initialized inside BaseSrvSharedHeap. PBASE_STATIC_SERVER_DATA BaseStaticServerData = NULL; // Data that we can share amongst processes. Initialized inside BaseSrvSharedHeap.
// Windows Server 2003 table from http://j00ru.vexillium.org/csrss_list/api_list.html#Windows_2k3 // Windows Server 2003 table from http://j00ru.vexillium.org/csrss_list/api_list.html#Windows_2k3
PCSR_API_ROUTINE BaseServerApiDispatchTable[BasepMaxApiNumber] = PCSR_API_ROUTINE BaseServerApiDispatchTable[BasepMaxApiNumber - BASESRV_FIRST_API_NUMBER] =
{ {
BaseSrvCreateProcess, BaseSrvCreateProcess,
BaseSrvCreateThread, BaseSrvCreateThread,
@ -57,7 +57,7 @@ PCSR_API_ROUTINE BaseServerApiDispatchTable[BasepMaxApiNumber] =
// BaseSrvNlsGetUserInfo, // BaseSrvNlsGetUserInfo,
}; };
BOOLEAN BaseServerApiServerValidTable[BasepMaxApiNumber] = BOOLEAN BaseServerApiServerValidTable[BasepMaxApiNumber - BASESRV_FIRST_API_NUMBER] =
{ {
TRUE, // BaseSrvCreateProcess TRUE, // BaseSrvCreateProcess
TRUE, // BaseSrvCreateThread TRUE, // BaseSrvCreateThread
@ -91,7 +91,7 @@ BOOLEAN BaseServerApiServerValidTable[BasepMaxApiNumber] =
// FALSE, // BaseSrvNlsGetUserInfo // FALSE, // BaseSrvNlsGetUserInfo
}; };
PCHAR BaseServerApiNameTable[BasepMaxApiNumber] = PCHAR BaseServerApiNameTable[BasepMaxApiNumber - BASESRV_FIRST_API_NUMBER] =
{ {
"BaseCreateProcess", "BaseCreateProcess",
"BaseCreateThread", "BaseCreateThread",

View file

@ -269,7 +269,7 @@ CsrpCheckRequestThreads(VOID)
NTSTATUS Status; NTSTATUS Status;
/* Decrease the count, and see if we're out */ /* Decrease the count, and see if we're out */
if (!(_InterlockedDecrement(&CsrpStaticThreadCount))) if (_InterlockedDecrement(&CsrpStaticThreadCount) == 0)
{ {
/* Check if we've still got space for a Dynamic Thread */ /* Check if we've still got space for a Dynamic Thread */
if (CsrpDynamicThreadTotal < CsrMaxApiRequestThreads) if (CsrpDynamicThreadTotal < CsrMaxApiRequestThreads)
@ -879,8 +879,7 @@ CsrApiRequestThread(IN PVOID Parameter)
* *
* @param None * @param None
* *
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
* otherwise.
* *
* @remarks None. * @remarks None.
* *
@ -1010,7 +1009,7 @@ PCSR_THREAD
NTAPI NTAPI
CsrConnectToUser(VOID) CsrConnectToUser(VOID)
{ {
#if 0 // This code is OK, however it is ClientThreadSetup which sucks. #if 0 // FIXME: This code is OK, however it is ClientThreadSetup which sucks.
NTSTATUS Status; NTSTATUS Status;
ANSI_STRING DllName; ANSI_STRING DllName;
UNICODE_STRING TempName; UNICODE_STRING TempName;
@ -1074,7 +1073,9 @@ CsrConnectToUser(VOID)
PCSR_THREAD CsrThread; PCSR_THREAD CsrThread;
/* Save pointer to this thread in TEB */ /* Save pointer to this thread in TEB */
CsrAcquireProcessLock();
CsrThread = CsrLocateThreadInProcess(NULL, &Teb->ClientId); CsrThread = CsrLocateThreadInProcess(NULL, &Teb->ClientId);
CsrReleaseProcessLock();
if (CsrThread) Teb->CsrClientThread = CsrThread; if (CsrThread) Teb->CsrClientThread = CsrThread;
/* Return it */ /* Return it */
@ -1099,7 +1100,6 @@ HANDLE
NTAPI NTAPI
CsrQueryApiPort(VOID) CsrQueryApiPort(VOID)
{ {
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
return CsrApiPort; return CsrApiPort;
} }
@ -1309,7 +1309,6 @@ CsrReleaseCapturedArguments(IN PCSR_API_MESSAGE ApiMessage)
RtlFreeHeap(CsrHeap, 0, RemoteCaptureBuffer); RtlFreeHeap(CsrHeap, 0, RemoteCaptureBuffer);
} }
/*++ /*++
* @name CsrValidateMessageBuffer * @name CsrValidateMessageBuffer
* @implemented NT5.1 * @implemented NT5.1
@ -1404,36 +1403,6 @@ CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage,
return FALSE; return FALSE;
} }
/*** This is what we have in consrv/server.c ***
/\* Ensure that a captured buffer is safe to access *\/
BOOL FASTCALL
Win32CsrValidateBuffer(PCSR_PROCESS ProcessData, PVOID Buffer,
SIZE_T NumElements, SIZE_T ElementSize)
{
/\* Check that the following conditions are true:
* 1. The start of the buffer is somewhere within the process's
* shared memory section view.
* 2. The remaining space in the view is at least as large as the buffer.
* (NB: Please don't try to "optimize" this by using multiplication
* instead of division; remember that 2147483648 * 2 = 0.)
* 3. The buffer is DWORD-aligned.
*\/
ULONG_PTR Offset = (BYTE *)Buffer - (BYTE *)ProcessData->ClientViewBase;
if (Offset >= ProcessData->ClientViewBounds
|| NumElements > (ProcessData->ClientViewBounds - Offset) / ElementSize
|| (Offset & (sizeof(DWORD) - 1)) != 0)
{
DPRINT1("Invalid buffer %p(%u*%u); section view is %p(%u)\n",
Buffer, NumElements, ElementSize,
ProcessData->ClientViewBase, ProcessData->ClientViewBounds);
return FALSE;
}
return TRUE;
}
***********************************************/
/*++ /*++
* @name CsrValidateMessageString * @name CsrValidateMessageString
* @implemented NT5.1 * @implemented NT5.1

View file

@ -64,7 +64,6 @@ extern UNICODE_STRING CsrApiPortName;
extern RTL_CRITICAL_SECTION CsrProcessLock; extern RTL_CRITICAL_SECTION CsrProcessLock;
extern RTL_CRITICAL_SECTION CsrWaitListsLock; extern RTL_CRITICAL_SECTION CsrWaitListsLock;
extern HANDLE CsrObjectDirectory; extern HANDLE CsrObjectDirectory;
extern PSB_API_ROUTINE CsrServerSbApiDispatch[5];
/****************************************************/ /****************************************************/
@ -75,24 +74,19 @@ CSR_API(CsrSrvIdentifyAlertableThread);
CSR_API(CsrSrvSetPriorityClass); CSR_API(CsrSrvSetPriorityClass);
/***
BOOLEAN
NTAPI
CsrCaptureArguments(
IN PCSR_THREAD CsrThread,
IN PCSR_API_MESSAGE ApiMessage
);
VOID
NTAPI
CsrReleaseCapturedArguments(IN PCSR_API_MESSAGE ApiMessage);
NTSTATUS NTSTATUS
NTAPI NTAPI
CsrServerDllInitialization(IN PCSR_SERVER_DLL LoadedServerDll); CsrServerDllInitialization(IN PCSR_SERVER_DLL LoadedServerDll);
***/
BOOLEAN
NTAPI
CsrCaptureArguments(IN PCSR_THREAD CsrThread,
IN PCSR_API_MESSAGE ApiMessage);
VOID
NTAPI
CsrReleaseCapturedArguments(IN PCSR_API_MESSAGE ApiMessage);
NTSTATUS NTSTATUS
NTAPI NTAPI
@ -113,18 +107,18 @@ VOID
NTAPI NTAPI
CsrDeallocateProcess(IN PCSR_PROCESS CsrProcess); CsrDeallocateProcess(IN PCSR_PROCESS CsrProcess);
VOID
NTAPI
CsrRemoveProcess(IN PCSR_PROCESS CsrProcess);
VOID VOID
NTAPI NTAPI
CsrInsertProcess(IN PCSR_PROCESS ParentProcess OPTIONAL, CsrInsertProcess(IN PCSR_PROCESS ParentProcess OPTIONAL,
IN PCSR_PROCESS CsrProcess); IN PCSR_PROCESS CsrProcess);
VOID
NTAPI
CsrRemoveProcess(IN PCSR_PROCESS CsrProcess);
NTSTATUS NTSTATUS
NTAPI NTAPI
CsrApiRequestThread(IN PVOID Parameter); // HANDLE ServerPort ?? CsrApiRequestThread(IN PVOID Parameter);
VOID VOID
NTAPI NTAPI

View file

@ -48,8 +48,7 @@ SYSTEM_BASIC_INFORMATION CsrNtSysInfo;
* *
* @param None. * @param None.
* *
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
* otherwise.
* *
* @remarks None. * @remarks None.
* *
@ -163,8 +162,7 @@ Quickie:
* @param ObjectDirectory * @param ObjectDirectory
* Handle fo the Object Directory to protect. * Handle fo the Object Directory to protect.
* *
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
* otherwise.
* *
* @remarks None. * @remarks None.
* *
@ -186,8 +184,7 @@ CsrSetDirectorySecurity(IN HANDLE ObjectDirectory)
* @param DosDevicesSd * @param DosDevicesSd
* Pointer to the Security Descriptor to return. * Pointer to the Security Descriptor to return.
* *
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
* otherwise.
* *
* @remarks Depending on the DOS Devices Protection Mode (set in the registry), * @remarks Depending on the DOS Devices Protection Mode (set in the registry),
* regular users may or may not have full access to the directory. * regular users may or may not have full access to the directory.
@ -403,8 +400,7 @@ FreeDosDevicesProtection(IN PSECURITY_DESCRIPTOR DosDevicesSd)
* @param Session * @param Session
* Session ID for which to create the directories. * Session ID for which to create the directories.
* *
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
* otherwise.
* *
* @remarks None. * @remarks None.
* *
@ -534,8 +530,7 @@ CsrCreateSessionObjectDirectory(IN ULONG Session)
* @param Arguments * @param Arguments
* Array of arguments. * Array of arguments.
* *
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
* otherwise.
* *
* @remarks None. * @remarks None.
* *
@ -714,8 +709,7 @@ CsrParseServerCommandLine(IN ULONG ArgumentCount,
* *
* @param None. * @param None.
* *
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
* otherwise.
* *
* @remarks None. * @remarks None.
* *
@ -777,7 +771,6 @@ CsrInitCsrRootProcess(VOID)
if (ServerDll && ServerDll->NewProcessCallback) if (ServerDll && ServerDll->NewProcessCallback)
{ {
/* Call the callback */ /* Call the callback */
DPRINT1("Call NewProcessCallback(NULL, 0x%p) called\n", CsrRootProcess);
ServerDll->NewProcessCallback(NULL, CsrRootProcess); ServerDll->NewProcessCallback(NULL, CsrRootProcess);
} }
} }
@ -794,8 +787,7 @@ CsrInitCsrRootProcess(VOID)
* @param LocalSystemSd * @param LocalSystemSd
* Pointer to a pointer to the security descriptor to create. * Pointer to a pointer to the security descriptor to create.
* *
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
* otherwise.
* *
* @remarks None. * @remarks None.
* *
@ -871,8 +863,7 @@ CsrCreateLocalSystemSD(OUT PSECURITY_DESCRIPTOR *LocalSystemSd)
* *
* @param None * @param None
* *
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
* otherwise.
* *
* @remarks None. * @remarks None.
* *
@ -960,7 +951,7 @@ CsrSbApiPortInitialize(VOID)
* @implemented NT4 * @implemented NT4
* *
* The CsrServerInitialization routine is the native (not Server) entrypoint * The CsrServerInitialization routine is the native (not Server) entrypoint
* of this Server DLL. It serves as the entrypoint for csrss. * of this Server DLL. It serves as the entrypoint for CSRSS.
* *
* @param ArgumentCount * @param ArgumentCount
* Number of arguments on the command line. * Number of arguments on the command line.
@ -968,8 +959,7 @@ CsrSbApiPortInitialize(VOID)
* @param Arguments * @param Arguments
* Array of arguments from the command line. * Array of arguments from the command line.
* *
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
* otherwise.
* *
* @remarks None. * @remarks None.
* *
@ -980,7 +970,6 @@ CsrServerInitialization(IN ULONG ArgumentCount,
IN PCHAR Arguments[]) IN PCHAR Arguments[])
{ {
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
/* Create the Init Event */ /* Create the Init Event */
Status = NtCreateEvent(&CsrInitializationEvent, Status = NtCreateEvent(&CsrInitializationEvent,

View file

@ -41,7 +41,7 @@ extern ULONG CsrTotalPerProcessDataLength;
* *
* @return None. * @return None.
* *
* @remarks The "Normal" Priority corresponds to the Normal Forground * @remarks The "Normal" Priority corresponds to the Normal Foreground
* Priority (9) plus a boost of 4. * Priority (9) plus a boost of 4.
* *
*--*/ *--*/
@ -69,7 +69,7 @@ CsrSetToNormalPriority(VOID)
* *
* @return None. * @return None.
* *
* @remarks The "Shutdown" Priority corresponds to the Normal Forground * @remarks The "Shutdown" Priority corresponds to the Normal Foreground
* Priority (9) plus a boost of 6. * Priority (9) plus a boost of 6.
* *
*--*/ *--*/
@ -264,7 +264,7 @@ CsrLockedDereferenceProcess(PCSR_PROCESS CsrProcess)
/* Decrease reference count */ /* Decrease reference count */
LockCount = --CsrProcess->ReferenceCount; LockCount = --CsrProcess->ReferenceCount;
ASSERT(LockCount >= 0); ASSERT(LockCount >= 0);
if (!LockCount) if (LockCount == 0)
{ {
/* Call the generic cleanup code */ /* Call the generic cleanup code */
DPRINT1("Should kill process: %p\n", CsrProcess); DPRINT1("Should kill process: %p\n", CsrProcess);
@ -345,8 +345,7 @@ CsrLockedReferenceProcess(IN PCSR_PROCESS CsrProcess)
* *
* @param None. * @param None.
* *
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
* otherwise.
* *
* @remarks None. * @remarks None.
* *
@ -495,18 +494,25 @@ CsrInsertProcess(IN PCSR_PROCESS ParentProcess OPTIONAL,
* @name CsrCreateProcess * @name CsrCreateProcess
* @implemented NT4 * @implemented NT4
* *
* Do nothing for 500ms. * The CsrCreateProcess routine creates a CSR Process object for an NT Process.
* *
* @param ArgumentCount * @param hProcess
* Description of the parameter. Wrapped to more lines on ~70th * Handle to an existing NT Process to which to associate this
* column. * CSR Process.
* *
* @param Arguments * @param hThread
* Description of the parameter. Wrapped to more lines on ~70th * Handle to an existing NT Thread to which to create its
* column. * corresponding CSR Thread for this CSR Process.
* *
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL * @param ClientId
* otherwise. * Pointer to the Client ID structure of the NT Process to associate
* with this CSR Process.
*
* @param NtSession
* @param Flags
* @param DebugCid
*
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
* *
* @remarks None. * @remarks None.
* *
@ -597,7 +603,7 @@ CsrCreateProcess(IN HANDLE hProcess,
} }
/* Check if CreateProcess got CREATE_NEW_PROCESS_GROUP */ /* Check if CreateProcess got CREATE_NEW_PROCESS_GROUP */
if (!(Flags & CsrProcessCreateNewGroup)) if ((Flags & CsrProcessCreateNewGroup) == 0)
{ {
/* Create new data */ /* Create new data */
CsrProcess->ProcessGroupId = HandleToUlong(ClientId->UniqueProcess); CsrProcess->ProcessGroupId = HandleToUlong(ClientId->UniqueProcess);
@ -781,7 +787,7 @@ CsrDereferenceProcess(IN PCSR_PROCESS CsrProcess)
/* Decrease reference count */ /* Decrease reference count */
LockCount = --CsrProcess->ReferenceCount; LockCount = --CsrProcess->ReferenceCount;
ASSERT(LockCount >= 0); ASSERT(LockCount >= 0);
if (!LockCount) if (LockCount == 0)
{ {
/* Call the generic cleanup code */ /* Call the generic cleanup code */
CsrProcessRefcountZero(CsrProcess); CsrProcessRefcountZero(CsrProcess);
@ -891,16 +897,15 @@ CsrDestroyProcess(IN PCLIENT_ID Cid,
* @name CsrGetProcessLuid * @name CsrGetProcessLuid
* @implemented NT4 * @implemented NT4
* *
* Do nothing for 500ms. * The CsrGetProcessLuid routine gets the LUID of the given process.
* *
* @param hProcess * @param hProcess
* Optional handle to the process whose LUID should be returned. * Optional handle to the process whose LUID should be returned.
* *
* @param Luid * @param Luid
* Pointer to a LUID Pointer which will receive the CSR Process' LUID * Pointer to a LUID Pointer which will receive the CSR Process' LUID.
* *
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
* otherwise.
* *
* @remarks If hProcess is not supplied, then the current thread's token will * @remarks If hProcess is not supplied, then the current thread's token will
* be used. If that too is missing, then the current process' token * be used. If that too is missing, then the current process' token
@ -1000,7 +1005,7 @@ CsrGetProcessLuid(IN HANDLE hProcess OPTIONAL,
* @param CsrThread * @param CsrThread
* Pointer to the CSR Thread to impersonate. * Pointer to the CSR Thread to impersonate.
* *
* @return TRUE if impersonation succeeded, false otherwise. * @return TRUE if impersonation succeeded, FALSE otherwise.
* *
* @remarks Impersonation can be recursive. * @remarks Impersonation can be recursive.
* *
@ -1030,10 +1035,8 @@ CsrImpersonateClient(IN PCSR_THREAD CsrThread)
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
/* Failure */ /* Failure */
/*
DPRINT1("CSRSS: Can't impersonate client thread - Status = %lx\n", Status); DPRINT1("CSRSS: Can't impersonate client thread - Status = %lx\n", Status);
if (Status != STATUS_BAD_IMPERSONATION_LEVEL) DbgBreakPoint(); // if (Status != STATUS_BAD_IMPERSONATION_LEVEL) DbgBreakPoint();
*/
return FALSE; return FALSE;
} }
@ -1058,8 +1061,7 @@ CsrImpersonateClient(IN PCSR_THREAD CsrThread)
* Optional pointer to a CSR Process pointer which will hold the * Optional pointer to a CSR Process pointer which will hold the
* CSR Process corresponding to the given Process ID. * CSR Process corresponding to the given Process ID.
* *
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
* otherwise.
* *
* @remarks Locking a CSR Process is defined as acquiring an extra * @remarks Locking a CSR Process is defined as acquiring an extra
* reference to it and returning with the Process Lock held. * reference to it and returning with the Process Lock held.
@ -1124,7 +1126,7 @@ CsrLockProcessByClientId(IN HANDLE Pid,
* *
* @param None. * @param None.
* *
* @return TRUE if the reversion was succesful, false otherwise. * @return TRUE if the reversion was succesful, FALSE otherwise.
* *
* @remarks Impersonation can be recursive; as such, the impersonation token * @remarks Impersonation can be recursive; as such, the impersonation token
* will only be deleted once the CSR Thread's impersonaton count * will only be deleted once the CSR Thread's impersonaton count
@ -1145,11 +1147,11 @@ CsrRevertToSelf(VOID)
/* Make sure impersonation is on */ /* Make sure impersonation is on */
if (!CurrentThread->ImpersonationCount) if (!CurrentThread->ImpersonationCount)
{ {
// DPRINT1("CSRSS: CsrRevertToSelf called while not impersonating\n"); DPRINT1("CSRSS: CsrRevertToSelf called while not impersonating\n");
// DbgBreakPoint(); // DbgBreakPoint();
return FALSE; return FALSE;
} }
else if (--CurrentThread->ImpersonationCount > 0) else if ((--CurrentThread->ImpersonationCount) > 0)
{ {
/* Success; impersonation count decreased but still not zero */ /* Success; impersonation count decreased but still not zero */
return TRUE; return TRUE;
@ -1242,8 +1244,7 @@ CsrSetForegroundPriority(IN PCSR_PROCESS CsrProcess)
* @param Flags * @param Flags
* Flags to send to the shutdown notification routine. * Flags to send to the shutdown notification routine.
* *
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
* otherwise.
* *
* @remarks None. * @remarks None.
* *

View file

@ -55,8 +55,8 @@ HANDLE CsrSrvSharedSection = NULL;
* @name CsrServerDllInitialization * @name CsrServerDllInitialization
* @implemented NT4 * @implemented NT4
* *
* The CsrServerDllInitialization is the initialization routine for * The CsrServerDllInitialization is the initialization routine
* the this Server DLL. * for this Server DLL.
* *
* @param LoadedServerDll * @param LoadedServerDll
* Pointer to the CSR Server DLL structure representing this Server DLL. * Pointer to the CSR Server DLL structure representing this Server DLL.
@ -86,18 +86,17 @@ CSR_SERVER_DLL_INIT(CsrServerDllInitialization)
* @name CsrLoadServerDll * @name CsrLoadServerDll
* @implemented NT4 * @implemented NT4
* *
* The CsrLoadServerDll routine loads a CSR Server DLL and calls its entrypoint * The CsrLoadServerDll routine loads a CSR Server DLL and calls its entrypoint.
* *
* @param DllString * @param DllString
* Pointer to the CSR Server DLL to load and call. * Pointer to the CSR Server DLL to load and call.
* *
* @param EntryPoint * @param EntryPoint
* Pointer to the name of the server's initialization function. If * Pointer to the name of the server's initialization function.
* this parameter is NULL, the default ServerDllInitialize will be * If this parameter is NULL, the default ServerDllInitialize
* assumed. * will be assumed.
* *
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
* otherwise.
* *
* @remarks None. * @remarks None.
* *
@ -119,8 +118,6 @@ CsrLoadServerDll(IN PCHAR DllString,
PCSR_SERVER_DLL_INIT_CALLBACK ServerDllInitProcedure; PCSR_SERVER_DLL_INIT_CALLBACK ServerDllInitProcedure;
ULONG Response; ULONG Response;
DPRINT1("CsrLoadServerDll(%s, 0x%p, %lu)\n", DllString, EntryPoint, ServerId);
/* Check if it's beyond the maximum we support */ /* Check if it's beyond the maximum we support */
if (ServerId >= CSR_SERVER_DLL_MAX) return STATUS_TOO_MANY_NAMES; if (ServerId >= CSR_SERVER_DLL_MAX) return STATUS_TOO_MANY_NAMES;
@ -225,15 +222,10 @@ CsrLoadServerDll(IN PCHAR DllString,
CsrSrvSharedStaticServerData[ServerDll->ServerId] = ServerDll->SharedSection; CsrSrvSharedStaticServerData[ServerDll->ServerId] = ServerDll->SharedSection;
} }
} }
else
{
/* Use shared failure code */
goto LoadFailed;
} }
}
else if (!NT_SUCCESS(Status))
{ {
LoadFailed:
/* Server Init failed, unload it */ /* Server Init failed, unload it */
if (hServerDll) LdrUnloadDll(hServerDll); if (hServerDll) LdrUnloadDll(hServerDll);
@ -316,15 +308,14 @@ CSR_API(CsrSrvClientConnect)
/*++ /*++
* @name CsrSrvCreateSharedSection * @name CsrSrvCreateSharedSection
* *
* The CsrSrvCreateSharedSection creates the Shared Section that all CSR Server * The CsrSrvCreateSharedSection creates the Shared Section that all
* DLLs and Clients can use to share data. * CSR Server DLLs and Clients can use to share data.
* *
* @param ParameterValue * @param ParameterValue
* Specially formatted string from our registry command-line which * Specially formatted string from our registry command-line which
* specifies various arguments for the shared section. * specifies various arguments for the shared section.
* *
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
* otherwise.
* *
* @remarks None. * @remarks None.
* *
@ -445,8 +436,7 @@ CsrSrvCreateSharedSection(IN PCHAR ParameterValue)
* Pointer to the CSR Connection Info structure for the incoming * Pointer to the CSR Connection Info structure for the incoming
* connection. * connection.
* *
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
* otherwise.
* *
* @remarks None. * @remarks None.
* *
@ -463,7 +453,6 @@ CsrSrvAttachSharedSection(IN PCSR_PROCESS CsrProcess OPTIONAL,
if (CsrProcess) if (CsrProcess)
{ {
/* Map the section into this process */ /* Map the section into this process */
DPRINT("CSR Process Handle: %p. CSR Process: %p\n", CsrProcess->ProcessHandle, CsrProcess);
Status = NtMapViewOfSection(CsrSrvSharedSection, Status = NtMapViewOfSection(CsrSrvSharedSection,
CsrProcess->ProcessHandle, CsrProcess->ProcessHandle,
&CsrSrvSharedSectionBase, &CsrSrvSharedSectionBase,
@ -553,8 +542,8 @@ CSR_API(CsrSrvSetPriorityClass)
* *
* @return STATUS_INVALID_PARAMETER. * @return STATUS_INVALID_PARAMETER.
* *
* @remarks CsrSrvSetPriorityClass does not use this stub because it must * @remarks CsrSrvSetPriorityClass does not use this stub because
* return success. * it must return success.
* *
*--*/ *--*/
CSR_API(CsrSrvUnusedFunction) CSR_API(CsrSrvUnusedFunction)
@ -621,12 +610,12 @@ CsrUnhandledExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo)
NULL); NULL);
/* Check if this is Session 0, and the Debugger is Enabled */ /* Check if this is Session 0, and the Debugger is Enabled */
if ((NtCurrentPeb()->SessionId) && (NT_SUCCESS(Status)) && if ((NtCurrentPeb()->SessionId != 0) && (NT_SUCCESS(Status)) &&
(DebuggerInfo.KernelDebuggerEnabled)) (DebuggerInfo.KernelDebuggerEnabled))
{ {
/* Call the Unhandled Exception Filter */ /* Call the Unhandled Exception Filter */
if ((Result = RtlUnhandledExceptionFilter(ExceptionInfo)) != Result = RtlUnhandledExceptionFilter(ExceptionInfo);
EXCEPTION_CONTINUE_EXECUTION) if (Result != EXCEPTION_CONTINUE_EXECUTION)
{ {
/* We're going to raise an error. Get Shutdown Privilege first */ /* We're going to raise an error. Get Shutdown Privilege first */
Status = RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, Status = RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE,

View file

@ -18,23 +18,20 @@
RTL_CRITICAL_SECTION CsrNtSessionLock; RTL_CRITICAL_SECTION CsrNtSessionLock;
LIST_ENTRY CsrNtSessionList; LIST_ENTRY CsrNtSessionList;
// Does it exist a enumeration associated with it ? PSB_API_ROUTINE CsrServerSbApiDispatch[SbpMaxApiNumber - SbpCreateSession] =
PSB_API_ROUTINE CsrServerSbApiDispatch[5] =
{ {
CsrSbCreateSession, CsrSbCreateSession,
CsrSbTerminateSession, CsrSbTerminateSession,
CsrSbForeignSessionComplete, CsrSbForeignSessionComplete,
CsrSbCreateProcess, CsrSbCreateProcess
NULL
}; };
PCHAR CsrServerSbApiName[5] = PCHAR CsrServerSbApiName[SbpMaxApiNumber - SbpCreateSession] =
{ {
"SbCreateSession", "SbCreateSession",
"SbTerminateSession", "SbTerminateSession",
"SbForeignSessionComplete", "SbForeignSessionComplete",
"SbCreateProcess", "SbCreateProcess"
"Unknown Csr Sb Api Number"
}; };
/* PRIVATE FUNCTIONS **********************************************************/ /* PRIVATE FUNCTIONS **********************************************************/
@ -55,8 +52,6 @@ NTSTATUS
NTAPI NTAPI
CsrInitializeNtSessionList(VOID) CsrInitializeNtSessionList(VOID)
{ {
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
/* Initialize the Session List */ /* Initialize the Session List */
InitializeListHead(&CsrNtSessionList); InitializeListHead(&CsrNtSessionList);
@ -170,7 +165,7 @@ CsrDereferenceNtSession(IN PCSR_NT_SESSION Session,
ASSERT(Session->ReferenceCount != 0); ASSERT(Session->ReferenceCount != 0);
/* Dereference the Session Object */ /* Dereference the Session Object */
if (!(--Session->ReferenceCount)) if ((--Session->ReferenceCount) == 0)
{ {
/* Remove it from the list */ /* Remove it from the list */
RemoveEntryList(&Session->SessionLink); RemoveEntryList(&Session->SessionLink);
@ -537,8 +532,8 @@ CsrSbApiRequestThread(IN PVOID Parameter)
} }
/* /*
* It's an API Message, check if it's within limits. If it's not, the * It's an API Message, check if it's within limits. If it's not,
* NT Behaviour is to set this to the Maximum API. * the NT Behaviour is to set this to the Maximum API.
*/ */
if (ReceiveMsg.ApiNumber > SbpMaxApiNumber) if (ReceiveMsg.ApiNumber > SbpMaxApiNumber)
{ {
@ -555,6 +550,9 @@ CsrSbApiRequestThread(IN PVOID Parameter)
/* Call the API */ /* Call the API */
if (!CsrServerSbApiDispatch[ReceiveMsg.ApiNumber](&ReceiveMsg)) if (!CsrServerSbApiDispatch[ReceiveMsg.ApiNumber](&ReceiveMsg))
{ {
DPRINT1("CSRSS: %s Session Api called and failed\n",
CsrServerSbApiName[ReceiveMsg.ApiNumber]);
/* It failed, so return nothing */ /* It failed, so return nothing */
ReplyMsg = NULL; ReplyMsg = NULL;
} }

View file

@ -14,8 +14,7 @@
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
#define CsrHashThread(t) \ #define CsrHashThread(t) (HandleToUlong(t)&(256 - 1))
(HandleToUlong(t)&(256 - 1))
/* GLOBALS ********************************************************************/ /* GLOBALS ********************************************************************/
@ -215,7 +214,6 @@ CsrLocateThreadByClientId(OUT PCSR_PROCESS *Process OPTIONAL,
if (Process) *Process = FoundThread->Process; if (Process) *Process = FoundThread->Process;
/* Return thread too */ /* Return thread too */
// DPRINT1("Found: %p %p\n", FoundThread, FoundThread->Process);
return FoundThread; return FoundThread;
} }
} }
@ -257,7 +255,6 @@ CsrLocateThreadInProcess(IN PCSR_PROCESS CsrProcess OPTIONAL,
if (!CsrProcess) CsrProcess = CsrRootProcess; if (!CsrProcess) CsrProcess = CsrRootProcess;
/* Save the List pointers */ /* Save the List pointers */
// DPRINT1("Searching in: %p %d\n", CsrProcess, CsrProcess->ThreadCount);
ListHead = &CsrProcess->ThreadList; ListHead = &CsrProcess->ThreadList;
NextEntry = ListHead->Flink; NextEntry = ListHead->Flink;
@ -275,7 +272,6 @@ CsrLocateThreadInProcess(IN PCSR_PROCESS CsrProcess OPTIONAL,
} }
/* Return what we found */ /* Return what we found */
// DPRINT1("Found: %p\n", FoundThread);
return FoundThread; return FoundThread;
} }
@ -312,7 +308,6 @@ CsrInsertThread(IN PCSR_PROCESS Process,
/* Hash the Thread */ /* Hash the Thread */
i = CsrHashThread(Thread->ClientId.UniqueThread); i = CsrHashThread(Thread->ClientId.UniqueThread);
// DPRINT1("TID %lx HASH: %lx\n", Thread->ClientId.UniqueThread, i);
/* Insert it there too */ /* Insert it there too */
InsertHeadList(&CsrThreadHashTable[i], &Thread->HashLinks); InsertHeadList(&CsrThreadHashTable[i], &Thread->HashLinks);
@ -377,10 +372,10 @@ CsrRemoveThread(IN PCSR_THREAD CsrThread)
if (CsrThread->HashLinks.Flink) RemoveEntryList(&CsrThread->HashLinks); if (CsrThread->HashLinks.Flink) RemoveEntryList(&CsrThread->HashLinks);
/* Check if this is the last Thread */ /* Check if this is the last Thread */
if (!CsrThread->Process->ThreadCount) if (CsrThread->Process->ThreadCount == 0)
{ {
/* Check if it's not already been marked for deletion */ /* Check if it's not already been marked for deletion */
if (!(CsrThread->Process->Flags & CsrProcessLastThreadTerminated)) if ((CsrThread->Process->Flags & CsrProcessLastThreadTerminated) == 0)
{ {
/* Let everyone know this process is about to lose the thread */ /* Let everyone know this process is about to lose the thread */
CsrThread->Process->Flags |= CsrProcessLastThreadTerminated; CsrThread->Process->Flags |= CsrProcessLastThreadTerminated;
@ -464,7 +459,7 @@ CsrLockedDereferenceThread(IN PCSR_THREAD CsrThread)
/* Decrease reference count */ /* Decrease reference count */
LockCount = --CsrThread->ReferenceCount; LockCount = --CsrThread->ReferenceCount;
ASSERT(LockCount >= 0); ASSERT(LockCount >= 0);
if (!LockCount) if (LockCount == 0)
{ {
/* Call the generic cleanup code */ /* Call the generic cleanup code */
CsrAcquireProcessLock(); CsrAcquireProcessLock();
@ -551,8 +546,7 @@ CsrAddStaticServerThread(IN HANDLE hThread,
* Pointer to the Client ID structure of the NT Thread to associate * Pointer to the Client ID structure of the NT Thread to associate
* with this CSR Thread. * with this CSR Thread.
* *
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
* otherwise.
* *
* @remarks None. * @remarks None.
* *
@ -567,7 +561,6 @@ CsrCreateRemoteThread(IN HANDLE hThread,
PCSR_THREAD CsrThread; PCSR_THREAD CsrThread;
PCSR_PROCESS CsrProcess; PCSR_PROCESS CsrProcess;
KERNEL_USER_TIMES KernelTimes; KERNEL_USER_TIMES KernelTimes;
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
/* Get the Thread Create Time */ /* Get the Thread Create Time */
Status = NtQueryInformationThread(hThread, Status = NtQueryInformationThread(hThread,
@ -654,8 +647,7 @@ CsrCreateRemoteThread(IN HANDLE hThread,
* Pointer to the Client ID structure of the NT Thread to associate * Pointer to the Client ID structure of the NT Thread to associate
* with this CSR Thread. * with this CSR Thread.
* *
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
* otherwise.
* *
* @remarks None. * @remarks None.
* *
@ -673,8 +665,6 @@ CsrCreateThread(IN PCSR_PROCESS CsrProcess,
CLIENT_ID CurrentCid; CLIENT_ID CurrentCid;
KERNEL_USER_TIMES KernelTimes; KERNEL_USER_TIMES KernelTimes;
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
if (HaveClient) if (HaveClient)
{ {
/* Get the current thread and CID */ /* Get the current thread and CID */
@ -762,7 +752,7 @@ CsrDereferenceThread(IN PCSR_THREAD CsrThread)
/* Decrease reference count */ /* Decrease reference count */
ASSERT(CsrThread->ReferenceCount > 0); ASSERT(CsrThread->ReferenceCount > 0);
if (!(--CsrThread->ReferenceCount)) if ((--CsrThread->ReferenceCount) == 0)
{ {
/* Call the generic cleanup code */ /* Call the generic cleanup code */
CsrThreadRefcountZero(CsrThread); CsrThreadRefcountZero(CsrThread);
@ -807,7 +797,7 @@ CsrDestroyThread(IN PCLIENT_ID Cid)
&ClientId); &ClientId);
/* Make sure we got one back, and that it's not already gone */ /* Make sure we got one back, and that it's not already gone */
if (!CsrThread || CsrThread->Flags & CsrThreadTerminated) if (!CsrThread || (CsrThread->Flags & CsrThreadTerminated))
{ {
/* Release the lock and return failure */ /* Release the lock and return failure */
CsrReleaseProcessLock(); CsrReleaseProcessLock();
@ -856,8 +846,7 @@ CsrDestroyThread(IN PCLIENT_ID Cid)
* @param Flags * @param Flags
* Initial CSR Thread Flags to set to the CSR Thread. * Initial CSR Thread Flags to set to the CSR Thread.
* *
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
* otherwise.
* *
* @remarks This routine is similar to CsrAddStaticServerThread, but it * @remarks This routine is similar to CsrAddStaticServerThread, but it
* also creates an NT Thread instead of expecting one to already * also creates an NT Thread instead of expecting one to already
@ -937,8 +926,7 @@ CsrExecServerThread(IN PVOID ThreadHandler,
* Optional pointer to a CSR Thread pointer which will hold the * Optional pointer to a CSR Thread pointer which will hold the
* CSR Thread corresponding to the given Thread ID. * CSR Thread corresponding to the given Thread ID.
* *
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL * @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
* otherwise.
* *
* @remarks Locking a CSR Thread is defined as acquiring an extra * @remarks Locking a CSR Thread is defined as acquiring an extra
* reference to it and returning with the Process Lock held. * reference to it and returning with the Process Lock held.
@ -975,7 +963,7 @@ CsrLockThreadByClientId(IN HANDLE Tid,
/* Check for PID Match */ /* Check for PID Match */
if ((CurrentThread->ClientId.UniqueThread == Tid) && if ((CurrentThread->ClientId.UniqueThread == Tid) &&
!(CurrentThread->Flags & CsrThreadTerminated)) (CurrentThread->Flags & CsrThreadTerminated) == 0)
{ {
/* Get out of here */ /* Get out of here */
break; break;

View file

@ -666,7 +666,6 @@ ConSrvConnect(IN PCSR_PROCESS CsrProcess,
/* If we don't need a console, then get out of here */ /* If we don't need a console, then get out of here */
if (!ConnectInfo->ConsoleNeeded || !ProcessData->ConsoleApp) // In fact, it is for GUI apps. if (!ConnectInfo->ConsoleNeeded || !ProcessData->ConsoleApp) // In fact, it is for GUI apps.
{ {
DPRINT("ConSrvConnect - No console needed\n");
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }

View file

@ -23,7 +23,7 @@ HANDLE ConSrvHeap = NULL; // Our own heap.
// Windows Server 2003 table from http://j00ru.vexillium.org/csrss_list/api_list.html#Windows_2k3 // Windows Server 2003 table from http://j00ru.vexillium.org/csrss_list/api_list.html#Windows_2k3
// plus a little bit of Windows 7. // plus a little bit of Windows 7.
PCSR_API_ROUTINE ConsoleServerApiDispatchTable[ConsolepMaxApiNumber] = PCSR_API_ROUTINE ConsoleServerApiDispatchTable[ConsolepMaxApiNumber - CONSRV_FIRST_API_NUMBER] =
{ {
SrvOpenConsole, SrvOpenConsole,
SrvGetConsoleInput, SrvGetConsoleInput,
@ -114,7 +114,7 @@ PCSR_API_ROUTINE ConsoleServerApiDispatchTable[ConsolepMaxApiNumber] =
SrvSetConsoleHistory, SrvSetConsoleHistory,
}; };
BOOLEAN ConsoleServerApiServerValidTable[ConsolepMaxApiNumber] = BOOLEAN ConsoleServerApiServerValidTable[ConsolepMaxApiNumber - CONSRV_FIRST_API_NUMBER] =
{ {
FALSE, // SrvOpenConsole, FALSE, // SrvOpenConsole,
FALSE, // SrvGetConsoleInput, FALSE, // SrvGetConsoleInput,
@ -205,7 +205,7 @@ BOOLEAN ConsoleServerApiServerValidTable[ConsolepMaxApiNumber] =
FALSE, // SrvSetConsoleHistory FALSE, // SrvSetConsoleHistory
}; };
PCHAR ConsoleServerApiNameTable[ConsolepMaxApiNumber] = PCHAR ConsoleServerApiNameTable[ConsolepMaxApiNumber - CONSRV_FIRST_API_NUMBER] =
{ {
"OpenConsole", "OpenConsole",
"GetConsoleInput", "GetConsoleInput",

View file

@ -22,7 +22,7 @@ HINSTANCE UserServerDllInstance = NULL;
HANDLE UserServerHeap = NULL; // Our own heap. HANDLE UserServerHeap = NULL; // Our own heap.
// Windows Server 2003 table from http://j00ru.vexillium.org/csrss_list/api_list.html#Windows_2k3 // Windows Server 2003 table from http://j00ru.vexillium.org/csrss_list/api_list.html#Windows_2k3
PCSR_API_ROUTINE UserServerApiDispatchTable[UserpMaxApiNumber] = PCSR_API_ROUTINE UserServerApiDispatchTable[UserpMaxApiNumber - USERSRV_FIRST_API_NUMBER] =
{ {
SrvExitWindowsEx, SrvExitWindowsEx,
// SrvEndTask, // SrvEndTask,
@ -39,7 +39,7 @@ PCSR_API_ROUTINE UserServerApiDispatchTable[UserpMaxApiNumber] =
// SrvGetSetShutdownBlockReason, // Added in Vista // SrvGetSetShutdownBlockReason, // Added in Vista
}; };
BOOLEAN UserServerApiServerValidTable[UserpMaxApiNumber] = BOOLEAN UserServerApiServerValidTable[UserpMaxApiNumber - USERSRV_FIRST_API_NUMBER] =
{ {
FALSE, // SrvExitWindowsEx FALSE, // SrvExitWindowsEx
// FALSE, // SrvEndTask // FALSE, // SrvEndTask
@ -56,7 +56,7 @@ BOOLEAN UserServerApiServerValidTable[UserpMaxApiNumber] =
// FALSE, // SrvGetSetShutdownBlockReason // FALSE, // SrvGetSetShutdownBlockReason
}; };
PCHAR UserServerApiNameTable[UserpMaxApiNumber] = PCHAR UserServerApiNameTable[UserpMaxApiNumber - USERSRV_FIRST_API_NUMBER] =
{ {
"SrvExitWindowsEx", "SrvExitWindowsEx",
// "SrvEndTask", // "SrvEndTask",