- 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
This commit is contained in:
Stefan Ginsberg 2009-08-08 16:50:27 +00:00
parent 6ff2cad0ff
commit 79c9204f9e
8 changed files with 42 additions and 19 deletions

View file

@ -7,6 +7,11 @@
#ifndef _CSRSERVER_H #ifndef _CSRSERVER_H
#define _CSRSERVER_H #define _CSRSERVER_H
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning (disable:4201)
#endif
/* DEPENDENCIES **************************************************************/ /* DEPENDENCIES **************************************************************/
/* TYPES **********************************************************************/ /* TYPES **********************************************************************/
@ -42,7 +47,7 @@ typedef struct _CSR_PROCESS
ULONG Reserved; ULONG Reserved;
ULONG ShutdownLevel; ULONG ShutdownLevel;
ULONG ShutdownFlags; ULONG ShutdownFlags;
PVOID ServerData[]; PVOID ServerData[ANYSIZE_ARRAY];
} CSR_PROCESS, *PCSR_PROCESS; } CSR_PROCESS, *PCSR_PROCESS;
typedef struct _CSR_THREAD typedef struct _CSR_THREAD
@ -325,4 +330,8 @@ CsrServerInitialization(
PCHAR Arguments[] PCHAR Arguments[]
); );
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif #endif

View file

@ -342,8 +342,8 @@ CsrApiRequestThread(IN PVOID Parameter)
ULONG Reply; ULONG Reply;
/* Probably because of the way GDI is loaded, this has to be done here */ /* Probably because of the way GDI is loaded, this has to be done here */
Teb->GdiClientPID = HandleToUlong(Teb->Cid.UniqueProcess); Teb->GdiClientPID = HandleToUlong(Teb->ClientId.UniqueProcess);
Teb->GdiClientTID = HandleToUlong(Teb->Cid.UniqueThread); Teb->GdiClientTID = HandleToUlong(Teb->ClientId.UniqueThread);
/* Set up the timeout for the connect (30 seconds) */ /* Set up the timeout for the connect (30 seconds) */
TimeOut.QuadPart = -30 * 1000 * 1000 * 10; TimeOut.QuadPart = -30 * 1000 * 1000 * 10;
@ -374,7 +374,7 @@ CsrApiRequestThread(IN PVOID Parameter)
while (TRUE) while (TRUE)
{ {
/* Make sure the real CID is set */ /* Make sure the real CID is set */
Teb->RealClientId = Teb->Cid; Teb->RealClientId = Teb->ClientId;
/* Wait for a message to come through */ /* Wait for a message to come through */
Status = NtReplyWaitReceivePort(CsrApiPort, Status = NtReplyWaitReceivePort(CsrApiPort,
@ -525,7 +525,7 @@ CsrApiRequestThread(IN PVOID Parameter)
/* Increase the static thread count */ /* Increase the static thread count */
_InterlockedIncrement((PLONG)&CsrpStaticThreadCount); _InterlockedIncrement((PLONG)&CsrpStaticThreadCount);
} }
_SEH_EXCEPT(CsrUnhandledExceptionFilter) _SEH2_EXCEPT(CsrUnhandledExceptionFilter(_SEH2_GetExceptionInformation()))
{ {
ReplyMsg = NULL; ReplyMsg = NULL;
} }
@ -751,7 +751,7 @@ CsrApiHandleConnectionRequest(IN PCSR_API_MESSAGE ApiMessage)
RemotePortView.ViewBase = NULL; RemotePortView.ViewBase = NULL;
/* Save the Process ID */ /* Save the Process ID */
ConnectInfo->ProcessId = NtCurrentTeb()->Cid.UniqueProcess; ConnectInfo->ProcessId = NtCurrentTeb()->ClientId.UniqueProcess;
/* Accept the Connection */ /* Accept the Connection */
Status = NtAcceptConnectPort(&hPort, Status = NtAcceptConnectPort(&hPort,
@ -1072,7 +1072,7 @@ CsrConnectToUser(VOID)
CsrClientThreadSetup(); CsrClientThreadSetup();
/* Save pointer to this thread in TEB */ /* Save pointer to this thread in TEB */
CsrThread = CsrLocateThreadInProcess(NULL, &Teb->Cid); CsrThread = CsrLocateThreadInProcess(NULL, &Teb->ClientId);
if (CsrThread) Teb->CsrClientThread = CsrThread; if (CsrThread) Teb->CsrClientThread = CsrThread;
/* Return it */ /* Return it */
@ -1346,7 +1346,7 @@ CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage,
if (!CaptureBuffer) if (!CaptureBuffer)
{ {
/* In this case, check only the Process ID */ /* In this case, check only the Process ID */
if (NtCurrentTeb()->Cid.UniqueProcess == if (NtCurrentTeb()->ClientId.UniqueProcess ==
ApiMessage->Header.ClientId.UniqueProcess) ApiMessage->Header.ClientId.UniqueProcess)
{ {
/* There is a match, validation succeeded */ /* There is a match, validation succeeded */

View file

@ -19,7 +19,7 @@
@ stdcall CsrLockThreadByClientId(ptr ptr) @ stdcall CsrLockThreadByClientId(ptr ptr)
@ stdcall CsrMoveSatisfiedWait(ptr ptr) @ stdcall CsrMoveSatisfiedWait(ptr ptr)
@ stdcall CsrNotifyWait(ptr long ptr ptr) @ stdcall CsrNotifyWait(ptr long ptr ptr)
@ stdcall CsrPopulateDosDevices(ptr ptr) @ stdcall CsrPopulateDosDevices()
@ stdcall CsrQueryApiPort() @ stdcall CsrQueryApiPort()
@ stdcall CsrReferenceThread(ptr) @ stdcall CsrReferenceThread(ptr)
@ stdcall CsrRevertToSelf() @ stdcall CsrRevertToSelf()
@ -28,7 +28,7 @@
@ stdcall CsrSetCallingSpooler(long) @ stdcall CsrSetCallingSpooler(long)
@ stdcall CsrSetForegroundPriority(ptr) @ stdcall CsrSetForegroundPriority(ptr)
@ stdcall CsrShutdownProcesses(ptr long) @ stdcall CsrShutdownProcesses(ptr long)
@ stdcall CsrUnhandledExceptionFilter(ptr ptr) @ stdcall CsrUnhandledExceptionFilter(ptr)
@ stdcall CsrUnlockProcess(ptr) @ stdcall CsrUnlockProcess(ptr)
@ stdcall CsrUnlockThread(ptr) @ stdcall CsrUnlockThread(ptr)
@ stdcall CsrValidateMessageBuffer(ptr ptr long long) @ stdcall CsrValidateMessageBuffer(ptr ptr long long)

View file

@ -126,6 +126,7 @@ CsrPopulateDosDevicesDirectory(IN HANDLE hDosDevicesDirectory,
} }
} }
} }
/* FIXME: Loop never ends! */
} }
} }
@ -1221,11 +1222,14 @@ CsrPopulateDosDevices(VOID)
BOOL BOOL
NTAPI NTAPI
DllMain(HANDLE hDll, DllMainCRTStartup(HANDLE hDll,
DWORD dwReason, DWORD dwReason,
LPVOID lpReserved) LPVOID lpReserved)
{ {
/* We don't do much */ /* We don't do much */
UNREFERENCED_PARAMETER(hDll);
UNREFERENCED_PARAMETER(dwReason);
UNREFERENCED_PARAMETER(lpReserved);
return TRUE; return TRUE;
} }

