reactos/subsystems/win32/csrsrv/api.h

261 lines
5.6 KiB
C
Raw Normal View History

/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: subsystems/win32/csrsrv/api.h
* PURPOSE: CSRSS Internal API
*/
#pragma once
extern RTL_CRITICAL_SECTION CsrProcessLock, CsrWaitListsLock;
#define CsrAcquireProcessLock() \
RtlEnterCriticalSection(&CsrProcessLock);
#define CsrReleaseProcessLock() \
RtlLeaveCriticalSection(&CsrProcessLock);
#define ProcessStructureListLocked() \
(CsrProcessLock.OwningThread == NtCurrentTeb()->ClientId.UniqueThread)
#define CsrAcquireWaitLock() \
RtlEnterCriticalSection(&CsrWaitListsLock);
#define CsrReleaseWaitLock() \
RtlLeaveCriticalSection(&CsrWaitListsLock);
#define CsrAcquireNtSessionLock() \
RtlEnterCriticalSection(&CsrNtSessionLock);
#define CsrReleaseNtSessionLock() \
RtlLeaveCriticalSection(&CsrNtSessionLock);
#define CSR_SERVER_DLL_MAX 4
[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;
extern HANDLE hBootstrapOk;
extern HANDLE CsrApiPort;
extern HANDLE CsrSmApiPort;
extern HANDLE CsrSbApiPort;
#define NUMBER_THREAD_HASH_BUCKETS 257
extern LIST_ENTRY CsrThreadHashTable[NUMBER_THREAD_HASH_BUCKETS];
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;
/****************************************************/
CSR_API(CsrSrvClientConnect);
CSR_API(CsrSrvUnusedFunction);
#if (NTDDI_VERSION < NTDDI_WS03)
CSR_API(CsrSrvIdentifyAlertableThread);
CSR_API(CsrSrvSetPriorityClass);
#endif
NTSTATUS
NTAPI
CsrServerDllInitialization(IN PCSR_SERVER_DLL LoadedServerDll);
BOOLEAN
NTAPI
CsrCaptureArguments(IN PCSR_THREAD CsrThread,
IN PCSR_API_MESSAGE ApiMessage);
VOID
NTAPI
CsrReleaseCapturedArguments(IN PCSR_API_MESSAGE ApiMessage);
NTSTATUS
NTAPI
CsrLoadServerDll(IN PCHAR DllString,
IN PCHAR EntryPoint OPTIONAL,
IN ULONG ServerId);
PCSR_THREAD
NTAPI
CsrAllocateThread(IN PCSR_PROCESS CsrProcess);
PCSR_PROCESS
NTAPI
CsrAllocateProcess(VOID);
VOID
NTAPI
CsrDeallocateProcess(IN PCSR_PROCESS CsrProcess);
VOID
NTAPI
CsrInsertProcess(IN PCSR_PROCESS ParentProcess OPTIONAL,
IN PCSR_PROCESS CsrProcess);
VOID
NTAPI
CsrRemoveProcess(IN PCSR_PROCESS CsrProcess);
NTSTATUS
NTAPI
CsrApiRequestThread(IN PVOID Parameter);
VOID
NTAPI
CsrSbApiRequestThread(IN PVOID Parameter);
NTSTATUS
NTAPI
CsrApiPortInitialize(VOID);
BOOLEAN
NTAPI
ProtectHandle(IN HANDLE ObjectHandle);
BOOLEAN
NTAPI
UnProtectHandle(IN HANDLE ObjectHandle);
NTSTATUS
NTAPI
CsrInsertThread(IN PCSR_PROCESS Process,
IN PCSR_THREAD Thread);
VOID
NTAPI
CsrDeallocateThread(IN PCSR_THREAD CsrThread);
VOID
NTAPI
CsrLockedReferenceProcess(IN PCSR_PROCESS CsrProcess);
VOID
NTAPI
CsrLockedReferenceThread(IN PCSR_THREAD CsrThread);
NTSTATUS
NTAPI
CsrInitializeProcessStructure(VOID);
PCSR_THREAD
NTAPI
CsrLocateThreadInProcess(IN PCSR_PROCESS CsrProcess OPTIONAL,
IN PCLIENT_ID Cid);
PCSR_THREAD
NTAPI
CsrLocateThreadByClientId(OUT PCSR_PROCESS *Process OPTIONAL,
IN PCLIENT_ID ClientId);
NTSTATUS
NTAPI
CsrInitializeNtSessionList(VOID);
NTSTATUS
NTAPI
CsrSrvAttachSharedSection(IN PCSR_PROCESS CsrProcess OPTIONAL,
OUT PCSR_API_CONNECTINFO ConnectInfo);
NTSTATUS
NTAPI
CsrSrvCreateSharedSection(IN PCHAR ParameterValue);
VOID
NTAPI
CsrLockedDereferenceProcess(PCSR_PROCESS CsrProcess);
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);
VOID
NTAPI
CsrReferenceNtSession(IN PCSR_NT_SESSION Session);
VOID
NTAPI
CsrDereferenceNtSession(IN PCSR_NT_SESSION Session,
IN NTSTATUS ExitStatus);
/******************************************************************************
******************************************************************************/
NTSTATUS
NTAPI
CsrCreateSessionObjectDirectory(IN ULONG SessionId);
NTSTATUS
NTAPI
CsrCreateObjectDirectory(IN PCHAR ObjectDirectory);
NTSTATUS
NTAPI
CsrSbApiPortInitialize(VOID);
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);
/* EOF */