2005-12-01 22:38:03 +00:00
|
|
|
/*
|
1999-06-08 22:50:59 +00:00
|
|
|
* reactos/subsys/csrss/api/process.c
|
|
|
|
*
|
|
|
|
* "\windows\ApiPort" port process management functions
|
|
|
|
*
|
|
|
|
* ReactOS Operating System
|
|
|
|
*/
|
1999-12-22 14:48:30 +00:00
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
2005-07-26 08:55:25 +00:00
|
|
|
#include <csrss.h>
|
1999-07-17 23:10:31 +00:00
|
|
|
|
2003-03-09 21:41:35 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
2001-08-14 12:57:16 +00:00
|
|
|
#define LOCK RtlEnterCriticalSection(&ProcessDataLock)
|
|
|
|
#define UNLOCK RtlLeaveCriticalSection(&ProcessDataLock)
|
|
|
|
|
1999-12-30 01:51:42 +00:00
|
|
|
/* GLOBALS *******************************************************************/
|
|
|
|
|
|
|
|
static ULONG NrProcess;
|
|
|
|
static PCSRSS_PROCESS_DATA ProcessData[256];
|
2005-01-03 23:02:15 +00:00
|
|
|
RTL_CRITICAL_SECTION ProcessDataLock;
|
1999-12-30 01:51:42 +00:00
|
|
|
|
1999-12-22 14:48:30 +00:00
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
VOID WINAPI CsrInitProcessData(VOID)
|
2000-02-27 02:12:07 +00:00
|
|
|
{
|
2001-08-14 12:57:16 +00:00
|
|
|
RtlZeroMemory (ProcessData, sizeof ProcessData);
|
|
|
|
NrProcess = sizeof ProcessData / sizeof ProcessData[0];
|
2000-05-26 05:43:33 +00:00
|
|
|
RtlInitializeCriticalSection( &ProcessDataLock );
|
2000-02-27 02:12:07 +00:00
|
|
|
}
|
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
PCSRSS_PROCESS_DATA WINAPI CsrGetProcessData(HANDLE ProcessId)
|
1999-12-30 01:51:42 +00:00
|
|
|
{
|
2003-01-11 15:51:48 +00:00
|
|
|
ULONG hash;
|
|
|
|
PCSRSS_PROCESS_DATA pProcessData;
|
2000-05-26 05:43:33 +00:00
|
|
|
|
2005-10-24 18:03:57 +00:00
|
|
|
hash = ((ULONG_PTR)ProcessId >> 2) % (sizeof(ProcessData) / sizeof(*ProcessData));
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2001-08-14 12:57:16 +00:00
|
|
|
LOCK;
|
2003-01-11 15:51:48 +00:00
|
|
|
|
|
|
|
pProcessData = ProcessData[hash];
|
|
|
|
|
2003-03-09 21:41:35 +00:00
|
|
|
while (pProcessData && pProcessData->ProcessId != ProcessId)
|
|
|
|
{
|
|
|
|
pProcessData = pProcessData->next;
|
|
|
|
}
|
|
|
|
UNLOCK;
|
|
|
|
return pProcessData;
|
|
|
|
}
|
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
PCSRSS_PROCESS_DATA WINAPI CsrCreateProcessData(HANDLE ProcessId)
|
2003-03-09 21:41:35 +00:00
|
|
|
{
|
|
|
|
ULONG hash;
|
|
|
|
PCSRSS_PROCESS_DATA pProcessData;
|
2005-04-03 13:04:10 +00:00
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
CLIENT_ID ClientId;
|
|
|
|
NTSTATUS Status;
|
2003-03-09 21:41:35 +00:00
|
|
|
|
2005-10-24 18:03:57 +00:00
|
|
|
hash = ((ULONG_PTR)ProcessId >> 2) % (sizeof(ProcessData) / sizeof(*ProcessData));
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2003-03-09 21:41:35 +00:00
|
|
|
LOCK;
|
|
|
|
|
|
|
|
pProcessData = ProcessData[hash];
|
|
|
|
|
2003-01-11 15:51:48 +00:00
|
|
|
while (pProcessData && pProcessData->ProcessId != ProcessId)
|
|
|
|
{
|
|
|
|
pProcessData = pProcessData->next;
|
|
|
|
}
|
|
|
|
if (pProcessData == NULL)
|
|
|
|
{
|
|
|
|
pProcessData = RtlAllocateHeap(CsrssApiHeap,
|
|
|
|
HEAP_ZERO_MEMORY,
|
|
|
|
sizeof(CSRSS_PROCESS_DATA));
|
|
|
|
if (pProcessData)
|
|
|
|
{
|
|
|
|
pProcessData->ProcessId = ProcessId;
|
|
|
|
pProcessData->next = ProcessData[hash];
|
|
|
|
ProcessData[hash] = pProcessData;
|
2005-04-03 13:04:10 +00:00
|
|
|
|
|
|
|
ClientId.UniqueThread = NULL;
|
|
|
|
ClientId.UniqueProcess = pProcessData->ProcessId;
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
/* using OpenProcess is not optimal due to HANDLE vs. DWORD PIDs... */
|
|
|
|
Status = NtOpenProcess(&pProcessData->Process,
|
|
|
|
PROCESS_DUP_HANDLE | PROCESS_VM_OPERATION |
|
2005-04-03 15:47:15 +00:00
|
|
|
PROCESS_VM_WRITE | PROCESS_CREATE_THREAD | SYNCHRONIZE,
|
2005-04-03 13:04:10 +00:00
|
|
|
&ObjectAttributes,
|
|
|
|
&ClientId);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
ProcessData[hash] = pProcessData->next;
|
|
|
|
RtlFreeHeap(CsrssApiHeap, 0, pProcessData);
|
|
|
|
pProcessData = NULL;
|
2005-05-26 19:22:45 +00:00
|
|
|
}
|
2005-10-24 18:03:57 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
RtlInitializeCriticalSection(&pProcessData->HandleTableLock);
|
|
|
|
}
|
2003-01-11 15:51:48 +00:00
|
|
|
}
|
|
|
|
}
|
2003-03-09 21:41:35 +00:00
|
|
|
else
|
|
|
|
{
|
2007-06-14 16:47:24 +00:00
|
|
|
DPRINT1("Process data for pid %d already exist\n", ProcessId);
|
2003-03-09 21:41:35 +00:00
|
|
|
}
|
2001-08-14 12:57:16 +00:00
|
|
|
UNLOCK;
|
2003-01-11 15:51:48 +00:00
|
|
|
if (pProcessData == NULL)
|
|
|
|
{
|
2005-10-24 18:03:57 +00:00
|
|
|
DPRINT1("CsrCreateProcessData() failed\n");
|
2003-01-11 15:51:48 +00:00
|
|
|
}
|
2005-12-01 22:38:03 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
pProcessData->Terminated = FALSE;
|
|
|
|
|
|
|
|
/* Set default shutdown parameters */
|
|
|
|
pProcessData->ShutdownLevel = 0x280;
|
|
|
|
pProcessData->ShutdownFlags = 0;
|
|
|
|
}
|
2003-01-11 15:51:48 +00:00
|
|
|
return pProcessData;
|
1999-12-30 01:51:42 +00:00
|
|
|
}
|
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
NTSTATUS WINAPI CsrFreeProcessData(HANDLE Pid)
|
2000-04-23 17:44:53 +00:00
|
|
|
{
|
2003-12-02 11:38:47 +00:00
|
|
|
ULONG hash;
|
2005-07-05 22:35:29 +00:00
|
|
|
UINT c;
|
2008-07-27 20:08:18 +00:00
|
|
|
PCSRSS_PROCESS_DATA pProcessData, *pPrevLink;
|
2008-10-25 15:33:02 +00:00
|
|
|
HANDLE Process;
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2005-10-24 18:03:57 +00:00
|
|
|
hash = ((ULONG_PTR)Pid >> 2) % (sizeof(ProcessData) / sizeof(*ProcessData));
|
2008-07-27 20:08:18 +00:00
|
|
|
pPrevLink = &ProcessData[hash];
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2003-12-02 11:38:47 +00:00
|
|
|
LOCK;
|
2003-01-11 15:51:48 +00:00
|
|
|
|
2008-07-27 20:08:18 +00:00
|
|
|
while ((pProcessData = *pPrevLink) && pProcessData->ProcessId != Pid)
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
2008-07-27 20:08:18 +00:00
|
|
|
pPrevLink = &pProcessData->next;
|
2003-12-02 11:38:47 +00:00
|
|
|
}
|
2003-01-11 15:51:48 +00:00
|
|
|
|
2003-12-02 11:38:47 +00:00
|
|
|
if (pProcessData)
|
|
|
|
{
|
|
|
|
DPRINT("CsrFreeProcessData pid: %d\n", Pid);
|
2008-10-25 15:33:02 +00:00
|
|
|
Process = pProcessData->Process;
|
2003-01-11 15:51:48 +00:00
|
|
|
if (pProcessData->HandleTable)
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
|
|
|
for (c = 0; c < pProcessData->HandleTableSize; c++)
|
|
|
|
{
|
2008-07-22 17:37:13 +00:00
|
|
|
if (pProcessData->HandleTable[c].Object)
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
2008-07-22 17:37:13 +00:00
|
|
|
CsrReleaseObjectByPointer(pProcessData->HandleTable[c].Object);
|
2003-12-02 11:38:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
RtlFreeHeap(CsrssApiHeap, 0, pProcessData->HandleTable);
|
|
|
|
}
|
2005-05-26 19:22:45 +00:00
|
|
|
RtlDeleteCriticalSection(&pProcessData->HandleTableLock);
|
2003-12-02 11:38:47 +00:00
|
|
|
if (pProcessData->Console)
|
|
|
|
{
|
2008-07-27 20:08:18 +00:00
|
|
|
RemoveEntryList(&pProcessData->ProcessEntry);
|
2003-12-02 11:38:47 +00:00
|
|
|
CsrReleaseObjectByPointer((Object_t *) pProcessData->Console);
|
|
|
|
}
|
2003-01-11 15:51:48 +00:00
|
|
|
if (pProcessData->CsrSectionViewBase)
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
|
|
|
NtUnmapViewOfSection(NtCurrentProcess(), pProcessData->CsrSectionViewBase);
|
|
|
|
}
|
2007-06-14 19:09:32 +00:00
|
|
|
if (pProcessData->ServerCommunicationPort)
|
|
|
|
{
|
|
|
|
NtClose(pProcessData->ServerCommunicationPort);
|
|
|
|
}
|
2008-07-27 20:08:18 +00:00
|
|
|
*pPrevLink = pProcessData->next;
|
2003-01-11 15:51:48 +00:00
|
|
|
|
2003-12-02 11:38:47 +00:00
|
|
|
RtlFreeHeap(CsrssApiHeap, 0, pProcessData);
|
2003-01-11 15:51:48 +00:00
|
|
|
UNLOCK;
|
2008-10-25 15:33:02 +00:00
|
|
|
if (Process)
|
|
|
|
{
|
|
|
|
NtClose(Process);
|
|
|
|
}
|
2003-01-11 15:51:48 +00:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2003-12-02 11:38:47 +00:00
|
|
|
|
2001-08-14 12:57:16 +00:00
|
|
|
UNLOCK;
|
2000-04-23 17:44:53 +00:00
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
NTSTATUS WINAPI
|
2005-12-01 22:38:03 +00:00
|
|
|
CsrEnumProcesses(CSRSS_ENUM_PROCESS_PROC EnumProc, PVOID Context)
|
|
|
|
{
|
|
|
|
UINT Hash;
|
|
|
|
PCSRSS_PROCESS_DATA pProcessData;
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
|
|
|
|
LOCK;
|
|
|
|
|
|
|
|
for (Hash = 0; Hash < (sizeof(ProcessData) / sizeof(*ProcessData)); Hash++)
|
|
|
|
{
|
|
|
|
pProcessData = ProcessData[Hash];
|
|
|
|
while (NULL != pProcessData)
|
|
|
|
{
|
|
|
|
Status = EnumProc(pProcessData, Context);
|
|
|
|
if (STATUS_SUCCESS != Status)
|
|
|
|
{
|
|
|
|
UNLOCK;
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
pProcessData = pProcessData->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UNLOCK;
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
1999-12-30 01:51:42 +00:00
|
|
|
|
2001-08-14 12:57:16 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* CSRSS API
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
CSR_API(CsrCreateProcess)
|
1999-06-08 22:50:59 +00:00
|
|
|
{
|
1999-12-30 01:51:42 +00:00
|
|
|
PCSRSS_PROCESS_DATA NewProcessData;
|
2005-07-31 21:23:40 +00:00
|
|
|
NTSTATUS Status;
|
2000-04-23 17:44:53 +00:00
|
|
|
|
2005-08-16 23:05:33 +00:00
|
|
|
Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
|
2005-08-11 02:58:54 +00:00
|
|
|
Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
|
2002-10-01 06:41:57 +00:00
|
|
|
|
2003-03-09 21:41:35 +00:00
|
|
|
NewProcessData = CsrCreateProcessData(Request->Data.CreateProcessRequest.NewProcessId);
|
1999-12-30 01:51:42 +00:00
|
|
|
if (NewProcessData == NULL)
|
|
|
|
{
|
|
|
|
return(STATUS_NO_MEMORY);
|
|
|
|
}
|
2002-10-01 06:41:57 +00:00
|
|
|
|
2005-07-31 21:23:40 +00:00
|
|
|
if (!(Request->Data.CreateProcessRequest.Flags & (CREATE_NEW_CONSOLE|DETACHED_PROCESS)))
|
|
|
|
{
|
|
|
|
NewProcessData->ParentConsole = ProcessData->Console;
|
|
|
|
NewProcessData->bInheritHandles = Request->Data.CreateProcessRequest.bInheritHandles;
|
|
|
|
if (Request->Data.CreateProcessRequest.bInheritHandles)
|
|
|
|
{
|
|
|
|
Status = CsrDuplicateHandleTable(ProcessData, NewProcessData);
|
|
|
|
}
|
|
|
|
}
|
2007-06-14 16:47:24 +00:00
|
|
|
|
2008-08-02 17:01:22 +00:00
|
|
|
if (Request->Data.CreateProcessRequest.Flags & CREATE_NEW_PROCESS_GROUP)
|
|
|
|
{
|
2008-10-26 15:23:00 +00:00
|
|
|
NewProcessData->ProcessGroup = (DWORD)(ULONG_PTR)NewProcessData->ProcessId;
|
2008-08-02 17:01:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NewProcessData->ProcessGroup = ProcessData->ProcessGroup;
|
|
|
|
}
|
|
|
|
|
2000-03-22 18:36:00 +00:00
|
|
|
return(STATUS_SUCCESS);
|
1999-06-08 22:50:59 +00:00
|
|
|
}
|
|
|
|
|
2001-08-14 12:57:16 +00:00
|
|
|
CSR_API(CsrTerminateProcess)
|
1999-12-22 14:48:30 +00:00
|
|
|
{
|
2006-11-05 20:31:35 +00:00
|
|
|
Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
|
|
|
|
Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
|
2001-08-14 12:57:16 +00:00
|
|
|
|
2005-12-01 22:38:03 +00:00
|
|
|
ProcessData->Terminated = TRUE;
|
2004-12-25 22:58:59 +00:00
|
|
|
return STATUS_SUCCESS;
|
1999-12-22 14:48:30 +00:00
|
|
|
}
|
1999-06-08 22:50:59 +00:00
|
|
|
|
2001-08-14 12:57:16 +00:00
|
|
|
CSR_API(CsrConnectProcess)
|
1999-06-08 22:50:59 +00:00
|
|
|
{
|
2005-08-11 02:58:54 +00:00
|
|
|
Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
|
2005-08-16 23:05:33 +00:00
|
|
|
Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
|
2002-10-01 06:41:57 +00:00
|
|
|
|
1999-12-22 14:48:30 +00:00
|
|
|
return(STATUS_SUCCESS);
|
1999-06-08 22:50:59 +00:00
|
|
|
}
|
|
|
|
|
2002-10-20 16:40:12 +00:00
|
|
|
CSR_API(CsrGetShutdownParameters)
|
|
|
|
{
|
2005-08-11 02:58:54 +00:00
|
|
|
Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
|
2005-08-16 23:05:33 +00:00
|
|
|
Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
|
2002-10-20 16:40:12 +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
|
|
|
Request->Data.GetShutdownParametersRequest.Level = ProcessData->ShutdownLevel;
|
|
|
|
Request->Data.GetShutdownParametersRequest.Flags = ProcessData->ShutdownFlags;
|
2002-10-20 16:40:12 +00:00
|
|
|
|
|
|
|
return(STATUS_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
CSR_API(CsrSetShutdownParameters)
|
|
|
|
{
|
2005-08-11 02:58:54 +00:00
|
|
|
Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
|
2005-08-16 23:05:33 +00:00
|
|
|
Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
|
2002-10-20 16:40:12 +00:00
|
|
|
|
|
|
|
ProcessData->ShutdownLevel = Request->Data.SetShutdownParametersRequest.Level;
|
|
|
|
ProcessData->ShutdownFlags = Request->Data.SetShutdownParametersRequest.Flags;
|
|
|
|
|
|
|
|
return(STATUS_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2003-02-24 23:20:16 +00:00
|
|
|
CSR_API(CsrGetInputHandle)
|
|
|
|
{
|
2005-08-11 02:58:54 +00:00
|
|
|
Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
|
2005-08-16 23:05:33 +00:00
|
|
|
Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
|
2003-02-24 23:20:16 +00:00
|
|
|
|
2008-08-02 22:09:22 +00:00
|
|
|
if (ProcessData->Console)
|
2003-02-24 23:20:16 +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
|
|
|
Request->Status = CsrInsertObject(ProcessData,
|
|
|
|
&Request->Data.GetInputHandleRequest.InputHandle,
|
2008-07-22 17:37:13 +00:00
|
|
|
(Object_t *)ProcessData->Console,
|
|
|
|
Request->Data.GetInputHandleRequest.Access,
|
|
|
|
Request->Data.GetInputHandleRequest.Inheritable);
|
2003-02-24 23:20:16 +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
|
|
|
Request->Data.GetInputHandleRequest.InputHandle = INVALID_HANDLE_VALUE;
|
|
|
|
Request->Status = STATUS_SUCCESS;
|
2003-02-24 23:20:16 +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
|
|
|
return Request->Status;
|
2003-02-24 23:20:16 +00:00
|
|
|
}
|
2002-10-20 16:40:12 +00:00
|
|
|
|
2003-02-24 23:20:16 +00:00
|
|
|
CSR_API(CsrGetOutputHandle)
|
|
|
|
{
|
2005-08-11 02:58:54 +00:00
|
|
|
Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
|
2005-08-16 23:05:33 +00:00
|
|
|
Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
|
2003-02-24 23:20:16 +00:00
|
|
|
|
2008-08-02 22:09:22 +00:00
|
|
|
if (ProcessData->Console)
|
2003-02-24 23:20:16 +00:00
|
|
|
{
|
2003-12-02 11:38:47 +00:00
|
|
|
RtlEnterCriticalSection(&ProcessDataLock);
|
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 = CsrInsertObject(ProcessData,
|
|
|
|
&Request->Data.GetOutputHandleRequest.OutputHandle,
|
2008-07-22 17:37:13 +00:00
|
|
|
&ProcessData->Console->ActiveBuffer->Header,
|
|
|
|
Request->Data.GetOutputHandleRequest.Access,
|
|
|
|
Request->Data.GetOutputHandleRequest.Inheritable);
|
2003-12-02 11:38:47 +00:00
|
|
|
RtlLeaveCriticalSection(&ProcessDataLock);
|
2003-02-24 23:20:16 +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
|
|
|
Request->Data.GetOutputHandleRequest.OutputHandle = INVALID_HANDLE_VALUE;
|
|
|
|
Request->Status = STATUS_SUCCESS;
|
2003-02-24 23:20:16 +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
|
|
|
return Request->Status;
|
2003-02-24 23:20:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CSR_API(CsrCloseHandle)
|
|
|
|
{
|
2005-08-11 02:58:54 +00:00
|
|
|
Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
|
2005-08-16 23:05:33 +00:00
|
|
|
Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
|
2003-02-24 23:20:16 +00:00
|
|
|
|
2008-08-02 22:09:22 +00:00
|
|
|
return CsrReleaseObject(ProcessData, Request->Data.CloseHandleRequest.Handle);
|
2003-02-24 23:20:16 +00:00
|
|
|
}
|
2003-03-05 22:51:48 +00:00
|
|
|
|
|
|
|
CSR_API(CsrVerifyHandle)
|
|
|
|
{
|
2005-08-11 02:58:54 +00:00
|
|
|
Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
|
2005-08-16 23:05:33 +00:00
|
|
|
Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
|
2003-03-05 22:51:48 +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
|
|
|
Request->Status = CsrVerifyObject(ProcessData, Request->Data.VerifyHandleRequest.Handle);
|
|
|
|
if (!NT_SUCCESS(Request->Status))
|
2003-03-05 22:51:48 +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
|
|
|
DPRINT("CsrVerifyObject failed, status=%x\n", Request->Status);
|
2003-03-09 21:41:35 +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
|
|
|
return Request->Status;
|
2003-03-09 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CSR_API(CsrDuplicateHandle)
|
|
|
|
{
|
2008-10-26 15:23:00 +00:00
|
|
|
ULONG_PTR Index;
|
2008-07-22 17:37:13 +00:00
|
|
|
PCSRSS_HANDLE Entry;
|
|
|
|
DWORD DesiredAccess;
|
2003-03-09 21:41:35 +00:00
|
|
|
|
2008-07-22 17:37:13 +00:00
|
|
|
Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
|
|
|
|
Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
|
2003-03-09 21:41:35 +00:00
|
|
|
|
2008-10-26 15:23:00 +00:00
|
|
|
Index = (ULONG_PTR)Request->Data.DuplicateHandleRequest.Handle >> 2;
|
2008-07-22 17:37:13 +00:00
|
|
|
RtlEnterCriticalSection(&ProcessData->HandleTableLock);
|
|
|
|
if (Index >= ProcessData->HandleTableSize
|
|
|
|
|| (Entry = &ProcessData->HandleTable[Index])->Object == NULL)
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
2008-07-22 17:37:13 +00:00
|
|
|
DPRINT1("Couldn't dup invalid handle %p\n", Request->Data.DuplicateHandleRequest.Handle);
|
|
|
|
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
|
2008-08-02 22:09:22 +00:00
|
|
|
return STATUS_INVALID_HANDLE;
|
2003-12-02 11:38:47 +00:00
|
|
|
}
|
2008-07-22 17:37:13 +00:00
|
|
|
|
|
|
|
if (Request->Data.DuplicateHandleRequest.Options & DUPLICATE_SAME_ACCESS)
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
2008-07-22 17:37:13 +00:00
|
|
|
DesiredAccess = Entry->Access;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DesiredAccess = Request->Data.DuplicateHandleRequest.Access;
|
|
|
|
/* Make sure the source handle has all the desired flags */
|
|
|
|
if (~Entry->Access & DesiredAccess)
|
|
|
|
{
|
|
|
|
DPRINT1("Handle %p only has access %X; requested %X\n",
|
|
|
|
Request->Data.DuplicateHandleRequest.Handle, Entry->Access, DesiredAccess);
|
|
|
|
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
|
2008-08-02 22:09:22 +00:00
|
|
|
return STATUS_INVALID_PARAMETER;
|
2008-07-22 17:37:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Request->Status = CsrInsertObject(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
|
|
|
&Request->Data.DuplicateHandleRequest.Handle,
|
2008-07-22 17:37:13 +00:00
|
|
|
Entry->Object,
|
|
|
|
DesiredAccess,
|
|
|
|
Request->Data.DuplicateHandleRequest.Inheritable);
|
|
|
|
if (NT_SUCCESS(Request->Status)
|
|
|
|
&& Request->Data.DuplicateHandleRequest.Options & DUPLICATE_CLOSE_SOURCE)
|
|
|
|
{
|
|
|
|
/* Close the original handle. This cannot drop the count to 0, since a new handle now exists */
|
|
|
|
_InterlockedDecrement(&Entry->Object->ReferenceCount);
|
|
|
|
Entry->Object = NULL;
|
2003-12-02 11:38:47 +00:00
|
|
|
}
|
2008-07-22 17:37:13 +00:00
|
|
|
|
|
|
|
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
|
|
|
|
return Request->Status;
|
2003-03-05 22:51:48 +00:00
|
|
|
}
|
|
|
|
|
2004-11-14 18:47:10 +00:00
|
|
|
CSR_API(CsrGetInputWaitHandle)
|
|
|
|
{
|
2005-08-11 02:58:54 +00:00
|
|
|
Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
|
2005-08-16 23:05:33 +00:00
|
|
|
Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
|
2004-11-14 18:47:10 +00:00
|
|
|
|
2008-08-02 22:09:22 +00:00
|
|
|
Request->Data.GetConsoleInputWaitHandle.InputWaitHandle = ProcessData->ConsoleEvent;
|
|
|
|
return STATUS_SUCCESS;
|
2004-11-14 18:47:10 +00:00
|
|
|
}
|
|
|
|
|
1999-06-08 22:50:59 +00:00
|
|
|
/* EOF */
|