View file

@ -94,7 +94,7 @@ CsrInitializeProcesses(VOID)
/* Set up the minimal information for it */ /* Set up the minimal information for it */
InitializeListHead(&CsrRootProcess->ListLink); InitializeListHead(&CsrRootProcess->ListLink);
CsrRootProcess->ProcessHandle = (HANDLE)-1; CsrRootProcess->ProcessHandle = (HANDLE)-1;
CsrRootProcess->ClientId = NtCurrentTeb()->Cid; CsrRootProcess->ClientId = NtCurrentTeb()->ClientId;
/* Initialize the Thread Hash List */ /* Initialize the Thread Hash List */
for (i = 0; i < 256; i++) InitializeListHead(&CsrThreadHashTable[i]); for (i = 0; i < 256; i++) InitializeListHead(&CsrThreadHashTable[i]);

View file

@ -598,9 +598,10 @@ CsrSetCallingSpooler(ULONG Reserved)
* @remarks None. * @remarks None.
* *
*--*/ *--*/
_SEH_FILTER(CsrUnhandledExceptionFilter) LONG
NTAPI
CsrUnhandledExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo)
{ {
struct _EXCEPTION_POINTERS *ExceptionInfo = _SEH_GetExceptionPointers();
SYSTEM_KERNEL_DEBUGGER_INFORMATION DebuggerInfo; SYSTEM_KERNEL_DEBUGGER_INFORMATION DebuggerInfo;
EXCEPTION_DISPOSITION Result = EXCEPTION_EXECUTE_HANDLER; EXCEPTION_DISPOSITION Result = EXCEPTION_EXECUTE_HANDLER;
BOOLEAN OldValue; BOOLEAN OldValue;

View file

@ -8,13 +8,12 @@
#include <windows.h> #include <windows.h>
#include <winnt.h> #include <winnt.h>
#include <ndk/ntndk.h> #include <ndk/ntndk.h>
#include <helper.h>
/* CSR Header */ /* CSR Header */
#include <csr/server.h> #include <csr/server.h>
/* PSEH for SEH Support */ /* PSEH for SEH Support */
#include <pseh/pseh.h> #include <pseh/pseh2.h>
/* DEFINES *******************************************************************/ /* DEFINES *******************************************************************/
@ -51,6 +50,9 @@
#define CSR_PORT_NAME L"ApiPort" #define CSR_PORT_NAME L"ApiPort"
#define UNICODE_PATH_SEP L"\\" #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 **********************************************************************/ /* DATA **********************************************************************/
extern ULONG CsrTotalPerProcessDataLength; extern ULONG CsrTotalPerProcessDataLength;
@ -345,7 +347,11 @@ CsrDestroyProcess(
IN NTSTATUS ExitStatus IN NTSTATUS ExitStatus
); );
_SEH_FILTER(CsrUnhandledExceptionFilter); LONG
NTAPI
CsrUnhandledExceptionFilter(
IN PEXCEPTION_POINTERS ExceptionInfo
);
VOID VOID
NTAPI NTAPI

View file

@ -68,6 +68,9 @@ _main(int argc,
KPRIORITY BasePriority = (8 + 1) + 4; KPRIORITY BasePriority = (8 + 1) + 4;
NTSTATUS Status; NTSTATUS Status;
ULONG Response; ULONG Response;
UNREFERENCED_PARAMETER(envp);
UNREFERENCED_PARAMETER(DebugFlag);
/* Set the Priority */ /* Set the Priority */
NtSetInformationProcess(NtCurrentProcess(), NtSetInformationProcess(NtCurrentProcess(),