mirror of
https://github.com/reactos/reactos.git
synced 2025-01-01 03:54:02 +00:00
[NTDLL]
- Add parameter annotations. - Improve CSR buffer allocation with 4-byte align. - Simplify the capture-buffer pointers settings. [CSRSRV] - Remove last console structure from csrsrv.h (in next commits it will be placed in a proper header). - Enable global CSR debugging (for debugging purposes... ;-) ). - api.c: Enable debugging. - api.c/.h: Remove old code and deprecated unused definitions. - Use the Win2k3-compliant version of CsrCreateThread (code from subsystems/csr/csrsrv) (TODO: correct its usage in basesrv:BaseSrvCreateThread). - init.c: Implement a helper routine, CsrInitCsrRootProcess, in order to initialize the per-process server data (see CSR_PROCESS structure) in the Root CSR process. New process inherit it from this Root process. - server.c - Add a DPRINT. Remove a hack. Correct a parameter passing. - session.c - Remove a hack (it will go to the new process initialization in consrv) - Disable the code of CsrConnectToUser while user32:ClientThreadSetup doesn't work. - Correct the implementation of CsrValidateMessageBuffer. - Basic implementation of CsrValidateMessageString using CsrValidateMessageBuffer. TODO: - Compare CsrpHandleConnectionRequest with the other one function in api.c. - Compare CsrValidateMessageBuffer with Win32CsrValidateBuffer ? svn path=/branches/ros-csrss/; revision=57673
This commit is contained in:
parent
a8f1d34118
commit
d736f0b914
14 changed files with 479 additions and 953 deletions
|
@ -50,7 +50,7 @@ CsrSetPriorityClass(HANDLE hProcess,
|
|||
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;
|
||||
|
||||
|
@ -68,7 +68,7 @@ CsrIdentifyAlertableThread(VOID)
|
|||
NTSTATUS Status;
|
||||
CSR_API_MESSAGE ApiMessage;
|
||||
PCSR_IDENTIFY_ALTERTABLE_THREAD IdentifyAlertableThread;
|
||||
|
||||
|
||||
/* Set up the data for CSR */
|
||||
DbgBreakPoint();
|
||||
IdentifyAlertableThread = &ApiMessage.Data.IdentifyAlertableThread;
|
||||
|
|
|
@ -82,10 +82,10 @@ CsrProbeForWrite(IN PVOID Address,
|
|||
/*
|
||||
* @implemented
|
||||
*/
|
||||
PVOID
|
||||
PCSR_CAPTURE_BUFFER
|
||||
NTAPI
|
||||
CsrAllocateCaptureBuffer(ULONG ArgumentCount,
|
||||
ULONG BufferSize)
|
||||
CsrAllocateCaptureBuffer(IN ULONG ArgumentCount,
|
||||
IN ULONG BufferSize)
|
||||
{
|
||||
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
||||
|
||||
|
@ -93,10 +93,13 @@ CsrAllocateCaptureBuffer(ULONG ArgumentCount,
|
|||
if (BufferSize >= MAXLONG) return NULL;
|
||||
|
||||
/* Add the size of the header and for each pointer to the pointers */
|
||||
BufferSize += sizeof(CSR_CAPTURE_BUFFER) + (ArgumentCount * sizeof(PVOID));
|
||||
BufferSize += FIELD_OFFSET(CSR_CAPTURE_BUFFER, PointerOffsetsArray) + (ArgumentCount * sizeof(ULONG_PTR));
|
||||
|
||||
/* Align it to a 4-byte boundary */
|
||||
BufferSize = (BufferSize + 3) & ~3;
|
||||
|
||||
/* Allocate memory from the port heap */
|
||||
CaptureBuffer = RtlAllocateHeap(CsrPortHeap, 0, BufferSize);
|
||||
CaptureBuffer = RtlAllocateHeap(CsrPortHeap, HEAP_ZERO_MEMORY, BufferSize);
|
||||
if (CaptureBuffer == NULL) return NULL;
|
||||
|
||||
/* Initialize the header */
|
||||
|
@ -104,12 +107,12 @@ CsrAllocateCaptureBuffer(ULONG ArgumentCount,
|
|||
CaptureBuffer->PointerCount = 0;
|
||||
|
||||
/* Initialize all the pointers */
|
||||
RtlZeroMemory(CaptureBuffer->PointerArray,
|
||||
RtlZeroMemory(CaptureBuffer->PointerOffsetsArray,
|
||||
ArgumentCount * sizeof(ULONG_PTR));
|
||||
|
||||
/* Point the start of the free buffer */
|
||||
CaptureBuffer->BufferEnd = (ULONG_PTR)CaptureBuffer->PointerArray +
|
||||
ArgumentCount * sizeof(ULONG_PTR);
|
||||
/* Point to the start of the free buffer */
|
||||
CaptureBuffer->BufferEnd = (PVOID)((ULONG_PTR)CaptureBuffer->PointerOffsetsArray +
|
||||
ArgumentCount * sizeof(ULONG_PTR));
|
||||
|
||||
/* Return the address of the buffer */
|
||||
return CaptureBuffer;
|
||||
|
@ -120,20 +123,19 @@ CsrAllocateCaptureBuffer(ULONG ArgumentCount,
|
|||
*/
|
||||
ULONG
|
||||
NTAPI
|
||||
CsrAllocateMessagePointer(PCSR_CAPTURE_BUFFER CaptureBuffer,
|
||||
ULONG MessageLength,
|
||||
PVOID *CaptureData)
|
||||
CsrAllocateMessagePointer(IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer,
|
||||
IN ULONG MessageLength,
|
||||
OUT PVOID *CapturedData)
|
||||
{
|
||||
/* If there's no data, our job is easy. */
|
||||
if (MessageLength == 0)
|
||||
{
|
||||
*CaptureData = NULL;
|
||||
CaptureData = NULL;
|
||||
*CapturedData = NULL;
|
||||
CapturedData = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set the capture data at our current available buffer */
|
||||
*CaptureData = (PVOID)CaptureBuffer->BufferEnd;
|
||||
*CapturedData = CaptureBuffer->BufferEnd;
|
||||
|
||||
/* Validate the size */
|
||||
if (MessageLength >= MAXLONG) return 0;
|
||||
|
@ -142,14 +144,11 @@ CsrAllocateMessagePointer(PCSR_CAPTURE_BUFFER CaptureBuffer,
|
|||
MessageLength = (MessageLength + 3) & ~3;
|
||||
|
||||
/* Move our available buffer beyond this space */
|
||||
CaptureBuffer->BufferEnd += MessageLength;
|
||||
CaptureBuffer->BufferEnd = (PVOID)((ULONG_PTR)CaptureBuffer->BufferEnd + MessageLength);
|
||||
}
|
||||
|
||||
/* Write down this pointer in the array */
|
||||
CaptureBuffer->PointerArray[CaptureBuffer->PointerCount] = (ULONG_PTR)CaptureData;
|
||||
|
||||
/* Increase the pointer count */
|
||||
CaptureBuffer->PointerCount++;
|
||||
/* Write down this pointer in the array and increase the count */
|
||||
CaptureBuffer->PointerOffsetsArray[CaptureBuffer->PointerCount++] = (ULONG_PTR)CapturedData;
|
||||
|
||||
/* Return the aligned length */
|
||||
return MessageLength;
|
||||
|
@ -160,19 +159,19 @@ CsrAllocateMessagePointer(PCSR_CAPTURE_BUFFER CaptureBuffer,
|
|||
*/
|
||||
VOID
|
||||
NTAPI
|
||||
CsrCaptureMessageBuffer(PCSR_CAPTURE_BUFFER CaptureBuffer,
|
||||
PVOID MessageString,
|
||||
ULONG StringLength,
|
||||
PVOID *CapturedData)
|
||||
CsrCaptureMessageBuffer(IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer,
|
||||
IN PVOID MessageBuffer OPTIONAL,
|
||||
IN ULONG MessageLength,
|
||||
OUT PVOID *CapturedData)
|
||||
{
|
||||
/* Simply allocate a message pointer in the buffer */
|
||||
CsrAllocateMessagePointer(CaptureBuffer, StringLength, CapturedData);
|
||||
CsrAllocateMessagePointer(CaptureBuffer, MessageLength, CapturedData);
|
||||
|
||||
/* Check if there was any data */
|
||||
if (!MessageString || !StringLength) return;
|
||||
if (!MessageBuffer || !MessageLength) return;
|
||||
|
||||
/* Copy the data into the buffer */
|
||||
RtlMoveMemory(*CapturedData, MessageString, StringLength);
|
||||
RtlMoveMemory(*CapturedData, MessageBuffer, MessageLength);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -180,14 +179,14 @@ CsrCaptureMessageBuffer(PCSR_CAPTURE_BUFFER CaptureBuffer,
|
|||
*/
|
||||
VOID
|
||||
NTAPI
|
||||
CsrFreeCaptureBuffer(PCSR_CAPTURE_BUFFER CaptureBuffer)
|
||||
CsrFreeCaptureBuffer(IN PCSR_CAPTURE_BUFFER CaptureBuffer)
|
||||
{
|
||||
/* Free it from the heap */
|
||||
RtlFreeHeap(CsrPortHeap, 0, CaptureBuffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
* @unimplemented
|
||||
*/
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
|
@ -206,8 +205,8 @@ CsrCaptureMessageMultiUnicodeStringsInPlace(IN PCSR_CAPTURE_BUFFER *CaptureBuffe
|
|||
*/
|
||||
VOID
|
||||
NTAPI
|
||||
CsrCaptureMessageString(PCSR_CAPTURE_BUFFER CaptureBuffer,
|
||||
LPSTR String,
|
||||
CsrCaptureMessageString(IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer,
|
||||
IN LPSTR String OPTIONAL,
|
||||
IN ULONG StringLength,
|
||||
IN ULONG MaximumLength,
|
||||
OUT PANSI_STRING CapturedString)
|
||||
|
@ -256,14 +255,14 @@ CsrCaptureMessageString(PCSR_CAPTURE_BUFFER CaptureBuffer,
|
|||
*/
|
||||
PLARGE_INTEGER
|
||||
NTAPI
|
||||
CsrCaptureTimeout(LONG Milliseconds,
|
||||
PLARGE_INTEGER Timeout)
|
||||
CsrCaptureTimeout(IN ULONG Milliseconds,
|
||||
OUT PLARGE_INTEGER Timeout)
|
||||
{
|
||||
/* Validate the time */
|
||||
if (Milliseconds == -1) return NULL;
|
||||
|
||||
/* Convert to relative ticks */
|
||||
Timeout->QuadPart = Milliseconds * -100000;
|
||||
Timeout->QuadPart = Int32x32To64(Milliseconds, -100000);
|
||||
return Timeout;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,120 +51,113 @@ CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage,
|
|||
IN ULONG DataLength)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
ULONG PointerCount;
|
||||
PULONG_PTR Pointers;
|
||||
ULONG_PTR CurrentPointer;
|
||||
DPRINT("CsrClientCallServer\n");
|
||||
ULONG i;
|
||||
|
||||
/* Fill out the Port Message Header */
|
||||
/* Fill out the Port Message Header. */
|
||||
ApiMessage->Header.u2.ZeroInit = 0;
|
||||
ApiMessage->Header.u1.s1.TotalLength =
|
||||
FIELD_OFFSET(CSR_API_MESSAGE, Data) + DataLength;
|
||||
/* FIELD_OFFSET(CSR_API_MESSAGE, Data) <= sizeof(CSR_API_MESSAGE) - sizeof(ApiMessage->Data) */
|
||||
ApiMessage->Header.u1.s1.DataLength =
|
||||
ApiMessage->Header.u1.s1.TotalLength - sizeof(PORT_MESSAGE);
|
||||
|
||||
/* Fill out the CSR Header */
|
||||
/* Fill out the CSR Header. */
|
||||
ApiMessage->ApiNumber = ApiNumber;
|
||||
ApiMessage->CsrCaptureData = NULL;
|
||||
|
||||
DPRINT("API: %lx, u1.s1.DataLength: %x, u1.s1.TotalLength: %x\n",
|
||||
DPRINT("API: %lx, u1.s1.DataLength: %x, u1.s1.TotalLength: %x\n",
|
||||
ApiNumber,
|
||||
ApiMessage->Header.u1.s1.DataLength,
|
||||
ApiMessage->Header.u1.s1.TotalLength);
|
||||
|
||||
/* Check if we are already inside a CSR Server */
|
||||
/* Check if we are already inside a CSR Server. */
|
||||
if (!InsideCsrProcess)
|
||||
{
|
||||
/* Check if we got a a Capture Buffer */
|
||||
/* Check if we got a Capture Buffer. */
|
||||
if (CaptureBuffer)
|
||||
{
|
||||
/* We have to convert from our local view to the remote view */
|
||||
ApiMessage->CsrCaptureData = (PVOID)((ULONG_PTR)CaptureBuffer +
|
||||
CsrPortMemoryDelta);
|
||||
/*
|
||||
* We have to convert from our local (client) view
|
||||
* to the remote (server) view.
|
||||
*/
|
||||
ApiMessage->CsrCaptureData = (PCSR_CAPTURE_BUFFER)
|
||||
((ULONG_PTR)CaptureBuffer + CsrPortMemoryDelta);
|
||||
|
||||
/* Lock the buffer */
|
||||
CaptureBuffer->BufferEnd = 0;
|
||||
/* Lock the buffer. */
|
||||
CaptureBuffer->BufferEnd = NULL;
|
||||
|
||||
/* Get the pointer information */
|
||||
PointerCount = CaptureBuffer->PointerCount;
|
||||
Pointers = CaptureBuffer->PointerArray;
|
||||
|
||||
/* Loop through every pointer and convert it */
|
||||
DPRINT("PointerCount: %lx\n", PointerCount);
|
||||
while (PointerCount--)
|
||||
/*
|
||||
* Each client pointer inside the CSR message is converted into
|
||||
* a server pointer, and each pointer to these message pointers
|
||||
* is converted into an offset.
|
||||
*/
|
||||
for (i = 0 ; i < CaptureBuffer->PointerCount ; ++i)
|
||||
{
|
||||
/* Get this pointer and check if it's valid */
|
||||
DPRINT("Array Address: %p. This pointer: %p. Data: %lx\n",
|
||||
&Pointers, Pointers, *Pointers);
|
||||
if ((CurrentPointer = *Pointers++))
|
||||
if (CaptureBuffer->PointerOffsetsArray[i] != 0)
|
||||
{
|
||||
/* Update it */
|
||||
DPRINT("CurrentPointer: %lx.\n", *(PULONG_PTR)CurrentPointer);
|
||||
*(PULONG_PTR)CurrentPointer += CsrPortMemoryDelta;
|
||||
Pointers[-1] = CurrentPointer - (ULONG_PTR)ApiMessage;
|
||||
DPRINT("CurrentPointer: %lx.\n", *(PULONG_PTR)CurrentPointer);
|
||||
*(PULONG_PTR)CaptureBuffer->PointerOffsetsArray[i] += CsrPortMemoryDelta;
|
||||
CaptureBuffer->PointerOffsetsArray[i] -= (ULONG_PTR)ApiMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Send the LPC Message */
|
||||
/* Send the LPC Message. */
|
||||
Status = NtRequestWaitReplyPort(CsrApiPort,
|
||||
&ApiMessage->Header,
|
||||
&ApiMessage->Header);
|
||||
|
||||
/* Check if we got a a Capture Buffer */
|
||||
/* Check if we got a Capture Buffer. */
|
||||
if (CaptureBuffer)
|
||||
{
|
||||
/* We have to convert back from the remote view to our local view */
|
||||
DPRINT("Reconverting CaptureBuffer\n");
|
||||
ApiMessage->CsrCaptureData = (PVOID)((ULONG_PTR)
|
||||
ApiMessage->CsrCaptureData -
|
||||
CsrPortMemoryDelta);
|
||||
/*
|
||||
* We have to convert back from the remote (server) view
|
||||
* to our local (client) view.
|
||||
*/
|
||||
ApiMessage->CsrCaptureData = (PCSR_CAPTURE_BUFFER)
|
||||
((ULONG_PTR)ApiMessage->CsrCaptureData - CsrPortMemoryDelta);
|
||||
|
||||
/* Get the pointer information */
|
||||
PointerCount = CaptureBuffer->PointerCount;
|
||||
Pointers = CaptureBuffer->PointerArray;
|
||||
|
||||
/* Loop through every pointer and convert it */
|
||||
while (PointerCount--)
|
||||
/*
|
||||
* Convert back the offsets into pointers to CSR message
|
||||
* pointers, and convert back these message server pointers
|
||||
* into client pointers.
|
||||
*/
|
||||
for (i = 0 ; i < CaptureBuffer->PointerCount ; ++i)
|
||||
{
|
||||
/* Get this pointer and check if it's valid */
|
||||
if ((CurrentPointer = *Pointers++))
|
||||
if (CaptureBuffer->PointerOffsetsArray[i] != 0)
|
||||
{
|
||||
/* Update it */
|
||||
CurrentPointer += (ULONG_PTR)ApiMessage;
|
||||
Pointers[-1] = CurrentPointer;
|
||||
*(PULONG_PTR)CurrentPointer -= CsrPortMemoryDelta;
|
||||
CaptureBuffer->PointerOffsetsArray[i] += (ULONG_PTR)ApiMessage;
|
||||
*(PULONG_PTR)CaptureBuffer->PointerOffsetsArray[i] -= CsrPortMemoryDelta;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for success */
|
||||
/* Check for success. */
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* We failed. Overwrite the return value with the failure */
|
||||
/* We failed. Overwrite the return value with the failure. */
|
||||
DPRINT1("LPC Failed: %lx\n", Status);
|
||||
ApiMessage->Status = Status;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is a server-to-server call. Save our CID and do a direct call */
|
||||
/* This is a server-to-server call. Save our CID and do a direct call. */
|
||||
DPRINT1("Next gen server-to-server call\n");
|
||||
|
||||
/* We check this equality inside CsrValidateMessageBuffer. */
|
||||
ApiMessage->Header.ClientId = NtCurrentTeb()->ClientId;
|
||||
|
||||
Status = CsrServerApiRoutine(&ApiMessage->Header,
|
||||
&ApiMessage->Header);
|
||||
|
||||
/* Check for success */
|
||||
|
||||
/* Check for success. */
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* We failed. Overwrite the return value with the failure */
|
||||
/* We failed. Overwrite the return value with the failure. */
|
||||
ApiMessage->Status = Status;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return the CSR Result */
|
||||
/* Return the CSR Result. */
|
||||
DPRINT("Got back: 0x%lx\n", ApiMessage->Status);
|
||||
return ApiMessage->Status;
|
||||
}
|
||||
|
@ -203,7 +196,7 @@ CsrpConnectToServer(IN PWSTR ObjectDirectory)
|
|||
PortName.MaximumLength = PortNameLength;
|
||||
|
||||
/* Allocate a buffer for it */
|
||||
PortName.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, PortNameLength);
|
||||
PortName.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, PortNameLength);
|
||||
if (PortName.Buffer == NULL)
|
||||
{
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
@ -307,6 +300,8 @@ CsrpConnectToServer(IN PWSTR ObjectDirectory)
|
|||
0);
|
||||
if (CsrPortHeap == NULL)
|
||||
{
|
||||
/* Failure */
|
||||
DPRINT1("Couldn't create heap for CSR port\n");
|
||||
NtClose(CsrApiPort);
|
||||
CsrApiPort = NULL;
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
@ -332,9 +327,9 @@ CsrClientConnectToServer(IN PWSTR ObjectDirectory,
|
|||
UNICODE_STRING CsrSrvName;
|
||||
HANDLE hCsrSrv;
|
||||
ANSI_STRING CsrServerRoutineName;
|
||||
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
||||
CSR_API_MESSAGE ApiMessage;
|
||||
PCSR_CLIENT_CONNECT ClientConnect = &ApiMessage.Data.CsrClientConnect;
|
||||
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
||||
|
||||
/* Validate the Connection Info */
|
||||
DPRINT("CsrClientConnectToServer: %lx %p\n", ServerId, ConnectionInfo);
|
||||
|
@ -419,15 +414,11 @@ CsrClientConnectToServer(IN PWSTR ObjectDirectory,
|
|||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
/* Allocate a pointer for the connection info*/
|
||||
CsrAllocateMessagePointer(CaptureBuffer,
|
||||
ClientConnect->ConnectionInfoSize,
|
||||
&ClientConnect->ConnectionInfo);
|
||||
|
||||
/* Copy the data into the buffer */
|
||||
RtlMoveMemory(ClientConnect->ConnectionInfo,
|
||||
ConnectionInfo,
|
||||
ClientConnect->ConnectionInfoSize);
|
||||
/* Capture the connection info data */
|
||||
CsrCaptureMessageBuffer(CaptureBuffer,
|
||||
ConnectionInfo,
|
||||
ClientConnect->ConnectionInfoSize,
|
||||
&ClientConnect->ConnectionInfo);
|
||||
|
||||
/* Return the allocated length */
|
||||
*ConnectionInfoSize = ClientConnect->ConnectionInfoSize;
|
||||
|
|
|
@ -38,27 +38,40 @@ CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage,
|
|||
IN CSR_API_NUMBER ApiNumber,
|
||||
IN ULONG DataLength);
|
||||
|
||||
PVOID
|
||||
PCSR_CAPTURE_BUFFER
|
||||
NTAPI
|
||||
CsrAllocateCaptureBuffer(IN ULONG ArgumentCount,
|
||||
IN ULONG BufferSize);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CsrFreeCaptureBuffer(IN PCSR_CAPTURE_BUFFER CaptureBuffer);
|
||||
|
||||
ULONG
|
||||
NTAPI
|
||||
CsrAllocateMessagePointer(IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer,
|
||||
IN ULONG MessageLength,
|
||||
OUT PVOID* CaptureData);
|
||||
OUT PVOID *CapturedData);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CsrCaptureMessageBuffer(IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer,
|
||||
IN PVOID MessageString,
|
||||
IN PVOID MessageBuffer OPTIONAL,
|
||||
IN ULONG MessageLength,
|
||||
OUT PVOID *CapturedData);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CsrCaptureMessageString(IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer,
|
||||
IN LPSTR String OPTIONAL,
|
||||
IN ULONG StringLength,
|
||||
OUT PVOID* CapturedData);
|
||||
IN ULONG MaximumLength,
|
||||
OUT PANSI_STRING CapturedString);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CsrFreeCaptureBuffer(IN PCSR_CAPTURE_BUFFER CaptureBuffer);
|
||||
|
||||
PLARGE_INTEGER
|
||||
NTAPI
|
||||
CsrCaptureTimeout(IN ULONG Milliseconds,
|
||||
OUT PLARGE_INTEGER Timeout);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
|
|
|
@ -93,8 +93,8 @@ typedef struct _CSR_CAPTURE_BUFFER
|
|||
ULONG Size;
|
||||
struct _CSR_CAPTURE_BUFFER *PreviousCaptureBuffer;
|
||||
ULONG PointerCount;
|
||||
ULONG_PTR BufferEnd;
|
||||
ULONG_PTR PointerArray[1];
|
||||
PVOID BufferEnd;
|
||||
ULONG_PTR PointerOffsetsArray[ANYSIZE_ARRAY];
|
||||
} CSR_CAPTURE_BUFFER, *PCSR_CAPTURE_BUFFER;
|
||||
|
||||
/* Keep in sync with definition below. */
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
/* TYPES **********************************************************************/
|
||||
|
||||
// Used in ntdll/csr/connect.c
|
||||
#define CSR_CSRSS_SECTION_SIZE (65536)
|
||||
#define CSR_CSRSS_SECTION_SIZE 65536
|
||||
|
||||
typedef struct _CSR_NT_SESSION
|
||||
{
|
||||
|
@ -33,21 +33,6 @@ typedef struct _CSR_NT_SESSION
|
|||
ULONG SessionId;
|
||||
} CSR_NT_SESSION, *PCSR_NT_SESSION;
|
||||
|
||||
/*** old thingie, remove it later... (put it in winsrv -- console) ***/
|
||||
#include <win/conmsg.h>
|
||||
typedef struct _CSRSS_CON_PROCESS_DATA
|
||||
{
|
||||
HANDLE ConsoleEvent;
|
||||
struct tagCSRSS_CONSOLE *Console;
|
||||
struct tagCSRSS_CONSOLE *ParentConsole;
|
||||
BOOL bInheritHandles;
|
||||
RTL_CRITICAL_SECTION HandleTableLock;
|
||||
ULONG HandleTableSize;
|
||||
struct _CSRSS_HANDLE *HandleTable;
|
||||
PCONTROLDISPATCHER CtrlDispatcher;
|
||||
LIST_ENTRY ConsoleLink;
|
||||
} CSRSS_CON_PROCESS_DATA, *PCSRSS_CON_PROCESS_DATA;
|
||||
/*********************************************************************/
|
||||
typedef struct _CSR_PROCESS
|
||||
{
|
||||
CLIENT_ID ClientId;
|
||||
|
@ -73,8 +58,7 @@ typedef struct _CSR_PROCESS
|
|||
ULONG Reserved;
|
||||
ULONG ShutdownLevel;
|
||||
ULONG ShutdownFlags;
|
||||
PVOID ServerData[ANYSIZE_ARRAY]; // ServerDllPerProcessData // One structure per CSR server.
|
||||
CSRSS_CON_PROCESS_DATA; //// FIXME: Remove it after we activate the previous member.
|
||||
PVOID ServerData[ANYSIZE_ARRAY]; // One structure per CSR server.
|
||||
} CSR_PROCESS, *PCSR_PROCESS;
|
||||
|
||||
typedef struct _CSR_THREAD
|
||||
|
@ -181,10 +165,10 @@ NTSTATUS
|
|||
OUT PULONG Reply
|
||||
);
|
||||
|
||||
#define CSR_API(n) NTSTATUS NTAPI n( \
|
||||
IN OUT PCSR_API_MESSAGE ApiMessage, \
|
||||
OUT PULONG Reply)
|
||||
// IN OUT PCSR_REPLY_STATUS ReplyStatus)
|
||||
#define CSR_API(n) \
|
||||
NTSTATUS NTAPI n(IN OUT PCSR_API_MESSAGE ApiMessage, \
|
||||
OUT PULONG Reply)
|
||||
// IN OUT PCSR_REPLY_STATUS ReplyStatus)
|
||||
|
||||
typedef
|
||||
NTSTATUS
|
||||
|
@ -250,7 +234,8 @@ typedef
|
|||
NTSTATUS
|
||||
(NTAPI *PCSR_SERVER_DLL_INIT_CALLBACK)(IN PCSR_SERVER_DLL LoadedServerDll);
|
||||
|
||||
#define CSR_SERVER_DLL_INIT(n) NTSTATUS NTAPI n(IN PCSR_SERVER_DLL LoadedServerDll)
|
||||
#define CSR_SERVER_DLL_INIT(n) \
|
||||
NTSTATUS NTAPI n(IN PCSR_SERVER_DLL LoadedServerDll)
|
||||
|
||||
|
||||
/* PROTOTYPES ****************************************************************/
|
||||
|
@ -306,7 +291,8 @@ NTSTATUS
|
|||
NTAPI
|
||||
CsrCreateThread(IN PCSR_PROCESS CsrProcess,
|
||||
IN HANDLE hThread,
|
||||
IN PCLIENT_ID ClientId);
|
||||
IN PCLIENT_ID ClientId,
|
||||
IN BOOLEAN HaveClient);
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
|
@ -431,8 +417,8 @@ BOOLEAN
|
|||
NTAPI
|
||||
CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage,
|
||||
IN PVOID *Buffer,
|
||||
IN ULONG ArgumentSize,
|
||||
IN ULONG ArgumentCount);
|
||||
IN ULONG ElementCount,
|
||||
IN ULONG ElementSize);
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@
|
|||
@ stdcall CsrConnectToUser()
|
||||
@ stdcall CsrCreateProcess(ptr ptr ptr ptr long ptr)
|
||||
@ stdcall CsrCreateRemoteThread(ptr ptr)
|
||||
@ stdcall CsrCreateThread(ptr ptr ptr) ;;; @ stdcall CsrCreateThread(ptr ptr ptr long) ??
|
||||
@ stdcall CsrCreateThread(ptr ptr ptr long)
|
||||
@ stdcall CsrCreateWait(ptr ptr ptr ptr ptr ptr)
|
||||
@ stdcall CsrDebugProcess(ptr)
|
||||
@ stdcall CsrDebugProcessStop(ptr)
|
||||
|
|
|
@ -41,37 +41,6 @@ extern RTL_CRITICAL_SECTION CsrProcessLock, CsrWaitListsLock;
|
|||
#define CSR_SERVER_DLL_MAX 4
|
||||
|
||||
|
||||
/***
|
||||
*** Old structure. Deprecated.
|
||||
***/
|
||||
typedef struct _CSRSS_API_DEFINITION
|
||||
{
|
||||
ULONG ApiID;
|
||||
ULONG MinRequestSize;
|
||||
PCSR_API_ROUTINE Handler;
|
||||
} CSRSS_API_DEFINITION, *PCSRSS_API_DEFINITION;
|
||||
|
||||
#define CSRSS_DEFINE_API(Func, Handler) \
|
||||
{ Func, sizeof(CSRSS_##Func), Handler }
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct _CSRSS_LISTEN_DATA
|
||||
{
|
||||
HANDLE ApiPortHandle;
|
||||
ULONG ApiDefinitionsCount;
|
||||
PCSRSS_API_DEFINITION *ApiDefinitions;
|
||||
} CSRSS_LISTEN_DATA, *PCSRSS_LISTEN_DATA;
|
||||
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
extern HANDLE hBootstrapOk;
|
||||
extern HANDLE CsrApiPort;
|
||||
extern HANDLE CsrSmApiPort;
|
||||
|
@ -154,13 +123,6 @@ CsrInsertProcess(IN PCSR_PROCESS Parent OPTIONAL,
|
|||
IN PCSR_PROCESS CurrentProcess OPTIONAL,
|
||||
IN PCSR_PROCESS CsrProcess);
|
||||
|
||||
|
||||
#if 0
|
||||
NTSTATUS FASTCALL CsrApiRegisterDefinitions(PCSRSS_API_DEFINITION NewDefinitions);
|
||||
#endif
|
||||
|
||||
VOID FASTCALL CsrApiCallHandler(IN OUT PCSR_API_MESSAGE ApiMessage, OUT PULONG Reply);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CsrApiRequestThread(IN PVOID Parameter); // HANDLE ServerPort ??
|
||||
|
@ -209,16 +171,6 @@ NTAPI
|
|||
CsrLocateThreadByClientId(OUT PCSR_PROCESS *Process OPTIONAL,
|
||||
IN PCLIENT_ID ClientId);
|
||||
|
||||
// HACK
|
||||
VOID
|
||||
NTAPI
|
||||
CsrProcessRefcountZero(IN PCSR_PROCESS CsrProcess);
|
||||
|
||||
// HACK
|
||||
VOID
|
||||
NTAPI
|
||||
CsrThreadRefcountZero(IN PCSR_THREAD CsrThread);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CsrInitializeNtSessionList(VOID);
|
||||
|
|
|
@ -25,7 +25,7 @@ PCSR_THREAD CsrSbApiRequestThreadPtr;
|
|||
HANDLE CsrSmApiPort = NULL;
|
||||
HANDLE hSbApiPort = NULL;
|
||||
HANDLE CsrApiPort = NULL;
|
||||
ULONG CsrDebug = 0;//0xFFFFFFFF;
|
||||
ULONG CsrDebug = 0xFFFFFFFF; // 0;
|
||||
ULONG CsrMaxApiRequestThreads;
|
||||
ULONG CsrTotalPerProcessDataLength;
|
||||
ULONG SessionId;
|
||||
|
@ -564,7 +564,7 @@ CsrCreateSessionObjectDirectory(IN ULONG Session)
|
|||
*
|
||||
*--*/
|
||||
NTSTATUS
|
||||
FASTCALL
|
||||
NTAPI
|
||||
CsrParseServerCommandLine(IN ULONG ArgumentCount,
|
||||
IN PCHAR Arguments[])
|
||||
{
|
||||
|
@ -668,7 +668,7 @@ CsrParseServerCommandLine(IN ULONG ArgumentCount,
|
|||
/* Load us */
|
||||
Status = CsrLoadServerDll("CSRSS" /* "CSRSRV" */, NULL, CSRSRV_SERVERDLL_INDEX);
|
||||
}
|
||||
else if (_stricmp(ParameterName, "ServerDLL") == 0)
|
||||
else if (_stricmp(ParameterName, "ServerDll") == 0)
|
||||
{
|
||||
/* Loop the command line */
|
||||
EntryPoint = NULL;
|
||||
|
@ -728,6 +728,84 @@ CsrParseServerCommandLine(IN ULONG ArgumentCount,
|
|||
return Status;
|
||||
}
|
||||
|
||||
/*++
|
||||
* @name CsrInitCsrRootProcess
|
||||
*
|
||||
* The CsrInitCsrRootProcess routine further initializes the CSR Root Process
|
||||
* created by CsrInitializeProcessStructure, by allocating and initializing
|
||||
* per-process data for each Server DLL.
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL
|
||||
* otherwise.
|
||||
*
|
||||
* @remarks None.
|
||||
*
|
||||
*--*/
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CsrInitCsrRootProcess(VOID)
|
||||
{
|
||||
PVOID ProcessData;
|
||||
PCSR_SERVER_DLL ServerDll;
|
||||
ULONG i = 0;
|
||||
|
||||
/* All Server DLLs are now loaded, allocate a heap for the Root Process */
|
||||
ProcessData = RtlAllocateHeap(CsrHeap,
|
||||
HEAP_ZERO_MEMORY,
|
||||
CsrTotalPerProcessDataLength);
|
||||
if (!ProcessData)
|
||||
{
|
||||
DPRINT1("CSRSRV:%s: RtlAllocateHeap failed (Status=%08lx)\n",
|
||||
__FUNCTION__, STATUS_NO_MEMORY);
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
/*
|
||||
* Our Root Process was never officially initalized, so write the data
|
||||
* for each Server DLL manually.
|
||||
*/
|
||||
for (i = 0; i < CSR_SERVER_DLL_MAX; i++)
|
||||
{
|
||||
/* Get the current Server */
|
||||
ServerDll = CsrLoadedServerDll[i];
|
||||
|
||||
/* Is it loaded, and does it have per process data? */
|
||||
if (ServerDll && ServerDll->SizeOfProcessData)
|
||||
{
|
||||
/* It does, give it part of our allocated heap */
|
||||
CsrRootProcess->ServerData[i] = ProcessData;
|
||||
|
||||
/* Move to the next heap position */
|
||||
ProcessData = (PVOID)((ULONG_PTR)ProcessData +
|
||||
ServerDll->SizeOfProcessData);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Nothing for this Server DLL */
|
||||
CsrRootProcess->ServerData[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Now initialize the Root Process manually as well */
|
||||
for (i = 0; i < CSR_SERVER_DLL_MAX; i++)
|
||||
{
|
||||
/* Get the current Server */
|
||||
ServerDll = CsrLoadedServerDll[i];
|
||||
|
||||
/* Is it loaded, and does it a callback for new processes? */
|
||||
if (ServerDll && ServerDll->NewProcessCallback)
|
||||
{
|
||||
/* Call the callback */
|
||||
DPRINT1("Call NewProcessCallback(NULL, 0x%p) called\n", CsrRootProcess);
|
||||
ServerDll->NewProcessCallback(NULL, CsrRootProcess);
|
||||
}
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/*++
|
||||
* @name CsrCreateLocalSystemSD
|
||||
*
|
||||
|
@ -971,7 +1049,7 @@ CsrServerInitialization(IN ULONG ArgumentCount,
|
|||
return Status;
|
||||
}
|
||||
|
||||
/* Set up Process Support */
|
||||
/* Set up Process Support and allocate the CSR Root Process */
|
||||
Status = CsrInitializeProcessStructure();
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
@ -989,6 +1067,15 @@ CsrServerInitialization(IN ULONG ArgumentCount,
|
|||
return Status;
|
||||
}
|
||||
|
||||
/* Finish to initialize the CSR Root Process */
|
||||
Status = CsrInitCsrRootProcess();
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("CSRSRV:%s: CsrInitCsrRootProcess failed (Status=%08lx)\n",
|
||||
__FUNCTION__, Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Now initialize our API Port */
|
||||
Status = CsrApiPortInitialize();
|
||||
if (!NT_SUCCESS(Status))
|
||||
|
@ -1068,12 +1155,12 @@ CsrPopulateDosDevices(VOID)
|
|||
|
||||
BOOL
|
||||
NTAPI
|
||||
DllMain(IN HANDLE hDll,
|
||||
DllMain(IN HINSTANCE hInstanceDll,
|
||||
IN DWORD dwReason,
|
||||
IN LPVOID lpReserved)
|
||||
{
|
||||
/* We don't do much */
|
||||
UNREFERENCED_PARAMETER(hDll);
|
||||
UNREFERENCED_PARAMETER(hInstanceDll);
|
||||
UNREFERENCED_PARAMETER(dwReason);
|
||||
UNREFERENCED_PARAMETER(lpReserved);
|
||||
|
||||
|
|
|
@ -341,7 +341,7 @@ CsrLockedReferenceProcess(IN PCSR_PROCESS CsrProcess)
|
|||
* @implemented NT4
|
||||
*
|
||||
* The CsrInitializeProcessStructure routine sets up support for CSR Processes
|
||||
* and CSR Threads.
|
||||
* and CSR Threads by initializing our own CSR Root Process.
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
|
@ -467,9 +467,9 @@ CsrRemoveProcess(IN PCSR_PROCESS CsrProcess)
|
|||
*--*/
|
||||
VOID
|
||||
NTAPI
|
||||
CsrInsertProcess(IN PCSR_PROCESS Parent OPTIONAL,
|
||||
IN PCSR_PROCESS CurrentProcess OPTIONAL,
|
||||
IN PCSR_PROCESS CsrProcess)
|
||||
CsrInsertProcess(IN PCSR_PROCESS Parent OPTIONAL, // ParentProcess
|
||||
IN PCSR_PROCESS CurrentProcess OPTIONAL, // CallingProcess
|
||||
IN PCSR_PROCESS CsrProcess) // Process
|
||||
{
|
||||
PCSR_SERVER_DLL ServerDll;
|
||||
ULONG i;
|
||||
|
@ -488,7 +488,7 @@ CsrInsertProcess(IN PCSR_PROCESS Parent OPTIONAL,
|
|||
ServerDll = CsrLoadedServerDll[i];
|
||||
|
||||
/* Make sure it's valid and that it has callback */
|
||||
if ((ServerDll) && (ServerDll->NewProcessCallback))
|
||||
if (ServerDll && ServerDll->NewProcessCallback)
|
||||
{
|
||||
ServerDll->NewProcessCallback(CurrentProcess, CsrProcess);
|
||||
}
|
||||
|
|
|
@ -119,6 +119,8 @@ CsrLoadServerDll(IN PCHAR DllString,
|
|||
PCSR_SERVER_DLL_INIT_CALLBACK ServerDllInitProcedure;
|
||||
ULONG Response;
|
||||
|
||||
DPRINT1("CsrLoadServerDll(%s, 0x%p, %lu)\n", DllString, EntryPoint, ServerId);
|
||||
|
||||
/* Check if it's beyond the maximum we support */
|
||||
if (ServerId >= CSR_SERVER_DLL_MAX) return STATUS_TOO_MANY_NAMES;
|
||||
|
||||
|
@ -222,14 +224,6 @@ CsrLoadServerDll(IN PCHAR DllString,
|
|||
/* No, save the pointer to its shared section in our list */
|
||||
CsrSrvSharedStaticServerData[ServerDll->ServerId] = ServerDll->SharedSection;
|
||||
}
|
||||
|
||||
#if 0 /* HACK: ReactOS Specific hax. REMOVE IT. */
|
||||
if (ServerDll->HighestApiSupported == 0xDEADBABE)
|
||||
{
|
||||
// CSRSS_API_DEFINITIONS == Old structure.
|
||||
Status = CsrApiRegisterDefinitions((PVOID)ServerDll->DispatchTable);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -274,12 +268,11 @@ CsrSrvClientConnect(IN OUT PCSR_API_MESSAGE ApiMessage,
|
|||
IN OUT PULONG Reply OPTIONAL)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PCSR_CLIENT_CONNECT ClientConnect;
|
||||
PCSR_CLIENT_CONNECT ClientConnect = &ApiMessage->Data.CsrClientConnect;
|
||||
PCSR_SERVER_DLL ServerDll;
|
||||
PCSR_PROCESS CurrentProcess = CsrGetClientThread()->Process;
|
||||
|
||||
/* Load the Message, set default reply */
|
||||
ClientConnect = &ApiMessage->Data.CsrClientConnect;
|
||||
/* Set default reply */
|
||||
*Reply = 0;
|
||||
|
||||
/* Validate the ServerID */
|
||||
|
@ -294,9 +287,9 @@ CsrSrvClientConnect(IN OUT PCSR_API_MESSAGE ApiMessage,
|
|||
|
||||
/* Validate the Message Buffer */
|
||||
if (!(CsrValidateMessageBuffer(ApiMessage,
|
||||
ClientConnect->ConnectionInfo,
|
||||
&ClientConnect->ConnectionInfo,
|
||||
ClientConnect->ConnectionInfoSize,
|
||||
1)))
|
||||
sizeof(BYTE))))
|
||||
{
|
||||
/* Fail due to buffer overflow or other invalid buffer */
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
@ -429,8 +422,7 @@ CsrSrvCreateSharedSection(IN PCHAR ParameterValue)
|
|||
/* Now allocate space from the heap for the Shared Data */
|
||||
CsrSrvSharedStaticServerData = RtlAllocateHeap(CsrSrvSharedSectionHeap,
|
||||
0,
|
||||
CSR_SERVER_DLL_MAX *
|
||||
sizeof(PVOID));
|
||||
CSR_SERVER_DLL_MAX * sizeof(PVOID));
|
||||
if (!CsrSrvSharedStaticServerData) return STATUS_NO_MEMORY;
|
||||
|
||||
/* Write the values to the PEB */
|
||||
|
|
|
@ -326,9 +326,6 @@ CsrSbCreateSession(IN PSB_API_MSG ApiMessage)
|
|||
}
|
||||
}
|
||||
|
||||
/* HACK: FIXME: should go in BaseSrv part of CreateCallback done in Insert below */
|
||||
// RtlInitializeCriticalSection(&CsrProcess->HandleTableLock);
|
||||
|
||||
/* Insert the Process */
|
||||
CsrInsertProcess(NULL, NULL, CsrProcess);
|
||||
|
||||
|
|
|
@ -659,7 +659,6 @@ CsrCreateRemoteThread(IN HANDLE hThread,
|
|||
*--*/
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
#if 0
|
||||
CsrCreateThread(IN PCSR_PROCESS CsrProcess,
|
||||
IN HANDLE hThread,
|
||||
IN PCLIENT_ID ClientId,
|
||||
|
@ -670,12 +669,13 @@ CsrCreateThread(IN PCSR_PROCESS CsrProcess,
|
|||
PCSR_PROCESS CurrentProcess;
|
||||
CLIENT_ID CurrentCid;
|
||||
KERNEL_USER_TIMES KernelTimes;
|
||||
|
||||
DPRINT("CSRSRV: %s called\n", __FUNCTION__);
|
||||
|
||||
if (HaveClient)
|
||||
{
|
||||
/* Get the current thread and CID */
|
||||
CurrentThread = NtCurrentTeb()->CsrClientThread;
|
||||
CurrentThread = CsrGetClientThread();
|
||||
CurrentCid = CurrentThread->ClientId;
|
||||
|
||||
/* Acquire the Process Lock */
|
||||
|
@ -683,6 +683,8 @@ CsrCreateThread(IN PCSR_PROCESS CsrProcess,
|
|||
|
||||
/* Get the current Process and make sure the Thread is valid with this CID */
|
||||
CurrentThread = CsrLocateThreadByClientId(&CurrentProcess, &CurrentCid);
|
||||
|
||||
/* Something is wrong if we get an empty thread back */
|
||||
if (!CurrentThread)
|
||||
{
|
||||
DPRINT1("CSRSRV:%s: invalid thread!\n", __FUNCTION__);
|
||||
|
@ -729,66 +731,9 @@ CsrCreateThread(IN PCSR_PROCESS CsrProcess,
|
|||
|
||||
/* Release the lock and return */
|
||||
CsrReleaseProcessLock();
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
#else
|
||||
CsrCreateThread(IN PCSR_PROCESS CsrProcess,
|
||||
IN HANDLE hThread,
|
||||
IN PCLIENT_ID ClientId)
|
||||
{
|
||||
PCSR_THREAD CsrThread;
|
||||
PCSR_PROCESS CurrentProcess;
|
||||
PCSR_THREAD CurrentThread = CsrGetClientThread();
|
||||
CLIENT_ID CurrentCid;
|
||||
KERNEL_USER_TIMES KernelTimes;
|
||||
|
||||
/* Get the current thread and CID */
|
||||
CurrentCid = CurrentThread->ClientId;
|
||||
|
||||
/* Acquire the Process Lock */
|
||||
CsrAcquireProcessLock();
|
||||
|
||||
/* Get the current Process and make sure the Thread is valid with this CID */
|
||||
CurrentThread = CsrLocateThreadByClientId(&CurrentProcess,
|
||||
&CurrentCid);
|
||||
|
||||
/* Something is wrong if we get an empty thread back */
|
||||
if (!CurrentThread)
|
||||
{
|
||||
DPRINT1("CSRSRV:%s: invalid thread!\n", __FUNCTION__);
|
||||
CsrReleaseProcessLock();
|
||||
return STATUS_THREAD_IS_TERMINATING;
|
||||
}
|
||||
|
||||
/* Get the Thread Create Time */
|
||||
NtQueryInformationThread(hThread,
|
||||
ThreadTimes,
|
||||
(PVOID)&KernelTimes,
|
||||
sizeof(KernelTimes),
|
||||
NULL);
|
||||
|
||||
/* Allocate a CSR Thread Structure */
|
||||
if (!(CsrThread = CsrAllocateThread(CsrProcess)))
|
||||
{
|
||||
DPRINT1("CSRSRV:%s: out of memory!\n", __FUNCTION__);
|
||||
CsrReleaseProcessLock();
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
/* Save the data we have */
|
||||
CsrThread->CreateTime = KernelTimes.CreateTime;
|
||||
CsrThread->ClientId = *ClientId;
|
||||
CsrThread->ThreadHandle = hThread;
|
||||
CsrThread->Flags = 0;
|
||||
|
||||
/* Insert the Thread into the Process */
|
||||
CsrInsertThread(CsrProcess, CsrThread);
|
||||
|
||||
/* Release the lock and return */
|
||||
CsrReleaseProcessLock();
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*++
|
||||
* @name CsrDereferenceThread
|
||||
|
|
Loading…
Reference in a new issue