- 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
#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

View file

@ -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 */

View file

@ -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)

View file

@ -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;
}

View file

@ -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]);

View file

@ -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;

View file

@ -8,13 +8,12 @@
#include <windows.h>
#include <winnt.h>
#include <ndk/ntndk.h>
#include <helper.h>
/* CSR Header */
#include <csr/server.h>
/* PSEH for SEH Support */
#include <pseh/pseh.h>
#include <pseh/pseh2.h>
/* 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

View file

@ -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(),