summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
24087a3)
- Correct a misspelling 'CsrThreadAltertable' -> 'CsrThreadAlertable'.
- Introduce CSR_REPLY_CODEs instead of using hardcoded values, and use them with CSR_API_ROUTINE-type functions. They correspond to which decision CSRSRV should take after a server function is called: answer to the client or not, and perform according tasks.
[BASESRV]
Use CSR_REPLY_CODEs.
svn path=/branches/ros-csrss/; revision=57801
-/* TYPES **********************************************************************/
+
+/* STRUCTURES *****************************************************************/
// Used in ntdll/csr/connect.c
#define CSR_CSRSS_SECTION_SIZE 65536
// Used in ntdll/csr/connect.c
#define CSR_CSRSS_SECTION_SIZE 65536
typedef enum _CSR_THREAD_FLAGS
{
typedef enum _CSR_THREAD_FLAGS
{
- CsrThreadAltertable = 0x1,
+ CsrThreadAlertable = 0x1,
CsrThreadInTermination = 0x2,
CsrThreadTerminated = 0x4,
CsrThreadIsServerThread = 0x10
CsrThreadInTermination = 0x2,
CsrThreadTerminated = 0x4,
CsrThreadIsServerThread = 0x10
CsrDebugProcessChildren = 2
} CSR_PROCESS_DEBUG_FLAGS, *PCSR_PROCESS_DEBUG_FLAGS;
CsrDebugProcessChildren = 2
} CSR_PROCESS_DEBUG_FLAGS, *PCSR_PROCESS_DEBUG_FLAGS;
+typedef enum _CSR_REPLY_CODE
+{
+ CsrReplyImmediately = 0,
+ CsrReplyPending = 1,
+ CsrReplyDeadClient = 2,
+ CsrReplyAlreadyDone = 3
+} CSR_REPLY_CODE, *PCSR_REPLY_CODE;
+
+
+/* FUNCTION TYPES AND STRUCTURES **********************************************/
NTSTATUS
(NTAPI *PCSR_API_ROUTINE)(
IN OUT PCSR_API_MESSAGE ApiMessage,
NTSTATUS
(NTAPI *PCSR_API_ROUTINE)(
IN OUT PCSR_API_MESSAGE ApiMessage,
+ IN OUT PCSR_REPLY_CODE ReplyCode OPTIONAL
);
#define CSR_API(n) \
NTSTATUS NTAPI n(IN OUT PCSR_API_MESSAGE ApiMessage, \
);
#define CSR_API(n) \
NTSTATUS NTAPI n(IN OUT PCSR_API_MESSAGE ApiMessage, \
- OUT PULONG Reply)
- // IN OUT PCSR_REPLY_STATUS ReplyStatus)
+ IN OUT PCSR_REPLY_CODE ReplyCode OPTIONAL)
} CSR_SERVER_DLL, *PCSR_SERVER_DLL;
} CSR_SERVER_DLL, *PCSR_SERVER_DLL;
-/* FUNCTION TYPES *************************************************************/
-
typedef
NTSTATUS
(NTAPI *PCSR_SERVER_DLL_INIT_CALLBACK)(IN PCSR_SERVER_DLL LoadedServerDll);
typedef
NTSTATUS
(NTAPI *PCSR_SERVER_DLL_INIT_CALLBACK)(IN PCSR_SERVER_DLL LoadedServerDll);
if (Status == STATUS_THREAD_IS_TERMINATING)
{
DPRINT1("Thread already dead\n");
if (Status == STATUS_THREAD_IS_TERMINATING)
{
DPRINT1("Thread already dead\n");
+
+ /* Set the special reply value so we don't reply this message back */
+ *ReplyCode = CsrReplyDeadClient;
+
ASSERT(CsrThread != NULL);
/* Set the special reply value so we don't reply this message back */
ASSERT(CsrThread != NULL);
/* Set the special reply value so we don't reply this message back */
+ *ReplyCode = CsrReplyDeadClient;
/* Remove the CSR_THREADs and CSR_PROCESS */
return CsrDestroyProcess(&CsrThread->ClientId,
/* Remove the CSR_THREADs and CSR_PROCESS */
return CsrDestroyProcess(&CsrThread->ClientId,
ULONG ServerId;
PCSR_SERVER_DLL ServerDll;
ULONG ApiId;
ULONG ServerId;
PCSR_SERVER_DLL ServerDll;
ULONG ApiId;
- ULONG Reply;
- NTSTATUS Status;
+ CSR_REPLY_CODE ReplyCode = CsrReplyImmediately;
/* Get the Server ID */
ServerId = CSR_API_NUMBER_TO_SERVER_ID(ReceiveMsg->ApiNumber);
/* Get the Server ID */
ServerId = CSR_API_NUMBER_TO_SERVER_ID(ReceiveMsg->ApiNumber);
/* Validation complete, start SEH */
_SEH2_TRY
{
/* Validation complete, start SEH */
_SEH2_TRY
{
- /* Call the API and get the result */
- /// CsrApiCallHandler(ReplyMsg, /*ProcessData*/ &ReplyCode); ///
- Status = (ServerDll->DispatchTable[ApiId])(ReceiveMsg, &Reply);
-
- /* Return the result, no matter what it is */
- ReplyMsg->Status = Status;
+ /* Call the API, get the reply code and return the result */
+ ReplyMsg->Status = ServerDll->DispatchTable[ApiId](ReceiveMsg, &ReplyCode);
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
LARGE_INTEGER TimeOut;
PCSR_THREAD CurrentThread, CsrThread;
NTSTATUS Status;
LARGE_INTEGER TimeOut;
PCSR_THREAD CurrentThread, CsrThread;
NTSTATUS Status;
+ CSR_REPLY_CODE ReplyCode;
PCSR_API_MESSAGE ReplyMsg;
CSR_API_MESSAGE ReceiveMsg;
PCSR_PROCESS CsrProcess;
PCSR_API_MESSAGE ReplyMsg;
CSR_API_MESSAGE ReceiveMsg;
PCSR_PROCESS CsrProcess;
PCSR_SERVER_DLL ServerDll;
PCLIENT_DIED_MSG ClientDiedMsg;
PDBGKM_MSG DebugMessage;
PCSR_SERVER_DLL ServerDll;
PCLIENT_DIED_MSG ClientDiedMsg;
PDBGKM_MSG DebugMessage;
- ULONG ServerId, ApiId, Reply, MessageType, i;
+ ULONG ServerId, ApiId, MessageType, i;
HANDLE ReplyPort;
/* Setup LPC loop port and message */
HANDLE ReplyPort;
/* Setup LPC loop port and message */
{
/* Handle the Connection Request */
CsrApiHandleConnectionRequest(&ReceiveMsg);
{
/* Handle the Connection Request */
CsrApiHandleConnectionRequest(&ReceiveMsg);
- ReplyPort = CsrApiPort;
+ ReplyPort = CsrApiPort;
DPRINT1("CSRSS: %lx is invalid ServerDllIndex (%08x)\n",
ServerId, ServerDll);
DbgBreakPoint();
DPRINT1("CSRSS: %lx is invalid ServerDllIndex (%08x)\n",
ServerId, ServerDll);
DbgBreakPoint();
- ReplyPort = CsrApiPort;
+ ReplyPort = CsrApiPort;
DPRINT1("CSRSS: %lx is invalid ApiTableIndex for %Z\n",
CSR_API_NUMBER_TO_API_ID(ReceiveMsg.ApiNumber),
&ServerDll->Name);
DPRINT1("CSRSS: %lx is invalid ApiTableIndex for %Z\n",
CSR_API_NUMBER_TO_API_ID(ReceiveMsg.ApiNumber),
&ServerDll->Name);
ReplyPort = CsrApiPort;
ReplyMsg = NULL;
continue;
ReplyPort = CsrApiPort;
ReplyMsg = NULL;
continue;
/* Make sure we have enough threads */
CsrpCheckRequestThreads();
/* Make sure we have enough threads */
CsrpCheckRequestThreads();
- /* Call the API and get the result */
+ /* Call the API and get the reply code */
ReplyMsg = NULL;
ReplyPort = CsrApiPort;
ReplyMsg = NULL;
ReplyPort = CsrApiPort;
- ServerDll->DispatchTable[ApiId](&ReceiveMsg, &Reply);
+ ServerDll->DispatchTable[ApiId](&ReceiveMsg, &ReplyCode);
/* Increase the static thread count */
_InterlockedIncrement(&CsrpStaticThreadCount);
/* Increase the static thread count */
_InterlockedIncrement(&CsrpStaticThreadCount);
/* Release the lock and keep looping */
CsrReleaseProcessLock();
/* Release the lock and keep looping */
CsrReleaseProcessLock();
ReplyMsg = NULL;
ReplyPort = CsrApiPort;
continue;
ReplyMsg = NULL;
ReplyPort = CsrApiPort;
continue;
Teb->CsrClientThread = CsrThread;
Teb->CsrClientThread = CsrThread;
- /* Call the API and get the result */
- Reply = 0;
- ServerDll->DispatchTable[ApiId](&ReceiveMsg, &Reply);
+ /* Call the API, get the reply code and return the result */
+ ReplyCode = CsrReplyImmediately;
+ ReplyMsg->Status = ServerDll->DispatchTable[ApiId](&ReceiveMsg, &ReplyCode);
/* Increase the static thread count */
_InterlockedIncrement(&CsrpStaticThreadCount);
Teb->CsrClientThread = CurrentThread;
/* Increase the static thread count */
_InterlockedIncrement(&CsrpStaticThreadCount);
Teb->CsrClientThread = CurrentThread;
+ if (ReplyCode == CsrReplyAlreadyDone)
if (ReceiveMsg.CsrCaptureData)
{
CsrReleaseCapturedArguments(&ReceiveMsg);
}
if (ReceiveMsg.CsrCaptureData)
{
CsrReleaseCapturedArguments(&ReceiveMsg);
}
- CsrDereferenceThread(CsrThread);
+ CsrDereferenceThread(CsrThread);
+ else if (ReplyCode == CsrReplyDeadClient)
+ /* Reply to the death message */
NtReplyPort(ReplyPort, &ReplyMsg->Header);
NtReplyPort(ReplyPort, &ReplyMsg->Header);
- ReplyPort = CsrApiPort;
+
+ /* Reply back to the API port now */
+ ReplyPort = CsrApiPort;
+
CsrDereferenceThread(CsrThread);
}
CsrDereferenceThread(CsrThread);
}
+ else if (ReplyCode == CsrReplyPending)
- ReplyPort = CsrApiPort;
+ ReplyPort = CsrApiPort;
* @param ApiMessage
* Pointer to the CSR API Message for this request.
*
* @param ApiMessage
* Pointer to the CSR API Message for this request.
*
* Optional reply to this request.
*
* @return STATUS_SUCCESS in case of success, STATUS_INVALID_PARAMETER
* Optional reply to this request.
*
* @return STATUS_SUCCESS in case of success, STATUS_INVALID_PARAMETER
-NTSTATUS
-NTAPI
-CsrSrvClientConnect(IN OUT PCSR_API_MESSAGE ApiMessage,
- IN OUT PULONG Reply OPTIONAL)
+CSR_API(CsrSrvClientConnect)
{
NTSTATUS Status;
PCSR_CLIENT_CONNECT ClientConnect = &ApiMessage->Data.CsrClientConnect;
{
NTSTATUS Status;
PCSR_CLIENT_CONNECT ClientConnect = &ApiMessage->Data.CsrClientConnect;
PCSR_PROCESS CurrentProcess = CsrGetClientThread()->Process;
/* Set default reply */
PCSR_PROCESS CurrentProcess = CsrGetClientThread()->Process;
/* Set default reply */
+ *ReplyCode = CsrReplyImmediately;
/* Validate the ServerID */
if (ClientConnect->ServerId >= CSR_SERVER_DLL_MAX)
/* Validate the ServerID */
if (ClientConnect->ServerId >= CSR_SERVER_DLL_MAX)
* @param ApiMessage
* Pointer to the CSR API Message for this request.
*
* @param ApiMessage
* Pointer to the CSR API Message for this request.
*
* Pointer to an optional reply to this request.
*
* @return STATUS_SUCCESS.
* Pointer to an optional reply to this request.
*
* @return STATUS_SUCCESS.
-NTSTATUS
-NTAPI
-CsrSrvIdentifyAlertableThread(IN OUT PCSR_API_MESSAGE ApiMessage,
- IN OUT PULONG Reply)
+CSR_API(CsrSrvIdentifyAlertableThread)
{
PCSR_THREAD CsrThread = CsrGetClientThread();
/* Set the alertable flag */
{
PCSR_THREAD CsrThread = CsrGetClientThread();
/* Set the alertable flag */
- CsrThread->Flags |= CsrThreadAltertable;
+ CsrThread->Flags |= CsrThreadAlertable;
/* Return success */
return STATUS_SUCCESS;
/* Return success */
return STATUS_SUCCESS;
* @param ApiMessage
* Pointer to the CSR API Message for this request.
*
* @param ApiMessage
* Pointer to the CSR API Message for this request.
*
* Pointer to an optional reply to this request.
*
* @return STATUS_SUCCESS.
* Pointer to an optional reply to this request.
*
* @return STATUS_SUCCESS.
-NTSTATUS
-NTAPI
-CsrSrvSetPriorityClass(IN OUT PCSR_API_MESSAGE ApiMessage,
- IN OUT PULONG Reply)
+CSR_API(CsrSrvSetPriorityClass)
{
/* Deprecated */
return STATUS_SUCCESS;
{
/* Deprecated */
return STATUS_SUCCESS;
* @param ApiMessage
* Pointer to the CSR API Message for this request.
*
* @param ApiMessage
* Pointer to the CSR API Message for this request.
*
* Pointer to an optional reply to this request.
*
* @return STATUS_INVALID_PARAMETER.
* Pointer to an optional reply to this request.
*
* @return STATUS_INVALID_PARAMETER.
* return success.
*
*--*/
* return success.
*
*--*/
-NTSTATUS
-NTAPI
-CsrSrvUnusedFunction(IN OUT PCSR_API_MESSAGE ApiMessage,
- IN OUT PULONG Reply)
+CSR_API(CsrSrvUnusedFunction)
{
/* Deprecated */
return STATUS_INVALID_PARAMETER;
{
/* Deprecated */
return STATUS_INVALID_PARAMETER;