[NTDLL:CSR][CSRSRV] Start to deprecate CSR functions removed on Windows 2003.

The server-side CsrSrvIdentifyAlertableThread and CsrSrvSetPriorityClass
functions are completely removed in Win2k3+, and are since stubbed by
CsrSrvUnusedFunction instead. They however were present up to Windows XP,
albeit with an extremely minimal implementation.

The corresponding client-side CsrIdentifyAlertableThread and CsrSetPriorityClass
now become just stubs that either trivially succeed or fail, respectively.

See https://www.geoffchappell.com/studies/windows/win32/csrsrv/api/srvinit/apidispatch.htm
for more information.

- Fix typo "al*T*ertable" --> "alertable".
- Remove ROS-specific CSRSS_IDENTIFY_ALERTABLE_THREAD that was
  deprecated since ages (at least before 2005)!
This commit is contained in:
Hermès Bélusca-Maïto 2021-11-21 23:46:11 +01:00
parent d575e828d7
commit 7353af1e3d
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
5 changed files with 75 additions and 42 deletions

View file

@ -35,29 +35,29 @@ CsrNewThread(VOID)
*/ */
NTSTATUS NTSTATUS
NTAPI NTAPI
CsrSetPriorityClass(HANDLE hProcess, CsrIdentifyAlertableThread(VOID)
PULONG PriorityClass)
{ {
#if (NTDDI_VERSION < NTDDI_WS03)
NTSTATUS Status; NTSTATUS Status;
CSR_API_MESSAGE ApiMessage; CSR_API_MESSAGE ApiMessage;
PCSR_SET_PRIORITY_CLASS SetPriorityClass = &ApiMessage.Data.SetPriorityClass; PCSR_IDENTIFY_ALERTABLE_THREAD IdentifyAlertableThread;
/* Set up the data for CSR */ /* Set up the data for CSR */
DbgBreakPoint(); IdentifyAlertableThread = &ApiMessage.Data.IdentifyAlertableThread;
SetPriorityClass->hProcess = hProcess; IdentifyAlertableThread->Cid = NtCurrentTeb()->ClientId;
SetPriorityClass->PriorityClass = *PriorityClass;
/* Call it */ /* Call it */
Status = CsrClientCallServer(&ApiMessage, Status = CsrClientCallServer(&ApiMessage,
NULL, NULL,
CSR_CREATE_API_NUMBER(CSRSRV_SERVERDLL_INDEX, CsrpSetPriorityClass), CSR_CREATE_API_NUMBER(CSRSRV_SERVERDLL_INDEX, CsrpIdentifyAlertableThread),
sizeof(CSR_SET_PRIORITY_CLASS)); sizeof(*IdentifyAlertableThread));
/* Return what we got, if requested */
if (*PriorityClass) *PriorityClass = SetPriorityClass->PriorityClass;
/* Return to caller */ /* Return to caller */
return Status; return Status;
#else
/* Deprecated */
return STATUS_SUCCESS;
#endif
} }
/* /*
@ -65,25 +65,36 @@ CsrSetPriorityClass(HANDLE hProcess,
*/ */
NTSTATUS NTSTATUS
NTAPI NTAPI
CsrIdentifyAlertableThread(VOID) CsrSetPriorityClass(IN HANDLE Process,
IN OUT PULONG PriorityClass)
{ {
#if (NTDDI_VERSION < NTDDI_WS03)
NTSTATUS Status; NTSTATUS Status;
CSR_API_MESSAGE ApiMessage; CSR_API_MESSAGE ApiMessage;
PCSR_IDENTIFY_ALTERTABLE_THREAD IdentifyAlertableThread; PCSR_SET_PRIORITY_CLASS SetPriorityClass = &ApiMessage.Data.SetPriorityClass;
/* Set up the data for CSR */ /* Set up the data for CSR */
DbgBreakPoint(); SetPriorityClass->hProcess = Process;
IdentifyAlertableThread = &ApiMessage.Data.IdentifyAlertableThread; SetPriorityClass->PriorityClass = *PriorityClass;
IdentifyAlertableThread->Cid = NtCurrentTeb()->ClientId;
/* Call it */ /* Call it */
Status = CsrClientCallServer(&ApiMessage, Status = CsrClientCallServer(&ApiMessage,
NULL, NULL,
CSR_CREATE_API_NUMBER(CSRSRV_SERVERDLL_INDEX, CsrpIdentifyAlertable), CSR_CREATE_API_NUMBER(CSRSRV_SERVERDLL_INDEX, CsrpSetPriorityClass),
sizeof(CSR_IDENTIFY_ALTERTABLE_THREAD)); sizeof(*SetPriorityClass));
/* Return what we got, if requested */
if (*PriorityClass) *PriorityClass = SetPriorityClass->PriorityClass;
/* Return to caller */ /* Return to caller */
return Status; return Status;
#else
UNREFERENCED_PARAMETER(Process);
UNREFERENCED_PARAMETER(PriorityClass);
/* Deprecated */
return STATUS_INVALID_PARAMETER;
#endif
} }
/* EOF */ /* EOF */

