2012-10-13 20:32:44 +00:00
|
|
|
/*
|
2003-12-02 11:38:47 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
2013-03-09 21:08:23 +00:00
|
|
|
* FILE: subsystems/win32/csrsrv/api.h
|
|
|
|
* PURPOSE: CSRSS Internal API
|
2003-12-02 11:38:47 +00:00
|
|
|
*/
|
|
|
|
|
2010-02-26 11:43:19 +00:00
|
|
|
#pragma once
|
2001-08-14 12:57:16 +00:00
|
|
|
|
2012-10-22 00:09:51 +00:00
|
|
|
extern RTL_CRITICAL_SECTION CsrProcessLock, CsrWaitListsLock;
|
|
|
|
|
2012-10-17 23:10:40 +00:00
|
|
|
#define CsrAcquireProcessLock() \
|
2012-10-20 13:00:41 +00:00
|
|
|
RtlEnterCriticalSection(&CsrProcessLock);
|
2012-10-17 23:10:40 +00:00
|
|
|
|
|
|
|
#define CsrReleaseProcessLock() \
|
2012-10-20 13:00:41 +00:00
|
|
|
RtlLeaveCriticalSection(&CsrProcessLock);
|
2012-10-17 23:10:40 +00:00
|
|
|
|
2012-02-16 06:45:25 +00:00
|
|
|
#define ProcessStructureListLocked() \
|
2012-10-20 13:00:41 +00:00
|
|
|
(CsrProcessLock.OwningThread == NtCurrentTeb()->ClientId.UniqueThread)
|
2012-02-16 06:45:25 +00:00
|
|
|
|
2012-02-16 06:57:27 +00:00
|
|
|
#define CsrAcquireWaitLock() \
|
|
|
|
RtlEnterCriticalSection(&CsrWaitListsLock);
|
|
|
|
|
|
|
|
#define CsrReleaseWaitLock() \
|
|
|
|
RtlLeaveCriticalSection(&CsrWaitListsLock);
|
|
|
|
|
|
|
|
#define CsrAcquireNtSessionLock() \
|
|
|
|
RtlEnterCriticalSection(&CsrNtSessionLock);
|
|
|
|
|
|
|
|
#define CsrReleaseNtSessionLock() \
|
|
|
|
RtlLeaveCriticalSection(&CsrNtSessionLock);
|
|
|
|
|
2012-02-19 11:39:07 +00:00
|
|
|
|
2012-10-22 00:09:51 +00:00
|
|
|
#define CSR_SERVER_DLL_MAX 4
|
|
|
|
|
2012-02-16 06:57:27 +00:00
|
|
|
|
[CSR]
During my investigations for making working Win2k3 csrsrv.dll (or other CSR servers) into ROS (to compare our behaviour with our own csrsrv.dll and Win2k3 one), I hit a problem: if I test a checked-build version of csrsrv (or other CSR servers), everything was fine when they were loaded, but if I use a release-build version (i.e. without any debug information), I systematically hit a memory access violation which was traced back to the moment when a CSR server's CsrInitialization entry point was called.
So I did the experiment, where I used our (debug-build) csrsrv with a free-build win2k3 CSR server dll (it was winsrv.dll, and I retested with basesrv.dll after). I hit the access violation. But if I took a debug-build version of winsrv.dll, everything was OK.
I then added in our csrsrv' server.c file the following line (around line 212 of the current file version):
DPRINT1("%s ; ServerDll->ValidTable = 0x%p ; ServerDll->NameTable = 0x%p ; ServerDll->SizeOfProcessData = %d ; ServerDll->ConnectCallback = 0x%p\n", DllString, ServerDll->ValidTable, ServerDll->NameTable, ServerDll->SizeOfProcessData, ServerDll->ConnectCallback);
and I saw that, when using a debug-build win2k3 CSR server, everything was fine (in particular the ServerDll->SizeOfProcessData member contained a reasonable value, e.g. a size of 88 bytes), whereas if I used a free-build version, I got an off-by-one problem, with the ServerDll->ValidTable pointer valid but the ServerDll->NameTable member being equal to 88 (i.e. invalid pointer) and the ServerDll->SizeOfProcessData member being equal to a very large value, which looked like a pointer value.
After more investigations, I saw that in debug-build CSR servers the list of API names were stored, whereas it was not the case in free-build versions. Therefore I concluded that the API names table was included *ONLY* in debug builds and not in release builds.
Hence, to be able to test in ROS either debug-builds or release-builds versions of Windows CSR servers in ROS (and vice-versa), I introduced a #define called CSR_DBG, which is defined only if the DBG macro is != 0, and which is not defined otherwise. When the CSR_DBG flag is defined, API names tables are added in CSR servers and otherwise, they are not.
Therefore, we are now able to test debug-build Windows CSR servers in ROS (the default possibility) or free-build versions of these CSR servers (but first, we have to build the other ones without the CSR_DBG flag, to avoid the off-by-one problem described above).
svn path=/trunk/; revision=60560
2013-10-06 13:33:17 +00:00
|
|
|
// Debug Flag
|
|
|
|
extern ULONG CsrDebug;
|
|
|
|
|
2005-03-20 22:55:05 +00:00
|
|
|
extern HANDLE hBootstrapOk;
|
2012-10-22 00:09:51 +00:00
|
|
|
extern HANDLE CsrApiPort;
|
|
|
|
extern HANDLE CsrSmApiPort;
|
|
|
|
extern HANDLE CsrSbApiPort;
|
2013-07-28 13:54:42 +00:00
|
|
|
#define NUMBER_THREAD_HASH_BUCKETS 257
|
|
|
|
extern LIST_ENTRY CsrThreadHashTable[NUMBER_THREAD_HASH_BUCKETS];
|
2012-10-22 00:09:51 +00:00
|
|
|
extern PCSR_PROCESS CsrRootProcess;
|
|
|
|
extern UNICODE_STRING CsrDirectoryName;
|
|
|
|
extern ULONG CsrTotalPerProcessDataLength;
|
|
|
|
extern SYSTEM_BASIC_INFORMATION CsrNtSysInfo;
|
|
|
|
extern HANDLE CsrHeap;
|
|
|
|
extern PVOID CsrSrvSharedSectionHeap;
|
|
|
|
extern PVOID *CsrSrvSharedStaticServerData;
|
|
|
|
extern HANDLE CsrInitializationEvent;
|
|
|
|
extern PCSR_SERVER_DLL CsrLoadedServerDll[CSR_SERVER_DLL_MAX];
|
|
|
|
extern ULONG CsrMaxApiRequestThreads;
|
|
|
|
|
|
|
|
/****************************************************/
|
|
|
|
extern UNICODE_STRING CsrSbApiPortName;
|
|
|
|
extern UNICODE_STRING CsrApiPortName;
|
|
|
|
extern RTL_CRITICAL_SECTION CsrProcessLock;
|
|
|
|
extern RTL_CRITICAL_SECTION CsrWaitListsLock;
|
|
|
|
extern HANDLE CsrObjectDirectory;
|
|
|
|
/****************************************************/
|
2005-03-20 22:55:05 +00:00
|
|
|
|
2012-10-22 00:09:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
CSR_API(CsrSrvClientConnect);
|
|
|
|
CSR_API(CsrSrvUnusedFunction);
|
2021-11-21 22:46:11 +00:00
|
|
|
#if (NTDDI_VERSION < NTDDI_WS03)
|
2012-10-22 00:09:51 +00:00
|
|
|
CSR_API(CsrSrvIdentifyAlertableThread);
|
|
|
|
CSR_API(CsrSrvSetPriorityClass);
|
2021-11-21 22:46:11 +00:00
|
|
|
#endif
|
2012-10-22 00:09:51 +00:00
|
|
|
|
|
|
|
|
2013-03-10 19:37:33 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
CsrServerDllInitialization(IN PCSR_SERVER_DLL LoadedServerDll);
|
|
|
|
|
2012-10-22 00:09:51 +00:00
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
2013-03-10 19:37:33 +00:00
|
|
|
CsrCaptureArguments(IN PCSR_THREAD CsrThread,
|
|
|
|
IN PCSR_API_MESSAGE ApiMessage);
|
1999-12-22 14:48:30 +00:00
|
|
|
|
2012-02-16 06:45:25 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2012-10-22 00:09:51 +00:00
|
|
|
CsrReleaseCapturedArguments(IN PCSR_API_MESSAGE ApiMessage);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
CsrLoadServerDll(IN PCHAR DllString,
|
|
|
|
IN PCHAR EntryPoint OPTIONAL,
|
|
|
|
IN ULONG ServerId);
|
|
|
|
|
2012-02-16 06:45:25 +00:00
|
|
|
|
2012-02-15 19:53:31 +00:00
|
|
|
PCSR_THREAD
|
|
|
|
NTAPI
|
2012-02-15 20:29:08 +00:00
|
|
|
CsrAllocateThread(IN PCSR_PROCESS CsrProcess);
|
2012-02-15 19:53:31 +00:00
|
|
|
|
2012-02-16 06:45:25 +00:00
|
|
|
PCSR_PROCESS
|
|
|
|
NTAPI
|
|
|
|
CsrAllocateProcess(VOID);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
CsrDeallocateProcess(IN PCSR_PROCESS CsrProcess);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
2013-03-10 19:37:33 +00:00
|
|
|
CsrInsertProcess(IN PCSR_PROCESS ParentProcess OPTIONAL,
|
|
|
|
IN PCSR_PROCESS CsrProcess);
|
2012-02-16 06:45:25 +00:00
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
2013-03-10 19:37:33 +00:00
|
|
|
CsrRemoveProcess(IN PCSR_PROCESS CsrProcess);
|
2012-02-16 06:45:25 +00:00
|
|
|
|
2012-02-16 16:40:15 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2013-03-10 19:37:33 +00:00
|
|
|
CsrApiRequestThread(IN PVOID Parameter);
|
2012-10-22 00:09:51 +00:00
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
CsrSbApiRequestThread(IN PVOID Parameter);
|
2012-02-16 06:45:25 +00:00
|
|
|
|
2012-02-19 11:39:07 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2012-10-22 00:09:51 +00:00
|
|
|
CsrApiPortInitialize(VOID);
|
2012-02-19 11:39:07 +00:00
|
|
|
|
2012-02-16 06:45:25 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
ProtectHandle(IN HANDLE ObjectHandle);
|
|
|
|
|
2012-10-22 00:09:51 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
UnProtectHandle(IN HANDLE ObjectHandle);
|
|
|
|
|
2013-09-12 09:02:48 +00:00
|
|
|
NTSTATUS
|
2012-02-16 06:45:25 +00:00
|
|
|
NTAPI
|
|
|
|
CsrInsertThread(IN PCSR_PROCESS Process,
|
2012-10-22 00:09:51 +00:00
|
|
|
IN PCSR_THREAD Thread);
|
1999-12-30 01:51:42 +00:00
|
|
|
|
2013-09-12 09:02:48 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
CsrDeallocateThread(IN PCSR_THREAD CsrThread);
|
|
|
|
|
2012-02-19 09:57:00 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2012-10-22 00:09:51 +00:00
|
|
|
CsrLockedReferenceProcess(IN PCSR_PROCESS CsrProcess);
|
2012-02-19 09:57:00 +00:00
|
|
|
|
2012-10-22 00:09:51 +00:00
|
|
|
VOID
|
2012-02-16 06:57:27 +00:00
|
|
|
NTAPI
|
2012-10-22 00:09:51 +00:00
|
|
|
CsrLockedReferenceThread(IN PCSR_THREAD CsrThread);
|
2012-02-16 06:57:27 +00:00
|
|
|
|
2012-02-16 19:53:47 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2012-10-22 00:09:51 +00:00
|
|
|
CsrInitializeProcessStructure(VOID);
|
2012-02-16 19:53:47 +00:00
|
|
|
|
2012-10-22 00:09:51 +00:00
|
|
|
PCSR_THREAD
|
2012-02-16 19:53:47 +00:00
|
|
|
NTAPI
|
2012-10-22 00:09:51 +00:00
|
|
|
CsrLocateThreadInProcess(IN PCSR_PROCESS CsrProcess OPTIONAL,
|
|
|
|
IN PCLIENT_ID Cid);
|
|
|
|
PCSR_THREAD
|
|
|
|
NTAPI
|
|
|
|
CsrLocateThreadByClientId(OUT PCSR_PROCESS *Process OPTIONAL,
|
|
|
|
IN PCLIENT_ID ClientId);
|
2012-02-16 19:53:47 +00:00
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2012-10-22 00:09:51 +00:00
|
|
|
CsrInitializeNtSessionList(VOID);
|
2012-02-16 19:53:47 +00:00
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2012-10-22 00:09:51 +00:00
|
|
|
CsrSrvAttachSharedSection(IN PCSR_PROCESS CsrProcess OPTIONAL,
|
2013-08-19 18:14:43 +00:00
|
|
|
OUT PCSR_API_CONNECTINFO ConnectInfo);
|
2012-02-16 19:53:47 +00:00
|
|
|
|
2012-02-19 18:05:49 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2012-10-22 00:09:51 +00:00
|
|
|
CsrSrvCreateSharedSection(IN PCHAR ParameterValue);
|
2012-02-19 18:05:49 +00:00
|
|
|
|
2012-10-22 00:09:51 +00:00
|
|
|
VOID
|
2012-02-19 18:46:05 +00:00
|
|
|
NTAPI
|
2012-10-22 00:09:51 +00:00
|
|
|
CsrLockedDereferenceProcess(PCSR_PROCESS CsrProcess);
|
2012-02-19 18:46:05 +00:00
|
|
|
|
2012-02-19 18:05:49 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
CsrLockedDereferenceThread(IN PCSR_THREAD CsrThread);
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
CsrNotifyWaitBlock(IN PCSR_WAIT_BLOCK WaitBlock,
|
|
|
|
IN PLIST_ENTRY WaitList,
|
|
|
|
IN PVOID WaitArgument1,
|
|
|
|
IN PVOID WaitArgument2,
|
|
|
|
IN ULONG WaitFlags,
|
|
|
|
IN BOOLEAN DereferenceThread);
|
2014-12-15 23:35:32 +00:00
|
|
|
|
2012-02-19 11:39:07 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
CsrReferenceNtSession(IN PCSR_NT_SESSION Session);
|
|
|
|
|
2012-02-19 19:40:28 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
CsrDereferenceNtSession(IN PCSR_NT_SESSION Session,
|
2012-10-22 00:09:51 +00:00
|
|
|
IN NTSTATUS ExitStatus);
|
2012-02-19 19:40:28 +00:00
|
|
|
|
2012-10-22 00:09:51 +00:00
|
|
|
/******************************************************************************
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
NTSTATUS
|
2012-02-16 21:46:59 +00:00
|
|
|
NTAPI
|
2012-10-22 00:09:51 +00:00
|
|
|
CsrCreateSessionObjectDirectory(IN ULONG SessionId);
|
2012-02-16 21:46:59 +00:00
|
|
|
|
2012-10-22 00:09:51 +00:00
|
|
|
NTSTATUS
|
2012-02-16 21:46:59 +00:00
|
|
|
NTAPI
|
2012-10-22 00:09:51 +00:00
|
|
|
CsrCreateObjectDirectory(IN PCHAR ObjectDirectory);
|
2012-02-16 21:46:59 +00:00
|
|
|
|
2012-02-16 20:08:34 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2012-10-22 00:09:51 +00:00
|
|
|
CsrSbApiPortInitialize(VOID);
|
2012-02-16 21:46:59 +00:00
|
|
|
|
2012-10-22 00:09:51 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
CsrSbCreateSession(IN PSB_API_MSG ApiMessage);
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
CsrSbTerminateSession(IN PSB_API_MSG ApiMessage);
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
CsrSbForeignSessionComplete(IN PSB_API_MSG ApiMessage);
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
CsrSbCreateProcess(IN PSB_API_MSG ApiMessage);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
CsrSbApiHandleConnectionRequest(IN PSB_API_MSG Message);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
CsrApiHandleConnectionRequest(IN PCSR_API_MESSAGE ApiMessage);
|
|
|
|
|
|
|
|
/** this API is used with CsrPopulateDosDevices, deprecated in r55585.
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
CsrPopulateDosDevicesDirectory(IN HANDLE DosDevicesDirectory,
|
|
|
|
IN PPROCESS_DEVICEMAP_INFORMATION DeviceMap);
|
|
|
|
**/
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
CsrCreateLocalSystemSD(OUT PSECURITY_DESCRIPTOR *LocalSystemSd);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
CsrSetDirectorySecurity(IN HANDLE ObjectDirectory);
|
2004-07-12 20:09:35 +00:00
|
|
|
|
2003-12-02 11:38:47 +00:00
|
|
|
/* EOF */
|