[CSR][NTDLL] Move the CSR subsystem into its own "csr" sub-directory. (#4802)

Move CSRSS, CSRSRV there, as well as CSR client calls from NTDLL into a "CSRLIB" library.
This commit is contained in:
Hermès Bélusca-Maïto 2022-10-23 18:02:38 +02:00
parent a6df7ddb95
commit d2aeaba5f8
No known key found for this signature in database
GPG Key ID: 3B2539C65E7B93D0
27 changed files with 94 additions and 43 deletions

View File

@ -18,9 +18,6 @@ include_directories(
${REACTOS_SOURCE_DIR}/sdk/include/reactos/subsys) ${REACTOS_SOURCE_DIR}/sdk/include/reactos/subsys)
list(APPEND SOURCE list(APPEND SOURCE
csr/api.c
csr/capture.c
csr/connect.c
dbg/dbgui.c dbg/dbgui.c
ldr/ldrapi.c ldr/ldrapi.c
ldr/ldrinit.c ldr/ldrinit.c
@ -60,7 +57,7 @@ set_module_type(ntdll win32dll ENTRYPOINT 0)
set_subsystem(ntdll console) set_subsystem(ntdll console)
################# END HACK ################# ################# END HACK #################
target_link_libraries(ntdll rtl rtl_vista ntdllsys libcntpr uuid ${PSEH_LIB}) target_link_libraries(ntdll csrlib rtl rtl_vista ntdllsys libcntpr uuid ${PSEH_LIB})
if (STACK_PROTECTOR) if (STACK_PROTECTOR)
target_sources(ntdll PRIVATE $<TARGET_OBJECTS:gcc_ssp_nt>) target_sources(ntdll PRIVATE $<TARGET_OBJECTS:gcc_ssp_nt>)

View File

@ -43,9 +43,6 @@
/* Internal NTDLL */ /* Internal NTDLL */
#include "ntdllp.h" #include "ntdllp.h"
/* CSRSS Headers */
#include <csr/csr.h>
/* PSEH */ /* PSEH */
#include <pseh/pseh2.h> #include <pseh/pseh2.h>

View File

@ -23,7 +23,7 @@
/* TYPES **********************************************************************/ /* TYPES **********************************************************************/
// Used in ntdll/csr/connect.c // Used in csr/connect.c
#define CSR_CSRSS_SECTION_SIZE 65536 #define CSR_CSRSS_SECTION_SIZE 65536
typedef struct _CSR_NT_SESSION typedef struct _CSR_NT_SESSION

View File

@ -1,4 +1,4 @@
add_subdirectory(csr)
add_subdirectory(mvdm) add_subdirectory(mvdm)
add_subdirectory(win) add_subdirectory(win)
add_subdirectory(win32)

View File

@ -1,3 +1,4 @@
add_subdirectory(csrlib)
add_subdirectory(csrsrv) add_subdirectory(csrsrv)
add_subdirectory(csrss) add_subdirectory(csrss)

View File

@ -0,0 +1,13 @@
add_definitions(-D_NTSYSTEM_)
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/subsys/csr)
list(APPEND SOURCE
api.c
capture.c
connect.c)
add_library(csrlib ${SOURCE})
add_pch(csrlib csrlib.h SOURCE)
add_dependencies(csrlib psdk)

View File

@ -1,22 +1,21 @@
/* /*
* COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS Client/Server Runtime SubSystem
* PROJECT: ReactOS kernel * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* FILE: dll/ntdll/csr/api.c * PURPOSE: CSR Client Library - API LPC Implementation
* PURPOSE: CSR APIs exported through NTDLL * COPYRIGHT: Copyright 2005-2012 Alex Ionescu <alex@relsoft.net>
* PROGRAMMER: Alex Ionescu (alex@relsoft.net) * Copyright 2012-2022 Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
*/ */
/* INCLUDES *******************************************************************/ /* INCLUDES *******************************************************************/
#include <ntdll.h> #include "csrlib.h"
#define NTOS_MODE_USER
#include <ndk/psfuncs.h>
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
/* GLOBALS ********************************************************************/
extern HANDLE CsrApiPort;
/* FUNCTIONS ******************************************************************/ /* FUNCTIONS ******************************************************************/
/* /*

View File

@ -1,23 +1,18 @@
/* /*
* COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS Client/Server Runtime SubSystem
* PROJECT: ReactOS kernel * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* FILE: dll/ntdll/csr/capture.c * PURPOSE: CSR Client Library - CSR API Messages probing and capturing
* PURPOSE: Routines for probing and capturing CSR API Messages * COPYRIGHT: Copyright 2005 Alex Ionescu <alex@relsoft.net>
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net) * Copyright 2012-2022 Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
* Hermes Belusca-Maito (hermes.belusca@sfr.fr)
*/ */
/* INCLUDES *******************************************************************/ /* INCLUDES *******************************************************************/
#include <ntdll.h> #include "csrlib.h"
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
/* GLOBALS ********************************************************************/
extern HANDLE CsrPortHeap;
/* FUNCTIONS ******************************************************************/ /* FUNCTIONS ******************************************************************/
/* /*

View File

@ -1,17 +1,23 @@
/* /*
* COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS Client/Server Runtime SubSystem
* PROJECT: ReactOS kernel * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* FILE: dll/ntdll/csr/connect.c * PURPOSE: CSR Client Library - CSR connection and calling
* PURPOSE: Routines for connecting and calling CSR * COPYRIGHT: Copyright 2005-2013 Alex Ionescu <alex@relsoft.net>
* PROGRAMMER: Alex Ionescu (alex@relsoft.net) * Copyright 2012-2022 Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
*/ */
/* INCLUDES *******************************************************************/ /* INCLUDES *******************************************************************/
#include <ntdll.h> #include "csrlib.h"
#define NTOS_MODE_USER
#include <ndk/ldrfuncs.h>
#include <ndk/lpcfuncs.h> #include <ndk/lpcfuncs.h>
#include <csr/csrsrv.h> #include <ndk/mmfuncs.h>
#include <ndk/obfuncs.h>
#include <ndk/umfuncs.h>
#include <csrsrv.h> // For CSR_CSRSS_SECTION_SIZE
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
@ -30,8 +36,6 @@ typedef NTSTATUS
PCSR_SERVER_API_ROUTINE CsrServerApiRoutine; PCSR_SERVER_API_ROUTINE CsrServerApiRoutine;
#define UNICODE_PATH_SEP L"\\"
/* FUNCTIONS ******************************************************************/ /* FUNCTIONS ******************************************************************/
NTSTATUS NTSTATUS
@ -80,8 +84,8 @@ CsrpConnectToServer(IN PWSTR ObjectDirectory)
} }
/* Create the name */ /* Create the name */
RtlAppendUnicodeToString(&PortName, ObjectDirectory ); RtlAppendUnicodeToString(&PortName, ObjectDirectory);
RtlAppendUnicodeToString(&PortName, UNICODE_PATH_SEP); RtlAppendUnicodeToString(&PortName, L"\\");
RtlAppendUnicodeToString(&PortName, CSR_PORT_NAME); RtlAppendUnicodeToString(&PortName, CSR_PORT_NAME);
/* Create a section for the port memory */ /* Create a section for the port memory */

