From 79c9204f9ee52578155252c26095ec99c5178f3f Mon Sep 17 00:00:00 2001 From: Stefan Ginsberg Date: Sat, 8 Aug 2009 16:50:27 +0000 Subject: [PATCH] - Fix compilation of csrsrv: - helper.h does not exist anymore, so define what was used in srv.h instead - Complete migration to PSEH2 - TEB's Cid was renamed to ClientId -- update the code - Rename DllMain to DllMainCRTStartup as this is what we link a native dll to - Fix some incorrect entries in the .spec - Also fix some /W4 warnings. Add a note to CsrPopulateDosDevicesDirectory that the code is incomplete and will never stop looping (spotted by /W4). - Does not link completely yet due to some missing function stubs. svn path=/trunk/; revision=42525 --- reactos/include/reactos/subsys/csr/server.h | 11 ++++++++++- reactos/subsystems/csr/csrsrv/api.c | 14 +++++++------- reactos/subsystems/csr/csrsrv/csrsrv.spec | 4 ++-- reactos/subsystems/csr/csrsrv/init.c | 10 +++++++--- reactos/subsystems/csr/csrsrv/process.c | 2 +- reactos/subsystems/csr/csrsrv/server.c | 5 +++-- reactos/subsystems/csr/csrsrv/srv.h | 12 +++++++++--- reactos/subsystems/csr/main.c | 3 +++ 8 files changed, 42 insertions(+), 19 deletions(-) diff --git a/reactos/include/reactos/subsys/csr/server.h b/reactos/include/reactos/subsys/csr/server.h index eeb7cf6d2a7..2e0ae7f5abf 100644 --- a/reactos/include/reactos/subsys/csr/server.h +++ b/reactos/include/reactos/subsys/csr/server.h @@ -7,6 +7,11 @@ #ifndef _CSRSERVER_H #define _CSRSERVER_H +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning (disable:4201) +#endif + /* DEPENDENCIES **************************************************************/ /* TYPES **********************************************************************/ @@ -42,7 +47,7 @@ typedef struct _CSR_PROCESS ULONG Reserved; ULONG ShutdownLevel; ULONG ShutdownFlags; - PVOID ServerData[]; + PVOID ServerData[ANYSIZE_ARRAY]; } CSR_PROCESS, *PCSR_PROCESS; typedef struct _CSR_THREAD @@ -325,4 +330,8 @@ CsrServerInitialization( PCHAR Arguments[] ); +#ifdef _MSC_VER +#pragma warning(pop) +#endif + #endif diff --git a/reactos/subsystems/csr/csrsrv/api.c b/reactos/subsystems/csr/csrsrv/api.c index 28e4cd82c01..123e6ff0486 100644 --- a/reactos/subsystems/csr/csrsrv/api.c +++ b/reactos/subsystems/csr/csrsrv/api.c @@ -342,8 +342,8 @@ CsrApiRequestThread(IN PVOID Parameter) ULONG Reply; /* Probably because of the way GDI is loaded, this has to be done here */ - Teb->GdiClientPID = HandleToUlong(Teb->Cid.UniqueProcess); - Teb->GdiClientTID = HandleToUlong(Teb->Cid.UniqueThread); + Teb->GdiClientPID = HandleToUlong(Teb->ClientId.UniqueProcess); + Teb->GdiClientTID = HandleToUlong(Teb->ClientId.UniqueThread); /* Set up the timeout for the connect (30 seconds) */ TimeOut.QuadPart = -30 * 1000 * 1000 * 10; @@ -374,7 +374,7 @@ CsrApiRequestThread(IN PVOID Parameter) while (TRUE) { /* Make sure the real CID is set */ - Teb->RealClientId = Teb->Cid; + Teb->RealClientId = Teb->ClientId; /* Wait for a message to come through */ Status = NtReplyWaitReceivePort(CsrApiPort, @@ -525,7 +525,7 @@ CsrApiRequestThread(IN PVOID Parameter) /* Increase the static thread count */ _InterlockedIncrement((PLONG)&CsrpStaticThreadCount); } - _SEH_EXCEPT(CsrUnhandledExceptionFilter) + _SEH2_EXCEPT(CsrUnhandledExceptionFilter(_SEH2_GetExceptionInformation())) { ReplyMsg = NULL; } @@ -751,7 +751,7 @@ CsrApiHandleConnectionRequest(IN PCSR_API_MESSAGE ApiMessage) RemotePortView.ViewBase = NULL; /* Save the Process ID */ - ConnectInfo->ProcessId = NtCurrentTeb()->Cid.UniqueProcess; + ConnectInfo->ProcessId = NtCurrentTeb()->ClientId.UniqueProcess; /* Accept the Connection */ Status = NtAcceptConnectPort(&hPort, @@ -1072,7 +1072,7 @@ CsrConnectToUser(VOID) CsrClientThreadSetup(); /* Save pointer to this thread in TEB */ - CsrThread = CsrLocateThreadInProcess(NULL, &Teb->Cid); + CsrThread = CsrLocateThreadInProcess(NULL, &Teb->ClientId); if (CsrThread) Teb->CsrClientThread = CsrThread; /* Return it */ @@ -1346,7 +1346,7 @@ CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, if (!CaptureBuffer) { /* In this case, check only the Process ID */ - if (NtCurrentTeb()->Cid.UniqueProcess == + if (NtCurrentTeb()->ClientId.UniqueProcess == ApiMessage->Header.ClientId.UniqueProcess) { /* There is a match, validation succeeded */ diff --git a/reactos/subsystems/csr/csrsrv/csrsrv.spec b/reactos/subsystems/csr/csrsrv/csrsrv.spec index e2ea60f5587..6b68980350b 100644 --- a/reactos/subsystems/csr/csrsrv/csrsrv.spec +++ b/reactos/subsystems/csr/csrsrv/csrsrv.spec @@ -19,7 +19,7 @@ @ stdcall CsrLockThreadByClientId(ptr ptr) @ stdcall CsrMoveSatisfiedWait(ptr ptr) @ stdcall CsrNotifyWait(ptr long ptr ptr) -@ stdcall CsrPopulateDosDevices(ptr ptr) +@ stdcall CsrPopulateDosDevices() @ stdcall CsrQueryApiPort() @ stdcall CsrReferenceThread(ptr) @ stdcall CsrRevertToSelf() @@ -28,7 +28,7 @@ @ stdcall CsrSetCallingSpooler(long) @ stdcall CsrSetForegroundPriority(ptr) @ stdcall CsrShutdownProcesses(ptr long) -@ stdcall CsrUnhandledExceptionFilter(ptr ptr) +@ stdcall CsrUnhandledExceptionFilter(ptr) @ stdcall CsrUnlockProcess(ptr) @ stdcall CsrUnlockThread(ptr) @ stdcall CsrValidateMessageBuffer(ptr ptr long long) diff --git a/reactos/subsystems/csr/csrsrv/init.c b/reactos/subsystems/csr/csrsrv/init.c index 45c8efaf581..02e14cdb791 100644 --- a/reactos/subsystems/csr/csrsrv/init.c +++ b/reactos/subsystems/csr/csrsrv/init.c @@ -126,6 +126,7 @@ CsrPopulateDosDevicesDirectory(IN HANDLE hDosDevicesDirectory, } } } + /* FIXME: Loop never ends! */ } } @@ -1221,11 +1222,14 @@ CsrPopulateDosDevices(VOID) BOOL NTAPI -DllMain(HANDLE hDll, - DWORD dwReason, - LPVOID lpReserved) +DllMainCRTStartup(HANDLE hDll, + DWORD dwReason, + LPVOID lpReserved) { /* We don't do much */ + UNREFERENCED_PARAMETER(hDll); + UNREFERENCED_PARAMETER(dwReason); + UNREFERENCED_PARAMETER(lpReserved); return TRUE; } diff --git a/reactos/subsystems/csr/csrsrv/process.c b/reactos/subsystems/csr/csrsrv/process.c index 09dd1ab2976..c26a6c1d94e 100644 --- a/reactos/subsystems/csr/csrsrv/process.c +++ b/reactos/subsystems/csr/csrsrv/process.c @@ -94,7 +94,7 @@ CsrInitializeProcesses(VOID) /* Set up the minimal information for it */ InitializeListHead(&CsrRootProcess->ListLink); CsrRootProcess->ProcessHandle = (HANDLE)-1; - CsrRootProcess->ClientId = NtCurrentTeb()->Cid; + CsrRootProcess->ClientId = NtCurrentTeb()->ClientId; /* Initialize the Thread Hash List */ for (i = 0; i < 256; i++) InitializeListHead(&CsrThreadHashTable[i]); diff --git a/reactos/subsystems/csr/csrsrv/server.c b/reactos/subsystems/csr/csrsrv/server.c index 883de7cb2d6..2faad8f6264 100644 --- a/reactos/subsystems/csr/csrsrv/server.c +++ b/reactos/subsystems/csr/csrsrv/server.c @@ -598,9 +598,10 @@ CsrSetCallingSpooler(ULONG Reserved) * @remarks None. * *--*/ -_SEH_FILTER(CsrUnhandledExceptionFilter) +LONG +NTAPI +CsrUnhandledExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo) { - struct _EXCEPTION_POINTERS *ExceptionInfo = _SEH_GetExceptionPointers(); SYSTEM_KERNEL_DEBUGGER_INFORMATION DebuggerInfo; EXCEPTION_DISPOSITION Result = EXCEPTION_EXECUTE_HANDLER; BOOLEAN OldValue; diff --git a/reactos/subsystems/csr/csrsrv/srv.h b/reactos/subsystems/csr/csrsrv/srv.h index 3abf76aba9e..1ddfac2194d 100644 --- a/reactos/subsystems/csr/csrsrv/srv.h +++ b/reactos/subsystems/csr/csrsrv/srv.h @@ -8,13 +8,12 @@ #include #include #include -#include /* CSR Header */ #include /* PSEH for SEH Support */ -#include +#include /* DEFINES *******************************************************************/ @@ -51,6 +50,9 @@ #define CSR_PORT_NAME L"ApiPort" #define UNICODE_PATH_SEP L"\\" +#define ROUND_UP(n, align) ROUND_DOWN(((ULONG)n) + (align) - 1, (align)) +#define ROUND_DOWN(n, align) (((ULONG)n) & ~((align) - 1l)) + /* DATA **********************************************************************/ extern ULONG CsrTotalPerProcessDataLength; @@ -345,7 +347,11 @@ CsrDestroyProcess( IN NTSTATUS ExitStatus ); -_SEH_FILTER(CsrUnhandledExceptionFilter); +LONG +NTAPI +CsrUnhandledExceptionFilter( + IN PEXCEPTION_POINTERS ExceptionInfo +); VOID NTAPI diff --git a/reactos/subsystems/csr/main.c b/reactos/subsystems/csr/main.c index 6e8c05db13b..de852fadf46 100644 --- a/reactos/subsystems/csr/main.c +++ b/reactos/subsystems/csr/main.c @@ -68,6 +68,9 @@ _main(int argc, KPRIORITY BasePriority = (8 + 1) + 4; NTSTATUS Status; ULONG Response; + UNREFERENCED_PARAMETER(envp); + UNREFERENCED_PARAMETER(DebugFlag); + /* Set the Priority */ NtSetInformationProcess(NtCurrentProcess(),