mirror of
https://github.com/reactos/reactos.git
synced 2025-05-01 19:50:36 +00:00
[NTDLL]
- Fix a variable and a header names. [CSR] - Move all the interesting code from the "old" csrsrv (see r57579) to the new one. TODO: finish to reorganize the code. - Rename the headers to a standard naming I will use for the other server dlls. - Remove now unneeded files. (one can sometimes find commented names next to declaration of variables: it is when a variable name doesn't satisfy me because it isn't enough self-explaining for my taste). [CONSOLE] - Add a new header for console working (win32csr --> consrv.dll == the console part of winsrv.dll I separate from it, because I plan a profound reworking on the console after all that). svn path=/branches/ros-csrss/; revision=57591
This commit is contained in:
parent
6144173cdf
commit
a195c2bcb5
25 changed files with 2371 additions and 1494 deletions
|
@ -433,7 +433,7 @@ CsrClientConnectToServer(PWSTR ObjectDirectory,
|
||||||
/* Call CSR */
|
/* Call CSR */
|
||||||
Status = CsrClientCallServer(&ApiMessage,
|
Status = CsrClientCallServer(&ApiMessage,
|
||||||
CaptureBuffer,
|
CaptureBuffer,
|
||||||
CSR_CREATE_API_NUMBER(CSR_SRV_DLL, CsrpClientConnect),
|
CSR_CREATE_API_NUMBER(CSRSRV_SERVERDLL_INDEX, CsrpClientConnect),
|
||||||
sizeof(CSR_CLIENT_CONNECT));
|
sizeof(CSR_CLIENT_CONNECT));
|
||||||
/*
|
/*
|
||||||
Status = CsrClientCallServer(&ApiMessage,
|
Status = CsrClientCallServer(&ApiMessage,
|
||||||
|
|
|
@ -42,8 +42,7 @@
|
||||||
#include "ntdllp.h"
|
#include "ntdllp.h"
|
||||||
|
|
||||||
/* CSRSS Header */
|
/* CSRSS Header */
|
||||||
#include <csrss/client.h>
|
#include <csr/csrcl.h>
|
||||||
#include <csrss/csrss.h> // FIXME: data header.
|
|
||||||
|
|
||||||
/* PSEH */
|
/* PSEH */
|
||||||
#include <pseh/pseh2.h>
|
#include <pseh/pseh2.h>
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
* Hermes Belusca-Maito (hermes.belusca@sfr.fr)
|
* Hermes Belusca-Maito (hermes.belusca@sfr.fr)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _CSRCLIENT_H
|
#ifndef _CSRCL_H
|
||||||
#define _CSRCLIENT_H
|
#define _CSRCL_H
|
||||||
|
|
||||||
#include "msg.h"
|
#include "csrmsg.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
|
@ -59,13 +59,6 @@ CsrCaptureMessageBuffer(IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer,
|
||||||
IN ULONG StringLength,
|
IN ULONG StringLength,
|
||||||
OUT PVOID* CapturedData);
|
OUT PVOID* CapturedData);
|
||||||
|
|
||||||
BOOLEAN
|
|
||||||
NTAPI
|
|
||||||
CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage,
|
|
||||||
IN PVOID* Buffer,
|
|
||||||
IN ULONG ArgumentSize,
|
|
||||||
IN ULONG ArgumentCount);
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrProbeForRead(IN PVOID Address,
|
CsrProbeForRead(IN PVOID Address,
|
144
include/reactos/subsys/csr/csrmsg.h
Normal file
144
include/reactos/subsys/csr/csrmsg.h
Normal file
|
@ -0,0 +1,144 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS Native Headers
|
||||||
|
* FILE: include/subsys/csrss/msg.h
|
||||||
|
* PURPOSE: Public Definitions for communication
|
||||||
|
* between CSR Clients and Servers.
|
||||||
|
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
|
||||||
|
* Hermes Belusca-Maito (hermes.belusca@sfr.fr)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CSRMSG_H
|
||||||
|
#define _CSRMSG_H
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
#define CSR_PORT_NAME L"ApiPort" // CSR_API_PORT_NAME
|
||||||
|
|
||||||
|
|
||||||
|
#define CSRSRV_SERVERDLL_INDEX 0
|
||||||
|
#define CSRSRV_FIRST_API_NUMBER 0
|
||||||
|
|
||||||
|
typedef enum _CSRSRV_API_NUMBER
|
||||||
|
{
|
||||||
|
CsrpClientConnect = CSRSRV_FIRST_API_NUMBER,
|
||||||
|
CsrpThreadConnect,
|
||||||
|
CsrpProfileControl,
|
||||||
|
CsrpIdentifyAlertable,
|
||||||
|
CsrpSetPriorityClass,
|
||||||
|
|
||||||
|
CsrpMaxApiNumber
|
||||||
|
} CSRSRV_API_NUMBER, *PCSRSRV_API_NUMBER;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
typedef union _CSR_API_NUMBER
|
||||||
|
{
|
||||||
|
WORD Index;
|
||||||
|
WORD Subsystem;
|
||||||
|
} CSR_API_NUMBER, *PCSR_API_NUMBER;
|
||||||
|
*/
|
||||||
|
typedef ULONG CSR_API_NUMBER;
|
||||||
|
|
||||||
|
#define CSR_CREATE_API_NUMBER(ServerId, ApiId) \
|
||||||
|
(CSR_API_NUMBER)(((ServerId) << 16) | (ApiId))
|
||||||
|
|
||||||
|
#define CSR_API_NUMBER_TO_SERVER_ID(ApiNumber) \
|
||||||
|
(ULONG)((ULONG)(ApiNumber) >> 16)
|
||||||
|
|
||||||
|
#define CSR_API_NUMBER_TO_API_ID(ApiNumber) \
|
||||||
|
(ULONG)((ULONG)(ApiNumber) & 0xFFFF)
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _CSR_CONNECTION_INFO
|
||||||
|
{
|
||||||
|
ULONG Version;
|
||||||
|
ULONG Unknown;
|
||||||
|
HANDLE ObjectDirectory;
|
||||||
|
PVOID SharedSectionBase;
|
||||||
|
PVOID SharedSectionHeap;
|
||||||
|
PVOID SharedSectionData;
|
||||||
|
ULONG DebugFlags;
|
||||||
|
ULONG Unknown2[3];
|
||||||
|
HANDLE ProcessId;
|
||||||
|
} CSR_CONNECTION_INFO, *PCSR_CONNECTION_INFO;
|
||||||
|
|
||||||
|
typedef struct _CSR_IDENTIFY_ALTERTABLE_THREAD
|
||||||
|
{
|
||||||
|
CLIENT_ID Cid;
|
||||||
|
} CSR_IDENTIFY_ALTERTABLE_THREAD, *PCSR_IDENTIFY_ALTERTABLE_THREAD;
|
||||||
|
|
||||||
|
typedef struct _CSR_SET_PRIORITY_CLASS
|
||||||
|
{
|
||||||
|
HANDLE hProcess;
|
||||||
|
ULONG PriorityClass;
|
||||||
|
} CSR_SET_PRIORITY_CLASS, *PCSR_SET_PRIORITY_CLASS;
|
||||||
|
|
||||||
|
typedef struct _CSR_CLIENT_CONNECT
|
||||||
|
{
|
||||||
|
ULONG ServerId;
|
||||||
|
PVOID ConnectionInfo;
|
||||||
|
ULONG ConnectionInfoSize;
|
||||||
|
} CSR_CLIENT_CONNECT, *PCSR_CLIENT_CONNECT;
|
||||||
|
|
||||||
|
typedef struct _CSR_CAPTURE_BUFFER
|
||||||
|
{
|
||||||
|
ULONG Size;
|
||||||
|
struct _CSR_CAPTURE_BUFFER *PreviousCaptureBuffer;
|
||||||
|
ULONG PointerCount;
|
||||||
|
ULONG_PTR BufferEnd;
|
||||||
|
ULONG_PTR PointerArray[1]; // MessagePointerOffsets // Offsets within CSR_API_MSG of pointers
|
||||||
|
} CSR_CAPTURE_BUFFER, *PCSR_CAPTURE_BUFFER;
|
||||||
|
|
||||||
|
|
||||||
|
#include "csrss.h" // remove it when the data structures are not used anymore.
|
||||||
|
|
||||||
|
/* Keep in sync with definition below. */
|
||||||
|
// #define CSRSS_HEADER_SIZE (sizeof(PORT_MESSAGE) + sizeof(ULONG) + sizeof(NTSTATUS))
|
||||||
|
|
||||||
|
typedef struct _CSR_API_MESSAGE
|
||||||
|
{
|
||||||
|
PORT_MESSAGE Header;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
CSR_CONNECTION_INFO ConnectionInfo; // Uniquely used in csrss/csrsrv for internal signaling (opening a new connection).
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
PCSR_CAPTURE_BUFFER CsrCaptureData;
|
||||||
|
CSR_API_NUMBER ApiNumber;
|
||||||
|
ULONG Status; // ReturnValue; // NTSTATUS Status
|
||||||
|
ULONG Reserved;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
CSR_CLIENT_CONNECT CsrClientConnect;
|
||||||
|
|
||||||
|
CSR_SET_PRIORITY_CLASS SetPriorityClass;
|
||||||
|
CSR_IDENTIFY_ALTERTABLE_THREAD IdentifyAlertableThread;
|
||||||
|
|
||||||
|
// ULONG_PTR ApiMessageData[39]; //// what to do ????
|
||||||
|
|
||||||
|
/*** Temporary ***/
|
||||||
|
#if 1
|
||||||
|
CSRSS_REGISTER_SERVICES_PROCESS RegisterServicesProcessRequest;
|
||||||
|
CSRSS_EXIT_REACTOS ExitReactosRequest;
|
||||||
|
CSRSS_CLOSE_HANDLE CloseHandleRequest;
|
||||||
|
CSRSS_VERIFY_HANDLE VerifyHandleRequest;
|
||||||
|
CSRSS_DUPLICATE_HANDLE DuplicateHandleRequest;
|
||||||
|
|
||||||
|
CSRSS_CREATE_DESKTOP CreateDesktopRequest;
|
||||||
|
CSRSS_SHOW_DESKTOP ShowDesktopRequest;
|
||||||
|
CSRSS_HIDE_DESKTOP HideDesktopRequest;
|
||||||
|
CSRSS_SET_LOGON_NOTIFY_WINDOW SetLogonNotifyWindowRequest;
|
||||||
|
CSRSS_REGISTER_LOGON_PROCESS RegisterLogonProcessRequest;
|
||||||
|
CSRSS_GET_INPUT_WAIT_HANDLE GetConsoleInputWaitHandle;
|
||||||
|
CSRSS_GET_PROCESS_LIST GetProcessListRequest;
|
||||||
|
#endif
|
||||||
|
/*****************/
|
||||||
|
} Data;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} CSR_API_MESSAGE, *PCSR_API_MESSAGE;
|
||||||
|
|
||||||
|
#endif // _CSRMSG_H
|
||||||
|
|
||||||
|
/* EOF */
|
|
@ -1,20 +1,24 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS Native Headers
|
* PROJECT: ReactOS Native Headers
|
||||||
* FILE: include/subsys/csrss/server.h
|
* FILE: include/subsys/csrss/csrsrv.h
|
||||||
* PURPOSE: Public Definitions for CSR Servers
|
* PURPOSE: Public Definitions for CSR Servers
|
||||||
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
|
||||||
* Hermes Belusca-Maito (hermes.belusca@sfr.fr)
|
* Hermes Belusca-Maito (hermes.belusca@sfr.fr)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _CSRSERVER_H
|
#ifndef _CSRSRV_H
|
||||||
#define _CSRSERVER_H
|
#define _CSRSRV_H
|
||||||
|
|
||||||
|
// see http://code.google.com/p/ontl/source/browse/branches/x64/ntl/nt/csr.hxx?r=67
|
||||||
|
|
||||||
|
/*
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning (disable:4201)
|
#pragma warning (disable:4201)
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
#include "msg.h"
|
#include "csrmsg.h"
|
||||||
|
|
||||||
/* TYPES **********************************************************************/
|
/* TYPES **********************************************************************/
|
||||||
|
|
||||||
|
@ -64,7 +68,7 @@ typedef struct _CSR_PROCESS
|
||||||
ULONG Reserved;
|
ULONG Reserved;
|
||||||
ULONG ShutdownLevel;
|
ULONG ShutdownLevel;
|
||||||
ULONG ShutdownFlags;
|
ULONG ShutdownFlags;
|
||||||
// PVOID ServerData[ANYSIZE_ARRAY];
|
PVOID ServerData[ANYSIZE_ARRAY]; // ServerDllPerProcessData // One structure per CSR server.
|
||||||
CSRSS_CON_PROCESS_DATA; //// FIXME: Remove it after we activate the previous member.
|
CSRSS_CON_PROCESS_DATA; //// FIXME: Remove it after we activate the previous member.
|
||||||
} CSR_PROCESS, *PCSR_PROCESS;
|
} CSR_PROCESS, *PCSR_PROCESS;
|
||||||
|
|
||||||
|
@ -172,9 +176,10 @@ NTSTATUS
|
||||||
OUT PULONG Reply
|
OUT PULONG Reply
|
||||||
);
|
);
|
||||||
|
|
||||||
#define CSR_API(n) NTSTATUS NTAPI n ( \
|
#define CSR_API(n) NTSTATUS NTAPI n( \
|
||||||
IN OUT PCSR_API_MESSAGE ApiMessage, \
|
IN OUT PCSR_API_MESSAGE ApiMessage, \
|
||||||
OUT PULONG Reply)
|
OUT PULONG Reply)
|
||||||
|
// IN OUT PCSR_REPLY_STATUS ReplyStatus)
|
||||||
|
|
||||||
typedef
|
typedef
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -218,8 +223,8 @@ typedef struct _CSR_SERVER_DLL
|
||||||
HANDLE ServerHandle;
|
HANDLE ServerHandle;
|
||||||
ULONG ServerId;
|
ULONG ServerId;
|
||||||
ULONG Unknown;
|
ULONG Unknown;
|
||||||
ULONG ApiBase;
|
ULONG ApiBase; // ApiNumberBase
|
||||||
ULONG HighestApiSupported;
|
ULONG HighestApiSupported; // MaxApiNumber
|
||||||
PCSR_API_ROUTINE *DispatchTable;
|
PCSR_API_ROUTINE *DispatchTable;
|
||||||
PBOOLEAN ValidTable;
|
PBOOLEAN ValidTable;
|
||||||
PCHAR *NameTable;
|
PCHAR *NameTable;
|
||||||
|
@ -227,7 +232,7 @@ typedef struct _CSR_SERVER_DLL
|
||||||
PCSR_CONNECT_CALLBACK ConnectCallback;
|
PCSR_CONNECT_CALLBACK ConnectCallback;
|
||||||
PCSR_DISCONNECT_CALLBACK DisconnectCallback;
|
PCSR_DISCONNECT_CALLBACK DisconnectCallback;
|
||||||
PCSR_HARDERROR_CALLBACK HardErrorCallback;
|
PCSR_HARDERROR_CALLBACK HardErrorCallback;
|
||||||
PVOID SharedSection;
|
PVOID SharedSection; // SharedStaticServerData
|
||||||
PCSR_NEWPROCESS_CALLBACK NewProcessCallback;
|
PCSR_NEWPROCESS_CALLBACK NewProcessCallback;
|
||||||
PCSR_SHUTDOWNPROCESS_CALLBACK ShutdownProcessCallback;
|
PCSR_SHUTDOWNPROCESS_CALLBACK ShutdownProcessCallback;
|
||||||
ULONG Unknown2[3];
|
ULONG Unknown2[3];
|
||||||
|
@ -240,51 +245,150 @@ typedef
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
(NTAPI *PCSR_SERVER_DLL_INIT_CALLBACK)(IN PCSR_SERVER_DLL LoadedServerDll);
|
(NTAPI *PCSR_SERVER_DLL_INIT_CALLBACK)(IN PCSR_SERVER_DLL LoadedServerDll);
|
||||||
|
|
||||||
/*
|
#define CSR_SERVER_DLL_INIT(n) NTSTATUS NTAPI n(IN PCSR_SERVER_DLL LoadedServerDll)
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
CsrServerDllInitialization(IN PCSR_SERVER_DLL LoadedServerDll);
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* PROTOTYPES ****************************************************************/
|
/* PROTOTYPES ****************************************************************/
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
CsrServerInitialization(
|
|
||||||
IN ULONG ArgumentCount,
|
|
||||||
IN PCHAR Arguments[]
|
|
||||||
);
|
|
||||||
|
|
||||||
///////////
|
///////////
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrCaptureArguments(
|
CsrCaptureArguments(IN PCSR_THREAD CsrThread,
|
||||||
IN PCSR_THREAD CsrThread,
|
IN PCSR_API_MESSAGE ApiMessage);
|
||||||
IN PCSR_API_MESSAGE ApiMessage
|
|
||||||
);
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrReleaseCapturedArguments(IN PCSR_API_MESSAGE ApiMessage);
|
CsrReleaseCapturedArguments(IN PCSR_API_MESSAGE ApiMessage);
|
||||||
//////////
|
//////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
CsrServerInitialization(IN ULONG ArgumentCount,
|
||||||
|
IN PCHAR Arguments[]);
|
||||||
|
|
||||||
PCSR_THREAD
|
PCSR_THREAD
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrAddStaticServerThread(
|
CsrAddStaticServerThread(IN HANDLE hThread,
|
||||||
IN HANDLE hThread,
|
IN PCLIENT_ID ClientId,
|
||||||
IN PCLIENT_ID ClientId,
|
IN ULONG ThreadFlags);
|
||||||
IN ULONG ThreadFlags
|
|
||||||
);
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
CsrCallServerFromServer(IN PCSR_API_MESSAGE ReceiveMsg,
|
||||||
|
IN OUT PCSR_API_MESSAGE ReplyMsg);
|
||||||
|
|
||||||
PCSR_THREAD
|
PCSR_THREAD
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrConnectToUser(VOID);
|
CsrConnectToUser(VOID);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
CsrCreateProcess(IN HANDLE hProcess,
|
||||||
|
IN HANDLE hThread,
|
||||||
|
IN PCLIENT_ID ClientId,
|
||||||
|
IN PCSR_NT_SESSION NtSession,
|
||||||
|
IN ULONG Flags,
|
||||||
|
IN PCLIENT_ID DebugCid);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
CsrCreateRemoteThread(IN HANDLE hThread,
|
||||||
|
IN PCLIENT_ID ClientId);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
CsrCreateThread(IN PCSR_PROCESS CsrProcess,
|
||||||
|
IN HANDLE hThread,
|
||||||
|
IN PCLIENT_ID ClientId);
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
CsrCreateWait(IN PLIST_ENTRY WaitList,
|
||||||
|
IN CSR_WAIT_FUNCTION WaitFunction,
|
||||||
|
IN PCSR_THREAD CsrWaitThread,
|
||||||
|
IN OUT PCSR_API_MESSAGE WaitApiMessage,
|
||||||
|
IN PVOID WaitContext,
|
||||||
|
IN PLIST_ENTRY UserWaitList OPTIONAL);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
CsrDebugProcess(IN PCSR_PROCESS CsrProcess);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
CsrDebugProcessStop(IN PCSR_PROCESS CsrProcess);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
CsrDereferenceProcess(IN PCSR_PROCESS CsrProcess);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
CsrDereferenceThread(IN PCSR_THREAD CsrThread);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
CsrDereferenceWait(IN PLIST_ENTRY WaitList);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
CsrDestroyProcess(IN PCLIENT_ID Cid,
|
||||||
|
IN NTSTATUS ExitStatus);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
CsrDestroyThread(IN PCLIENT_ID Cid);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
CsrExecServerThread(IN PVOID ThreadHandler,
|
||||||
|
IN ULONG Flags);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
CsrGetProcessLuid(IN HANDLE hProcess OPTIONAL,
|
||||||
|
OUT PLUID Luid);
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrImpersonateClient(IN PCSR_THREAD CsrThread);
|
CsrImpersonateClient(IN PCSR_THREAD CsrThread);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
CsrLockProcessByClientId(IN HANDLE Pid,
|
||||||
|
OUT PCSR_PROCESS *CsrProcess OPTIONAL);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
CsrLockThreadByClientId(IN HANDLE Tid,
|
||||||
|
OUT PCSR_THREAD *CsrThread);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
CsrMoveSatisfiedWait(IN PLIST_ENTRY NewEntry,
|
||||||
|
IN PLIST_ENTRY WaitList);
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
CsrNotifyWait(IN PLIST_ENTRY WaitList,
|
||||||
|
IN ULONG WaitType,
|
||||||
|
IN PVOID WaitArgument1,
|
||||||
|
IN PVOID WaitArgument2);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
CsrPopulateDosDevices(VOID);
|
||||||
|
|
||||||
|
HANDLE
|
||||||
|
NTAPI
|
||||||
|
CsrQueryApiPort(VOID);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
CsrReferenceThread(IN PCSR_THREAD CsrThread);
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrRevertToSelf(VOID);
|
CsrRevertToSelf(VOID);
|
||||||
|
@ -293,17 +397,48 @@ VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrSetBackgroundPriority(IN PCSR_PROCESS CsrProcess);
|
CsrSetBackgroundPriority(IN PCSR_PROCESS CsrProcess);
|
||||||
|
|
||||||
LONG
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrUnhandledExceptionFilter(
|
CsrSetCallingSpooler(ULONG Reserved);
|
||||||
IN PEXCEPTION_POINTERS ExceptionInfo
|
|
||||||
);
|
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
CsrSetForegroundPriority(IN PCSR_PROCESS CsrProcess);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
CsrShutdownProcesses(IN PLUID CallerLuid,
|
||||||
|
IN ULONG Flags);
|
||||||
|
|
||||||
|
EXCEPTION_DISPOSITION
|
||||||
|
NTAPI
|
||||||
|
CsrUnhandledExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
CsrUnlockProcess(IN PCSR_PROCESS CsrProcess);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
CsrUnlockThread(IN PCSR_THREAD CsrThread);
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage,
|
||||||
|
IN PVOID *Buffer,
|
||||||
|
IN ULONG ArgumentSize,
|
||||||
|
IN ULONG ArgumentCount);
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
CsrValidateMessageString(IN PCSR_API_MESSAGE ApiMessage,
|
||||||
|
IN LPWSTR *MessageString);
|
||||||
|
|
||||||
|
/*
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
#endif // _CSRSERVER_H
|
#endif // _CSRSERVER_H
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#define CONSOLE_OUTPUT_MODE_VALID (0x03)
|
#define CONSOLE_OUTPUT_MODE_VALID (0x03)
|
||||||
|
|
||||||
|
|
||||||
#define CSR_CSRSS_SECTION_SIZE (65536)
|
#define CSR_CSRSS_SECTION_SIZE (65536)
|
||||||
|
|
||||||
typedef VOID (CALLBACK *PCONTROLDISPATCHER)(DWORD);
|
typedef VOID (CALLBACK *PCONTROLDISPATCHER)(DWORD);
|
||||||
|
|
|
@ -1,219 +0,0 @@
|
||||||
/*
|
|
||||||
* PROJECT: ReactOS Native Headers
|
|
||||||
* FILE: include/subsys/csrss/msg.h
|
|
||||||
* PURPOSE: Public Definitions for communication
|
|
||||||
* between CSR Clients and Servers.
|
|
||||||
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
|
|
||||||
* Hermes Belusca-Maito (hermes.belusca@sfr.fr)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _CSRMSG_H
|
|
||||||
#define _CSRMSG_H
|
|
||||||
|
|
||||||
typedef struct _CSR_CONNECTION_INFO
|
|
||||||
{
|
|
||||||
ULONG Version;
|
|
||||||
ULONG Unknown;
|
|
||||||
HANDLE ObjectDirectory;
|
|
||||||
PVOID SharedSectionBase;
|
|
||||||
PVOID SharedSectionHeap;
|
|
||||||
PVOID SharedSectionData;
|
|
||||||
ULONG DebugFlags;
|
|
||||||
ULONG Unknown2[3];
|
|
||||||
HANDLE ProcessId;
|
|
||||||
} CSR_CONNECTION_INFO, *PCSR_CONNECTION_INFO;
|
|
||||||
|
|
||||||
typedef struct _CSR_IDENTIFY_ALTERTABLE_THREAD
|
|
||||||
{
|
|
||||||
CLIENT_ID Cid;
|
|
||||||
} CSR_IDENTIFY_ALTERTABLE_THREAD, *PCSR_IDENTIFY_ALTERTABLE_THREAD;
|
|
||||||
|
|
||||||
typedef struct _CSR_SET_PRIORITY_CLASS
|
|
||||||
{
|
|
||||||
HANDLE hProcess;
|
|
||||||
ULONG PriorityClass;
|
|
||||||
} CSR_SET_PRIORITY_CLASS, *PCSR_SET_PRIORITY_CLASS;
|
|
||||||
|
|
||||||
typedef struct _CSR_CLIENT_CONNECT
|
|
||||||
{
|
|
||||||
ULONG ServerId;
|
|
||||||
PVOID ConnectionInfo;
|
|
||||||
ULONG ConnectionInfoSize;
|
|
||||||
} CSR_CLIENT_CONNECT, *PCSR_CLIENT_CONNECT;
|
|
||||||
|
|
||||||
typedef struct _CSR_CAPTURE_BUFFER
|
|
||||||
{
|
|
||||||
ULONG Size;
|
|
||||||
struct _CSR_CAPTURE_BUFFER *PreviousCaptureBuffer;
|
|
||||||
ULONG PointerCount;
|
|
||||||
ULONG_PTR BufferEnd;
|
|
||||||
ULONG_PTR PointerArray[1];
|
|
||||||
} CSR_CAPTURE_BUFFER, *PCSR_CAPTURE_BUFFER;
|
|
||||||
|
|
||||||
/*
|
|
||||||
typedef union _CSR_API_NUMBER
|
|
||||||
{
|
|
||||||
WORD Index;
|
|
||||||
WORD Subsystem;
|
|
||||||
} CSR_API_NUMBER, *PCSR_API_NUMBER;
|
|
||||||
*/
|
|
||||||
typedef ULONG CSR_API_NUMBER;
|
|
||||||
|
|
||||||
#include "csrss.h" // remove it when the data structures are not used anymore.
|
|
||||||
|
|
||||||
/* Keep in sync with definition below. */
|
|
||||||
// #define CSRSS_HEADER_SIZE (sizeof(PORT_MESSAGE) + sizeof(ULONG) + sizeof(NTSTATUS))
|
|
||||||
|
|
||||||
typedef struct _CSR_API_MESSAGE
|
|
||||||
{
|
|
||||||
PORT_MESSAGE Header;
|
|
||||||
union
|
|
||||||
{
|
|
||||||
CSR_CONNECTION_INFO ConnectionInfo;
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
PCSR_CAPTURE_BUFFER CsrCaptureData;
|
|
||||||
CSR_API_NUMBER ApiNumber;
|
|
||||||
ULONG Status;
|
|
||||||
ULONG Reserved;
|
|
||||||
union
|
|
||||||
{
|
|
||||||
CSR_CLIENT_CONNECT CsrClientConnect;
|
|
||||||
|
|
||||||
CSR_SET_PRIORITY_CLASS SetPriorityClass;
|
|
||||||
CSR_IDENTIFY_ALTERTABLE_THREAD IdentifyAlertableThread;
|
|
||||||
|
|
||||||
/*** Temporary ***/
|
|
||||||
#if 1
|
|
||||||
CSRSS_CREATE_PROCESS CreateProcessRequest;
|
|
||||||
CSRSS_CREATE_THREAD CreateThreadRequest;
|
|
||||||
CSRSS_TERMINATE_PROCESS TerminateProcessRequest;
|
|
||||||
CSRSS_CONNECT_PROCESS ConnectRequest;
|
|
||||||
CSRSS_WRITE_CONSOLE WriteConsoleRequest;
|
|
||||||
CSRSS_READ_CONSOLE ReadConsoleRequest;
|
|
||||||
CSRSS_ALLOC_CONSOLE AllocConsoleRequest;
|
|
||||||
CSRSS_SCREEN_BUFFER_INFO ScreenBufferInfoRequest;
|
|
||||||
CSRSS_SET_CURSOR SetCursorRequest;
|
|
||||||
CSRSS_FILL_OUTPUT FillOutputRequest;
|
|
||||||
CSRSS_READ_INPUT ReadInputRequest;
|
|
||||||
CSRSS_WRITE_CONSOLE_OUTPUT_CHAR WriteConsoleOutputCharRequest;
|
|
||||||
CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB WriteConsoleOutputAttribRequest;
|
|
||||||
CSRSS_FILL_OUTPUT_ATTRIB FillOutputAttribRequest;
|
|
||||||
CSRSS_SET_CURSOR_INFO SetCursorInfoRequest;
|
|
||||||
CSRSS_GET_CURSOR_INFO GetCursorInfoRequest;
|
|
||||||
CSRSS_SET_ATTRIB SetAttribRequest;
|
|
||||||
CSRSS_SET_CONSOLE_MODE SetConsoleModeRequest;
|
|
||||||
CSRSS_GET_CONSOLE_MODE GetConsoleModeRequest;
|
|
||||||
CSRSS_CREATE_SCREEN_BUFFER CreateScreenBufferRequest;
|
|
||||||
CSRSS_SET_SCREEN_BUFFER SetScreenBufferRequest;
|
|
||||||
CSRSS_SET_TITLE SetTitleRequest;
|
|
||||||
CSRSS_GET_TITLE GetTitleRequest;
|
|
||||||
CSRSS_WRITE_CONSOLE_OUTPUT WriteConsoleOutputRequest;
|
|
||||||
CSRSS_FLUSH_INPUT_BUFFER FlushInputBufferRequest;
|
|
||||||
CSRSS_SCROLL_CONSOLE_SCREEN_BUFFER ScrollConsoleScreenBufferRequest;
|
|
||||||
CSRSS_READ_CONSOLE_OUTPUT_CHAR ReadConsoleOutputCharRequest;
|
|
||||||
CSRSS_READ_CONSOLE_OUTPUT_ATTRIB ReadConsoleOutputAttribRequest;
|
|
||||||
CSRSS_GET_NUM_INPUT_EVENTS GetNumInputEventsRequest;
|
|
||||||
CSRSS_REGISTER_SERVICES_PROCESS RegisterServicesProcessRequest;
|
|
||||||
CSRSS_EXIT_REACTOS ExitReactosRequest;
|
|
||||||
CSRSS_SET_SHUTDOWN_PARAMETERS SetShutdownParametersRequest;
|
|
||||||
CSRSS_GET_SHUTDOWN_PARAMETERS GetShutdownParametersRequest;
|
|
||||||
CSRSS_PEEK_CONSOLE_INPUT PeekConsoleInputRequest;
|
|
||||||
CSRSS_READ_CONSOLE_OUTPUT ReadConsoleOutputRequest;
|
|
||||||
CSRSS_WRITE_CONSOLE_INPUT WriteConsoleInputRequest;
|
|
||||||
CSRSS_GET_INPUT_HANDLE GetInputHandleRequest;
|
|
||||||
CSRSS_GET_OUTPUT_HANDLE GetOutputHandleRequest;
|
|
||||||
CSRSS_CLOSE_HANDLE CloseHandleRequest;
|
|
||||||
CSRSS_VERIFY_HANDLE VerifyHandleRequest;
|
|
||||||
CSRSS_DUPLICATE_HANDLE DuplicateHandleRequest;
|
|
||||||
CSRSS_SETGET_CONSOLE_HW_STATE ConsoleHardwareStateRequest;
|
|
||||||
CSRSS_GET_CONSOLE_WINDOW GetConsoleWindowRequest;
|
|
||||||
CSRSS_CREATE_DESKTOP CreateDesktopRequest;
|
|
||||||
CSRSS_SHOW_DESKTOP ShowDesktopRequest;
|
|
||||||
CSRSS_HIDE_DESKTOP HideDesktopRequest;
|
|
||||||
CSRSS_SET_CONSOLE_ICON SetConsoleIconRequest;
|
|
||||||
CSRSS_SET_LOGON_NOTIFY_WINDOW SetLogonNotifyWindowRequest;
|
|
||||||
CSRSS_REGISTER_LOGON_PROCESS RegisterLogonProcessRequest;
|
|
||||||
CSRSS_GET_CONSOLE_CP GetConsoleCodePage;
|
|
||||||
CSRSS_SET_CONSOLE_CP SetConsoleCodePage;
|
|
||||||
CSRSS_GET_CONSOLE_OUTPUT_CP GetConsoleOutputCodePage;
|
|
||||||
CSRSS_SET_CONSOLE_OUTPUT_CP SetConsoleOutputCodePage;
|
|
||||||
CSRSS_GET_INPUT_WAIT_HANDLE GetConsoleInputWaitHandle;
|
|
||||||
CSRSS_GET_PROCESS_LIST GetProcessListRequest;
|
|
||||||
CSRSS_ADD_CONSOLE_ALIAS AddConsoleAlias;
|
|
||||||
CSRSS_GET_CONSOLE_ALIAS GetConsoleAlias;
|
|
||||||
CSRSS_GET_ALL_CONSOLE_ALIASES GetAllConsoleAlias;
|
|
||||||
CSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH GetAllConsoleAliasesLength;
|
|
||||||
CSRSS_GET_CONSOLE_ALIASES_EXES GetConsoleAliasesExes;
|
|
||||||
CSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH GetConsoleAliasesExesLength;
|
|
||||||
CSRSS_GENERATE_CTRL_EVENT GenerateCtrlEvent;
|
|
||||||
CSRSS_SET_SCREEN_BUFFER_SIZE SetScreenBufferSize;
|
|
||||||
CSRSS_GET_CONSOLE_SELECTION_INFO GetConsoleSelectionInfo;
|
|
||||||
CSRSS_GET_COMMAND_HISTORY_LENGTH GetCommandHistoryLength;
|
|
||||||
CSRSS_GET_COMMAND_HISTORY GetCommandHistory;
|
|
||||||
CSRSS_EXPUNGE_COMMAND_HISTORY ExpungeCommandHistory;
|
|
||||||
CSRSS_SET_HISTORY_NUMBER_COMMANDS SetHistoryNumberCommands;
|
|
||||||
CSRSS_GET_HISTORY_INFO GetHistoryInfo;
|
|
||||||
CSRSS_SET_HISTORY_INFO SetHistoryInfo;
|
|
||||||
CSRSS_GET_TEMP_FILE GetTempFile;
|
|
||||||
CSRSS_DEFINE_DOS_DEVICE DefineDosDeviceRequest;
|
|
||||||
CSRSS_SOUND_SENTRY SoundSentryRequest;
|
|
||||||
CSRSS_UPDATE_VDM_ENTRY UpdateVdmEntry;
|
|
||||||
CSRSS_GET_VDM_EXIT_CODE GetVdmExitCode;
|
|
||||||
CSRSS_CHECK_VDM CheckVdm;
|
|
||||||
#endif
|
|
||||||
/*****************/
|
|
||||||
} Data;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
} CSR_API_MESSAGE, *PCSR_API_MESSAGE;
|
|
||||||
|
|
||||||
/*** old ***
|
|
||||||
typedef struct _CSR_API_MESSAGE
|
|
||||||
{
|
|
||||||
PORT_MESSAGE Header;
|
|
||||||
PVOID CsrCaptureData;
|
|
||||||
ULONG Type;
|
|
||||||
NTSTATUS Status;
|
|
||||||
union
|
|
||||||
{
|
|
||||||
CSRSS_CREATE_PROCESS CreateProcessRequest;
|
|
||||||
CSRSS_CREATE_THREAD CreateThreadRequest;
|
|
||||||
CSRSS_TERMINATE_PROCESS TerminateProcessRequest;
|
|
||||||
CSRSS_CONNECT_PROCESS ConnectRequest;
|
|
||||||
|
|
||||||
. . . . . . . . . . . . . . .
|
|
||||||
|
|
||||||
CSRSS_GET_VDM_EXIT_CODE GetVdmExitCode;
|
|
||||||
CSRSS_CHECK_VDM CheckVdm;
|
|
||||||
} Data;
|
|
||||||
} CSR_API_MESSAGE, *PCSR_API_MESSAGE;
|
|
||||||
|
|
||||||
***/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define CSR_PORT_NAME L"ApiPort"
|
|
||||||
|
|
||||||
/**** move these defines elsewhere ****/
|
|
||||||
|
|
||||||
#define CSR_SRV_SERVER 0
|
|
||||||
#define CSR_SERVER_DLL_MAX 4
|
|
||||||
|
|
||||||
/**************************************/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define CSR_CREATE_API_NUMBER(ServerId, ApiId) \
|
|
||||||
(CSR_API_NUMBER)(((ServerId) << 16) | (ApiId))
|
|
||||||
|
|
||||||
#define CSR_API_NUMBER_TO_SERVER_ID(ApiNumber) \
|
|
||||||
(ULONG)((ULONG)(ApiNumber) >> 16)
|
|
||||||
|
|
||||||
#define CSR_API_NUMBER_TO_API_ID(ApiNumber) \
|
|
||||||
(ULONG)((ULONG)(ApiNumber) & 0xFFFF)
|
|
||||||
|
|
||||||
#endif // _CSRMSG_H
|
|
||||||
|
|
||||||
/* EOF */
|
|
|
@ -2,18 +2,26 @@
|
||||||
* CSRSS Console management structures.
|
* CSRSS Console management structures.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __CSRCONS_H__
|
#ifndef __CONMSG_H__
|
||||||
#define __CSRCONS_H__
|
#define __CONMSG_H__
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Remove it.
|
||||||
#include <drivers/blue/ntddblue.h>
|
#include <drivers/blue/ntddblue.h>
|
||||||
|
|
||||||
|
#define CONSRV_SERVERDLL_INDEX 2
|
||||||
|
#define CONSRV_FIRST_API_NUMBER 512
|
||||||
|
|
||||||
|
/* w32 console server - move to con.h */
|
||||||
|
CSR_SERVER_DLL_INIT(ConServerDllInitialization);
|
||||||
|
|
||||||
|
// Windows NT 4 table, adapted from http://j00ru.vexillium.org/csrss_list/api_list.html#Windows_NT
|
||||||
|
// It is for testing purposes. After that I will update it to 2k3 version and add stubs.
|
||||||
|
typedef enum _CONSRV_API_NUMBER
|
||||||
|
{
|
||||||
|
BasepCreateProcess = CONSRV_FIRST_API_NUMBER,
|
||||||
|
|
||||||
#define CSRSS_MAX_WRITE_CONSOLE (LPC_MAX_DATA_LENGTH - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE))
|
|
||||||
#define CSRSS_MAX_WRITE_CONSOLE_OUTPUT_CHAR (LPC_MAX_DATA_LENGTH - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE_OUTPUT_CHAR))
|
|
||||||
#define CSRSS_MAX_WRITE_CONSOLE_OUTPUT_ATTRIB (LPC_MAX_DATA_LENGTH - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB))
|
|
||||||
#define CSRSS_MAX_READ_CONSOLE_OUTPUT_CHAR (LPC_MAX_DATA_LENGTH - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_READ_CONSOLE_OUTPUT_CHAR))
|
|
||||||
#define CSRSS_MAX_READ_CONSOLE_OUTPUT_ATTRIB (LPC_MAX_DATA_LENGTH - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_READ_CONSOLE_OUTPUT_ATTRIB))
|
|
||||||
|
|
||||||
#define WRITE_CONSOLE (0x2)
|
#define WRITE_CONSOLE (0x2)
|
||||||
#define READ_CONSOLE (0x3)
|
#define READ_CONSOLE (0x3)
|
||||||
|
@ -70,9 +78,17 @@
|
||||||
#define SET_HISTORY_INFO (0x47)
|
#define SET_HISTORY_INFO (0x47)
|
||||||
|
|
||||||
|
|
||||||
|
BasepMaxApiNumber
|
||||||
|
} CONSRV_API_NUMBER, *PCONSRV_API_NUMBER;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define CSRSS_MAX_WRITE_CONSOLE (LPC_MAX_DATA_LENGTH - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE))
|
||||||
|
#define CSRSS_MAX_WRITE_CONSOLE_OUTPUT_CHAR (LPC_MAX_DATA_LENGTH - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE_OUTPUT_CHAR))
|
||||||
|
#define CSRSS_MAX_WRITE_CONSOLE_OUTPUT_ATTRIB (LPC_MAX_DATA_LENGTH - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB))
|
||||||
|
#define CSRSS_MAX_READ_CONSOLE_OUTPUT_CHAR (LPC_MAX_DATA_LENGTH - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_READ_CONSOLE_OUTPUT_CHAR))
|
||||||
|
#define CSRSS_MAX_READ_CONSOLE_OUTPUT_ATTRIB (LPC_MAX_DATA_LENGTH - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_READ_CONSOLE_OUTPUT_ATTRIB))
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
HANDLE ConsoleHandle;
|
HANDLE ConsoleHandle;
|
||||||
|
@ -453,77 +469,72 @@ typedef struct
|
||||||
UINT CodePage;
|
UINT CodePage;
|
||||||
} CSRSS_SET_CONSOLE_OUTPUT_CP, *PCSRSS_SET_CONSOLE_OUTPUT_CP;
|
} CSRSS_SET_CONSOLE_OUTPUT_CP, *PCSRSS_SET_CONSOLE_OUTPUT_CP;
|
||||||
|
|
||||||
|
typedef struct _CONSOLE_API_MESSAGE
|
||||||
|
{
|
||||||
|
PORT_MESSAGE Header;
|
||||||
|
|
||||||
|
PCSR_CAPTURE_BUFFER CsrCaptureData;
|
||||||
|
CSR_API_NUMBER ApiNumber;
|
||||||
|
ULONG Status; // ReturnValue; // NTSTATUS Status
|
||||||
|
ULONG Reserved;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
CSRSS_WRITE_CONSOLE WriteConsoleRequest;
|
||||||
|
CSRSS_READ_CONSOLE ReadConsoleRequest;
|
||||||
|
CSRSS_ALLOC_CONSOLE AllocConsoleRequest;
|
||||||
|
CSRSS_FREE_CONSOLE FreeConsoleRequest;
|
||||||
|
CSRSS_SCREEN_BUFFER_INFO ScreenBufferInfoRequest;
|
||||||
|
CSRSS_SET_CURSOR SetCursorRequest;
|
||||||
|
CSRSS_FILL_OUTPUT FillOutputRequest;
|
||||||
|
CSRSS_FILL_OUTPUT_ATTRIB FillOutputAttribRequest;
|
||||||
|
CSRSS_READ_INPUT ReadInputRequest;
|
||||||
|
CSRSS_WRITE_CONSOLE_OUTPUT_CHAR WriteConsoleOutputCharRequest;
|
||||||
|
CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB WriteConsoleOutputAttribRequest;
|
||||||
|
CSRSS_GET_CURSOR_INFO GetCursorInfoRequest;
|
||||||
|
CSRSS_SET_CURSOR_INFO SetCursorInfoRequest;
|
||||||
|
CSRSS_SET_ATTRIB SetAttribRequest;
|
||||||
|
CSRSS_SET_CONSOLE_MODE SetConsoleModeRequest;
|
||||||
|
CSRSS_GET_CONSOLE_MODE GetConsoleModeRequest;
|
||||||
|
CSRSS_CREATE_SCREEN_BUFFER CreateScreenBufferRequest;
|
||||||
|
CSRSS_SET_SCREEN_BUFFER SetScreenBufferRequest;
|
||||||
|
CSRSS_SET_TITLE SetTitleRequest;
|
||||||
|
CSRSS_GET_TITLE GetTitleRequest;
|
||||||
|
CSRSS_WRITE_CONSOLE_OUTPUT WriteConsoleOutputRequest;
|
||||||
|
CSRSS_FLUSH_INPUT_BUFFER FlushInputBufferRequest;
|
||||||
|
CSRSS_SCROLL_CONSOLE_SCREEN_BUFFER ScrollConsoleScreenBufferRequest;
|
||||||
|
CSRSS_READ_CONSOLE_OUTPUT_CHAR ReadConsoleOutputCharRequest;
|
||||||
|
CSRSS_READ_CONSOLE_OUTPUT_ATTRIB ReadConsoleOutputAttribRequest;
|
||||||
|
CSRSS_PEEK_CONSOLE_INPUT PeekConsoleInputRequest;
|
||||||
|
CSRSS_READ_CONSOLE_OUTPUT ReadConsoleOutputRequest;
|
||||||
|
CSRSS_WRITE_CONSOLE_INPUT WriteConsoleInputRequest;
|
||||||
|
CSRSS_GET_INPUT_HANDLE GetInputHandleRequest;
|
||||||
|
CSRSS_GET_OUTPUT_HANDLE GetOutputHandleRequest;
|
||||||
|
CSRSS_SETGET_CONSOLE_HW_STATE ConsoleHardwareStateRequest;
|
||||||
|
CSRSS_GET_CONSOLE_WINDOW GetConsoleWindowRequest;
|
||||||
|
CSRSS_SET_CONSOLE_ICON SetConsoleIconRequest;
|
||||||
|
CSRSS_ADD_CONSOLE_ALIAS AddConsoleAlias;
|
||||||
|
CSRSS_GET_CONSOLE_ALIAS GetConsoleAlias;
|
||||||
|
CSRSS_GET_ALL_CONSOLE_ALIASES GetAllConsoleAlias;
|
||||||
|
CSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH GetAllConsoleAliasesLength;
|
||||||
|
CSRSS_GET_CONSOLE_ALIASES_EXES GetConsoleAliasesExes;
|
||||||
|
CSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH GetConsoleAliasesExesLength;
|
||||||
|
CSRSS_GENERATE_CTRL_EVENT GenerateCtrlEvent;
|
||||||
|
CSRSS_GET_NUM_INPUT_EVENTS GetNumInputEventsRequest;
|
||||||
|
CSRSS_SET_SCREEN_BUFFER_SIZE SetScreenBufferSize;
|
||||||
|
CSRSS_GET_CONSOLE_SELECTION_INFO GetConsoleSelectionInfo;
|
||||||
|
CSRSS_GET_COMMAND_HISTORY_LENGTH GetCommandHistoryLength;
|
||||||
|
CSRSS_GET_COMMAND_HISTORY GetCommandHistory;
|
||||||
|
CSRSS_EXPUNGE_COMMAND_HISTORY ExpungeCommandHistory;
|
||||||
|
CSRSS_SET_HISTORY_NUMBER_COMMANDS SetHistoryNumberCommands;
|
||||||
|
CSRSS_GET_HISTORY_INFO GetHistoryInfo;
|
||||||
|
CSRSS_SET_HISTORY_INFO SetHistoryInfo;
|
||||||
|
CSRSS_GET_CONSOLE_CP GetConsoleCodePage;
|
||||||
|
CSRSS_SET_CONSOLE_CP SetConsoleCodePage;
|
||||||
|
CSRSS_GET_CONSOLE_OUTPUT_CP GetConsoleOutputCodePage;
|
||||||
|
CSRSS_SET_CONSOLE_OUTPUT_CP SetConsoleOutputCodePage;
|
||||||
|
} Data;
|
||||||
|
} CONSOLE_API_MESSAGE, *PCONSOLE_API_MESSAGE;
|
||||||
|
|
||||||
|
#endif // __CONMSG_H__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
CSRSS_WRITE_CONSOLE WriteConsoleRequest;
|
|
||||||
CSRSS_READ_CONSOLE ReadConsoleRequest;
|
|
||||||
CSRSS_ALLOC_CONSOLE AllocConsoleRequest;
|
|
||||||
CSRSS_FREE_CONSOLE FreeConsoleRequest;
|
|
||||||
CSRSS_SCREEN_BUFFER_INFO ScreenBufferInfoRequest;
|
|
||||||
CSRSS_SET_CURSOR SetCursorRequest;
|
|
||||||
CSRSS_FILL_OUTPUT FillOutputRequest;
|
|
||||||
CSRSS_FILL_OUTPUT_ATTRIB FillOutputAttribRequest;
|
|
||||||
CSRSS_READ_INPUT ReadInputRequest;
|
|
||||||
CSRSS_WRITE_CONSOLE_OUTPUT_CHAR WriteConsoleOutputCharRequest;
|
|
||||||
CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB WriteConsoleOutputAttribRequest;
|
|
||||||
CSRSS_GET_CURSOR_INFO GetCursorInfoRequest;
|
|
||||||
CSRSS_SET_CURSOR_INFO SetCursorInfoRequest;
|
|
||||||
CSRSS_SET_ATTRIB SetAttribRequest;
|
|
||||||
CSRSS_SET_CONSOLE_MODE SetConsoleModeRequest;
|
|
||||||
CSRSS_GET_CONSOLE_MODE GetConsoleModeRequest;
|
|
||||||
CSRSS_CREATE_SCREEN_BUFFER CreateScreenBufferRequest;
|
|
||||||
CSRSS_SET_SCREEN_BUFFER SetScreenBufferRequest;
|
|
||||||
CSRSS_SET_TITLE SetTitleRequest;
|
|
||||||
CSRSS_GET_TITLE GetTitleRequest;
|
|
||||||
CSRSS_WRITE_CONSOLE_OUTPUT WriteConsoleOutputRequest;
|
|
||||||
CSRSS_FLUSH_INPUT_BUFFER FlushInputBufferRequest;
|
|
||||||
CSRSS_SCROLL_CONSOLE_SCREEN_BUFFER ScrollConsoleScreenBufferRequest;
|
|
||||||
CSRSS_READ_CONSOLE_OUTPUT_CHAR ReadConsoleOutputCharRequest;
|
|
||||||
CSRSS_READ_CONSOLE_OUTPUT_ATTRIB ReadConsoleOutputAttribRequest;
|
|
||||||
CSRSS_PEEK_CONSOLE_INPUT PeekConsoleInputRequest;
|
|
||||||
CSRSS_READ_CONSOLE_OUTPUT ReadConsoleOutputRequest;
|
|
||||||
CSRSS_WRITE_CONSOLE_INPUT WriteConsoleInputRequest;
|
|
||||||
CSRSS_GET_INPUT_HANDLE GetInputHandleRequest;
|
|
||||||
CSRSS_GET_OUTPUT_HANDLE GetOutputHandleRequest;
|
|
||||||
CSRSS_SETGET_CONSOLE_HW_STATE ConsoleHardwareStateRequest;
|
|
||||||
CSRSS_GET_CONSOLE_WINDOW GetConsoleWindowRequest;
|
|
||||||
CSRSS_SET_CONSOLE_ICON SetConsoleIconRequest;
|
|
||||||
CSRSS_ADD_CONSOLE_ALIAS AddConsoleAlias;
|
|
||||||
CSRSS_GET_CONSOLE_ALIAS GetConsoleAlias;
|
|
||||||
CSRSS_GET_ALL_CONSOLE_ALIASES GetAllConsoleAlias;
|
|
||||||
CSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH GetAllConsoleAliasesLength;
|
|
||||||
CSRSS_GET_CONSOLE_ALIASES_EXES GetConsoleAliasesExes;
|
|
||||||
CSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH GetConsoleAliasesExesLength;
|
|
||||||
CSRSS_GENERATE_CTRL_EVENT GenerateCtrlEvent;
|
|
||||||
CSRSS_GET_NUM_INPUT_EVENTS GetNumInputEventsRequest;
|
|
||||||
CSRSS_SET_SCREEN_BUFFER_SIZE SetScreenBufferSize;
|
|
||||||
CSRSS_GET_CONSOLE_SELECTION_INFO GetConsoleSelectionInfo;
|
|
||||||
CSRSS_GET_COMMAND_HISTORY_LENGTH GetCommandHistoryLength;
|
|
||||||
CSRSS_GET_COMMAND_HISTORY GetCommandHistory;
|
|
||||||
CSRSS_EXPUNGE_COMMAND_HISTORY ExpungeCommandHistory;
|
|
||||||
CSRSS_SET_HISTORY_NUMBER_COMMANDS SetHistoryNumberCommands;
|
|
||||||
CSRSS_GET_HISTORY_INFO GetHistoryInfo;
|
|
||||||
CSRSS_SET_HISTORY_INFO SetHistoryInfo;
|
|
||||||
CSRSS_GET_CONSOLE_CP GetConsoleCodePage;
|
|
||||||
CSRSS_SET_CONSOLE_CP SetConsoleCodePage;
|
|
||||||
CSRSS_GET_CONSOLE_OUTPUT_CP GetConsoleOutputCodePage;
|
|
||||||
CSRSS_SET_CONSOLE_OUTPUT_CP SetConsoleOutputCodePage;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // __CSRCONS_H__
|
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
|
@ -1,14 +0,0 @@
|
||||||
#if !defined(__INCLUDE_WIN_WINDOWS_H)
|
|
||||||
#define __INCLUDE_WIN_WINDOWS_H
|
|
||||||
|
|
||||||
#include <csr/protocol.h>
|
|
||||||
|
|
||||||
/* w32 console server */
|
|
||||||
CSR_SERVER_DLL_INIT(ConServerDllInitialization);
|
|
||||||
|
|
||||||
/* w32 user server */
|
|
||||||
CSR_SERVER_DLL_INIT(UserServerDllInitialization);
|
|
||||||
|
|
||||||
#endif /* ndef __INCLUDE_WIN_WINDOWS_H */
|
|
||||||
|
|
||||||
|
|
15
include/reactos/subsys/win/winmsg.h
Normal file
15
include/reactos/subsys/win/winmsg.h
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
|
||||||
|
#ifndef __WINMSG_H__
|
||||||
|
#define __WINMSG_H__
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define USERSRV_SERVERDLL_INDEX 3
|
||||||
|
#define USERSRV_FIRST_API_NUMBER 1024
|
||||||
|
|
||||||
|
/* w32 user server - move to win.h */
|
||||||
|
CSR_SERVER_DLL_INIT(UserServerDllInitialization);
|
||||||
|
|
||||||
|
#endif // __WINMSG_H__
|
||||||
|
|
||||||
|
/* EOF */
|
|
@ -5,15 +5,14 @@ include_directories(${REACTOS_SOURCE_DIR}/include/reactos/subsys)
|
||||||
spec2def(csrsrv.dll csrsrv.spec ADD_IMPORTLIB)
|
spec2def(csrsrv.dll csrsrv.spec ADD_IMPORTLIB)
|
||||||
|
|
||||||
list(APPEND SOURCE
|
list(APPEND SOURCE
|
||||||
api/process.c
|
api.c
|
||||||
api/user.c
|
|
||||||
api/wapi.c
|
|
||||||
procsup.c
|
|
||||||
thredsup.c
|
|
||||||
init.c
|
init.c
|
||||||
wait.c
|
procsup.c
|
||||||
session.c
|
|
||||||
server.c
|
server.c
|
||||||
|
session.c
|
||||||
|
thredsup.c
|
||||||
|
user.c
|
||||||
|
wait.c
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/csrsrv.def)
|
${CMAKE_CURRENT_BINARY_DIR}/csrsrv.def)
|
||||||
|
|
||||||
add_library(csrsrv SHARED ${SOURCE})
|
add_library(csrsrv SHARED ${SOURCE})
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,33 +0,0 @@
|
||||||
/*
|
|
||||||
* subsystems/win32/csrss/csrsrv/api/process.c
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* ReactOS Operating System
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* INCLUDES ******************************************************************/
|
|
||||||
|
|
||||||
#include <srv.h>
|
|
||||||
|
|
||||||
#define NDEBUG
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* GLOBALS *******************************************************************/
|
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* CSRSS API
|
|
||||||
*********************************************************************/
|
|
||||||
|
|
||||||
/***
|
|
||||||
*** Some APIs from here will go to basesrv.dll, some others to winsrv.dll.
|
|
||||||
*** Furthermore, this structure uses the old definition of APIs list.
|
|
||||||
*** The new one is in fact three arrays, one of APIs pointers, one other of
|
|
||||||
*** corresponding indexes, and the third one of names (not very efficient...).
|
|
||||||
***/
|
|
||||||
|
|
||||||
/* EOF */
|
|
|
@ -12,7 +12,7 @@
|
||||||
@ stdcall CsrDereferenceWait(ptr)
|
@ stdcall CsrDereferenceWait(ptr)
|
||||||
@ stdcall CsrDestroyProcess(ptr long)
|
@ stdcall CsrDestroyProcess(ptr long)
|
||||||
@ stdcall CsrDestroyThread(ptr)
|
@ stdcall CsrDestroyThread(ptr)
|
||||||
@ stdcall CsrEnumProcesses(ptr ptr) ;;;;;;; Temporary hack used in win32csr, to be removed
|
;@ stdcall CsrEnumProcesses(ptr ptr) ;;;;;;; Temporary hack used in win32csr, to be removed
|
||||||
@ stdcall CsrExecServerThread(ptr long)
|
@ stdcall CsrExecServerThread(ptr long)
|
||||||
@ stdcall CsrGetProcessLuid(ptr ptr)
|
@ stdcall CsrGetProcessLuid(ptr ptr)
|
||||||
@ stdcall CsrImpersonateClient(ptr)
|
@ stdcall CsrImpersonateClient(ptr)
|
||||||
|
|
|
@ -11,9 +11,11 @@
|
||||||
#include <ndk/psfuncs.h>
|
#include <ndk/psfuncs.h>
|
||||||
#include <ndk/rtlfuncs.h>
|
#include <ndk/rtlfuncs.h>
|
||||||
|
|
||||||
#include <csrss/server.h>
|
#include <csr/csrsrv.h>
|
||||||
|
|
||||||
|
|
||||||
|
extern RTL_CRITICAL_SECTION CsrProcessLock, CsrWaitListsLock;
|
||||||
|
|
||||||
#define CsrAcquireProcessLock() \
|
#define CsrAcquireProcessLock() \
|
||||||
RtlEnterCriticalSection(&CsrProcessLock);
|
RtlEnterCriticalSection(&CsrProcessLock);
|
||||||
|
|
||||||
|
@ -36,7 +38,12 @@
|
||||||
RtlLeaveCriticalSection(&CsrNtSessionLock);
|
RtlLeaveCriticalSection(&CsrNtSessionLock);
|
||||||
|
|
||||||
|
|
||||||
|
#define CSR_SERVER_DLL_MAX 4
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
*** Old structure. Deprecated.
|
||||||
|
***/
|
||||||
typedef struct _CSRSS_API_DEFINITION
|
typedef struct _CSRSS_API_DEFINITION
|
||||||
{
|
{
|
||||||
ULONG ApiID;
|
ULONG ApiID;
|
||||||
|
@ -49,6 +56,7 @@ typedef struct _CSRSS_API_DEFINITION
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _CSRSS_LISTEN_DATA
|
typedef struct _CSRSS_LISTEN_DATA
|
||||||
{
|
{
|
||||||
HANDLE ApiPortHandle;
|
HANDLE ApiPortHandle;
|
||||||
|
@ -64,22 +72,66 @@ typedef struct _CSRSS_LISTEN_DATA
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* init.c */
|
|
||||||
extern HANDLE hBootstrapOk;
|
extern HANDLE hBootstrapOk;
|
||||||
NTSTATUS NTAPI CsrServerInitialization(ULONG ArgumentCount, PCHAR Arguments[]);
|
extern HANDLE CsrApiPort;
|
||||||
|
extern HANDLE CsrSmApiPort;
|
||||||
|
extern HANDLE CsrSbApiPort;
|
||||||
|
extern LIST_ENTRY CsrThreadHashTable[256];
|
||||||
|
extern PCSR_PROCESS CsrRootProcess;
|
||||||
|
extern UNICODE_STRING CsrDirectoryName;
|
||||||
|
extern ULONG CsrDebug;
|
||||||
|
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;
|
||||||
|
|
||||||
/* api/process.c */
|
/****************************************************/
|
||||||
CSR_API(CsrConnectProcess);
|
extern UNICODE_STRING CsrSbApiPortName;
|
||||||
CSR_API(BaseSrvCreateProcess);
|
extern UNICODE_STRING CsrApiPortName;
|
||||||
CSR_API(BaseSrvExitProcess);
|
extern RTL_CRITICAL_SECTION CsrProcessLock;
|
||||||
CSR_API(BaseSrvCreateThread);
|
extern RTL_CRITICAL_SECTION CsrWaitListsLock;
|
||||||
CSR_API(BaseSrvGetProcessShutdownParam);
|
extern HANDLE CsrObjectDirectory;
|
||||||
CSR_API(BaseSrvSetProcessShutdownParam);
|
extern PSB_API_ROUTINE CsrServerSbApiDispatch[5];
|
||||||
|
/****************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CSR_API(CsrSrvClientConnect);
|
||||||
|
CSR_API(CsrSrvUnusedFunction);
|
||||||
|
CSR_API(CsrSrvIdentifyAlertableThread);
|
||||||
|
CSR_API(CsrSrvSetPriorityClass);
|
||||||
|
CSR_API(SrvRegisterServicesProcess);
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
CsrCaptureArguments(
|
||||||
|
IN PCSR_THREAD CsrThread,
|
||||||
|
IN PCSR_API_MESSAGE ApiMessage
|
||||||
|
);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrSetBackgroundPriority(IN PCSR_PROCESS CsrProcess);
|
CsrReleaseCapturedArguments(IN PCSR_API_MESSAGE ApiMessage);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
CsrServerDllInitialization(IN PCSR_SERVER_DLL LoadedServerDll);
|
||||||
|
|
||||||
|
***/
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
CsrLoadServerDll(IN PCHAR DllString,
|
||||||
|
IN PCHAR EntryPoint OPTIONAL,
|
||||||
|
IN ULONG ServerId);
|
||||||
|
|
||||||
|
|
||||||
PCSR_THREAD
|
PCSR_THREAD
|
||||||
NTAPI
|
NTAPI
|
||||||
|
@ -97,10 +149,6 @@ VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrRemoveProcess(IN PCSR_PROCESS CsrProcess);
|
CsrRemoveProcess(IN PCSR_PROCESS CsrProcess);
|
||||||
|
|
||||||
VOID
|
|
||||||
NTAPI
|
|
||||||
CsrDereferenceThread(IN PCSR_THREAD CsrThread);
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrInsertProcess(IN PCSR_PROCESS Parent OPTIONAL,
|
CsrInsertProcess(IN PCSR_PROCESS Parent OPTIONAL,
|
||||||
|
@ -108,69 +156,66 @@ CsrInsertProcess(IN PCSR_PROCESS Parent OPTIONAL,
|
||||||
IN PCSR_PROCESS CsrProcess);
|
IN PCSR_PROCESS CsrProcess);
|
||||||
|
|
||||||
|
|
||||||
/* api/wapi.c */
|
|
||||||
NTSTATUS FASTCALL CsrApiRegisterDefinitions(PCSRSS_API_DEFINITION NewDefinitions);
|
NTSTATUS FASTCALL CsrApiRegisterDefinitions(PCSRSS_API_DEFINITION NewDefinitions);
|
||||||
VOID FASTCALL CsrApiCallHandler(IN OUT PCSR_API_MESSAGE ApiMessage, OUT PULONG Reply);
|
VOID FASTCALL CsrApiCallHandler(IN OUT PCSR_API_MESSAGE ApiMessage, OUT PULONG Reply);
|
||||||
VOID WINAPI CsrSbApiRequestThread (PVOID PortHandle);
|
|
||||||
VOID NTAPI ClientConnectionThread(HANDLE ServerPort);
|
|
||||||
|
|
||||||
extern HANDLE CsrApiPort;
|
NTSTATUS
|
||||||
extern HANDLE CsrSmApiPort;
|
NTAPI
|
||||||
extern HANDLE CsrSbApiPort;
|
CsrApiRequestThread(IN PVOID Parameter); // HANDLE ServerPort ??
|
||||||
extern LIST_ENTRY CsrThreadHashTable[256];
|
|
||||||
extern PCSR_PROCESS CsrRootProcess;
|
VOID
|
||||||
extern RTL_CRITICAL_SECTION CsrProcessLock, CsrWaitListsLock;
|
NTAPI
|
||||||
extern UNICODE_STRING CsrDirectoryName;
|
CsrSbApiRequestThread(IN PVOID Parameter);
|
||||||
extern ULONG CsrDebug;
|
|
||||||
extern ULONG CsrTotalPerProcessDataLength;
|
|
||||||
extern SYSTEM_BASIC_INFORMATION CsrNtSysInfo;
|
|
||||||
extern PVOID CsrSrvSharedSectionHeap;
|
|
||||||
extern PVOID *CsrSrvSharedStaticServerData;
|
|
||||||
extern HANDLE CsrInitializationEvent;
|
|
||||||
extern PCSR_SERVER_DLL CsrLoadedServerDll[CSR_SERVER_DLL_MAX];
|
|
||||||
extern ULONG CsrMaxApiRequestThreads;
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrApiPortInitialize(VOID);
|
CsrApiPortInitialize(VOID);
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
CsrCreateProcess(IN HANDLE hProcess,
|
|
||||||
IN HANDLE hThread,
|
|
||||||
IN PCLIENT_ID ClientId,
|
|
||||||
IN PCSR_NT_SESSION NtSession,
|
|
||||||
IN ULONG Flags,
|
|
||||||
IN PCLIENT_ID DebugCid);
|
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NTAPI
|
NTAPI
|
||||||
ProtectHandle(IN HANDLE ObjectHandle);
|
ProtectHandle(IN HANDLE ObjectHandle);
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
UnProtectHandle(IN HANDLE ObjectHandle);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrInsertThread(IN PCSR_PROCESS Process,
|
CsrInsertThread(IN PCSR_PROCESS Process,
|
||||||
IN PCSR_THREAD Thread);
|
IN PCSR_THREAD Thread);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
CsrLockedReferenceProcess(IN PCSR_PROCESS CsrProcess);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrLockedReferenceThread(IN PCSR_THREAD CsrThread);
|
CsrLockedReferenceThread(IN PCSR_THREAD CsrThread);
|
||||||
|
|
||||||
/* api/process.c */
|
NTSTATUS
|
||||||
typedef NTSTATUS (WINAPI *CSRSS_ENUM_PROCESS_PROC)(PCSR_PROCESS ProcessData,
|
NTAPI
|
||||||
PVOID Context);
|
CsrInitializeProcessStructure(VOID);
|
||||||
NTSTATUS WINAPI CsrInitializeProcessStructure(VOID);
|
|
||||||
|
|
||||||
NTSTATUS WINAPI CsrEnumProcesses(CSRSS_ENUM_PROCESS_PROC EnumProc, PVOID Context);
|
// NTSTATUS WINAPI CsrEnumProcesses(CSRSS_ENUM_PROCESS_PROC EnumProc,
|
||||||
PCSR_THREAD NTAPI CsrAddStaticServerThread(IN HANDLE hThread, IN PCLIENT_ID ClientId, IN ULONG ThreadFlags);
|
// PVOID Context);
|
||||||
PCSR_THREAD NTAPI CsrLocateThreadInProcess(IN PCSR_PROCESS CsrProcess OPTIONAL, IN PCLIENT_ID Cid);
|
PCSR_THREAD
|
||||||
PCSR_THREAD NTAPI CsrLocateThreadByClientId(OUT PCSR_PROCESS *Process OPTIONAL, IN PCLIENT_ID ClientId);
|
NTAPI
|
||||||
NTSTATUS NTAPI CsrLockProcessByClientId(IN HANDLE Pid, OUT PCSR_PROCESS *CsrProcess OPTIONAL);
|
CsrLocateThreadInProcess(IN PCSR_PROCESS CsrProcess OPTIONAL,
|
||||||
NTSTATUS NTAPI CsrCreateThread(IN PCSR_PROCESS CsrProcess, IN HANDLE hThread, IN PCLIENT_ID ClientId);
|
IN PCLIENT_ID Cid);
|
||||||
NTSTATUS NTAPI CsrUnlockProcess(IN PCSR_PROCESS CsrProcess);
|
PCSR_THREAD
|
||||||
|
NTAPI
|
||||||
|
CsrLocateThreadByClientId(OUT PCSR_PROCESS *Process OPTIONAL,
|
||||||
|
IN PCLIENT_ID ClientId);
|
||||||
|
|
||||||
//hack
|
// HACK
|
||||||
VOID NTAPI CsrThreadRefcountZero(IN PCSR_THREAD CsrThread);
|
VOID
|
||||||
|
NTAPI
|
||||||
|
CsrProcessRefcountZero(IN PCSR_PROCESS CsrProcess);
|
||||||
|
|
||||||
|
// HACK
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
CsrThreadRefcountZero(IN PCSR_THREAD CsrThread);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
|
@ -179,48 +224,15 @@ CsrInitializeNtSessionList(VOID);
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrSrvAttachSharedSection(IN PCSR_PROCESS CsrProcess OPTIONAL,
|
CsrSrvAttachSharedSection(IN PCSR_PROCESS CsrProcess OPTIONAL,
|
||||||
OUT PCSR_CONNECTION_INFO ConnectInfo);
|
OUT PCSR_CONNECTION_INFO ConnectInfo);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrSrvCreateSharedSection(IN PCHAR ParameterValue);
|
CsrSrvCreateSharedSection(IN PCHAR ParameterValue);
|
||||||
|
|
||||||
NTSTATUS
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrSrvClientConnect(
|
CsrLockedDereferenceProcess(PCSR_PROCESS CsrProcess);
|
||||||
IN OUT PCSR_API_MESSAGE ApiMessage,
|
|
||||||
IN OUT PULONG Reply
|
|
||||||
);
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
CsrSrvUnusedFunction(
|
|
||||||
IN OUT PCSR_API_MESSAGE ApiMessage,
|
|
||||||
IN OUT PULONG Reply
|
|
||||||
);
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
CsrSrvIdentifyAlertableThread(
|
|
||||||
IN OUT PCSR_API_MESSAGE ApiMessage,
|
|
||||||
IN OUT PULONG Reply
|
|
||||||
);
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
CsrSrvSetPriorityClass(
|
|
||||||
IN OUT PCSR_API_MESSAGE ApiMessage,
|
|
||||||
IN OUT PULONG Reply
|
|
||||||
);
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
CsrDestroyProcess(IN PCLIENT_ID Cid,
|
|
||||||
IN NTSTATUS ExitStatus);
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
CsrDestroyThread(IN PCLIENT_ID Cid);
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
|
@ -239,30 +251,63 @@ VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrReferenceNtSession(IN PCSR_NT_SESSION Session);
|
CsrReferenceNtSession(IN PCSR_NT_SESSION Session);
|
||||||
|
|
||||||
LONG
|
|
||||||
NTAPI
|
|
||||||
CsrUnhandledExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo);
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrDereferenceNtSession(IN PCSR_NT_SESSION Session,
|
CsrDereferenceNtSession(IN PCSR_NT_SESSION Session,
|
||||||
IN NTSTATUS ExitStatus);
|
IN NTSTATUS ExitStatus);
|
||||||
|
|
||||||
VOID
|
/******************************************************************************
|
||||||
NTAPI
|
******************************************************************************/
|
||||||
CsrLockedDereferenceProcess(PCSR_PROCESS CsrProcess);
|
|
||||||
|
|
||||||
VOID
|
|
||||||
NTAPI
|
|
||||||
CsrDereferenceProcess(IN PCSR_PROCESS CsrProcess);
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrLoadServerDll(IN PCHAR DllString,
|
CsrCreateSessionObjectDirectory(IN ULONG SessionId);
|
||||||
IN PCHAR EntryPoint OPTIONAL,
|
|
||||||
IN ULONG ServerId);
|
|
||||||
|
|
||||||
/* api/user.c */
|
NTSTATUS
|
||||||
CSR_API(SrvRegisterServicesProcess);
|
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 */
|
/* EOF */
|
||||||
|
|
|
@ -18,15 +18,21 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "api.h"
|
|
||||||
|
|
||||||
|
#include <csr/csrcl.h>
|
||||||
|
//#include "api.h"
|
||||||
|
|
||||||
|
/*
|
||||||
typedef NTSTATUS (WINAPI *CSRSS_ENUM_PROCESSES_PROC)(CSRSS_ENUM_PROCESS_PROC EnumProc,
|
typedef NTSTATUS (WINAPI *CSRSS_ENUM_PROCESSES_PROC)(CSRSS_ENUM_PROCESS_PROC EnumProc,
|
||||||
PVOID Context);
|
PVOID Context);
|
||||||
|
typedef NTSTATUS (WINAPI *CSRSS_ENUM_PROCESS_PROC)(PCSR_PROCESS ProcessData,
|
||||||
|
PVOID Context);
|
||||||
|
|
||||||
typedef struct tagCSRSS_EXPORTED_FUNCS
|
typedef struct tagCSRSS_EXPORTED_FUNCS
|
||||||
{
|
{
|
||||||
CSRSS_ENUM_PROCESSES_PROC CsrEnumProcessesProc;
|
CSRSS_ENUM_PROCESSES_PROC CsrEnumProcessesProc;
|
||||||
} CSRSS_EXPORTED_FUNCS, *PCSRSS_EXPORTED_FUNCS;
|
} CSRSS_EXPORTED_FUNCS, *PCSRSS_EXPORTED_FUNCS;
|
||||||
|
*/
|
||||||
|
|
||||||
typedef BOOL (WINAPI *CSRPLUGIN_INIT_COMPLETE_PROC)(void);
|
typedef BOOL (WINAPI *CSRPLUGIN_INIT_COMPLETE_PROC)(void);
|
||||||
|
|
||||||
|
|
|
@ -16,15 +16,15 @@
|
||||||
|
|
||||||
/* DATA ***********************************************************************/
|
/* DATA ***********************************************************************/
|
||||||
|
|
||||||
HANDLE CsrHeap = (HANDLE) 0;
|
HANDLE CsrHeap = NULL;
|
||||||
HANDLE CsrObjectDirectory = (HANDLE) 0;
|
HANDLE CsrObjectDirectory = NULL;
|
||||||
UNICODE_STRING CsrDirectoryName;
|
UNICODE_STRING CsrDirectoryName;
|
||||||
UNICODE_STRING CsrSbApiPortName;
|
UNICODE_STRING CsrSbApiPortName;
|
||||||
HANDLE CsrSbApiPort = 0;
|
HANDLE CsrSbApiPort = NULL;
|
||||||
PCSR_THREAD CsrSbApiRequestThreadPtr;
|
PCSR_THREAD CsrSbApiRequestThreadPtr;
|
||||||
HANDLE CsrSmApiPort;
|
HANDLE CsrSmApiPort = NULL;
|
||||||
HANDLE hSbApiPort = (HANDLE) 0;
|
HANDLE hSbApiPort = NULL;
|
||||||
HANDLE CsrApiPort = (HANDLE) 0;
|
HANDLE CsrApiPort = NULL;
|
||||||
ULONG CsrDebug = 0;//0xFFFFFFFF;
|
ULONG CsrDebug = 0;//0xFFFFFFFF;
|
||||||
ULONG CsrMaxApiRequestThreads;
|
ULONG CsrMaxApiRequestThreads;
|
||||||
ULONG CsrTotalPerProcessDataLength;
|
ULONG CsrTotalPerProcessDataLength;
|
||||||
|
@ -35,6 +35,7 @@ HANDLE DosDevicesDirectory;
|
||||||
HANDLE CsrInitializationEvent;
|
HANDLE CsrInitializationEvent;
|
||||||
SYSTEM_BASIC_INFORMATION CsrNtSysInfo;
|
SYSTEM_BASIC_INFORMATION CsrNtSysInfo;
|
||||||
|
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS **********************************************************/
|
/* PRIVATE FUNCTIONS **********************************************************/
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
@ -60,34 +61,6 @@ CallHardError(IN PCSR_THREAD ThreadData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
NTSTATUS
|
|
||||||
CallProcessCreated(IN PCSR_PROCESS SourceProcessData,
|
|
||||||
IN PCSR_PROCESS TargetProcessData)
|
|
||||||
{
|
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
|
||||||
ULONG i;
|
|
||||||
PCSR_SERVER_DLL ServerDll;
|
|
||||||
|
|
||||||
DPRINT("CSR: %s called\n", __FUNCTION__);
|
|
||||||
|
|
||||||
/* Notify the Server DLLs */
|
|
||||||
for (i = 0; i < CSR_SERVER_DLL_MAX; i++)
|
|
||||||
{
|
|
||||||
/* Get the current Server DLL */
|
|
||||||
ServerDll = CsrLoadedServerDll[i];
|
|
||||||
|
|
||||||
/* Make sure it's valid and that it has callback */
|
|
||||||
if ((ServerDll) && (ServerDll->NewProcessCallback))
|
|
||||||
{
|
|
||||||
Status = ServerDll->NewProcessCallback(SourceProcessData, TargetProcessData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CSRSS_API_DEFINITION NativeDefinitions[] =
|
CSRSS_API_DEFINITION NativeDefinitions[] =
|
||||||
{
|
{
|
||||||
CSRSS_DEFINE_API(REGISTER_SERVICES_PROCESS, SrvRegisterServicesProcess), // winsrv.dll
|
CSRSS_DEFINE_API(REGISTER_SERVICES_PROCESS, SrvRegisterServicesProcess), // winsrv.dll
|
||||||
|
@ -928,7 +901,6 @@ CsrSbApiPortInitialize(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* PUBLIC FUNCTIONS ***********************************************************/
|
/* PUBLIC FUNCTIONS ***********************************************************/
|
||||||
|
|
||||||
/*++
|
/*++
|
||||||
|
@ -1103,7 +1075,7 @@ VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrPopulateDosDevices(VOID)
|
CsrPopulateDosDevices(VOID)
|
||||||
{
|
{
|
||||||
DPRINT1("Deprecated API\n");
|
DPRINT1("Deprecated API in r55585.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -498,344 +498,6 @@ CsrInsertProcess(IN PCSR_PROCESS Parent OPTIONAL,
|
||||||
|
|
||||||
/* PUBLIC FUNCTIONS ***********************************************************/
|
/* PUBLIC FUNCTIONS ***********************************************************/
|
||||||
|
|
||||||
/*++
|
|
||||||
* @name CsrGetProcessLuid
|
|
||||||
* @implemented NT4
|
|
||||||
*
|
|
||||||
* Do nothing for 500ms.
|
|
||||||
*
|
|
||||||
* @param hProcess
|
|
||||||
* Optional handle to the process whose LUID should be returned.
|
|
||||||
*
|
|
||||||
* @param Luid
|
|
||||||
* Pointer to a LUID Pointer which will receive the CSR Process' LUID
|
|
||||||
*
|
|
||||||
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL
|
|
||||||
* otherwise.
|
|
||||||
*
|
|
||||||
* @remarks If hProcess is not supplied, then the current thread's token will
|
|
||||||
* be used. If that too is missing, then the current process' token
|
|
||||||
* will be used.
|
|
||||||
*
|
|
||||||
*--*/
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
CsrGetProcessLuid(HANDLE hProcess OPTIONAL,
|
|
||||||
PLUID Luid)
|
|
||||||
{
|
|
||||||
HANDLE hToken = NULL;
|
|
||||||
NTSTATUS Status;
|
|
||||||
ULONG Length;
|
|
||||||
PTOKEN_STATISTICS TokenStats;
|
|
||||||
|
|
||||||
/* Check if we have a handle to a CSR Process */
|
|
||||||
if (!hProcess)
|
|
||||||
{
|
|
||||||
/* We don't, so try opening the Thread's Token */
|
|
||||||
Status = NtOpenThreadToken(NtCurrentThread(),
|
|
||||||
TOKEN_QUERY,
|
|
||||||
FALSE,
|
|
||||||
&hToken);
|
|
||||||
|
|
||||||
/* Check for success */
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
/* If we got some other failure, then return and quit */
|
|
||||||
if (Status != STATUS_NO_TOKEN) return Status;
|
|
||||||
|
|
||||||
/* We don't have a Thread Token, use a Process Token */
|
|
||||||
hProcess = NtCurrentProcess();
|
|
||||||
hToken = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if we have a token by now */
|
|
||||||
if (!hToken)
|
|
||||||
{
|
|
||||||
/* No token yet, so open the Process Token */
|
|
||||||
Status = NtOpenProcessToken(hProcess,
|
|
||||||
TOKEN_QUERY,
|
|
||||||
&hToken);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
/* Still no token, return the error */
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now get the size we'll need for the Token Information */
|
|
||||||
Status = NtQueryInformationToken(hToken,
|
|
||||||
TokenStatistics,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
&Length);
|
|
||||||
|
|
||||||
/* Allocate memory for the Token Info */
|
|
||||||
if (!(TokenStats = RtlAllocateHeap(CsrHeap, 0, Length)))
|
|
||||||
{
|
|
||||||
/* Fail and close the token */
|
|
||||||
NtClose(hToken);
|
|
||||||
return STATUS_NO_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now query the information */
|
|
||||||
Status = NtQueryInformationToken(hToken,
|
|
||||||
TokenStatistics,
|
|
||||||
TokenStats,
|
|
||||||
Length,
|
|
||||||
&Length);
|
|
||||||
|
|
||||||
/* Close the handle */
|
|
||||||
NtClose(hToken);
|
|
||||||
|
|
||||||
/* Check for success */
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
/* Return the LUID */
|
|
||||||
*Luid = TokenStats->AuthenticationId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Free the query information */
|
|
||||||
RtlFreeHeap(CsrHeap, 0, TokenStats);
|
|
||||||
|
|
||||||
/* Return the Status */
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*++
|
|
||||||
* @name CsrImpersonateClient
|
|
||||||
* @implemented NT4
|
|
||||||
*
|
|
||||||
* The CsrImpersonateClient will impersonate the given CSR Thread.
|
|
||||||
*
|
|
||||||
* @param CsrThread
|
|
||||||
* Pointer to the CSR Thread to impersonate.
|
|
||||||
*
|
|
||||||
* @return TRUE if impersionation suceeded, false otherwise.
|
|
||||||
*
|
|
||||||
* @remarks Impersonation can be recursive.
|
|
||||||
*
|
|
||||||
*--*/
|
|
||||||
BOOLEAN
|
|
||||||
NTAPI
|
|
||||||
CsrImpersonateClient(IN PCSR_THREAD CsrThread)
|
|
||||||
{
|
|
||||||
NTSTATUS Status;
|
|
||||||
PCSR_THREAD CurrentThread = CsrGetClientThread();
|
|
||||||
|
|
||||||
/* Use the current thread if none given */
|
|
||||||
if (!CsrThread) CsrThread = CurrentThread;
|
|
||||||
|
|
||||||
/* Still no thread, something is wrong */
|
|
||||||
if (!CsrThread)
|
|
||||||
{
|
|
||||||
/* Failure */
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Make the call */
|
|
||||||
Status = NtImpersonateThread(NtCurrentThread(),
|
|
||||||
CsrThread->ThreadHandle,
|
|
||||||
&CsrSecurityQos);
|
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
/* Failure */
|
|
||||||
/*
|
|
||||||
DPRINT1("CSRSS: Can't impersonate client thread - Status = %lx\n", Status);
|
|
||||||
if (Status != STATUS_BAD_IMPERSONATION_LEVEL) DbgBreakPoint();
|
|
||||||
*/
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Increase the impersonation count for the current thread */
|
|
||||||
if (CurrentThread) ++CurrentThread->ImpersonationCount;
|
|
||||||
|
|
||||||
/* Return Success */
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*++
|
|
||||||
* @name CsrRevertToSelf
|
|
||||||
* @implemented NT4
|
|
||||||
*
|
|
||||||
* The CsrRevertToSelf routine will attempt to remove an active impersonation.
|
|
||||||
*
|
|
||||||
* @param None.
|
|
||||||
*
|
|
||||||
* @return TRUE if the reversion was succesful, false otherwise.
|
|
||||||
*
|
|
||||||
* @remarks Impersonation can be recursive; as such, the impersonation token
|
|
||||||
* will only be deleted once the CSR Thread's impersonaton count
|
|
||||||
* has reached zero.
|
|
||||||
*
|
|
||||||
*--*/
|
|
||||||
BOOLEAN
|
|
||||||
NTAPI
|
|
||||||
CsrRevertToSelf(VOID)
|
|
||||||
{
|
|
||||||
NTSTATUS Status;
|
|
||||||
PCSR_THREAD CurrentThread = CsrGetClientThread();
|
|
||||||
HANDLE ImpersonationToken = NULL;
|
|
||||||
|
|
||||||
/* Check if we have a Current Thread */
|
|
||||||
if (CurrentThread)
|
|
||||||
{
|
|
||||||
/* Make sure impersonation is on */
|
|
||||||
if (!CurrentThread->ImpersonationCount)
|
|
||||||
{
|
|
||||||
// DPRINT1("CSRSS: CsrRevertToSelf called while not impersonating\n");
|
|
||||||
// DbgBreakPoint();
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
else if (--CurrentThread->ImpersonationCount > 0)
|
|
||||||
{
|
|
||||||
/* Success; impersonation count decreased but still not zero */
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Impersonation has been totally removed, revert to ourselves */
|
|
||||||
Status = NtSetInformationThread(NtCurrentThread(),
|
|
||||||
ThreadImpersonationToken,
|
|
||||||
&ImpersonationToken,
|
|
||||||
sizeof(HANDLE));
|
|
||||||
|
|
||||||
/* Return TRUE or FALSE */
|
|
||||||
return NT_SUCCESS(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*++
|
|
||||||
* @name CsrDereferenceProcess
|
|
||||||
* @implemented NT4
|
|
||||||
*
|
|
||||||
* The CsrDereferenceProcess routine removes a reference from a CSR Process.
|
|
||||||
*
|
|
||||||
* @param CsrThread
|
|
||||||
* Pointer to the CSR Process to dereference.
|
|
||||||
*
|
|
||||||
* @return None.
|
|
||||||
*
|
|
||||||
* @remarks If the reference count has reached zero (ie: the CSR Process has
|
|
||||||
* no more active references), it will be deleted.
|
|
||||||
*
|
|
||||||
*--*/
|
|
||||||
VOID
|
|
||||||
NTAPI
|
|
||||||
CsrDereferenceProcess(IN PCSR_PROCESS CsrProcess)
|
|
||||||
{
|
|
||||||
LONG LockCount;
|
|
||||||
|
|
||||||
/* Acquire process lock */
|
|
||||||
CsrAcquireProcessLock();
|
|
||||||
|
|
||||||
/* Decrease reference count */
|
|
||||||
LockCount = --CsrProcess->ReferenceCount;
|
|
||||||
ASSERT(LockCount >= 0);
|
|
||||||
if (!LockCount)
|
|
||||||
{
|
|
||||||
/* Call the generic cleanup code */
|
|
||||||
CsrProcessRefcountZero(CsrProcess);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Just release the lock */
|
|
||||||
CsrReleaseProcessLock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*++
|
|
||||||
* @name CsrDestroyProcess
|
|
||||||
* @implemented NT4
|
|
||||||
*
|
|
||||||
* The CsrDestroyProcess routine destroys the CSR Process corresponding to
|
|
||||||
* a given Client ID.
|
|
||||||
*
|
|
||||||
* @param Cid
|
|
||||||
* Pointer to the Client ID Structure corresponding to the CSR
|
|
||||||
* Process which is about to be destroyed.
|
|
||||||
*
|
|
||||||
* @param ExitStatus
|
|
||||||
* Unused.
|
|
||||||
*
|
|
||||||
* @return STATUS_SUCCESS in case of success, STATUS_THREAD_IS_TERMINATING
|
|
||||||
* if the CSR Process is already terminating.
|
|
||||||
*
|
|
||||||
* @remarks None.
|
|
||||||
*
|
|
||||||
*--*/
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
CsrDestroyProcess(IN PCLIENT_ID Cid,
|
|
||||||
IN NTSTATUS ExitStatus)
|
|
||||||
{
|
|
||||||
PCSR_THREAD CsrThread;
|
|
||||||
PCSR_PROCESS CsrProcess;
|
|
||||||
CLIENT_ID ClientId = *Cid;
|
|
||||||
PLIST_ENTRY NextEntry;
|
|
||||||
|
|
||||||
/* Acquire lock */
|
|
||||||
CsrAcquireProcessLock();
|
|
||||||
|
|
||||||
/* Find the thread */
|
|
||||||
CsrThread = CsrLocateThreadByClientId(&CsrProcess, &ClientId);
|
|
||||||
|
|
||||||
/* Make sure we got one back, and that it's not already gone */
|
|
||||||
if (!(CsrThread) || (CsrProcess->Flags & CsrProcessTerminating))
|
|
||||||
{
|
|
||||||
/* Release the lock and return failure */
|
|
||||||
CsrReleaseProcessLock();
|
|
||||||
return STATUS_THREAD_IS_TERMINATING;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the terminated flag */
|
|
||||||
CsrProcess->Flags |= CsrProcessTerminating;
|
|
||||||
|
|
||||||
/* Get the List Pointers */
|
|
||||||
NextEntry = CsrProcess->ThreadList.Flink;
|
|
||||||
while (NextEntry != &CsrProcess->ThreadList)
|
|
||||||
{
|
|
||||||
/* Get the current thread entry */
|
|
||||||
CsrThread = CONTAINING_RECORD(NextEntry, CSR_THREAD, Link);
|
|
||||||
|
|
||||||
/* Make sure the thread isn't already dead */
|
|
||||||
if (CsrThread->Flags & CsrThreadTerminated)
|
|
||||||
{
|
|
||||||
NextEntry = NextEntry->Flink;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the Terminated flag */
|
|
||||||
CsrThread->Flags |= CsrThreadTerminated;
|
|
||||||
|
|
||||||
/* Acquire the Wait Lock */
|
|
||||||
CsrAcquireWaitLock();
|
|
||||||
|
|
||||||
/* Do we have an active wait block? */
|
|
||||||
if (CsrThread->WaitBlock)
|
|
||||||
{
|
|
||||||
/* Notify waiters of termination */
|
|
||||||
CsrNotifyWaitBlock(CsrThread->WaitBlock,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
CsrProcessTerminating,
|
|
||||||
TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Release the Wait Lock */
|
|
||||||
CsrReleaseWaitLock();
|
|
||||||
|
|
||||||
/* Dereference the thread */
|
|
||||||
CsrLockedDereferenceThread(CsrThread);
|
|
||||||
NextEntry = CsrProcess->ThreadList.Flink;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Release the Process Lock and return success */
|
|
||||||
CsrReleaseProcessLock();
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*++
|
/*++
|
||||||
* @name CsrCreateProcess
|
* @name CsrCreateProcess
|
||||||
* @implemented NT4
|
* @implemented NT4
|
||||||
|
@ -1048,60 +710,339 @@ CsrCreateProcess(IN HANDLE hProcess,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*++
|
/*++
|
||||||
* @name CsrUnlockProcess
|
* @name CsrDebugProcess
|
||||||
* @implemented NT4
|
* @implemented NT4
|
||||||
*
|
*
|
||||||
* The CsrUnlockProcess undoes a previous CsrLockProcessByClientId operation.
|
* The CsrDebugProcess routine is deprecated in NT 5.1 and higher. It is
|
||||||
|
* exported only for compatibility with older CSR Server DLLs.
|
||||||
*
|
*
|
||||||
* @param CsrProcess
|
* @param CsrProcess
|
||||||
* Pointer to a previously locked CSR Process.
|
* Deprecated.
|
||||||
*
|
*
|
||||||
* @return STATUS_SUCCESS.
|
* @return Deprecated
|
||||||
*
|
*
|
||||||
* @remarks This routine must be called with the Process Lock held.
|
* @remarks Deprecated.
|
||||||
*
|
*
|
||||||
*--*/
|
*--*/
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrUnlockProcess(IN PCSR_PROCESS CsrProcess)
|
CsrDebugProcess(IN PCSR_PROCESS CsrProcess)
|
||||||
{
|
{
|
||||||
/* Dereference the process */
|
/* CSR does not handle debugging anymore */
|
||||||
CsrLockedDereferenceProcess(CsrProcess);
|
DPRINT("CSRSRV: %s(%08lx) called\n", __FUNCTION__, CsrProcess);
|
||||||
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Release the lock and return */
|
/*++
|
||||||
|
* @name CsrDebugProcessStop
|
||||||
|
* @implemented NT4
|
||||||
|
*
|
||||||
|
* The CsrDebugProcessStop routine is deprecated in NT 5.1 and higher. It is
|
||||||
|
* exported only for compatibility with older CSR Server DLLs.
|
||||||
|
*
|
||||||
|
* @param CsrProcess
|
||||||
|
* Deprecated.
|
||||||
|
*
|
||||||
|
* @return Deprecated
|
||||||
|
*
|
||||||
|
* @remarks Deprecated.
|
||||||
|
*
|
||||||
|
*--*/
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
CsrDebugProcessStop(IN PCSR_PROCESS CsrProcess)
|
||||||
|
{
|
||||||
|
/* CSR does not handle debugging anymore */
|
||||||
|
DPRINT("CSRSRV: %s(%08lx) called\n", __FUNCTION__, CsrProcess);
|
||||||
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*++
|
||||||
|
* @name CsrDereferenceProcess
|
||||||
|
* @implemented NT4
|
||||||
|
*
|
||||||
|
* The CsrDereferenceProcess routine removes a reference from a CSR Process.
|
||||||
|
*
|
||||||
|
* @param CsrThread
|
||||||
|
* Pointer to the CSR Process to dereference.
|
||||||
|
*
|
||||||
|
* @return None.
|
||||||
|
*
|
||||||
|
* @remarks If the reference count has reached zero (ie: the CSR Process has
|
||||||
|
* no more active references), it will be deleted.
|
||||||
|
*
|
||||||
|
*--*/
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
CsrDereferenceProcess(IN PCSR_PROCESS CsrProcess)
|
||||||
|
{
|
||||||
|
LONG LockCount;
|
||||||
|
|
||||||
|
/* Acquire process lock */
|
||||||
|
CsrAcquireProcessLock();
|
||||||
|
|
||||||
|
/* Decrease reference count */
|
||||||
|
LockCount = --CsrProcess->ReferenceCount;
|
||||||
|
ASSERT(LockCount >= 0);
|
||||||
|
if (!LockCount)
|
||||||
|
{
|
||||||
|
/* Call the generic cleanup code */
|
||||||
|
CsrProcessRefcountZero(CsrProcess);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Just release the lock */
|
||||||
|
CsrReleaseProcessLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*++
|
||||||
|
* @name CsrDestroyProcess
|
||||||
|
* @implemented NT4
|
||||||
|
*
|
||||||
|
* The CsrDestroyProcess routine destroys the CSR Process corresponding to
|
||||||
|
* a given Client ID.
|
||||||
|
*
|
||||||
|
* @param Cid
|
||||||
|
* Pointer to the Client ID Structure corresponding to the CSR
|
||||||
|
* Process which is about to be destroyed.
|
||||||
|
*
|
||||||
|
* @param ExitStatus
|
||||||
|
* Unused.
|
||||||
|
*
|
||||||
|
* @return STATUS_SUCCESS in case of success, STATUS_THREAD_IS_TERMINATING
|
||||||
|
* if the CSR Process is already terminating.
|
||||||
|
*
|
||||||
|
* @remarks None.
|
||||||
|
*
|
||||||
|
*--*/
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
CsrDestroyProcess(IN PCLIENT_ID Cid,
|
||||||
|
IN NTSTATUS ExitStatus)
|
||||||
|
{
|
||||||
|
PCSR_THREAD CsrThread;
|
||||||
|
PCSR_PROCESS CsrProcess;
|
||||||
|
CLIENT_ID ClientId = *Cid;
|
||||||
|
PLIST_ENTRY NextEntry;
|
||||||
|
|
||||||
|
/* Acquire lock */
|
||||||
|
CsrAcquireProcessLock();
|
||||||
|
|
||||||
|
/* Find the thread */
|
||||||
|
CsrThread = CsrLocateThreadByClientId(&CsrProcess, &ClientId);
|
||||||
|
|
||||||
|
/* Make sure we got one back, and that it's not already gone */
|
||||||
|
if (!(CsrThread) || (CsrProcess->Flags & CsrProcessTerminating))
|
||||||
|
{
|
||||||
|
/* Release the lock and return failure */
|
||||||
|
CsrReleaseProcessLock();
|
||||||
|
return STATUS_THREAD_IS_TERMINATING;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the terminated flag */
|
||||||
|
CsrProcess->Flags |= CsrProcessTerminating;
|
||||||
|
|
||||||
|
/* Get the List Pointers */
|
||||||
|
NextEntry = CsrProcess->ThreadList.Flink;
|
||||||
|
while (NextEntry != &CsrProcess->ThreadList)
|
||||||
|
{
|
||||||
|
/* Get the current thread entry */
|
||||||
|
CsrThread = CONTAINING_RECORD(NextEntry, CSR_THREAD, Link);
|
||||||
|
|
||||||
|
/* Make sure the thread isn't already dead */
|
||||||
|
if (CsrThread->Flags & CsrThreadTerminated)
|
||||||
|
{
|
||||||
|
NextEntry = NextEntry->Flink;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the Terminated flag */
|
||||||
|
CsrThread->Flags |= CsrThreadTerminated;
|
||||||
|
|
||||||
|
/* Acquire the Wait Lock */
|
||||||
|
CsrAcquireWaitLock();
|
||||||
|
|
||||||
|
/* Do we have an active wait block? */
|
||||||
|
if (CsrThread->WaitBlock)
|
||||||
|
{
|
||||||
|
/* Notify waiters of termination */
|
||||||
|
CsrNotifyWaitBlock(CsrThread->WaitBlock,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
CsrProcessTerminating,
|
||||||
|
TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Release the Wait Lock */
|
||||||
|
CsrReleaseWaitLock();
|
||||||
|
|
||||||
|
/* Dereference the thread */
|
||||||
|
CsrLockedDereferenceThread(CsrThread);
|
||||||
|
NextEntry = CsrProcess->ThreadList.Flink;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Release the Process Lock and return success */
|
||||||
CsrReleaseProcessLock();
|
CsrReleaseProcessLock();
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*++
|
/*++
|
||||||
* @name CsrSetBackgroundPriority
|
* @name CsrGetProcessLuid
|
||||||
* @implemented NT4
|
* @implemented NT4
|
||||||
*
|
*
|
||||||
* The CsrSetBackgroundPriority routine sets the priority for the given CSR
|
* Do nothing for 500ms.
|
||||||
* Process as a Background priority.
|
|
||||||
*
|
*
|
||||||
* @param CsrProcess
|
* @param hProcess
|
||||||
* Pointer to the CSR Process whose priority will be modified.
|
* Optional handle to the process whose LUID should be returned.
|
||||||
*
|
*
|
||||||
* @return None.
|
* @param Luid
|
||||||
|
* Pointer to a LUID Pointer which will receive the CSR Process' LUID
|
||||||
*
|
*
|
||||||
* @remarks None.
|
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL
|
||||||
|
* otherwise.
|
||||||
|
*
|
||||||
|
* @remarks If hProcess is not supplied, then the current thread's token will
|
||||||
|
* be used. If that too is missing, then the current process' token
|
||||||
|
* will be used.
|
||||||
*
|
*
|
||||||
*--*/
|
*--*/
|
||||||
VOID
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrSetBackgroundPriority(IN PCSR_PROCESS CsrProcess)
|
CsrGetProcessLuid(IN HANDLE hProcess OPTIONAL,
|
||||||
|
OUT PLUID Luid)
|
||||||
{
|
{
|
||||||
PROCESS_PRIORITY_CLASS PriorityClass;
|
HANDLE hToken = NULL;
|
||||||
|
NTSTATUS Status;
|
||||||
|
ULONG Length;
|
||||||
|
PTOKEN_STATISTICS TokenStats;
|
||||||
|
|
||||||
/* Set the Foreground bit off */
|
/* Check if we have a handle to a CSR Process */
|
||||||
PriorityClass.Foreground = FALSE;
|
if (!hProcess)
|
||||||
|
{
|
||||||
|
/* We don't, so try opening the Thread's Token */
|
||||||
|
Status = NtOpenThreadToken(NtCurrentThread(),
|
||||||
|
TOKEN_QUERY,
|
||||||
|
FALSE,
|
||||||
|
&hToken);
|
||||||
|
|
||||||
/* Set the new Priority */
|
/* Check for success */
|
||||||
NtSetInformationProcess(CsrProcess->ProcessHandle,
|
if (!NT_SUCCESS(Status))
|
||||||
ProcessPriorityClass,
|
{
|
||||||
&PriorityClass,
|
/* If we got some other failure, then return and quit */
|
||||||
sizeof(PriorityClass));
|
if (Status != STATUS_NO_TOKEN) return Status;
|
||||||
|
|
||||||
|
/* We don't have a Thread Token, use a Process Token */
|
||||||
|
hProcess = NtCurrentProcess();
|
||||||
|
hToken = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if we have a token by now */
|
||||||
|
if (!hToken)
|
||||||
|
{
|
||||||
|
/* No token yet, so open the Process Token */
|
||||||
|
Status = NtOpenProcessToken(hProcess,
|
||||||
|
TOKEN_QUERY,
|
||||||
|
&hToken);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
/* Still no token, return the error */
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now get the size we'll need for the Token Information */
|
||||||
|
Status = NtQueryInformationToken(hToken,
|
||||||
|
TokenStatistics,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
&Length);
|
||||||
|
|
||||||
|
/* Allocate memory for the Token Info */
|
||||||
|
if (!(TokenStats = RtlAllocateHeap(CsrHeap, 0, Length)))
|
||||||
|
{
|
||||||
|
/* Fail and close the token */
|
||||||
|
NtClose(hToken);
|
||||||
|
return STATUS_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now query the information */
|
||||||
|
Status = NtQueryInformationToken(hToken,
|
||||||
|
TokenStatistics,
|
||||||
|
TokenStats,
|
||||||
|
Length,
|
||||||
|
&Length);
|
||||||
|
|
||||||
|
/* Close the handle */
|
||||||
|
NtClose(hToken);
|
||||||
|
|
||||||
|
/* Check for success */
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
/* Return the LUID */
|
||||||
|
*Luid = TokenStats->AuthenticationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free the query information */
|
||||||
|
RtlFreeHeap(CsrHeap, 0, TokenStats);
|
||||||
|
|
||||||
|
/* Return the Status */
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*++
|
||||||
|
* @name CsrImpersonateClient
|
||||||
|
* @implemented NT4
|
||||||
|
*
|
||||||
|
* The CsrImpersonateClient will impersonate the given CSR Thread.
|
||||||
|
*
|
||||||
|
* @param CsrThread
|
||||||
|
* Pointer to the CSR Thread to impersonate.
|
||||||
|
*
|
||||||
|
* @return TRUE if impersionation suceeded, false otherwise.
|
||||||
|
*
|
||||||
|
* @remarks Impersonation can be recursive.
|
||||||
|
*
|
||||||
|
*--*/
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
CsrImpersonateClient(IN PCSR_THREAD CsrThread)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
PCSR_THREAD CurrentThread = CsrGetClientThread();
|
||||||
|
|
||||||
|
/* Use the current thread if none given */
|
||||||
|
if (!CsrThread) CsrThread = CurrentThread;
|
||||||
|
|
||||||
|
/* Still no thread, something is wrong */
|
||||||
|
if (!CsrThread)
|
||||||
|
{
|
||||||
|
/* Failure */
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make the call */
|
||||||
|
Status = NtImpersonateThread(NtCurrentThread(),
|
||||||
|
CsrThread->ThreadHandle,
|
||||||
|
&CsrSecurityQos);
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
/* Failure */
|
||||||
|
/*
|
||||||
|
DPRINT1("CSRSS: Can't impersonate client thread - Status = %lx\n", Status);
|
||||||
|
if (Status != STATUS_BAD_IMPERSONATION_LEVEL) DbgBreakPoint();
|
||||||
|
*/
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Increase the impersonation count for the current thread */
|
||||||
|
if (CurrentThread) ++CurrentThread->ImpersonationCount;
|
||||||
|
|
||||||
|
/* Return Success */
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*++
|
/*++
|
||||||
|
@ -1176,6 +1117,118 @@ CsrLockProcessByClientId(IN HANDLE Pid,
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*++
|
||||||
|
* @name CsrRevertToSelf
|
||||||
|
* @implemented NT4
|
||||||
|
*
|
||||||
|
* The CsrRevertToSelf routine will attempt to remove an active impersonation.
|
||||||
|
*
|
||||||
|
* @param None.
|
||||||
|
*
|
||||||
|
* @return TRUE if the reversion was succesful, false otherwise.
|
||||||
|
*
|
||||||
|
* @remarks Impersonation can be recursive; as such, the impersonation token
|
||||||
|
* will only be deleted once the CSR Thread's impersonaton count
|
||||||
|
* has reached zero.
|
||||||
|
*
|
||||||
|
*--*/
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
CsrRevertToSelf(VOID)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
PCSR_THREAD CurrentThread = CsrGetClientThread();
|
||||||
|
HANDLE ImpersonationToken = NULL;
|
||||||
|
|
||||||
|
/* Check if we have a Current Thread */
|
||||||
|
if (CurrentThread)
|
||||||
|
{
|
||||||
|
/* Make sure impersonation is on */
|
||||||
|
if (!CurrentThread->ImpersonationCount)
|
||||||
|
{
|
||||||
|
// DPRINT1("CSRSS: CsrRevertToSelf called while not impersonating\n");
|
||||||
|
// DbgBreakPoint();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else if (--CurrentThread->ImpersonationCount > 0)
|
||||||
|
{
|
||||||
|
/* Success; impersonation count decreased but still not zero */
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Impersonation has been totally removed, revert to ourselves */
|
||||||
|
Status = NtSetInformationThread(NtCurrentThread(),
|
||||||
|
ThreadImpersonationToken,
|
||||||
|
&ImpersonationToken,
|
||||||
|
sizeof(HANDLE));
|
||||||
|
|
||||||
|
/* Return TRUE or FALSE */
|
||||||
|
return NT_SUCCESS(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*++
|
||||||
|
* @name CsrSetBackgroundPriority
|
||||||
|
* @implemented NT4
|
||||||
|
*
|
||||||
|
* The CsrSetBackgroundPriority routine sets the priority for the given CSR
|
||||||
|
* Process as a Background priority.
|
||||||
|
*
|
||||||
|
* @param CsrProcess
|
||||||
|
* Pointer to the CSR Process whose priority will be modified.
|
||||||
|
*
|
||||||
|
* @return None.
|
||||||
|
*
|
||||||
|
* @remarks None.
|
||||||
|
*
|
||||||
|
*--*/
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
CsrSetBackgroundPriority(IN PCSR_PROCESS CsrProcess)
|
||||||
|
{
|
||||||
|
PROCESS_PRIORITY_CLASS PriorityClass;
|
||||||
|
|
||||||
|
/* Set the Foreground bit off */
|
||||||
|
PriorityClass.Foreground = FALSE;
|
||||||
|
|
||||||
|
/* Set the new Priority */
|
||||||
|
NtSetInformationProcess(CsrProcess->ProcessHandle,
|
||||||
|
ProcessPriorityClass,
|
||||||
|
&PriorityClass,
|
||||||
|
sizeof(PriorityClass));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*++
|
||||||
|
* @name CsrSetForegroundPriority
|
||||||
|
* @implemented NT4
|
||||||
|
*
|
||||||
|
* The CsrSetForegroundPriority routine sets the priority for the given CSR
|
||||||
|
* Process as a Foreground priority.
|
||||||
|
*
|
||||||
|
* @param CsrProcess
|
||||||
|
* Pointer to the CSR Process whose priority will be modified.
|
||||||
|
*
|
||||||
|
* @return None.
|
||||||
|
*
|
||||||
|
* @remarks None.
|
||||||
|
*
|
||||||
|
*--*/
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
CsrSetForegroundPriority(IN PCSR_PROCESS CsrProcess)
|
||||||
|
{
|
||||||
|
PROCESS_PRIORITY_CLASS PriorityClass;
|
||||||
|
|
||||||
|
/* Set the Foreground bit on */
|
||||||
|
PriorityClass.Foreground = TRUE;
|
||||||
|
|
||||||
|
/* Set the new Priority */
|
||||||
|
NtSetInformationProcess(CsrProcess->ProcessHandle,
|
||||||
|
ProcessPriorityClass,
|
||||||
|
&PriorityClass,
|
||||||
|
sizeof(PriorityClass));
|
||||||
|
}
|
||||||
|
|
||||||
/*++
|
/*++
|
||||||
* @name CsrShutdownProcesses
|
* @name CsrShutdownProcesses
|
||||||
* @implemented NT4
|
* @implemented NT4
|
||||||
|
@ -1231,7 +1284,8 @@ CsrShutdownProcesses(IN PLUID CallerLuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set shudown Priority */
|
/* Set shudown Priority */
|
||||||
CsrpSetToShutdownPriority();
|
// CsrpSetToShutdownPriority();
|
||||||
|
CsrSetToShutdownPriority();
|
||||||
|
|
||||||
/* Start looping */
|
/* Start looping */
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
|
@ -1305,11 +1359,14 @@ CsrShutdownProcesses(IN PLUID CallerLuid,
|
||||||
|
|
||||||
Quickie:
|
Quickie:
|
||||||
/* Return to normal priority */
|
/* Return to normal priority */
|
||||||
CsrpSetToNormalPriority();
|
// CsrpSetToNormalPriority();
|
||||||
|
CsrSetToNormalPriority();
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Temporary hack. This is really "CsrShutdownProcess", mostly. Used by win32csr */
|
/* FIXME: Temporary hack. This is really "CsrShutdownProcess", mostly. Used by win32csr */
|
||||||
|
#if 0
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
WINAPI
|
WINAPI
|
||||||
CsrEnumProcesses(IN CSRSS_ENUM_PROCESS_PROC EnumProc,
|
CsrEnumProcesses(IN CSRSS_ENUM_PROCESS_PROC EnumProc,
|
||||||
|
@ -1400,84 +1457,32 @@ Quickie:
|
||||||
CsrSetToNormalPriority();
|
CsrSetToNormalPriority();
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*++
|
/*++
|
||||||
* @name CsrDebugProcess
|
* @name CsrUnlockProcess
|
||||||
* @implemented NT4
|
* @implemented NT4
|
||||||
*
|
*
|
||||||
* The CsrDebugProcess routine is deprecated in NT 5.1 and higher. It is
|
* The CsrUnlockProcess undoes a previous CsrLockProcessByClientId operation.
|
||||||
* exported only for compatibility with older CSR Server DLLs.
|
|
||||||
*
|
*
|
||||||
* @param CsrProcess
|
* @param CsrProcess
|
||||||
* Deprecated.
|
* Pointer to a previously locked CSR Process.
|
||||||
*
|
*
|
||||||
* @return Deprecated
|
* @return STATUS_SUCCESS.
|
||||||
*
|
*
|
||||||
* @remarks Deprecated.
|
* @remarks This routine must be called with the Process Lock held.
|
||||||
*
|
*
|
||||||
*--*/
|
*--*/
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
CsrDebugProcess(IN PCSR_PROCESS CsrProcess)
|
CsrUnlockProcess(IN PCSR_PROCESS CsrProcess)
|
||||||
{
|
{
|
||||||
/* CSR does not handle debugging anymore */
|
/* Dereference the process */
|
||||||
DPRINT("CSRSRV: %s(%08lx) called\n", __FUNCTION__, CsrProcess);
|
CsrLockedDereferenceProcess(CsrProcess);
|
||||||
return STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*++
|
/* Release the lock and return */
|
||||||
* @name CsrDebugProcessStop
|
CsrReleaseProcessLock();
|
||||||
* @implemented NT4
|
return STATUS_SUCCESS;
|
||||||
*
|
|
||||||
* The CsrDebugProcessStop routine is deprecated in NT 5.1 and higher. It is
|
|
||||||
* exported only for compatibility with older CSR Server DLLs.
|
|
||||||
*
|
|
||||||
* @param CsrProcess
|
|
||||||
* Deprecated.
|
|
||||||
*
|
|
||||||
* @return Deprecated
|
|
||||||
*
|
|
||||||
* @remarks Deprecated.
|
|
||||||
*
|
|
||||||
*--*/
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
CsrDebugProcessStop(IN PCSR_PROCESS CsrProcess)
|
|
||||||
{
|
|
||||||
/* CSR does not handle debugging anymore */
|
|
||||||
DPRINT("CSRSRV: %s(%08lx) called\n", __FUNCTION__, CsrProcess);
|
|
||||||
return STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*++
|
|
||||||
* @name CsrSetForegroundPriority
|
|
||||||
* @implemented NT4
|
|
||||||
*
|
|
||||||
* The CsrSetForegroundPriority routine sets the priority for the given CSR
|
|
||||||
* Process as a Foreground priority.
|
|
||||||
*
|
|
||||||
* @param CsrProcess
|
|
||||||
* Pointer to the CSR Process whose priority will be modified.
|
|
||||||
*
|
|
||||||
* @return None.
|
|
||||||
*
|
|
||||||
* @remarks None.
|
|
||||||
*
|
|
||||||
*--*/
|
|
||||||
VOID
|
|
||||||
NTAPI
|
|
||||||
CsrSetForegroundPriority(IN PCSR_PROCESS CsrProcess)
|
|
||||||
{
|
|
||||||
PROCESS_PRIORITY_CLASS PriorityClass;
|
|
||||||
|
|
||||||
/* Set the Foreground bit on */
|
|
||||||
PriorityClass.Foreground = TRUE;
|
|
||||||
|
|
||||||
/* Set the new Priority */
|
|
||||||
NtSetInformationProcess(CsrProcess->ProcessHandle,
|
|
||||||
ProcessPriorityClass,
|
|
||||||
&PriorityClass,
|
|
||||||
sizeof(PriorityClass));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -15,24 +15,6 @@
|
||||||
|
|
||||||
/* DATA **********************************************************************/
|
/* DATA **********************************************************************/
|
||||||
|
|
||||||
/*** Must go elsewhere ***/
|
|
||||||
#define CSR_SERVER_DLL_MAX 4
|
|
||||||
|
|
||||||
#define CSRSRV_SERVERDLL_INDEX 0
|
|
||||||
#define CSRSRV_FIRST_API_NUMBER 0
|
|
||||||
|
|
||||||
typedef enum _CSR_SRV_API_NUMBER
|
|
||||||
{
|
|
||||||
CsrpClientConnect = CSRSRV_FIRST_API_NUMBER,
|
|
||||||
CsrpThreadConnect,
|
|
||||||
CsrpProfileControl,
|
|
||||||
CsrpIdentifyAlertable,
|
|
||||||
CsrpSetPriorityClass,
|
|
||||||
|
|
||||||
CsrpMaxApiNumber
|
|
||||||
} CSR_SRV_API_NUMBER, *PCSR_SRV_API_NUMBER;
|
|
||||||
/*************************/
|
|
||||||
|
|
||||||
PCSR_API_ROUTINE CsrServerApiDispatchTable[CsrpMaxApiNumber] =
|
PCSR_API_ROUTINE CsrServerApiDispatchTable[CsrpMaxApiNumber] =
|
||||||
{
|
{
|
||||||
CsrSrvClientConnect,
|
CsrSrvClientConnect,
|
||||||
|
@ -186,7 +168,7 @@ CsrLoadServerDll(IN PCHAR DllString,
|
||||||
|
|
||||||
/* Set up the Object */
|
/* Set up the Object */
|
||||||
ServerDll->Length = Size;
|
ServerDll->Length = Size;
|
||||||
ServerDll->SharedSection = CsrSrvSharedSectionHeap;
|
ServerDll->SharedSection = CsrSrvSharedSectionHeap; // Send to the server dll our shared heap pointer.
|
||||||
ServerDll->Event = CsrInitializationEvent;
|
ServerDll->Event = CsrInitializationEvent;
|
||||||
ServerDll->Name.Length = DllName.Length;
|
ServerDll->Name.Length = DllName.Length;
|
||||||
ServerDll->Name.MaximumLength = DllName.MaximumLength;
|
ServerDll->Name.MaximumLength = DllName.MaximumLength;
|
||||||
|
@ -297,7 +279,7 @@ CsrSrvClientConnect(IN OUT PCSR_API_MESSAGE ApiMessage,
|
||||||
PCSR_PROCESS CurrentProcess = CsrGetClientThread()->Process;
|
PCSR_PROCESS CurrentProcess = CsrGetClientThread()->Process;
|
||||||
|
|
||||||
/* Load the Message, set default reply */
|
/* Load the Message, set default reply */
|
||||||
ClientConnect = (PCSR_CLIENT_CONNECT)&ApiMessage->CsrClientConnect;
|
ClientConnect = &ApiMessage->Data.CsrClientConnect;
|
||||||
*Reply = 0;
|
*Reply = 0;
|
||||||
|
|
||||||
/* Validate the ServerID */
|
/* Validate the ServerID */
|
||||||
|
|
|
@ -543,7 +543,7 @@ CsrSbApiRequestThread(IN PVOID Parameter)
|
||||||
{
|
{
|
||||||
ReceiveMsg.ApiNumber = SbpMaxApiNumber;
|
ReceiveMsg.ApiNumber = SbpMaxApiNumber;
|
||||||
DPRINT1("CSRSS: %lx is invalid Sb ApiNumber\n", ReceiveMsg.ApiNumber);
|
DPRINT1("CSRSS: %lx is invalid Sb ApiNumber\n", ReceiveMsg.ApiNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reuse the message */
|
/* Reuse the message */
|
||||||
ReplyMsg = &ReceiveMsg;
|
ReplyMsg = &ReceiveMsg;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include <ndk/ntndk.h>
|
#include <ndk/ntndk.h>
|
||||||
|
|
||||||
/* CSR Header */
|
/* CSR Header */
|
||||||
//#include <csr/server.h>
|
#include <csr/csrsrv.h>
|
||||||
|
|
||||||
/* PSEH for SEH Support */
|
/* PSEH for SEH Support */
|
||||||
#include <pseh/pseh2.h>
|
#include <pseh/pseh2.h>
|
||||||
|
@ -20,11 +20,10 @@
|
||||||
#include <sm/smmsg.h>
|
#include <sm/smmsg.h>
|
||||||
|
|
||||||
/* Internal CSRSS Headers */
|
/* Internal CSRSS Headers */
|
||||||
#include <api.h>
|
#include "include/api.h"
|
||||||
#include <csrplugin.h>
|
#include "include/csrplugin.h"
|
||||||
|
|
||||||
extern HANDLE CsrHeap;
|
|
||||||
|
|
||||||
|
/* Defines */
|
||||||
#define SM_REG_KEY \
|
#define SM_REG_KEY \
|
||||||
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Session Manager"
|
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Session Manager"
|
||||||
|
|
||||||
|
@ -35,7 +34,6 @@ extern HANDLE CsrHeap;
|
||||||
#define CSR_PORT_NAME L"ApiPort"
|
#define CSR_PORT_NAME L"ApiPort"
|
||||||
#define UNICODE_PATH_SEP L"\\"
|
#define UNICODE_PATH_SEP L"\\"
|
||||||
|
|
||||||
/* Defines */
|
|
||||||
#define ROUND_UP(n, align) ROUND_DOWN(((ULONG)n) + (align) - 1, (align))
|
#define ROUND_UP(n, align) ROUND_DOWN(((ULONG)n) + (align) - 1, (align))
|
||||||
#define ROUND_DOWN(n, align) (((ULONG)n) & ~((align) - 1l))
|
#define ROUND_DOWN(n, align) (((ULONG)n) & ~((align) - 1l))
|
||||||
|
|
||||||
|
|
|
@ -472,6 +472,67 @@ CsrLockedDereferenceThread(IN PCSR_THREAD CsrThread)
|
||||||
|
|
||||||
/* PUBLIC FUNCTIONS ***********************************************************/
|
/* PUBLIC FUNCTIONS ***********************************************************/
|
||||||
|
|
||||||
|
/*++
|
||||||
|
* @name CsrAddStaticServerThread
|
||||||
|
* @implemented NT4
|
||||||
|
*
|
||||||
|
* The CsrAddStaticServerThread routine adds a new CSR Thread to the
|
||||||
|
* CSR Server Process (CsrRootProcess).
|
||||||
|
*
|
||||||
|
* @param hThread
|
||||||
|
* Handle to an existing NT Thread to which to associate this
|
||||||
|
* CSR Thread.
|
||||||
|
*
|
||||||
|
* @param ClientId
|
||||||
|
* Pointer to the Client ID structure of the NT Thread to associate
|
||||||
|
* with this CSR Thread.
|
||||||
|
*
|
||||||
|
* @param ThreadFlags
|
||||||
|
* Initial CSR Thread Flags to associate to this CSR Thread. Usually
|
||||||
|
* CsrThreadIsServerThread.
|
||||||
|
*
|
||||||
|
* @return Pointer to the newly allocated CSR Thread.
|
||||||
|
*
|
||||||
|
* @remarks None.
|
||||||
|
*
|
||||||
|
*--*/
|
||||||
|
PCSR_THREAD
|
||||||
|
NTAPI
|
||||||
|
CsrAddStaticServerThread(IN HANDLE hThread,
|
||||||
|
IN PCLIENT_ID ClientId,
|
||||||
|
IN ULONG ThreadFlags)
|
||||||
|
{
|
||||||
|
PCSR_THREAD CsrThread;
|
||||||
|
|
||||||
|
/* Get the Lock */
|
||||||
|
CsrAcquireProcessLock();
|
||||||
|
|
||||||
|
/* Allocate the Server Thread */
|
||||||
|
CsrThread = CsrAllocateThread(CsrRootProcess);
|
||||||
|
if (CsrThread)
|
||||||
|
{
|
||||||
|
/* Setup the Object */
|
||||||
|
CsrThread->ThreadHandle = hThread;
|
||||||
|
ProtectHandle(hThread);
|
||||||
|
CsrThread->ClientId = *ClientId;
|
||||||
|
CsrThread->Flags = ThreadFlags;
|
||||||
|
|
||||||
|
/* Insert it into the Thread List */
|
||||||
|
InsertTailList(&CsrRootProcess->ThreadList, &CsrThread->Link);
|
||||||
|
|
||||||
|
/* Increment the thread count */
|
||||||
|
CsrRootProcess->ThreadCount++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DPRINT1("CsrAddStaticServerThread: alloc failed for thread 0x%x\n", hThread);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Release the Process Lock and return */
|
||||||
|
CsrReleaseProcessLock();
|
||||||
|
return CsrThread;
|
||||||
|
}
|
||||||
|
|
||||||
/*++
|
/*++
|
||||||
* @name CsrCreateRemoteThread
|
* @name CsrCreateRemoteThread
|
||||||
* @implemented NT4
|
* @implemented NT4
|
||||||
|
@ -573,75 +634,6 @@ CsrCreateRemoteThread(IN HANDLE hThread,
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*++
|
|
||||||
* @name CsrDestroyThread
|
|
||||||
* @implemented NT4
|
|
||||||
*
|
|
||||||
* The CsrDestroyThread routine destroys the CSR Thread corresponding to
|
|
||||||
* a given Thread ID.
|
|
||||||
*
|
|
||||||
* @param Cid
|
|
||||||
* Pointer to the Client ID Structure corresponding to the CSR
|
|
||||||
* Thread which is about to be destroyed.
|
|
||||||
*
|
|
||||||
* @return STATUS_SUCCESS in case of success, STATUS_THREAD_IS_TERMINATING
|
|
||||||
* if the CSR Thread is already terminating.
|
|
||||||
*
|
|
||||||
* @remarks None.
|
|
||||||
*
|
|
||||||
*--*/
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
CsrDestroyThread(IN PCLIENT_ID Cid)
|
|
||||||
{
|
|
||||||
CLIENT_ID ClientId = *Cid;
|
|
||||||
PCSR_THREAD CsrThread;
|
|
||||||
PCSR_PROCESS CsrProcess;
|
|
||||||
|
|
||||||
/* Acquire lock */
|
|
||||||
CsrAcquireProcessLock();
|
|
||||||
|
|
||||||
/* Find the thread */
|
|
||||||
CsrThread = CsrLocateThreadByClientId(&CsrProcess,
|
|
||||||
&ClientId);
|
|
||||||
|
|
||||||
/* Make sure we got one back, and that it's not already gone */
|
|
||||||
if (!CsrThread || CsrThread->Flags & CsrThreadTerminated)
|
|
||||||
{
|
|
||||||
/* Release the lock and return failure */
|
|
||||||
CsrReleaseProcessLock();
|
|
||||||
return STATUS_THREAD_IS_TERMINATING;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the terminated flag */
|
|
||||||
CsrThread->Flags |= CsrThreadTerminated;
|
|
||||||
|
|
||||||
/* Acquire the Wait Lock */
|
|
||||||
CsrAcquireWaitLock();
|
|
||||||
|
|
||||||
/* Do we have an active wait block? */
|
|
||||||
if (CsrThread->WaitBlock)
|
|
||||||
{
|
|
||||||
/* Notify waiters of termination */
|
|
||||||
CsrNotifyWaitBlock(CsrThread->WaitBlock,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
CsrProcessTerminating,
|
|
||||||
TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Release the Wait Lock */
|
|
||||||
CsrReleaseWaitLock();
|
|
||||||
|
|
||||||
/* Dereference the thread */
|
|
||||||
CsrLockedDereferenceThread(CsrThread);
|
|
||||||
|
|
||||||
/* Release the Process Lock and return success */
|
|
||||||
CsrReleaseProcessLock();
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*++
|
/*++
|
||||||
* @name CsrCreateThread
|
* @name CsrCreateThread
|
||||||
* @implemented NT4
|
* @implemented NT4
|
||||||
|
@ -798,67 +790,6 @@ CsrCreateThread(IN PCSR_PROCESS CsrProcess,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*++
|
|
||||||
* @name CsrAddStaticServerThread
|
|
||||||
* @implemented NT4
|
|
||||||
*
|
|
||||||
* The CsrAddStaticServerThread routine adds a new CSR Thread to the
|
|
||||||
* CSR Server Process (CsrRootProcess).
|
|
||||||
*
|
|
||||||
* @param hThread
|
|
||||||
* Handle to an existing NT Thread to which to associate this
|
|
||||||
* CSR Thread.
|
|
||||||
*
|
|
||||||
* @param ClientId
|
|
||||||
* Pointer to the Client ID structure of the NT Thread to associate
|
|
||||||
* with this CSR Thread.
|
|
||||||
*
|
|
||||||
* @param ThreadFlags
|
|
||||||
* Initial CSR Thread Flags to associate to this CSR Thread. Usually
|
|
||||||
* CsrThreadIsServerThread.
|
|
||||||
*
|
|
||||||
* @return Pointer to the newly allocated CSR Thread.
|
|
||||||
*
|
|
||||||
* @remarks None.
|
|
||||||
*
|
|
||||||
*--*/
|
|
||||||
PCSR_THREAD
|
|
||||||
NTAPI
|
|
||||||
CsrAddStaticServerThread(IN HANDLE hThread,
|
|
||||||
IN PCLIENT_ID ClientId,
|
|
||||||
IN ULONG ThreadFlags)
|
|
||||||
{
|
|
||||||
PCSR_THREAD CsrThread;
|
|
||||||
|
|
||||||
/* Get the Lock */
|
|
||||||
CsrAcquireProcessLock();
|
|
||||||
|
|
||||||
/* Allocate the Server Thread */
|
|
||||||
CsrThread = CsrAllocateThread(CsrRootProcess);
|
|
||||||
if (CsrThread)
|
|
||||||
{
|
|
||||||
/* Setup the Object */
|
|
||||||
CsrThread->ThreadHandle = hThread;
|
|
||||||
ProtectHandle(hThread);
|
|
||||||
CsrThread->ClientId = *ClientId;
|
|
||||||
CsrThread->Flags = ThreadFlags;
|
|
||||||
|
|
||||||
/* Insert it into the Thread List */
|
|
||||||
InsertTailList(&CsrRootProcess->ThreadList, &CsrThread->Link);
|
|
||||||
|
|
||||||
/* Increment the thread count */
|
|
||||||
CsrRootProcess->ThreadCount++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DPRINT1("CsrAddStaticServerThread: alloc failed for thread 0x%x\n", hThread);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Release the Process Lock and return */
|
|
||||||
CsrReleaseProcessLock();
|
|
||||||
return CsrThread;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*++
|
/*++
|
||||||
* @name CsrDereferenceThread
|
* @name CsrDereferenceThread
|
||||||
* @implemented NT4
|
* @implemented NT4
|
||||||
|
@ -895,6 +826,74 @@ CsrDereferenceThread(IN PCSR_THREAD CsrThread)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*++
|
||||||
|
* @name CsrDestroyThread
|
||||||
|
* @implemented NT4
|
||||||
|
*
|
||||||
|
* The CsrDestroyThread routine destroys the CSR Thread corresponding to
|
||||||
|
* a given Thread ID.
|
||||||
|
*
|
||||||
|
* @param Cid
|
||||||
|
* Pointer to the Client ID Structure corresponding to the CSR
|
||||||
|
* Thread which is about to be destroyed.
|
||||||
|
*
|
||||||
|
* @return STATUS_SUCCESS in case of success, STATUS_THREAD_IS_TERMINATING
|
||||||
|
* if the CSR Thread is already terminating.
|
||||||
|
*
|
||||||
|
* @remarks None.
|
||||||
|
*
|
||||||
|
*--*/
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
CsrDestroyThread(IN PCLIENT_ID Cid)
|
||||||
|
{
|
||||||
|
CLIENT_ID ClientId = *Cid;
|
||||||
|
PCSR_THREAD CsrThread;
|
||||||
|
PCSR_PROCESS CsrProcess;
|
||||||
|
|
||||||
|
/* Acquire lock */
|
||||||
|
CsrAcquireProcessLock();
|
||||||
|
|
||||||
|
/* Find the thread */
|
||||||
|
CsrThread = CsrLocateThreadByClientId(&CsrProcess,
|
||||||
|
&ClientId);
|
||||||
|
|
||||||
|
/* Make sure we got one back, and that it's not already gone */
|
||||||
|
if (!CsrThread || CsrThread->Flags & CsrThreadTerminated)
|
||||||
|
{
|
||||||
|
/* Release the lock and return failure */
|
||||||
|
CsrReleaseProcessLock();
|
||||||
|
return STATUS_THREAD_IS_TERMINATING;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the terminated flag */
|
||||||
|
CsrThread->Flags |= CsrThreadTerminated;
|
||||||
|
|
||||||
|
/* Acquire the Wait Lock */
|
||||||
|
CsrAcquireWaitLock();
|
||||||
|
|
||||||
|
/* Do we have an active wait block? */
|
||||||
|
if (CsrThread->WaitBlock)
|
||||||
|
{
|
||||||
|
/* Notify waiters of termination */
|
||||||
|
CsrNotifyWaitBlock(CsrThread->WaitBlock,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
CsrProcessTerminating,
|
||||||
|
TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Release the Wait Lock */
|
||||||
|
CsrReleaseWaitLock();
|
||||||
|
|
||||||
|
/* Dereference the thread */
|
||||||
|
CsrLockedDereferenceThread(CsrThread);
|
||||||
|
|
||||||
|
/* Release the Process Lock and return success */
|
||||||
|
CsrReleaseProcessLock();
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
/*++
|
/*++
|
||||||
* @name CsrExecServerThread
|
* @name CsrExecServerThread
|
||||||
|
|
|
@ -25,16 +25,16 @@ static ULONG_PTR ServicesProcessId;
|
||||||
|
|
||||||
CSR_API(SrvRegisterServicesProcess)
|
CSR_API(SrvRegisterServicesProcess)
|
||||||
{
|
{
|
||||||
if (ServicesProcessIdValid == TRUE)
|
if (ServicesProcessIdValid == TRUE)
|
||||||
{
|
{
|
||||||
/* Only accept a single call */
|
/* Only accept a single call */
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ServicesProcessId = (ULONG_PTR)ApiMessage->Data.RegisterServicesProcessRequest.ProcessId;
|
ServicesProcessId = (ULONG_PTR)ApiMessage->Data.RegisterServicesProcessRequest.ProcessId;
|
||||||
ServicesProcessIdValid = TRUE;
|
ServicesProcessIdValid = TRUE;
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
include
|
${REACTOS_SOURCE_DIR}/subsystems/win32/csrsrv/include
|
||||||
${REACTOS_SOURCE_DIR}/include/reactos/subsys)
|
${REACTOS_SOURCE_DIR}/include/reactos/subsys)
|
||||||
|
|
||||||
add_executable(csrss csrss.c csrss.rc)
|
add_executable(csrss csrss.c csrss.rc)
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#define NTOS_MODE_USER
|
#define NTOS_MODE_USER
|
||||||
#include <ndk/ntndk.h>
|
#include <ndk/ntndk.h>
|
||||||
#include <api.h>
|
|
||||||
// #include <csr/server.h>
|
#include <csr/csrsrv.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
Loading…
Reference in a new issue