Modified: trunk/reactos/include/ndk/umfuncs.h
Modified: trunk/reactos/include/ndk/zwfuncs.h
Modified: trunk/reactos/include/subsys/csrss/csrss.h
Modified: trunk/reactos/lib/kernel32/misc/console.c
Modified: trunk/reactos/lib/kernel32/misc/dllmain.c
Added: trunk/reactos/lib/ntdll/csr/api.c
Modified: trunk/reactos/lib/ntdll/csr/capture.c
Added: trunk/reactos/lib/ntdll/csr/connect.c
Deleted: trunk/reactos/lib/ntdll/csr/lpc.c
Deleted: trunk/reactos/lib/ntdll/csr/probe.c
Deleted: trunk/reactos/lib/ntdll/csr/srv.c
Deleted: trunk/reactos/lib/ntdll/csr/thread.c
Modified: trunk/reactos/lib/ntdll/def/ntdll.def
Modified: trunk/reactos/lib/ntdll/ntdll.xml
Modified: trunk/reactos/subsys/csrss/init.c
Modified: trunk/reactos/tools/nci/sysfuncs.lst
--- trunk/reactos/include/ndk/umfuncs.h 2005-09-07 19:09:56 UTC (rev 17726)
+++ trunk/reactos/include/ndk/umfuncs.h 2005-09-07 19:37:28 UTC (rev 17727)
@@ -8,29 +8,53 @@
#define _UMFUNCS_H
/* DEPENDENCIES **************************************************************/
+struct _CSR_API_MESSAGE;
+struct _CSR_CAPTURE_BUFFER;
/* PROTOTYPES ****************************************************************/
/*
* CSR Functions
*/
+PVOID
+NTAPI
+CsrAllocateCaptureBuffer(
+ ULONG ArgumentCount,
+ ULONG BufferSize
+);
+
+ULONG
+NTAPI
+CsrAllocateMessagePointer(
+ struct _CSR_CAPTURE_BUFFER *CaptureBuffer,
+ ULONG MessageLength,
+ PVOID *CaptureData
+);
+
+VOID
+NTAPI
+CsrCaptureMessageBuffer(
+ struct _CSR_CAPTURE_BUFFER *CaptureBuffer,
+ PVOID MessageString,
+ ULONG StringLength,
+ PVOID *CapturedData
+);
+
NTSTATUS
NTAPI
CsrClientConnectToServer(
PWSTR ObjectDirectory,
ULONG ServerId,
- PVOID Unknown,
- PVOID Context,
- ULONG ContextLength,
+ PVOID ConnectionInfo,
+ PULONG ConnectionInfoSize,
PBOOLEAN ServerToServerCall
);
-struct _CSR_API_MESSAGE;
NTSTATUS
NTAPI
CsrClientCallServer(
struct _CSR_API_MESSAGE *Request,
- PVOID CapturedBuffer OPTIONAL,
+ struct _CSR_CAPTURE_BUFFER *CaptureBuffer OPTIONAL,
ULONG ApiNumber,
ULONG RequestLength
);
@@ -39,6 +63,10 @@
NTAPI
CsrIdentifyAlertableThread(VOID);
+VOID
+NTAPI
+CsrFreeCaptureBuffer(struct _CSR_CAPTURE_BUFFER *CaptureBuffer);
+
NTSTATUS
NTAPI
CsrNewThread(VOID);
@@ -53,7 +81,7 @@
VOID
NTAPI
CsrProbeForRead(
- IN CONST PVOID Address,
+ IN PVOID Address,
IN ULONG Length,
IN ULONG Alignment
);
@@ -61,24 +89,11 @@
VOID
NTAPI
CsrProbeForWrite(
- IN CONST PVOID Address,
+ IN PVOID Address,
IN ULONG Length,
IN ULONG Alignment
);
-NTSTATUS
-NTAPI
-CsrCaptureParameterBuffer(
- PVOID ParameterBuffer,
- ULONG ParameterBufferSize,
- PVOID* ClientAddress,
- PVOID* ServerAddress
-);
-
-NTSTATUS
-NTAPI
-CsrReleaseParameterBuffer(PVOID ClientAddress);
-
/*
* Debug Functions
*/
--- trunk/reactos/include/ndk/zwfuncs.h 2005-09-07 19:09:56 UTC (rev 17726)
+++ trunk/reactos/include/ndk/zwfuncs.h 2005-09-07 19:37:28 UTC (rev 17727)
@@ -3322,8 +3322,39 @@
IN ULONG Flags
);
+
+NTSYSCALLAPI
NTSTATUS
NTAPI
+NtSecureConnectPort(
+ PHANDLE PortHandle,
+ PUNICODE_STRING PortName,
+ PSECURITY_QUALITY_OF_SERVICE SecurityQos,
+ PPORT_VIEW ClientView OPTIONAL,
+ PSID Sid OPTIONAL,
+ PREMOTE_PORT_VIEW ServerView OPTIONAL,
+ PULONG MaxMessageLength OPTIONAL,
+ PVOID ConnectionInformation OPTIONAL,
+ PULONG ConnectionInformationLength OPTIONAL
+);
+
+NTSYSAPI
+NTSTATUS
+NTAPI
+ZwSecureConnectPort(
+ PHANDLE PortHandle,
+ PUNICODE_STRING PortName,
+ PSECURITY_QUALITY_OF_SERVICE SecurityQos,
+ PPORT_VIEW ClientView OPTIONAL,
+ PSID Sid OPTIONAL,
+ PREMOTE_PORT_VIEW ServerView OPTIONAL,
+ PULONG MaxMessageLength OPTIONAL,
+ PVOID ConnectionInformation OPTIONAL,
+ PULONG ConnectionInformationLength OPTIONAL
+);
+
+NTSTATUS
+NTAPI
NtSetBootEntryOrder(
IN ULONG Unknown1,
IN ULONG Unknown2
--- trunk/reactos/include/subsys/csrss/csrss.h 2005-09-07 19:09:56 UTC (rev 17726)
+++ trunk/reactos/include/subsys/csrss/csrss.h 2005-09-07 19:37:28 UTC (rev 17727)
@@ -484,6 +484,7 @@
typedef struct _CSR_API_MESSAGE
{
PORT_MESSAGE Header;
+ PVOID CsrCaptureData;
ULONG Type;
NTSTATUS Status;
union
@@ -544,4 +545,75 @@
} Data;
} CSR_API_MESSAGE, *PCSR_API_MESSAGE;
+/* Types used in the new CSR. Temporarly here for proper compile of NTDLL */
+#define CSR_SRV_SERVER 0
+
+#define CsrSrvClientConnect 0
+#define CsrSrvIdentifyAlertableThread 3
+#define CsrSrvSetPriorityClass 4
+
+#define CSR_MAKE_OPCODE(s,m) ((s) << 16) | (m)
+
+typedef struct _CSR_CONNECTION_INFO
+{
+ ULONG Version;
+ ULONG Unknown;
+ HANDLE ObjectDirectory;
+ PVOID SharedSectionBase;
+ PVOID SharedSectionHeap;
+ PVOID SharedSectionData;
+ ULONG DebugFlags;
+ ULONG Unknown2[3];
+ HANDLE ProcessId;
+} CSR_CONNECTION_INFO, *PCSR_CONNECTION_INFO;
+
+typedef struct _CSR_CLIENT_CONNECT
+{
+ ULONG ServerId;
+ PVOID ConnectionInfo;
+ ULONG ConnectionInfoSize;
+} CSR_CLIENT_CONNECT, *PCSR_CLIENT_CONNECT;
+
+typedef struct _CSR_IDENTIFY_ALTERTABLE_THREAD
+{
+ CLIENT_ID Cid;
+} CSR_IDENTIFY_ALTERTABLE_THREAD, *PCSR_IDENTIFY_ALTERTABLE_THREAD;
+
+typedef struct _CSR_SET_PRIORITY_CLASS
+{
+ HANDLE hProcess;
+ ULONG PriorityClass;
+} CSR_SET_PRIORITY_CLASS, *PCSR_SET_PRIORITY_CLASS;
+
+typedef struct _CSR_API_MESSAGE2
+{
+ PORT_MESSAGE Header;
+ union
+ {
+ CSR_CONNECTION_INFO ConnectionInfo;
+ struct
+ {
+ PVOID CsrCaptureData;
+ CSR_API_NUMBER Opcode;
+ ULONG Status;
+ ULONG Reserved;
+ union
+ {
+ CSR_CLIENT_CONNECT ClientConnect;
+ CSR_SET_PRIORITY_CLASS SetPriorityClass;
+ CSR_IDENTIFY_ALTERTABLE_THREAD IdentifyAlertableThread;
+ };
+ };
+ };
+} CSR_API_MESSAGE2, *PCSR_API_MESSAGE2;
+
+typedef struct _CSR_CAPTURE_BUFFER
+{
+ ULONG Size;
+ struct _CSR_CAPTURE_BUFFER *PreviousCaptureBuffer;
+ ULONG PointerCount;
+ ULONG_PTR BufferEnd;
+ ULONG_PTR PointerArray[1];
+} CSR_CAPTURE_BUFFER, *PCSR_CAPTURE_BUFFER;
+
#endif /* __INCLUDE_CSRSS_CSRSS_H */
--- trunk/reactos/lib/kernel32/misc/console.c 2005-09-07 19:09:56 UTC (rev 17726)
+++ trunk/reactos/lib/kernel32/misc/console.c 2005-09-07 19:37:28 UTC (rev 17727)
@@ -1546,8 +1546,8 @@
BOOL bUnicode)
{
CSR_API_MESSAGE Request; ULONG CsrRequest;
+ PCSR_CAPTURE_BUFFER CaptureBuffer;
NTSTATUS Status;
- PVOID BufferBase;
PVOID BufferTargetBase;
ULONG Size;
@@ -1559,40 +1559,55 @@
Size = nLength * sizeof(INPUT_RECORD);
- Status = CsrCaptureParameterBuffer(NULL, Size, &BufferBase, &BufferTargetBase);
- if(!NT_SUCCESS(Status))
- {
- SetLastErrorByStatus(Status);
- return FALSE;
- }
+ /* Allocate a Capture Buffer */
+ DPRINT1("IntPeekConsoleInput: %lx %p\n", Size, lpNumberOfEventsRead);
+ CaptureBuffer = CsrAllocateCaptureBuffer(1, Size);
+ /* Allocate space in the Buffer */
+ CsrCaptureMessageBuffer(CaptureBuffer, NULL, Size, &BufferTargetBase);
+ DPRINT1("Allocated message buffer: %p %p\n", CaptureBuffer, BufferTargetBase);
+
+ /* Set up the data to send to the Console Server */
CsrRequest = MAKE_CSR_API(PEEK_CONSOLE_INPUT, CSR_CONSOLE);
Request.Data.PeekConsoleInputRequest.ConsoleHandle = hConsoleInput;
Request.Data.PeekConsoleInputRequest.Unicode = bUnicode;
Request.Data.PeekConsoleInputRequest.Length = nLength;
Request.Data.PeekConsoleInputRequest.InputRecord = (INPUT_RECORD*)BufferTargetBase;
+ /* Call the server */
+ DPRINT1("Calling Server\n");
Status = CsrClientCallServer(&Request,
- NULL,
+ CaptureBuffer,
CsrRequest,
sizeof(CSR_API_MESSAGE));
+ DPRINT1("Server returned: %x\n", Request.Status);
- if(!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
+ /* Check for success*/
+ if (NT_SUCCESS(Request.Status))
{
- CsrReleaseParameterBuffer(BufferBase);
- return FALSE;
+ /* Return the number of events read */
+ DPRINT1("Events read: %lx\n", Request.Data.PeekConsoleInputRequest.Length);
+ *lpNumberOfEventsRead = Request.Data.PeekConsoleInputRequest.Length;
+
+ /* Copy into the buffer */
+ DPRINT1("Copying to buffer\n");
+ RtlCopyMemory(lpBuffer,
+ Request.Data.PeekConsoleInputRequest.InputRecord,
+ sizeof(INPUT_RECORD) * *lpNumberOfEventsRead);
}
-
- memcpy(lpBuffer, BufferBase, sizeof(INPUT_RECORD) * Request.Data.PeekConsoleInputRequest.Length);
-
- CsrReleaseParameterBuffer(BufferBase);
-
- if(lpNumberOfEventsRead != NULL)
+ else
{
- *lpNumberOfEventsRead = Request.Data.PeekConsoleInputRequest.Length;
+ /* Error out */
+ *lpNumberOfEventsRead = 0;
+ SetLastErrorByStatus(Request.Status);
}
- return TRUE;
+ /* Release the capture buffer */
+ DPRINT1("Release buffer and return\n");
+ CsrFreeCaptureBuffer(CaptureBuffer);
+
+ /* Return TRUE or FALSE */
+ return NT_SUCCESS(Request.Status);
}
/*--------------------------------------------------------------
@@ -1751,8 +1766,8 @@
BOOL bUnicode)
{
CSR_API_MESSAGE Request; ULONG CsrRequest;
-
- PVOID BufferBase, BufferTargetBase;
+ PCSR_CAPTURE_BUFFER CaptureBuffer;
+ PVOID BufferTargetBase;
NTSTATUS Status;
DWORD Size;
@@ -1764,37 +1779,55 @@
Size = nLength * sizeof(INPUT_RECORD);
- Status = CsrCaptureParameterBuffer((PVOID)lpBuffer, Size, &BufferBase, &BufferTargetBase);
- if(!NT_SUCCESS(Status))
- {
- SetLastErrorByStatus(Status);
- return FALSE;
- }
+ /* Allocate a Capture Buffer */
+ DPRINT1("IntWriteConsoleInput: %lx %p\n", Size, lpNumberOfEventsWritten);
+ CaptureBuffer = CsrAllocateCaptureBuffer(1, Size);
+ /* Allocate space in the Buffer */
+ CsrCaptureMessageBuffer(CaptureBuffer, NULL, Size, &BufferTargetBase);
+ DPRINT1("Allocated message buffer: %p %p\n", CaptureBuffer, BufferTargetBase);
+
+ /* Set up the data to send to the Console Server */
CsrRequest = MAKE_CSR_API(WRITE_CONSOLE_INPUT, CSR_CONSOLE);
Request.Data.WriteConsoleInputRequest.ConsoleHandle = hConsoleInput;
Request.Data.WriteConsoleInputRequest.Unicode = bUnicode;
Request.Data.WriteConsoleInputRequest.Length = nLength;
Request.Data.WriteConsoleInputRequest.InputRecord = (PINPUT_RECORD)BufferTargetBase;
- Status = CsrClientCallServer(&Request, NULL,
+ /* Call the server */
+ DPRINT1("Calling Server\n");
+ Status = CsrClientCallServer(&Request,
+ CaptureBuffer,
CsrRequest,
sizeof(CSR_API_MESSAGE));
+ DPRINT1("Server returned: %x\n", Request.Status);
- CsrReleaseParameterBuffer(BufferBase);
+ /* Check for success*/
+ if (NT_SUCCESS(Request.Status))
+ {
+ /* Return the number of events read */
+ DPRINT1("Events read: %lx\n", Request.Data.WriteConsoleInputRequest.Length);
+ *lpNumberOfEventsWritten = Request.Data.WriteConsoleInputRequest.Length;
- if(!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
- {
- SetLastErrorByStatus(Status);
- return FALSE;
+ /* Copy into the buffer */
+ DPRINT1("Copying to buffer\n");
+ RtlCopyMemory(lpBuffer,
+ Request.Data.WriteConsoleInputRequest.InputRecord,
+ sizeof(INPUT_RECORD) * *lpNumberOfEventsWritten);
}
-
- if(lpNumberOfEventsWritten != NULL)
+ else
{
- *lpNumberOfEventsWritten = Request.Data.WriteConsoleInputRequest.Length;
+ /* Error out */
+ *lpNumberOfEventsWritten = 0;
+ SetLastErrorByStatus(Request.Status);
}
- return TRUE;
+ /* Release the capture buffer */
+ DPRINT1("Release buffer and return\n");
+ CsrFreeCaptureBuffer(CaptureBuffer);
+
+ /* Return TRUE or FALSE */
+ return NT_SUCCESS(Request.Status);
}
@@ -1851,8 +1884,7 @@
BOOL bUnicode)
{
CSR_API_MESSAGE Request; ULONG CsrRequest;
-
- PVOID BufferBase;
+ PCSR_CAPTURE_BUFFER CaptureBuffer;
PVOID BufferTargetBase;
NTSTATUS Status;
DWORD Size, SizeX, SizeY;
@@ -1865,13 +1897,15 @@
Size = dwBufferSize.X * dwBufferSize.Y * sizeof(CHAR_INFO);
- Status = CsrCaptureParameterBuffer(NULL, Size, &BufferBase, &BufferTargetBase);
- if(!NT_SUCCESS(Status))
- {
- SetLastErrorByStatus(Status);
- return FALSE;
- }
+ /* Allocate a Capture Buffer */
+ DPRINT1("IntReadConsoleOutput: %lx %p\n", Size, lpReadRegion);
+ CaptureBuffer = CsrAllocateCaptureBuffer(1, Size);
+ /* Allocate space in the Buffer */
+ CsrCaptureMessageBuffer(CaptureBuffer, NULL, Size, &BufferTargetBase);
+ DPRINT1("Allocated message buffer: %p %p\n", CaptureBuffer, BufferTargetBase);
+
+ /* Set up the data to send to the Console Server */
CsrRequest = MAKE_CSR_API(READ_CONSOLE_OUTPUT, CSR_CONSOLE);
Request.Data.ReadConsoleOutputRequest.ConsoleHandle = hConsoleOutput;
Request.Data.ReadConsoleOutputRequest.Unicode = bUnicode;
@@ -1880,28 +1914,43 @@
Request.Data.ReadConsoleOutputRequest.ReadRegion = *lpReadRegion;
Request.Data.ReadConsoleOutputRequest.CharInfo = (PCHAR_INFO)BufferTargetBase;
+ /* Call the server */
+ DPRINT1("Calling Server\n");
Status = CsrClientCallServer(&Request,
- NULL,
+ CaptureBuffer,
CsrRequest,
sizeof(CSR_API_MESSAGE));
+ DPRINT1("Server returned: %x\n", Request.Status);
- if(!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
+ /* Check for success*/
+ if (NT_SUCCESS(Request.Status))
{
- SetLastErrorByStatus(Status);
- CsrReleaseParameterBuffer(BufferBase);
- return FALSE;
+ /* Copy into the buffer */
+ DPRINT1("Copying to buffer\n");
+ SizeX = Request.Data.ReadConsoleOutputRequest.ReadRegion.Right -
+ Request.Data.ReadConsoleOutputRequest.ReadRegion.Left + 1;
+ SizeY = Request.Data.ReadConsoleOutputRequest.ReadRegion.Bottom -
+ Request.Data.ReadConsoleOutputRequest.ReadRegion.Top + 1;
+ RtlCopyMemory(lpBuffer,
+ Request.Data.ReadConsoleOutputRequest.CharInfo,
+ sizeof(CHAR_INFO) * SizeX * SizeY);
}
+ else
+ {
+ /* Error out */
+ SetLastErrorByStatus(Request.Status);
+ }
- SizeX = Request.Data.ReadConsoleOutputRequest.ReadRegion.Right - Request.Data.ReadConsoleOutputRequest.ReadRegion.Left + 1;
- SizeY = Request.Data.ReadConsoleOutputRequest.ReadRegion.Bottom - Request.Data.ReadConsoleOutputRequest.ReadRegion.Top + 1;
+ /* Return the read region */
+ DPRINT1("read region: %lx\n", Request.Data.ReadConsoleOutputRequest.ReadRegion);
+ *lpReadRegion = Request.Data.ReadConsoleOutputRequest.ReadRegion;
- memcpy(lpBuffer, BufferBase, sizeof(CHAR_INFO) * SizeX * SizeY);
+ /* Release the capture buffer */
+ DPRINT1("Release buffer and return\n");
+ CsrFreeCaptureBuffer(CaptureBuffer);
- CsrReleaseParameterBuffer(BufferBase);
-
- *lpReadRegion = Request.Data.ReadConsoleOutputRequest.ReadRegion;
-
- return TRUE;
+ /* Return TRUE or FALSE */
+ return NT_SUCCESS(Request.Status);
}
/*--------------------------------------------------------------
@@ -1953,49 +2002,59 @@
BOOL bUnicode)
{
CSR_API_MESSAGE Request; ULONG CsrRequest;
+ PCSR_CAPTURE_BUFFER CaptureBuffer;
NTSTATUS Status;
ULONG Size;
- PVOID BufferBase;
PVOID BufferTargetBase;
Size = dwBufferSize.Y * dwBufferSize.X * sizeof(CHAR_INFO);
- Status = CsrCaptureParameterBuffer((PVOID)lpBuffer,
- Size,
- &BufferBase,
- &BufferTargetBase);
- if (!NT_SUCCESS(Status))
- {
- SetLastErrorByStatus(Status);
- return(FALSE);
- }
+ /* Allocate a Capture Buffer */
+ DPRINT1("IntWriteConsoleOutput: %lx %p\n", Size, lpWriteRegion);
+ CaptureBuffer = CsrAllocateCaptureBuffer(1, Size);
+ /* Allocate space in the Buffer */
+ CsrCaptureMessageBuffer(CaptureBuffer, NULL, Size, &BufferTargetBase);
+ DPRINT1("Allocated message buffer: %p %p\n", CaptureBuffer, BufferTargetBase);
+
+ /* Copy from the buffer */
+ DPRINT1("Copying into buffer\n");
+ RtlCopyMemory(BufferTargetBase, lpBuffer, Size);
+
+ /* Set up the data to send to the Console Server */
CsrRequest = MAKE_CSR_API(WRITE_CONSOLE_OUTPUT, CSR_CONSOLE);
Request.Data.WriteConsoleOutputRequest.ConsoleHandle = hConsoleOutput;
Request.Data.WriteConsoleOutputRequest.Unicode = bUnicode;
Request.Data.WriteConsoleOutputRequest.BufferSize = dwBufferSize;
Request.Data.WriteConsoleOutputRequest.BufferCoord = dwBufferCoord;
Request.Data.WriteConsoleOutputRequest.WriteRegion = *lpWriteRegion;
- Request.Data.WriteConsoleOutputRequest.CharInfo =
- (CHAR_INFO*)BufferTargetBase;
+ Request.Data.WriteConsoleOutputRequest.CharInfo = (CHAR_INFO*)BufferTargetBase;
+ /* Call the server */
+ DPRINT1("Calling Server\n");
Status = CsrClientCallServer(&Request,
- NULL,
- CsrRequest,
- sizeof(CSR_API_MESSAGE));
+ CaptureBuffer,
+ CsrRequest,
+ sizeof(CSR_API_MESSAGE));
+ DPRINT1("Server returned: %x\n", Request.Status);
- if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
- {
- CsrReleaseParameterBuffer(BufferBase);
- SetLastErrorByStatus(Status);
- return FALSE;
- }
+ /* Check for success*/
+ if (!NT_SUCCESS(Request.Status))
+ {
+ /* Error out */
+ SetLastErrorByStatus(Request.Status);
+ }
- CsrReleaseParameterBuffer(BufferBase);
-
+ /* Return the read region */
+ DPRINT1("read region: %lx\n", Request.Data.WriteConsoleOutputRequest.WriteRegion);
*lpWriteRegion = Request.Data.WriteConsoleOutputRequest.WriteRegion;
- return(TRUE);
+ /* Release the capture buffer */
+ DPRINT1("Release buffer and return\n");
+ CsrFreeCaptureBuffer(CaptureBuffer);
+
+ /* Return TRUE or FALSE */
+ return NT_SUCCESS(Request.Status);
}
/*--------------------------------------------------------------
--- trunk/reactos/lib/kernel32/misc/dllmain.c 2005-09-07 19:09:56 UTC (rev 17726)
+++ trunk/reactos/lib/kernel32/misc/dllmain.c 2005-09-07 19:37:28 UTC (rev 17727)
@@ -16,6 +16,8 @@
#define NDEBUG
#include "../include/debug.h"
+#define CSR_BASE_DLL 0 // <- This should be 1 when CSR gets committed
+
/* GLOBALS *******************************************************************/
extern UNICODE_STRING SystemDirectory;
@@ -198,42 +200,47 @@
}
-BOOL STDCALL
+BOOL
+STDCALL
DllMain(HANDLE hDll,
- DWORD dwReason,
- LPVOID lpReserved)
+ DWORD dwReason,
+ LPVOID lpReserved)
{
- NTSTATUS Status;
+ NTSTATUS Status;
+ BOOLEAN IsServer;
+ ULONG Dummy;
+ ULONG DummySize = sizeof(Dummy);
- (void)lpReserved;
+ DPRINT("DllMain(hInst %lx, dwReason %lu)\n",
+ hDll, dwReason);
- DPRINT("DllMain(hInst %lx, dwReason %lu)\n",
- hDll, dwReason);
-
- switch (dwReason)
+ switch (dwReason)
{
- case DLL_PROCESS_ATTACH:
- DPRINT("DLL_PROCESS_ATTACH\n");
+ case DLL_PROCESS_ATTACH:
- LdrDisableThreadCalloutsForDll ((PVOID)hDll);
+ /* Don't bother us for each thread */
+ LdrDisableThreadCalloutsForDll((PVOID)hDll);
- /*
- * Connect to the csrss server
- */
- Status = CsrClientConnectToServer(L"\\Windows\\ApiPort",
- 0,
- NULL,
- NULL,
- 0,
- NULL);
- if (!NT_SUCCESS(Status))
- {
- DbgPrint("Failed to connect to csrss.exe (Status %lx)\n",
- Status);
- ZwTerminateProcess(NtCurrentProcess(), Status);
- return FALSE;
- }
+ /* Connect to the base server */
+ Status = CsrClientConnectToServer(L"\\Windows", // <- FIXME: SessionDir
+ CSR_BASE_DLL,
+ &Dummy,
+ &DummySize,
+ &IsServer);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to connect to CSR (Status %lx)\n", Status);
+ ZwTerminateProcess(NtCurrentProcess(), Status);
+ return FALSE;
+ }
+ /* Check if we are running a CSR Server */
+ if (!IsServer)
+ {
+ /* Set the termination port for the thread */
+ CsrNewThread();
+ }
+
hProcessHeap = RtlGetProcessHeap();
hCurrentModule = hDll;
--- trunk/reactos/lib/ntdll/csr/api.c 2005-09-07 19:09:56 UTC (rev 17726)
+++ trunk/reactos/lib/ntdll/csr/api.c 2005-09-07 19:37:28 UTC (rev 17727)
@@ -0,0 +1,89 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * FILE: lib/ntdll/csr/api.c
+ * PURPOSE: CSR APIs exported through NTDLL
+ * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include <ntdll.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS *******************************************************************/
+extern HANDLE CsrApiPort;
+
+/* FUNCTIONS *****************************************************************/
+
+/*
+ * @implemented
+ */
+NTSTATUS
+NTAPI
+CsrNewThread(VOID)
+{
+ /* Register the termination port to CSR's */
+ return NtRegisterThreadTerminatePort(CsrApiPort);
+}
+
+/*
+ * @implemented
+ */
+NTSTATUS
+NTAPI
+CsrSetPriorityClass(HANDLE hProcess,
+ PULONG PriorityClass)
+{
+ NTSTATUS Status;
+ CSR_API_MESSAGE2 ApiMessage; /* <- Remove the "2" when CSR is commited */
+ PCSR_SET_PRIORITY_CLASS SetPriorityClass = &ApiMessage.SetPriorityClass;
+
+ /* Set up the data for CSR */
+ DbgBreakPoint();
+ SetPriorityClass->hProcess = hProcess;
+ SetPriorityClass->PriorityClass = *PriorityClass;
+
+ /* Call it */
+ Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_MAKE_OPCODE(CsrSrvSetPriorityClass,
+ CSR_SRV_SERVER),
+ sizeof(CSR_SET_PRIORITY_CLASS));
+
+ /* Return what we got, if requested */
+ if (*PriorityClass) *PriorityClass = SetPriorityClass->PriorityClass;
+
+ /* Return to caller */
+ return Status;
+}
+
+/*
+ * @implemented
+ */
+NTSTATUS
+NTAPI
+CsrIdentifyAlertableThread (VOID)
+{
+ NTSTATUS Status;
+ CSR_API_MESSAGE2 ApiMessage; /* <- Remove the "2" when CSR is commited */
+ PCSR_IDENTIFY_ALTERTABLE_THREAD IdentifyAlertableThread;
+
+ /* Set up the data for CSR */
+ DbgBreakPoint();
+ IdentifyAlertableThread = &ApiMessage.IdentifyAlertableThread;
+ IdentifyAlertableThread->Cid = NtCurrentTeb()->Cid;
+
+ /* Call it */
+ Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_MAKE_OPCODE(CsrSrvIdentifyAlertableThread,
+ CSR_SRV_SERVER),
+ sizeof(CSR_SET_PRIORITY_CLASS));
+
+ /* Return to caller */
+ return Status;
+}
+
+/* EOF */
--- trunk/reactos/lib/ntdll/csr/capture.c 2005-09-07 19:09:56 UTC (rev 17726)
+++ trunk/reactos/lib/ntdll/csr/capture.c 2005-09-07 19:37:28 UTC (rev 17727)
@@ -1,9 +1,9 @@
-/* $Id$
- *
+/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/ntdll/csr/capture.c
- * PURPOSE: CSRSS Capture API
+ * PURPOSE: routines for probing and capturing CSR API Messages
+ * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
*/
/* INCLUDES *****************************************************************/
@@ -13,90 +13,255 @@
#include <debug.h>
/* GLOBALS *******************************************************************/
+extern HANDLE CsrPortHeap;
-static HANDLE hCaptureHeap = INVALID_HANDLE_VALUE; /* FIXME: use the general NTDLL heap */
-
/* FUNCTIONS *****************************************************************/
/*
- * @unimplemented
+ * @implemented
*/
-PVOID
-STDCALL CsrAllocateCaptureBuffer (
- DWORD Unknown0,
- DWORD Unknown1,
- DWORD Unknown2
- )
+VOID
+NTAPI
+CsrProbeForRead(IN PVOID Address,
+ IN ULONG Length,
+ IN ULONG Alignment)
{
- /* FIXME: implement it! */
- return NULL;
+ PUCHAR Pointer;
+ UCHAR Data;
+
+ /* Validate length */
+ if (Length == 0) return;
+
+ /* Validate alignment */
+ if ((ULONG_PTR)Address & (Alignment - 1))
+ {
+ /* Raise exception if it doesn't match */
+ RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT);
+ }
+
+ /* Do the probe */
+ Pointer = (PUCHAR)Address;
+ Data = *Pointer;
+ Pointer = (PUCHAR)((ULONG)Address + Length -1);
+ Data = *Pointer;
}
/*
- * @unimplemented
+ * @implemented
*/
-VOID STDCALL
-CsrCaptureMessageString (DWORD Unknown0,
- DWORD Unknown1,
- DWORD Unknown2,
- DWORD Unknown3,
- DWORD Unknown4)
+VOID
+NTAPI
+CsrProbeForWrite(IN PVOID Address,
+ IN ULONG Length,
+ IN ULONG Alignment)
{
+ PUCHAR Pointer;
+ UCHAR Data;
+
+ /* Validate length */
+ if (Length == 0) return;
+
+ /* Validate alignment */
+ if ((ULONG_PTR)Address & (Alignment - 1))
+ {
+ /* Raise exception if it doesn't match */
+ RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT);
+ }
+
+ /* Do the probe */
+ Pointer = (PUCHAR)Address;
+ Data = *Pointer;
+ *Pointer = Data;
+ Pointer = (PUCHAR)((ULONG)Address + Length -1);
+ Data = *Pointer;
+ *Pointer = Data;
}
/*
- * @unimplemented
+ * @implemented
*/
-VOID STDCALL
-CsrAllocateCapturePointer(ULONG Unknown0,
- ULONG Unknown1,
- ULONG Unknown2)
+PVOID
+NTAPI
+CsrAllocateCaptureBuffer(ULONG ArgumentCount,
+ ULONG BufferSize)
{
+ PCSR_CAPTURE_BUFFER CaptureBuffer;
+ /* Validate size */
+ 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));
+
+ /* Allocate memory from the port heap */
+ CaptureBuffer = RtlAllocateHeap(CsrPortHeap, 0, BufferSize);
+
+ /* Initialize the header */
+ CaptureBuffer->Size = BufferSize;
+ CaptureBuffer->PointerCount = 0;
+
+ /* Initialize all the pointers */
+ RtlZeroMemory(CaptureBuffer->PointerArray,
+ ArgumentCount * sizeof(ULONG_PTR));
+
+ /* Point the start of the free buffer */
+ CaptureBuffer->BufferEnd = (ULONG_PTR)CaptureBuffer->PointerArray +
+ ArgumentCount * sizeof(ULONG_PTR);
+
+ /* Return the address of the buffer */
+ return CaptureBuffer;
}
/*
- * @unimplemented
+ * @implemented
*/
-VOID STDCALL CsrAllocateMessagePointer (DWORD Unknown0,
- DWORD Unknown1,
- DWORD Unknown2)
+ULONG
+NTAPI
+CsrAllocateMessagePointer(PCSR_CAPTURE_BUFFER CaptureBuffer,
+ ULONG MessageLength,
+ PVOID *CaptureData)
{
+ /* If there's no data, our job is easy. */
+ if (MessageLength == 0)
+ {
+ *CaptureData = NULL;
+ CaptureData = NULL;
+ }
+ else
+ {
+ /* Set the capture data at our current available buffer */
+ *CaptureData = (PVOID)CaptureBuffer->BufferEnd;
+
+ /* Validate the size */
+ if (MessageLength >= MAXLONG) return 0;
+
+ /* Align it to a 4-byte boundary */
+ MessageLength = (MessageLength + 3) & ~3;
+
+ /* Move our available buffer beyond this space */
+ CaptureBuffer->BufferEnd += MessageLength;
+ }
+
+ /* Increase the pointer count */
+ CaptureBuffer->PointerCount++;
+
+ /* Write down this pointer in the array */
+ CaptureBuffer->PointerArray[CaptureBuffer->PointerCount] = (ULONG_PTR)CaptureData;
+
+ /* Return the aligned length */
+ return MessageLength;
}
/*
- * @unimplemented
+ * @implemented
*/
-VOID STDCALL
-CsrCaptureMessageBuffer(ULONG Unknown0,
- ULONG Unknown1,
- ULONG Unknown2,
- ULONG Unknown3)
+VOID
+NTAPI
+CsrCaptureMessageBuffer(PCSR_CAPTURE_BUFFER CaptureBuffer,
+ PVOID MessageString,
+ ULONG StringLength,
+ PVOID *CapturedData)
{
+ /* Simply allocate a message pointer in the buffer */
+ CsrAllocateMessagePointer(CaptureBuffer, StringLength, CapturedData);
+ /* Check if there was any data */
+ if (!MessageString || !StringLength) return;
+
+ /* Copy the data into the buffer */
+ RtlMoveMemory(*CapturedData, MessageString, StringLength);
}
/*
- * @unimplemented
+ * @implemented
*/
-BOOLEAN STDCALL CsrFreeCaptureBuffer (PVOID CaptureBuffer)
+VOID
+NTAPI
+CsrFreeCaptureBuffer(PCSR_CAPTURE_BUFFER CaptureBuffer)
{
- /* FIXME: use NTDLL own heap */
- return RtlFreeHeap (hCaptureHeap, 0, CaptureBuffer);
+ /* Free it from the heap */
+ RtlFreeHeap(CsrPortHeap, 0, CaptureBuffer);
}
/*
* @implemented
*/
-PLARGE_INTEGER STDCALL
[truncated at 1000 lines; 971 more skipped]