2005-01-06 13:58:04 +00:00
|
|
|
/* $Id$
|
2005-05-08 04:07:56 +00:00
|
|
|
*
|
2000-02-29 23:57:47 +00:00
|
|
|
* reactos/subsys/csrss/api/wapi.c
|
1999-12-22 14:48:30 +00:00
|
|
|
*
|
2005-02-26 15:06:19 +00:00
|
|
|
* CSRSS port message processing
|
1999-12-22 14:48:30 +00:00
|
|
|
*
|
|
|
|
* ReactOS Operating System
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
2005-07-26 08:55:25 +00:00
|
|
|
#include <csrss.h>
|
2005-03-20 22:55:05 +00:00
|
|
|
|
|
|
|
#define NDEBUG
|
2002-09-07 15:13:13 +00:00
|
|
|
#include <debug.h>
|
|
|
|
|
1999-12-30 01:51:42 +00:00
|
|
|
/* GLOBALS *******************************************************************/
|
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
HANDLE CsrssApiHeap = (HANDLE) 0;
|
1999-12-30 01:51:42 +00:00
|
|
|
|
2003-12-02 11:38:47 +00:00
|
|
|
static unsigned ApiDefinitionsCount = 0;
|
|
|
|
static PCSRSS_API_DEFINITION ApiDefinitions = NULL;
|
|
|
|
|
1999-12-22 14:48:30 +00:00
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
2003-12-02 11:38:47 +00:00
|
|
|
NTSTATUS FASTCALL
|
|
|
|
CsrApiRegisterDefinitions(PCSRSS_API_DEFINITION NewDefinitions)
|
1999-12-22 14:48:30 +00:00
|
|
|
{
|
2003-12-02 11:38:47 +00:00
|
|
|
unsigned NewCount;
|
|
|
|
PCSRSS_API_DEFINITION Scan;
|
|
|
|
PCSRSS_API_DEFINITION New;
|
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
DPRINT("CSR: %s called", __FUNCTION__);
|
|
|
|
|
2003-12-02 11:38:47 +00:00
|
|
|
NewCount = 0;
|
|
|
|
for (Scan = NewDefinitions; 0 != Scan->Handler; Scan++)
|
|
|
|
{
|
|
|
|
NewCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
New = RtlAllocateHeap(CsrssApiHeap, 0,
|
|
|
|
(ApiDefinitionsCount + NewCount)
|
|
|
|
* sizeof(CSRSS_API_DEFINITION));
|
|
|
|
if (NULL == New)
|
|
|
|
{
|
|
|
|
DPRINT1("Unable to allocate memory\n");
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
}
|
|
|
|
if (0 != ApiDefinitionsCount)
|
|
|
|
{
|
|
|
|
RtlCopyMemory(New, ApiDefinitions,
|
|
|
|
ApiDefinitionsCount * sizeof(CSRSS_API_DEFINITION));
|
|
|
|
RtlFreeHeap(CsrssApiHeap, 0, ApiDefinitions);
|
|
|
|
}
|
|
|
|
RtlCopyMemory(New + ApiDefinitionsCount, NewDefinitions,
|
|
|
|
NewCount * sizeof(CSRSS_API_DEFINITION));
|
|
|
|
ApiDefinitions = New;
|
|
|
|
ApiDefinitionsCount += NewCount;
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
VOID
|
|
|
|
FASTCALL
|
2003-12-02 11:38:47 +00:00
|
|
|
CsrApiCallHandler(PCSRSS_PROCESS_DATA ProcessData,
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
PCSR_API_MESSAGE Request)
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
BOOL Found = FALSE;
|
2003-12-02 11:38:47 +00:00
|
|
|
unsigned DefIndex;
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
ULONG Type;
|
|
|
|
|
|
|
|
DPRINT("CSR: Calling handler for type: %x.\n", Request->Type);
|
|
|
|
Type = Request->Type & 0xFFFF; /* FIXME: USE MACRO */
|
|
|
|
DPRINT("CSR: API Number: %x ServerID: %x\n",Type, Request->Type >> 16);
|
2003-12-02 11:38:47 +00:00
|
|
|
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
/* FIXME: Extract DefIndex instead of looping */
|
2003-12-02 11:38:47 +00:00
|
|
|
for (DefIndex = 0; ! Found && DefIndex < ApiDefinitionsCount; DefIndex++)
|
|
|
|
{
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
if (ApiDefinitions[DefIndex].Type == Type)
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
|
|
|
if (Request->Header.DataSize < ApiDefinitions[DefIndex].MinRequestSize)
|
|
|
|
{
|
|
|
|
DPRINT1("Request type %d min request size %d actual %d\n",
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
Type, ApiDefinitions[DefIndex].MinRequestSize,
|
2003-12-02 11:38:47 +00:00
|
|
|
Request->Header.DataSize);
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
Request->Status = STATUS_INVALID_PARAMETER;
|
2003-12-02 11:38:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
(ApiDefinitions[DefIndex].Handler)(ProcessData, Request);
|
2003-12-02 11:38:47 +00:00
|
|
|
Found = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (! Found)
|
|
|
|
{
|
2003-12-05 08:43:16 +00:00
|
|
|
DPRINT1("CSR: Unknown request type 0x%x\n", Request->Type);
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
Request->Header.MessageSize = sizeof(CSR_API_MESSAGE);
|
|
|
|
Request->Header.DataSize = sizeof(CSR_API_MESSAGE) - LPC_MESSAGE_BASE_SIZE;
|
|
|
|
Request->Status = STATUS_INVALID_SYSTEM_SERVICE;
|
2003-12-02 11:38:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
STATIC
|
|
|
|
VOID
|
|
|
|
STDCALL
|
2004-07-03 17:15:02 +00:00
|
|
|
ClientConnectionThread(HANDLE ServerPort)
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
LPC_MAX_MESSAGE LpcRequest;
|
|
|
|
PCSR_API_MESSAGE Request;
|
|
|
|
PCSR_API_MESSAGE Reply;
|
|
|
|
PCSRSS_PROCESS_DATA ProcessData;
|
|
|
|
|
|
|
|
DPRINT("CSR: %s called", __FUNCTION__);
|
|
|
|
|
2005-06-22 17:43:59 +00:00
|
|
|
/* Reply must be NULL at the first call to NtReplyWaitReceivePort */
|
|
|
|
Reply = NULL;
|
|
|
|
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
/* Loop and reply/wait for a new message */
|
|
|
|
for (;;)
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
/* Send the reply and wait for a new request */
|
|
|
|
Status = NtReplyWaitReceivePort(ServerPort,
|
|
|
|
0,
|
|
|
|
&Reply->Header,
|
|
|
|
&LpcRequest.Header);
|
|
|
|
if (!NT_SUCCESS(Status))
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
DPRINT1("CSR: NtReplyWaitReceivePort failed\n");
|
|
|
|
break;
|
2003-12-02 11:38:47 +00:00
|
|
|
}
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
|
|
|
|
/* If the connection was closed, handle that */
|
|
|
|
if (LpcRequest.Header.MessageType == LPC_PORT_CLOSED)
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
CsrFreeProcessData( LpcRequest.Header.ClientId.UniqueProcess );
|
|
|
|
break;
|
2003-12-02 11:38:47 +00:00
|
|
|
}
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
|
|
|
|
/* Get the CSR Message */
|
|
|
|
Request = (PCSR_API_MESSAGE)&LpcRequest;
|
|
|
|
|
|
|
|
DPRINT("CSR: Got CSR API: %x [Message Origin: %x]\n",
|
|
|
|
Request->Type,
|
|
|
|
Request->Header.ClientId.UniqueProcess);
|
|
|
|
|
|
|
|
/* Get the Process Data */
|
|
|
|
ProcessData = CsrGetProcessData(LpcRequest.Header.ClientId.UniqueProcess);
|
|
|
|
if (ProcessData == NULL)
|
2004-07-03 17:15:02 +00:00
|
|
|
{
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
DPRINT1("CSR: Message %d: Unable to find data for process 0x%x\n",
|
|
|
|
LpcRequest.Header.MessageType,
|
|
|
|
LpcRequest.Header.ClientId.UniqueProcess);
|
|
|
|
break;
|
2005-05-08 04:07:56 +00:00
|
|
|
}
|
2004-07-03 17:15:02 +00:00
|
|
|
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
/* Call the Handler */
|
|
|
|
CsrApiCallHandler(ProcessData, Request);
|
|
|
|
|
|
|
|
/* Send back the reply */
|
|
|
|
Reply = Request;
|
2003-12-02 11:38:47 +00:00
|
|
|
}
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
|
|
|
|
/* Close the port and exit the thread */
|
|
|
|
NtClose(ServerPort);
|
2005-07-02 13:45:23 +00:00
|
|
|
RtlExitUserThread(STATUS_SUCCESS);
|
1999-12-22 14:48:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* NAME
|
2005-02-26 15:06:19 +00:00
|
|
|
* ServerApiPortThread/1
|
1999-12-22 14:48:30 +00:00
|
|
|
*
|
|
|
|
* DESCRIPTION
|
|
|
|
* Handle connection requests from clients to the port
|
|
|
|
* "\Windows\ApiPort".
|
|
|
|
*/
|
2005-03-20 22:55:05 +00:00
|
|
|
DWORD STDCALL
|
2005-02-26 15:06:19 +00:00
|
|
|
ServerApiPortThread (PVOID PortHandle)
|
1999-12-22 14:48:30 +00:00
|
|
|
{
|
2005-03-20 22:55:05 +00:00
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
2000-04-03 21:54:42 +00:00
|
|
|
LPC_MAX_MESSAGE Request;
|
2005-03-20 22:55:05 +00:00
|
|
|
HANDLE hApiListenPort = * (PHANDLE) PortHandle;
|
|
|
|
HANDLE ServerPort = (HANDLE) 0;
|
|
|
|
HANDLE ServerThread = (HANDLE) 0;
|
|
|
|
PCSRSS_PROCESS_DATA ProcessData = NULL;
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2000-02-27 02:12:07 +00:00
|
|
|
CsrInitProcessData();
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
DPRINT("CSR: %s called", __FUNCTION__);
|
|
|
|
|
1999-12-22 14:48:30 +00:00
|
|
|
for (;;)
|
|
|
|
{
|
2003-12-02 11:38:47 +00:00
|
|
|
LPC_SECTION_READ LpcRead;
|
2004-07-03 17:15:02 +00:00
|
|
|
ServerPort = NULL;
|
2001-12-02 23:34:43 +00:00
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
Status = NtListenPort (hApiListenPort, & Request.Header);
|
1999-12-22 14:48:30 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2003-12-02 11:38:47 +00:00
|
|
|
DPRINT1("CSR: NtListenPort() failed\n");
|
2004-07-03 17:15:02 +00:00
|
|
|
break;
|
1999-12-22 14:48:30 +00:00
|
|
|
}
|
2005-03-20 22:55:05 +00:00
|
|
|
Status = NtAcceptConnectPort(& ServerPort,
|
|
|
|
hApiListenPort,
|
1999-12-22 14:48:30 +00:00
|
|
|
NULL,
|
2005-02-19 22:56:59 +00:00
|
|
|
TRUE,
|
1999-12-22 14:48:30 +00:00
|
|
|
0,
|
2005-03-20 22:55:05 +00:00
|
|
|
& LpcRead);
|
1999-12-22 14:48:30 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2003-12-02 11:38:47 +00:00
|
|
|
DPRINT1("CSR: NtAcceptConnectPort() failed\n");
|
2004-07-03 17:15:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-01-26 00:03:05 +00:00
|
|
|
ProcessData = CsrCreateProcessData(Request.Header.ClientId.UniqueProcess);
|
2004-07-03 17:15:02 +00:00
|
|
|
if (ProcessData == NULL)
|
|
|
|
{
|
2005-01-26 00:03:05 +00:00
|
|
|
DPRINT1("Unable to allocate or find data for process 0x%x\n",
|
|
|
|
Request.Header.ClientId.UniqueProcess);
|
2004-07-03 17:15:02 +00:00
|
|
|
Status = STATUS_UNSUCCESSFUL;
|
|
|
|
break;
|
1999-12-22 14:48:30 +00:00
|
|
|
}
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2001-12-02 23:34:43 +00:00
|
|
|
|
|
|
|
ProcessData->CsrSectionViewBase = LpcRead.ViewBase;
|
|
|
|
ProcessData->CsrSectionViewSize = LpcRead.ViewSize;
|
2005-05-08 04:07:56 +00:00
|
|
|
|
1999-12-22 14:48:30 +00:00
|
|
|
Status = NtCompleteConnectPort(ServerPort);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2003-12-02 11:38:47 +00:00
|
|
|
DPRINT1("CSR: NtCompleteConnectPort() failed\n");
|
2004-07-03 17:15:02 +00:00
|
|
|
break;
|
1999-12-22 14:48:30 +00:00
|
|
|
}
|
2005-05-08 04:07:56 +00:00
|
|
|
|
1999-12-22 14:48:30 +00:00
|
|
|
Status = RtlCreateUserThread(NtCurrentProcess(),
|
|
|
|
NULL,
|
|
|
|
FALSE,
|
|
|
|
0,
|
2005-07-12 01:56:14 +00:00
|
|
|
0,
|
|
|
|
0,
|
2004-07-03 17:15:02 +00:00
|
|
|
(PTHREAD_START_ROUTINE)ClientConnectionThread,
|
1999-12-22 14:48:30 +00:00
|
|
|
ServerPort,
|
2005-03-20 22:55:05 +00:00
|
|
|
& ServerThread,
|
1999-12-22 14:48:30 +00:00
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2003-12-02 11:38:47 +00:00
|
|
|
DPRINT1("CSR: Unable to create server thread\n");
|
2004-07-03 17:15:02 +00:00
|
|
|
break;
|
1999-12-22 14:48:30 +00:00
|
|
|
}
|
2000-04-03 21:54:42 +00:00
|
|
|
NtClose(ServerThread);
|
1999-12-22 14:48:30 +00:00
|
|
|
}
|
2004-07-03 17:15:02 +00:00
|
|
|
if (ServerPort)
|
|
|
|
{
|
|
|
|
NtClose(ServerPort);
|
|
|
|
}
|
|
|
|
NtClose(PortHandle);
|
|
|
|
NtTerminateThread(NtCurrentThread(), Status);
|
2005-03-20 22:55:05 +00:00
|
|
|
return 0;
|
1999-12-22 14:48:30 +00:00
|
|
|
}
|
2000-02-27 02:12:07 +00:00
|
|
|
|
2005-02-26 15:06:19 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* NAME
|
|
|
|
* ServerSbApiPortThread/1
|
|
|
|
*
|
|
|
|
* DESCRIPTION
|
|
|
|
* Handle connection requests from SM to the port
|
2005-03-20 22:55:05 +00:00
|
|
|
* "\Windows\SbApiPort". We will accept only one
|
|
|
|
* connection request (from the SM).
|
2005-02-26 15:06:19 +00:00
|
|
|
*/
|
2005-03-20 22:55:05 +00:00
|
|
|
DWORD STDCALL
|
2005-02-26 15:06:19 +00:00
|
|
|
ServerSbApiPortThread (PVOID PortHandle)
|
|
|
|
{
|
2005-03-20 22:55:05 +00:00
|
|
|
HANDLE hSbApiPortListen = * (PHANDLE) PortHandle;
|
2005-02-26 15:06:19 +00:00
|
|
|
HANDLE hConnectedPort = (HANDLE) 0;
|
|
|
|
LPC_MAX_MESSAGE Request = {{0}};
|
2005-03-20 22:55:05 +00:00
|
|
|
PVOID Context = NULL;
|
2005-02-26 15:06:19 +00:00
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
DPRINT("CSR: %s called\n", __FUNCTION__);
|
|
|
|
|
|
|
|
Status = NtListenPort (hSbApiPortListen, & Request.Header);
|
|
|
|
if (!NT_SUCCESS(Status))
|
2005-02-26 15:06:19 +00:00
|
|
|
{
|
2005-03-20 22:55:05 +00:00
|
|
|
DPRINT1("CSR: %s: NtListenPort(SB) failed (Status=0x%08lx)\n",
|
|
|
|
__FUNCTION__, Status);
|
|
|
|
} else {
|
|
|
|
DPRINT("-- 1\n");
|
2005-02-26 15:06:19 +00:00
|
|
|
Status = NtAcceptConnectPort (& hConnectedPort,
|
|
|
|
hSbApiPortListen,
|
2005-03-20 22:55:05 +00:00
|
|
|
NULL,
|
|
|
|
TRUE,
|
|
|
|
NULL,
|
2005-02-26 15:06:19 +00:00
|
|
|
NULL);
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
2005-03-20 22:55:05 +00:00
|
|
|
DPRINT1("CSR: %s: NtAcceptConnectPort() failed (Status=0x%08lx)\n",
|
|
|
|
__FUNCTION__, Status);
|
|
|
|
} else {
|
|
|
|
DPRINT("-- 2\n");
|
|
|
|
Status = NtCompleteConnectPort (hConnectedPort);
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("CSR: %s: NtCompleteConnectPort() failed (Status=0x%08lx)\n",
|
|
|
|
__FUNCTION__, Status);
|
|
|
|
} else {
|
|
|
|
DPRINT("-- 3\n");
|
|
|
|
PLPC_MESSAGE Reply = NULL;
|
2005-05-08 04:07:56 +00:00
|
|
|
/*
|
2005-03-20 22:55:05 +00:00
|
|
|
* Tell the init thread the SM gave the
|
|
|
|
* green light for boostrapping.
|
|
|
|
*/
|
|
|
|
Status = NtSetEvent (hBootstrapOk, NULL);
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("CSR: %s: NtSetEvent failed (Status=0x%08lx)\n",
|
|
|
|
__FUNCTION__, Status);
|
|
|
|
}
|
|
|
|
/* Wait for messages from the SM */
|
|
|
|
DPRINT("-- 4\n");
|
|
|
|
while (TRUE)
|
|
|
|
{
|
|
|
|
Status = NtReplyWaitReceivePort(hConnectedPort,
|
|
|
|
Context,
|
|
|
|
Reply,
|
|
|
|
& Request.Header);
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("CSR: %s: NtReplyWaitReceivePort failed (Status=0x%08lx)\n",
|
|
|
|
__FUNCTION__, Status);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch (Request.Header.MessageType)//fix .h PORT_MESSAGE_TYPE(Request))
|
|
|
|
{
|
|
|
|
/* TODO */
|
|
|
|
default:
|
|
|
|
DPRINT1("CSR: %s received message (type=%d)\n",
|
|
|
|
__FUNCTION__, Request.Header.MessageType);
|
|
|
|
}
|
|
|
|
DPRINT("-- 5\n");
|
|
|
|
}
|
|
|
|
}
|
2005-02-26 15:06:19 +00:00
|
|
|
}
|
|
|
|
}
|
2005-03-20 22:55:05 +00:00
|
|
|
DPRINT1("CSR: %s: terminating!\n", __FUNCTION__);
|
|
|
|
if(hConnectedPort) NtClose (hConnectedPort);
|
2005-02-26 15:06:19 +00:00
|
|
|
NtClose (hSbApiPortListen);
|
|
|
|
NtTerminateThread (NtCurrentThread(), Status);
|
2005-03-20 22:55:05 +00:00
|
|
|
return 0;
|
2005-02-26 15:06:19 +00:00
|
|
|
}
|
|
|
|
|
2001-08-14 12:57:16 +00:00
|
|
|
/* EOF */
|