View File

@ -0,0 +1,17 @@
@ stdcall CsrAllocateCaptureBuffer(long long)
@ stdcall CsrAllocateMessagePointer(ptr long ptr)
@ stdcall CsrCaptureMessageBuffer(ptr ptr long ptr)
@ stdcall CsrCaptureMessageMultiUnicodeStringsInPlace(ptr long ptr)
@ stdcall CsrCaptureMessageString(ptr str long long ptr)
@ stdcall CsrCaptureTimeout(long ptr)
@ stdcall CsrClientCallServer(ptr ptr long long)
@ stdcall CsrClientConnectToServer(str long ptr ptr ptr)
@ stdcall CsrFreeCaptureBuffer(ptr)
@ stdcall CsrGetProcessId()
@ stdcall CsrIdentifyAlertableThread()
@ stdcall -version=0x502 CsrNewThread()
@ stdcall -version=0x502 CsrProbeForRead(ptr long long)
@ stdcall -version=0x502 CsrProbeForWrite(ptr long long)
@ stdcall CsrSetPriorityClass(ptr ptr)
@ stdcall -stub -version=0x600+ CsrVerifyRegion(ptr long)
@ stdcall -stub -version=0x600+ RtlRegisterThreadWithCsrss()

View File

@ -0,0 +1,29 @@
/*
* PROJECT: ReactOS Client/Server Runtime SubSystem
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: CSR Client Library - Main Header
* COPYRIGHT: Copyright 2022 Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
*/
#ifndef _CSRLIB_H_
#define _CSRLIB_H_
/* INCLUDES ******************************************************************/
/* PSDK/NDK Headers */
#define WIN32_NO_STATUS
//#include <windef.h>
#define NTOS_MODE_USER
#include <ndk/rtlfuncs.h>
/* CSRSS Headers */
#include <csr.h>
/* GLOBALS ********************************************************************/
extern HANDLE CsrApiPort;
extern HANDLE CsrPortHeap;
#endif /* _CSRLIB_H_ */
/* EOF */

View File

@ -1,5 +1,4 @@
include_directories(${REACTOS_SOURCE_DIR}/subsystems/win32/csrss/include)
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/subsys) include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/subsys)
spec2def(csrsrv.dll csrsrv.spec ADD_IMPORTLIB) spec2def(csrsrv.dll csrsrv.spec ADD_IMPORTLIB)
@ -20,7 +19,7 @@ add_library(csrsrv MODULE
${CMAKE_CURRENT_BINARY_DIR}/csrsrv.def) ${CMAKE_CURRENT_BINARY_DIR}/csrsrv.def)
set_module_type(csrsrv nativedll) set_module_type(csrsrv nativedll)
target_link_libraries(csrsrv ${PSEH_LIB} smlib) target_link_libraries(csrsrv smlib ${PSEH_LIB})
add_importlibs(csrsrv ntdll) add_importlibs(csrsrv ntdll)
add_pch(csrsrv srv.h SOURCE) add_pch(csrsrv srv.h SOURCE)
add_dependencies(csrsrv psdk bugcodes) add_dependencies(csrsrv psdk bugcodes)