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

View File

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

View File

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

View File

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

View File

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