View file

@ -80,10 +80,6 @@ CsrProbeForWrite(IN PVOID Address,
IN ULONG Length, IN ULONG Length,
IN ULONG Alignment); IN ULONG Alignment);
NTSTATUS
NTAPI
CsrIdentifyAlertableThread(VOID);
HANDLE HANDLE
NTAPI NTAPI
CsrGetProcessId(VOID); CsrGetProcessId(VOID);
@ -92,6 +88,10 @@ NTSTATUS
NTAPI NTAPI
CsrNewThread(VOID); CsrNewThread(VOID);
NTSTATUS
NTAPI
CsrIdentifyAlertableThread(VOID);
NTSTATUS NTSTATUS
NTAPI NTAPI
CsrSetPriorityClass(IN HANDLE Process, CsrSetPriorityClass(IN HANDLE Process,

View file

@ -25,7 +25,7 @@ typedef enum _CSRSRV_API_NUMBER
CsrpClientConnect = CSRSRV_FIRST_API_NUMBER, CsrpClientConnect = CSRSRV_FIRST_API_NUMBER,
CsrpThreadConnect, CsrpThreadConnect,
CsrpProfileControl, CsrpProfileControl,
CsrpIdentifyAlertable, CsrpIdentifyAlertableThread,
CsrpSetPriorityClass, CsrpSetPriorityClass,
CsrpMaxApiNumber CsrpMaxApiNumber
@ -65,10 +65,12 @@ C_ASSERT(sizeof(CSR_API_CONNECTINFO) == 0x24);
C_ASSERT(sizeof(CSR_API_CONNECTINFO) <= LPC_MAX_DATA_LENGTH); C_ASSERT(sizeof(CSR_API_CONNECTINFO) <= LPC_MAX_DATA_LENGTH);
typedef struct _CSR_IDENTIFY_ALTERTABLE_THREAD #if (NTDDI_VERSION < NTDDI_WS03)
typedef struct _CSR_IDENTIFY_ALERTABLE_THREAD
{ {
CLIENT_ID Cid; CLIENT_ID Cid;
} CSR_IDENTIFY_ALTERTABLE_THREAD, *PCSR_IDENTIFY_ALTERTABLE_THREAD; } CSR_IDENTIFY_ALERTABLE_THREAD, *PCSR_IDENTIFY_ALERTABLE_THREAD;
typedef struct _CSR_SET_PRIORITY_CLASS typedef struct _CSR_SET_PRIORITY_CLASS
{ {
@ -76,11 +78,7 @@ typedef struct _CSR_SET_PRIORITY_CLASS
ULONG PriorityClass; ULONG PriorityClass;
} CSR_SET_PRIORITY_CLASS, *PCSR_SET_PRIORITY_CLASS; } CSR_SET_PRIORITY_CLASS, *PCSR_SET_PRIORITY_CLASS;
typedef struct #endif // (NTDDI_VERSION < NTDDI_WS03)
{
HANDLE UniqueThread;
CLIENT_ID Cid;
} CSRSS_IDENTIFY_ALERTABLE_THREAD, *PCSRSS_IDENTIFY_ALERTABLE_THREAD;
typedef struct _CSR_CLIENT_CONNECT typedef struct _CSR_CLIENT_CONNECT
{ {
@ -114,9 +112,10 @@ typedef struct _CSR_API_MESSAGE
union union
{ {
CSR_CLIENT_CONNECT CsrClientConnect; CSR_CLIENT_CONNECT CsrClientConnect;
#if (NTDDI_VERSION < NTDDI_WS03)
CSR_SET_PRIORITY_CLASS SetPriorityClass; CSR_SET_PRIORITY_CLASS SetPriorityClass;
CSR_IDENTIFY_ALTERTABLE_THREAD IdentifyAlertableThread; CSR_IDENTIFY_ALERTABLE_THREAD IdentifyAlertableThread;
#endif
// //
// This padding is used to make the CSR_API_MESSAGE structure // This padding is used to make the CSR_API_MESSAGE structure
// large enough to hold full other API_MESSAGE-type structures // large enough to hold full other API_MESSAGE-type structures

View file

@ -66,8 +66,10 @@ extern HANDLE CsrObjectDirectory;
CSR_API(CsrSrvClientConnect); CSR_API(CsrSrvClientConnect);
CSR_API(CsrSrvUnusedFunction); CSR_API(CsrSrvUnusedFunction);
#if (NTDDI_VERSION < NTDDI_WS03)
CSR_API(CsrSrvIdentifyAlertableThread); CSR_API(CsrSrvIdentifyAlertableThread);
CSR_API(CsrSrvSetPriorityClass); CSR_API(CsrSrvSetPriorityClass);
#endif
NTSTATUS NTSTATUS

View file

@ -27,19 +27,29 @@ HANDLE CsrSrvSharedSection = NULL;
PCSR_API_ROUTINE CsrServerApiDispatchTable[CsrpMaxApiNumber] = PCSR_API_ROUTINE CsrServerApiDispatchTable[CsrpMaxApiNumber] =
{ {
CsrSrvClientConnect, CsrSrvClientConnect,
CsrSrvUnusedFunction, CsrSrvUnusedFunction, // <= WinNT4: CsrSrvThreadConnect
CsrSrvUnusedFunction, CsrSrvUnusedFunction, // <= WinNT4: CsrSrvProfileControl
CsrSrvIdentifyAlertableThread, #if (NTDDI_VERSION < NTDDI_WS03)
CsrSrvIdentifyAlertableThread
CsrSrvSetPriorityClass CsrSrvSetPriorityClass
#else
CsrSrvUnusedFunction, // <= WinXP : CsrSrvIdentifyAlertableThread
CsrSrvUnusedFunction // <= WinXP : CsrSrvSetPriorityClass
#endif
}; };
BOOLEAN CsrServerApiServerValidTable[CsrpMaxApiNumber] = BOOLEAN CsrServerApiServerValidTable[CsrpMaxApiNumber] =
{ {
TRUE, TRUE,
FALSE, FALSE,
TRUE, FALSE,
#if (NTDDI_VERSION < NTDDI_WS03)
TRUE, TRUE,
TRUE TRUE
#else
FALSE,
FALSE
#endif
}; };
/* /*
@ -501,9 +511,11 @@ CsrSrvAttachSharedSection(IN PCSR_PROCESS CsrProcess OPTIONAL,
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
#if (NTDDI_VERSION < NTDDI_WS03)
/*++ /*++
* @name CsrSrvIdentifyAlertableThread * @name CsrSrvIdentifyAlertableThread
* @implemented NT4 * @implemented NT4, up to WinXP
* *
* The CsrSrvIdentifyAlertableThread CSR API marks a CSR Thread as alertable. * The CsrSrvIdentifyAlertableThread CSR API marks a CSR Thread as alertable.
* *
@ -515,13 +527,16 @@ CsrSrvAttachSharedSection(IN PCSR_PROCESS CsrProcess OPTIONAL,
* *
* @return STATUS_SUCCESS. * @return STATUS_SUCCESS.
* *
* @remarks None. * @remarks Deprecated.
* *
*--*/ *--*/
CSR_API(CsrSrvIdentifyAlertableThread) CSR_API(CsrSrvIdentifyAlertableThread)
{ {
PCSR_THREAD CsrThread = CsrGetClientThread(); PCSR_THREAD CsrThread = CsrGetClientThread();
UNREFERENCED_PARAMETER(ApiMessage);
UNREFERENCED_PARAMETER(ReplyCode);
/* Set the alertable flag */ /* Set the alertable flag */
CsrThread->Flags |= CsrThreadAlertable; CsrThread->Flags |= CsrThreadAlertable;
@ -531,7 +546,7 @@ CSR_API(CsrSrvIdentifyAlertableThread)
/*++ /*++
* @name CsrSrvSetPriorityClass * @name CsrSrvSetPriorityClass
* @implemented NT4 * @implemented NT4, up to WinXP
* *
* The CsrSrvSetPriorityClass CSR API is deprecated. * The CsrSrvSetPriorityClass CSR API is deprecated.
* *
@ -543,23 +558,26 @@ CSR_API(CsrSrvIdentifyAlertableThread)
* *
* @return STATUS_SUCCESS. * @return STATUS_SUCCESS.
* *
* @remarks None. * @remarks Deprecated.
* *
*--*/ *--*/
CSR_API(CsrSrvSetPriorityClass) CSR_API(CsrSrvSetPriorityClass)
{ {
UNREFERENCED_PARAMETER(ApiMessage);
UNREFERENCED_PARAMETER(ReplyCode);
/* Deprecated */ /* Deprecated */
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
#endif // (NTDDI_VERSION < NTDDI_WS03)
/*++ /*++
* @name CsrSrvUnusedFunction * @name CsrSrvUnusedFunction
* @implemented NT4 * @implemented NT4
* *
* The CsrSrvUnusedFunction CSR API is a stub for deprecated APIs. * The CsrSrvUnusedFunction CSR API is a stub for deprecated APIs.
* *
* The CsrSrvSetPriorityClass CSR API is deprecated.
*
* @param ApiMessage * @param ApiMessage
* Pointer to the CSR API Message for this request. * Pointer to the CSR API Message for this request.
* *
@ -574,6 +592,9 @@ CSR_API(CsrSrvSetPriorityClass)
*--*/ *--*/
CSR_API(CsrSrvUnusedFunction) CSR_API(CsrSrvUnusedFunction)
{ {
UNREFERENCED_PARAMETER(ApiMessage);
UNREFERENCED_PARAMETER(ReplyCode);
/* Deprecated */ /* Deprecated */
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
} }