mirror of
https://github.com/reactos/reactos.git
synced 2025-07-05 04:01:23 +00:00
Correct LPC implementation
Removed thread leak in csrss Added notification of port closing svn path=/trunk/; revision=1103
This commit is contained in:
parent
eb1f2f9bd1
commit
d54e68673b
30 changed files with 627 additions and 636 deletions
|
@ -1,5 +1,5 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
/* $Id: lpcclt.c,v 1.5 2000/01/22 22:22:48 ea Exp $
|
/* $Id: lpcclt.c,v 1.6 2000/04/03 21:54:33 dwelch Exp $
|
||||||
*
|
*
|
||||||
* DESCRIPTION: Simple LPC Client
|
* DESCRIPTION: Simple LPC Client
|
||||||
* PROGRAMMER: David Welch
|
* PROGRAMMER: David Welch
|
||||||
*/
|
*/
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
#include <napi/lpc.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -29,7 +30,7 @@ int main(int argc, char* argv[])
|
||||||
UNICODE_STRING PortName;
|
UNICODE_STRING PortName;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
HANDLE PortHandle;
|
HANDLE PortHandle;
|
||||||
LPCMESSAGE Request;
|
LPC_MAX_MESSAGE Request;
|
||||||
ULONG ConnectInfoLength;
|
ULONG ConnectInfoLength;
|
||||||
|
|
||||||
printf("(lpcclt.exe) Lpc client\n");
|
printf("(lpcclt.exe) Lpc client\n");
|
||||||
|
@ -52,15 +53,19 @@ int main(int argc, char* argv[])
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(Request.MessageData, GetCommandLineA());
|
strcpy(Request.Data, GetCommandLineA());
|
||||||
Request.ActualMessageLength = strlen(Request.MessageData);
|
Request.Header.DataSize = strlen(Request.Data);
|
||||||
Request.TotalMessageLength = sizeof(LPCMESSAGE);
|
Request.Header.MessageSize = sizeof(LPC_MESSAGE_HEADER) +
|
||||||
|
Request.Header.DataSize;
|
||||||
|
|
||||||
printf("(lpcclt.exe) Sending message \"%s\"\n", (char *) Request.MessageData);
|
printf("(lpcclt.exe) Sending message \"%s\"\n",
|
||||||
Status = NtRequestPort(PortHandle, &Request);
|
(char *) Request.Data);
|
||||||
|
Status = NtRequestPort(PortHandle,
|
||||||
|
&Request.Header);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
printf("(lpcclt.exe) Failed to send request (Status = 0x%=8X)\n", Status);
|
printf("(lpcclt.exe) Failed to send request (Status = 0x%8X)\n",
|
||||||
|
Status);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
/* $Id: lpcsrv.c,v 1.5 2000/03/10 13:46:07 ekohl Exp $
|
/* $Id: lpcsrv.c,v 1.6 2000/04/03 21:54:33 dwelch Exp $
|
||||||
*
|
*
|
||||||
* DESCRIPTION: Simple LPC Server
|
* DESCRIPTION: Simple LPC Server
|
||||||
* PROGRAMMER: David Welch
|
* PROGRAMMER: David Welch
|
||||||
*/
|
*/
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
#include <napi/lpc.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -31,7 +32,7 @@ int main(int argc, char* argv[])
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
HANDLE NamedPortHandle;
|
HANDLE NamedPortHandle;
|
||||||
HANDLE PortHandle;
|
HANDLE PortHandle;
|
||||||
LPCMESSAGE ConnectMsg;
|
LPC_MAX_MESSAGE ConnectMsg;
|
||||||
|
|
||||||
printf("(lpcsrv.exe) Lpc test server\n");
|
printf("(lpcsrv.exe) Lpc test server\n");
|
||||||
|
|
||||||
|
@ -57,7 +58,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
printf("(lpcsrv.exe) Listening for connections\n");
|
printf("(lpcsrv.exe) Listening for connections\n");
|
||||||
Status = NtListenPort(NamedPortHandle,
|
Status = NtListenPort(NamedPortHandle,
|
||||||
&ConnectMsg);
|
&ConnectMsg.Header);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
printf("(lpcsrv.exe) Failed to listen for connections (Status = 0x%08lX)\n", Status);
|
printf("(lpcsrv.exe) Failed to listen for connections (Status = 0x%08lX)\n", Status);
|
||||||
|
@ -87,19 +88,20 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
LPCMESSAGE Request;
|
LPC_MAX_MESSAGE Request;
|
||||||
|
|
||||||
Status = NtReplyWaitReceivePort(PortHandle,
|
Status = NtReplyWaitReceivePort(PortHandle,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
&Request);
|
&Request.Header);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
printf("(lpcsrv.exe) Failed to receive request (Status = 0x%08lX)\n", Status);
|
printf("(lpcsrv.exe) Failed to receive request (Status = 0x%08lX)\n", Status);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("(lpcsrv.exe) Message contents are <%s>\n", Request.MessageData);
|
printf("(lpcsrv.exe) Message contents are <%s>\n",
|
||||||
|
Request.Data);
|
||||||
}
|
}
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef __INCLUDE_CSRSS_CSRSS_H
|
#ifndef __INCLUDE_CSRSS_CSRSS_H
|
||||||
#define __INCLUDE_CSRSS_CSRSS_H
|
#define __INCLUDE_CSRSS_CSRSS_H
|
||||||
|
|
||||||
|
#include <napi/lpc.h>
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
} CSRSS_CONNECT_PROCESS_REQUEST, PCSRSS_CONNECT_PROCESS_REQUEST;
|
} CSRSS_CONNECT_PROCESS_REQUEST, PCSRSS_CONNECT_PROCESS_REQUEST;
|
||||||
|
@ -54,6 +56,7 @@ typedef struct
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
LPC_MESSAGE_HEADER Header;
|
||||||
ULONG Type;
|
ULONG Type;
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
|
@ -66,6 +69,7 @@ typedef struct
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
LPC_MESSAGE_HEADER Header;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
|
|
|
@ -175,35 +175,35 @@ typedef struct
|
||||||
|
|
||||||
typedef struct _ETHREAD
|
typedef struct _ETHREAD
|
||||||
{
|
{
|
||||||
KTHREAD Tcb;
|
KTHREAD Tcb;
|
||||||
TIME CreateTime;
|
TIME CreateTime;
|
||||||
TIME ExitTime;
|
TIME ExitTime;
|
||||||
NTSTATUS ExitStatus;
|
NTSTATUS ExitStatus;
|
||||||
LIST_ENTRY PostBlockList;
|
LIST_ENTRY PostBlockList;
|
||||||
LIST_ENTRY TerminationPortList;
|
LIST_ENTRY TerminationPortList;
|
||||||
ULONG ActiveTimerListLock;
|
KSPIN_LOCK ActiveTimerListLock;
|
||||||
PVOID ActiveTimerListHead;
|
PVOID ActiveTimerListHead;
|
||||||
CLIENT_ID Cid;
|
CLIENT_ID Cid;
|
||||||
PLARGE_INTEGER LpcReplySemaphore;
|
PLARGE_INTEGER LpcReplySemaphore;
|
||||||
PVOID LpcReplyMessage;
|
PVOID LpcReplyMessage;
|
||||||
PLARGE_INTEGER LpcReplyMessageId;
|
PLARGE_INTEGER LpcReplyMessageId;
|
||||||
PPS_IMPERSONATION_INFO ImpersonationInfo;
|
PPS_IMPERSONATION_INFO ImpersonationInfo;
|
||||||
LIST_ENTRY IrpList; //
|
LIST_ENTRY IrpList;
|
||||||
TOP_LEVEL_IRP TopLevelIrp;
|
TOP_LEVEL_IRP TopLevelIrp;
|
||||||
ULONG ReadClusterSize;
|
ULONG ReadClusterSize;
|
||||||
UCHAR ForwardClusterOnly;
|
UCHAR ForwardClusterOnly;
|
||||||
UCHAR DisablePageFaultClustering;
|
UCHAR DisablePageFaultClustering;
|
||||||
UCHAR DeadThread;
|
UCHAR DeadThread;
|
||||||
UCHAR HasTerminated;
|
UCHAR HasTerminated;
|
||||||
ACCESS_MASK GrantedAccess;
|
ACCESS_MASK GrantedAccess;
|
||||||
struct _EPROCESS* ThreadsProcess;
|
struct _EPROCESS* ThreadsProcess;
|
||||||
PKSTART_ROUTINE StartAddress;
|
PKSTART_ROUTINE StartAddress;
|
||||||
LPTHREAD_START_ROUTINE Win32StartAddress; // Should Specify a win32 start func
|
LPTHREAD_START_ROUTINE Win32StartAddress;
|
||||||
UCHAR LpcExitThreadCalled;
|
UCHAR LpcExitThreadCalled;
|
||||||
UCHAR HardErrorsAreDisabled;
|
UCHAR HardErrorsAreDisabled;
|
||||||
UCHAR LpcReceivedMsgIdValid;
|
UCHAR LpcReceivedMsgIdValid;
|
||||||
UCHAR ActiveImpersonationInfo;
|
UCHAR ActiveImpersonationInfo;
|
||||||
ULONG PerformanceCountHigh;
|
ULONG PerformanceCountHigh;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Added by David Welch (welch@cwcom.net)
|
* Added by David Welch (welch@cwcom.net)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
/* $Id: zw.h,v 1.27 2000/03/26 22:00:06 dwelch Exp $
|
/* $Id: zw.h,v 1.28 2000/04/03 21:54:34 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -5119,81 +5119,6 @@ ZwYieldExecution(
|
||||||
* These prototypes are unknown as yet
|
* These prototypes are unknown as yet
|
||||||
* (stack sizes by Peter-Michael Hager)
|
* (stack sizes by Peter-Michael Hager)
|
||||||
*/
|
*/
|
||||||
NTSTATUS STDCALL NtAcceptConnectPort (PHANDLE PortHandle,
|
|
||||||
HANDLE NamedPortHandle,
|
|
||||||
PLPCMESSAGE ServerReply,
|
|
||||||
ULONG AcceptIt,
|
|
||||||
ULONG Unknown3,
|
|
||||||
PLPCSECTIONMAPINFO MapInfo);
|
|
||||||
|
|
||||||
NTSTATUS STDCALL NtCompleteConnectPort (IN HANDLE PortHandle);
|
|
||||||
|
|
||||||
NTSTATUS STDCALL NtConnectPort(OUT PHANDLE PortHandle,
|
|
||||||
IN PUNICODE_STRING PortName,
|
|
||||||
IN PVOID Unknown1,
|
|
||||||
IN PLPCSECTIONINFO SectionInfo,
|
|
||||||
IN PLPCSECTIONMAPINFO MapInfo,
|
|
||||||
IN PVOID Unknown2,
|
|
||||||
IN PVOID ConnectInfo,
|
|
||||||
IN PULONG ConnectInfoLength);
|
|
||||||
|
|
||||||
NTSTATUS STDCALL NtReplyWaitReplyPort(PVOID Unknown1,
|
|
||||||
PVOID Unknown2);
|
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL NtCreatePort(PHANDLE PortHandle,
|
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes,
|
|
||||||
ULONG MaxConnectInfoLength,
|
|
||||||
ULONG MaxDataLength,
|
|
||||||
ULONG Unknown1);
|
|
||||||
|
|
||||||
NTSTATUS STDCALL NtImpersonateClientOfPort (IN HANDLE PortHandle,
|
|
||||||
IN PLPCMESSAGE ClientMessage);
|
|
||||||
|
|
||||||
NTSTATUS STDCALL NtListenPort (IN HANDLE PortHAndle,
|
|
||||||
IN PLPCMESSAGE LpcMessage);
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
STDCALL
|
|
||||||
NtQueryInformationPort ( /* @20 */
|
|
||||||
IN HANDLE PortHandle,
|
|
||||||
IN CINT PortInformationClass, /* guess */
|
|
||||||
OUT PVOID PortInformation, /* guess */
|
|
||||||
IN ULONG PortInformationLength, /* guess */
|
|
||||||
OUT PULONG ReturnLength /* guess */
|
|
||||||
);
|
|
||||||
NTSTATUS STDCALL NtReplyPort (IN HANDLE PortHandle,
|
|
||||||
IN PLPCMESSAGE LpcReply);
|
|
||||||
NTSTATUS STDCALL NtReplyWaitReceivePort (IN HANDLE PortHandle,
|
|
||||||
PVOID Unknown1,
|
|
||||||
PLPCMESSAGE MessageReply,
|
|
||||||
PLPCMESSAGE MessageRequest);
|
|
||||||
NTSTATUS STDCALL NtRequestPort ( IN HANDLE PortHandle,
|
|
||||||
IN PLPCMESSAGE LpcMessage);
|
|
||||||
NTSTATUS STDCALL NtRequestWaitReplyPort (IN HANDLE PortHandle,
|
|
||||||
IN OUT PLPCMESSAGE LpcReply,
|
|
||||||
OUT PLPCMESSAGE LpcRequest);
|
|
||||||
NTSTATUS
|
|
||||||
STDCALL
|
|
||||||
NtReadRequestData ( /* @24 */
|
|
||||||
DWORD a0,
|
|
||||||
DWORD a1,
|
|
||||||
DWORD a2,
|
|
||||||
DWORD a3,
|
|
||||||
DWORD a4,
|
|
||||||
DWORD a5
|
|
||||||
);
|
|
||||||
NTSTATUS
|
|
||||||
STDCALL
|
|
||||||
NtWriteRequestData ( /* @24 */
|
|
||||||
DWORD a0,
|
|
||||||
DWORD a1,
|
|
||||||
DWORD a2,
|
|
||||||
DWORD a3,
|
|
||||||
DWORD a4,
|
|
||||||
DWORD a5
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
/* --- REGISTRY --- */
|
/* --- REGISTRY --- */
|
||||||
|
|
||||||
|
|
|
@ -1,51 +1,6 @@
|
||||||
#ifndef __INCLUDE_DDK_ZWTYPES_H
|
#ifndef __INCLUDE_DDK_ZWTYPES_H
|
||||||
#define __INCLUDE_DDK_ZWTYPES_H
|
#define __INCLUDE_DDK_ZWTYPES_H
|
||||||
|
|
||||||
#define MAX_MESSAGE_DATA (0x130)
|
|
||||||
|
|
||||||
#define UNUSED_MSG_TYPE (0x0)
|
|
||||||
#define LPC_REQUEST (0x1)
|
|
||||||
#define LPC_REPLY (0x2)
|
|
||||||
#define LPC_DATAGRAM (0x3)
|
|
||||||
#define LPC_LOST_REPLY (0x4)
|
|
||||||
#define LPC_PORT_CLOSED (0x5)
|
|
||||||
#define LPC_CLIENT_DIED (0x6)
|
|
||||||
#define LPC_EXCEPTION (0x7)
|
|
||||||
#define LPC_DEBUG_EVENT (0x8)
|
|
||||||
#define LPC_ERROR_EVENT (0x9)
|
|
||||||
#define LPC_CONNECTION_REQUEST (0xa)
|
|
||||||
#define LPC_CONNECTION_REFUSED (0xb)
|
|
||||||
|
|
||||||
typedef struct _LPCSECTIONINFO
|
|
||||||
{
|
|
||||||
DWORD Length;
|
|
||||||
HANDLE SectionHandle;
|
|
||||||
DWORD Unknown1;
|
|
||||||
DWORD SectionSize;
|
|
||||||
DWORD ClientBaseAddress;
|
|
||||||
DWORD ServerBaseAddress;
|
|
||||||
} LPCSECTION, *PLPCSECTIONINFO;
|
|
||||||
|
|
||||||
typedef struct _LPCSECTIONMAPINFO
|
|
||||||
{
|
|
||||||
DWORD Length;
|
|
||||||
DWORD SectionSize;
|
|
||||||
DWORD ServerBaseAddress;
|
|
||||||
} LPCSECTIONMAPINFO, *PLPCSECTIONMAPINFO;
|
|
||||||
|
|
||||||
typedef struct _LPCMESSAGE
|
|
||||||
{
|
|
||||||
WORD ActualMessageLength;
|
|
||||||
WORD TotalMessageLength;
|
|
||||||
DWORD MessageType;
|
|
||||||
DWORD ClientProcessId;
|
|
||||||
DWORD ClientThreadId;
|
|
||||||
DWORD MessageId;
|
|
||||||
DWORD SharedSectionSize;
|
|
||||||
BYTE MessageData[MAX_MESSAGE_DATA];
|
|
||||||
} LPCMESSAGE, *PLPCMESSAGE;
|
|
||||||
|
|
||||||
|
|
||||||
#define NtCurrentProcess() ( (HANDLE) 0xFFFFFFFF )
|
#define NtCurrentProcess() ( (HANDLE) 0xFFFFFFFF )
|
||||||
#define NtCurrentThread() ( (HANDLE) 0xFFFFFFFE )
|
#define NtCurrentThread() ( (HANDLE) 0xFFFFFFFE )
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,22 @@ enum
|
||||||
MEMORY_AREA_CACHE_SEGMENT,
|
MEMORY_AREA_CACHE_SEGMENT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) ((x) / (4*1024*1024))
|
||||||
|
#define PAGE_TO_SECTION_PAGE_TABLE_OFFSET(x) (((x) % 4*1024*1024) / (4*1024))
|
||||||
|
|
||||||
|
#define NR_SECTION_PAGE_TABLES (1024)
|
||||||
|
#define NR_SECTION_PAGE_ENTRIES (1024)
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
PVOID Pages[NR_SECTION_PAGE_ENTRIES];
|
||||||
|
} SECTION_PAGE_TABLE, *PSECTION_PAGE_TABLE;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
PSECTION_PAGE_TABLE PageTables[NR_SECTION_PAGE_TABLES];
|
||||||
|
} SECTION_PAGE_DIRECTORY, *PSECTION_PAGE_DIRECTORY;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
CSHORT Type;
|
CSHORT Type;
|
||||||
|
@ -36,6 +52,8 @@ typedef struct
|
||||||
PFILE_OBJECT FileObject;
|
PFILE_OBJECT FileObject;
|
||||||
LIST_ENTRY ViewListHead;
|
LIST_ENTRY ViewListHead;
|
||||||
KSPIN_LOCK ViewListLock;
|
KSPIN_LOCK ViewListLock;
|
||||||
|
KMUTEX Lock;
|
||||||
|
SECTION_PAGE_DIRECTORY PageDirectory;
|
||||||
} SECTION_OBJECT, *PSECTION_OBJECT;
|
} SECTION_OBJECT, *PSECTION_OBJECT;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
|
@ -1,8 +1,15 @@
|
||||||
|
#ifndef __INCLUDE_INTERNAL_PORT_H
|
||||||
|
#define __INCLUDE_INTERNAL_PORT_H
|
||||||
|
|
||||||
|
#include <napi/lpc.h>
|
||||||
|
|
||||||
typedef struct _EPORT
|
typedef struct _EPORT
|
||||||
{
|
{
|
||||||
KSPIN_LOCK Lock;
|
KSPIN_LOCK Lock;
|
||||||
KEVENT Event;
|
KEVENT Event;
|
||||||
|
|
||||||
|
ULONG State;
|
||||||
|
|
||||||
struct _EPORT* OtherPort;
|
struct _EPORT* OtherPort;
|
||||||
|
|
||||||
ULONG QueueLength;
|
ULONG QueueLength;
|
||||||
|
@ -15,9 +22,19 @@ typedef struct _EPORT
|
||||||
ULONG MaxConnectInfoLength;
|
ULONG MaxConnectInfoLength;
|
||||||
} EPORT, *PEPORT;
|
} EPORT, *PEPORT;
|
||||||
|
|
||||||
|
typedef struct _EPORT_TERMINATION_REQUEST
|
||||||
|
{
|
||||||
|
LIST_ENTRY ThreadListEntry;
|
||||||
|
PEPORT Port;
|
||||||
|
} EPORT_TERMINATION_REQUEST, *PEPORT_TERMINATION_REQUEST;
|
||||||
|
|
||||||
NTSTATUS STDCALL LpcRequestPort(PEPORT Port,
|
NTSTATUS STDCALL LpcRequestPort(PEPORT Port,
|
||||||
PLPCMESSAGE LpcMessage);
|
PLPC_MESSAGE LpcMessage);
|
||||||
|
NTSTATUS STDCALL LpcSendTerminationPort(PEPORT Port,
|
||||||
|
TIME CreationTime);
|
||||||
|
|
||||||
#define PORT_ALL_ACCESS (0x1)
|
#define PORT_ALL_ACCESS (0x1)
|
||||||
|
|
||||||
extern POBJECT_TYPE ExPortType;
|
extern POBJECT_TYPE ExPortType;
|
||||||
|
|
||||||
|
#endif /* __INCLUDE_INTERNAL_PORT_H */
|
||||||
|
|
129
reactos/include/napi/lpc.h
Normal file
129
reactos/include/napi/lpc.h
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
#ifndef __INCLUDE_NAPI_LPC_H
|
||||||
|
#define __INCLUDE_NAPI_LPC_H
|
||||||
|
|
||||||
|
#include <security.h>
|
||||||
|
|
||||||
|
#define MAX_MESSAGE_DATA (0x130)
|
||||||
|
|
||||||
|
#define UNUSED_MSG_TYPE (0x0)
|
||||||
|
#define LPC_REQUEST (0x1)
|
||||||
|
#define LPC_REPLY (0x2)
|
||||||
|
#define LPC_DATAGRAM (0x3)
|
||||||
|
#define LPC_LOST_REPLY (0x4)
|
||||||
|
#define LPC_PORT_CLOSED (0x5)
|
||||||
|
#define LPC_CLIENT_DIED (0x6)
|
||||||
|
#define LPC_EXCEPTION (0x7)
|
||||||
|
#define LPC_DEBUG_EVENT (0x8)
|
||||||
|
#define LPC_ERROR_EVENT (0x9)
|
||||||
|
#define LPC_CONNECTION_REQUEST (0xa)
|
||||||
|
#define LPC_CONNECTION_REFUSED (0xb)
|
||||||
|
|
||||||
|
typedef struct _LPC_SECTION_WRITE
|
||||||
|
{
|
||||||
|
ULONG Length;
|
||||||
|
HANDLE SectionHandle;
|
||||||
|
ULONG SectionOffset;
|
||||||
|
ULONG ViewSize;
|
||||||
|
PVOID ViewBase;
|
||||||
|
PVOID TargetViewBase;
|
||||||
|
} LPC_SECTION_WRITE, *PLPC_SECTION_WRITE;
|
||||||
|
|
||||||
|
typedef struct _LPC_SECTION_READ
|
||||||
|
{
|
||||||
|
ULONG Length;
|
||||||
|
ULONG ViewSize;
|
||||||
|
PVOID ViewBase;
|
||||||
|
} LPC_SECTION_READ, *PLPC_SECTION_READ;
|
||||||
|
|
||||||
|
typedef struct _LPC_MESSAGE_HEADER
|
||||||
|
{
|
||||||
|
USHORT DataSize;
|
||||||
|
USHORT MessageSize;
|
||||||
|
USHORT MessageType;
|
||||||
|
USHORT VirtualRangesOffset;
|
||||||
|
CLIENT_ID Cid;
|
||||||
|
ULONG MessageId;
|
||||||
|
ULONG SharedSectionSize;
|
||||||
|
} LPC_MESSAGE_HEADER, *PLPC_MESSAGE_HEADER;
|
||||||
|
|
||||||
|
typedef struct _LPC_TERMINATION_MESSAGE
|
||||||
|
{
|
||||||
|
LPC_MESSAGE_HEADER Header;
|
||||||
|
TIME CreationTime;
|
||||||
|
} LPC_TERMINATION_MESSAGE, *PLPC_TERMINATION_MESSAGE;
|
||||||
|
|
||||||
|
typedef LPC_MESSAGE_HEADER LPC_MESSAGE, *PLPC_MESSAGE;
|
||||||
|
|
||||||
|
typedef struct _LPC_MAX_MESSAGE
|
||||||
|
{
|
||||||
|
LPC_MESSAGE_HEADER Header;
|
||||||
|
BYTE Data[MAX_MESSAGE_DATA];
|
||||||
|
} LPC_MAX_MESSAGE, *PLPC_MAX_MESSAGE;
|
||||||
|
|
||||||
|
NTSTATUS STDCALL NtAcceptConnectPort (PHANDLE PortHandle,
|
||||||
|
HANDLE NamedPortHandle,
|
||||||
|
PLPC_MESSAGE ServerReply,
|
||||||
|
BOOLEAN AcceptIt,
|
||||||
|
PLPC_SECTION_WRITE WriteMap,
|
||||||
|
PLPC_SECTION_READ ReadMap);
|
||||||
|
|
||||||
|
NTSTATUS STDCALL NtCompleteConnectPort (HANDLE PortHandle);
|
||||||
|
|
||||||
|
NTSTATUS STDCALL NtConnectPort(PHANDLE PortHandle,
|
||||||
|
PUNICODE_STRING PortName,
|
||||||
|
PSECURITY_QUALITY_OF_SERVICE SecurityQos,
|
||||||
|
PLPC_SECTION_WRITE SectionInfo,
|
||||||
|
PLPC_SECTION_READ MapInfo,
|
||||||
|
PULONG MaxMessageSize,
|
||||||
|
PVOID ConnectInfo,
|
||||||
|
PULONG ConnectInfoLength);
|
||||||
|
|
||||||
|
NTSTATUS STDCALL NtReplyWaitReplyPort (HANDLE PortHandle,
|
||||||
|
PLPC_MESSAGE ReplyMessage);
|
||||||
|
|
||||||
|
NTSTATUS STDCALL NtCreatePort(PHANDLE PortHandle,
|
||||||
|
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
ULONG MaxConnectInfoLength,
|
||||||
|
ULONG MaxDataLength,
|
||||||
|
ULONG Reserved);
|
||||||
|
|
||||||
|
NTSTATUS STDCALL NtImpersonateClientOfPort (HANDLE PortHandle,
|
||||||
|
PLPC_MESSAGE ClientMessage);
|
||||||
|
|
||||||
|
NTSTATUS STDCALL NtListenPort (HANDLE PortHandle,
|
||||||
|
PLPC_MESSAGE LpcMessage);
|
||||||
|
|
||||||
|
NTSTATUS STDCALL NtQueryInformationPort (HANDLE PortHandle,
|
||||||
|
CINT PortInformationClass,
|
||||||
|
PVOID PortInformation,
|
||||||
|
ULONG PortInformationLength,
|
||||||
|
PULONG ReturnLength);
|
||||||
|
NTSTATUS STDCALL NtReplyPort (HANDLE PortHandle,
|
||||||
|
PLPC_MESSAGE LpcReply);
|
||||||
|
NTSTATUS STDCALL NtReplyWaitReceivePort (HANDLE PortHandle,
|
||||||
|
PULONG PortId,
|
||||||
|
PLPC_MESSAGE MessageReply,
|
||||||
|
PLPC_MESSAGE MessageRequest);
|
||||||
|
NTSTATUS STDCALL NtRequestPort (HANDLE PortHandle,
|
||||||
|
PLPC_MESSAGE LpcMessage);
|
||||||
|
|
||||||
|
NTSTATUS STDCALL NtRequestWaitReplyPort (HANDLE PortHandle,
|
||||||
|
PLPC_MESSAGE LpcReply,
|
||||||
|
PLPC_MESSAGE LpcRequest);
|
||||||
|
|
||||||
|
NTSTATUS STDCALL NtReadRequestData (HANDLE PortHandle,
|
||||||
|
PLPC_MESSAGE Message,
|
||||||
|
ULONG Index,
|
||||||
|
PVOID Buffer,
|
||||||
|
ULONG BufferLength,
|
||||||
|
PULONG ReturnLength);
|
||||||
|
|
||||||
|
NTSTATUS STDCALL NtWriteRequestData (HANDLE PortHandle,
|
||||||
|
PLPC_MESSAGE Message,
|
||||||
|
ULONG Index,
|
||||||
|
PVOID Buffer,
|
||||||
|
ULONG BufferLength,
|
||||||
|
PULONG ReturnLength);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __INCLUDE_NAPI_LPC_H */
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: rw.c,v 1.10 2000/03/26 22:00:07 dwelch Exp $
|
/* $Id: rw.c,v 1.11 2000/04/03 21:54:35 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -35,6 +35,8 @@ WINBOOL STDCALL WriteFile(HANDLE hFile,
|
||||||
PIO_STATUS_BLOCK IoStatusBlock;
|
PIO_STATUS_BLOCK IoStatusBlock;
|
||||||
PLARGE_INTEGER ptrOffset;
|
PLARGE_INTEGER ptrOffset;
|
||||||
|
|
||||||
|
DPRINT("WriteFile(hFile %x)\n",hFile);
|
||||||
|
|
||||||
if (IsConsoleHandle(hFile))
|
if (IsConsoleHandle(hFile))
|
||||||
{
|
{
|
||||||
return(WriteConsoleA(hFile,
|
return(WriteConsoleA(hFile,
|
||||||
|
@ -43,9 +45,7 @@ WINBOOL STDCALL WriteFile(HANDLE hFile,
|
||||||
lpNumberOfBytesWritten,
|
lpNumberOfBytesWritten,
|
||||||
NULL));
|
NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("WriteFile(hFile %x)\n",hFile);
|
|
||||||
|
|
||||||
if (lpOverLapped != NULL)
|
if (lpOverLapped != NULL)
|
||||||
{
|
{
|
||||||
Offset.u.LowPart = lpOverLapped->Offset;
|
Offset.u.LowPart = lpOverLapped->Offset;
|
||||||
|
@ -100,6 +100,8 @@ WINBOOL STDCALL ReadFile(HANDLE hFile,
|
||||||
PIO_STATUS_BLOCK IoStatusBlock;
|
PIO_STATUS_BLOCK IoStatusBlock;
|
||||||
PLARGE_INTEGER ptrOffset;
|
PLARGE_INTEGER ptrOffset;
|
||||||
|
|
||||||
|
DbgPrint("ReadFile(hFile %x)\n", hFile);
|
||||||
|
|
||||||
if (IsConsoleHandle(hFile))
|
if (IsConsoleHandle(hFile))
|
||||||
{
|
{
|
||||||
return(ReadConsoleA(hFile,
|
return(ReadConsoleA(hFile,
|
||||||
|
|
|
@ -47,10 +47,13 @@ HANDLE STDCALL GetStdHandle(DWORD nStdHandle)
|
||||||
{
|
{
|
||||||
PRTL_USER_PROCESS_PARAMETERS Ppb;
|
PRTL_USER_PROCESS_PARAMETERS Ppb;
|
||||||
|
|
||||||
DPRINT("GetStdHandle(nStdHandle %d)\n",nStdHandle);
|
// DbgPrint("GetStdHandle(nStdHandle %d)\n",nStdHandle);
|
||||||
|
|
||||||
SetLastError(ERROR_SUCCESS); /* OK */
|
SetLastError(ERROR_SUCCESS); /* OK */
|
||||||
|
// DbgPrint("NtCurrentPeb() %x\n", NtCurrentPeb());
|
||||||
Ppb = NtCurrentPeb()->ProcessParameters;
|
Ppb = NtCurrentPeb()->ProcessParameters;
|
||||||
|
// DbgPrint("Ppb %x\n", Ppb);
|
||||||
|
// DbgPrint("Ppb->OutputHandle %x\n", Ppb->OutputHandle);
|
||||||
switch (nStdHandle)
|
switch (nStdHandle)
|
||||||
{
|
{
|
||||||
case STD_INPUT_HANDLE: return Ppb->InputHandle;
|
case STD_INPUT_HANDLE: return Ppb->InputHandle;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: api.c,v 1.4 2000/03/22 18:35:50 dwelch Exp $
|
/* $Id: api.c,v 1.5 2000/04/03 21:54:36 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -28,21 +28,20 @@ NTSTATUS STDCALL CsrClientCallServer(PCSRSS_API_REQUEST Request,
|
||||||
ULONG Length,
|
ULONG Length,
|
||||||
ULONG ReplyLength)
|
ULONG ReplyLength)
|
||||||
{
|
{
|
||||||
LPCMESSAGE LpcRequest;
|
|
||||||
LPCMESSAGE LpcReply;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
// DbgPrint("Length %d\n", Length);
|
// DbgPrint("CsrClientCallServer(Request %x, Reply %x, Length %d, "
|
||||||
|
// "ReplyLength %d)\n", Request, Reply, Length, ReplyLength);
|
||||||
|
|
||||||
LpcRequest.ActualMessageLength = Length;
|
Request->Header.DataSize = Length;
|
||||||
LpcRequest.TotalMessageLength = sizeof(LPCMESSAGE) + Length;
|
Request->Header.MessageSize = sizeof(LPC_MESSAGE_HEADER) + Length;
|
||||||
memcpy(LpcRequest.MessageData, Request, Length);
|
|
||||||
|
|
||||||
Status = NtRequestWaitReplyPort(WindowsApiPort,
|
Status = NtRequestWaitReplyPort(WindowsApiPort,
|
||||||
&LpcRequest,
|
&Request->Header,
|
||||||
&LpcReply);
|
&Reply->Header);
|
||||||
memcpy(Reply, LpcReply.MessageData, ReplyLength);
|
|
||||||
// DbgPrint("Status %x Reply.Status %x\n", Status, Reply->Status);
|
// DbgPrint("Status %x\n", Status);
|
||||||
|
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -239,12 +239,9 @@ RtlInitializeContext(HANDLE ProcessHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL RtlDestroyUserThreadStack(param1, param2)
|
||||||
RtlDestroyUserThreadStack(param1, param2)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -875,9 +875,9 @@ _to_pmode:
|
||||||
mov ah,12
|
mov ah,12
|
||||||
int 10h
|
int 10h
|
||||||
|
|
||||||
; mov ax,1112h ;! Use 8x8 font
|
mov ax,1112h ;! Use 8x8 font
|
||||||
; xor bl,bl
|
xor bl,bl
|
||||||
; int 10h
|
int 10h
|
||||||
mov ax,1200h ;! Use alternate print screen
|
mov ax,1200h ;! Use alternate print screen
|
||||||
mov bl,20h
|
mov bl,20h
|
||||||
int 10h
|
int 10h
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
#include <napi/lpc.h>
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
/* GLOBALS ******************************************************************/
|
/* GLOBALS ******************************************************************/
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: errlog.c,v 1.4 2000/03/26 19:38:22 ea Exp $
|
/* $Id: errlog.c,v 1.5 2000/04/03 21:54:38 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -36,169 +36,13 @@ typedef struct _IO_ERROR_LOG_PACKET
|
||||||
ULONG DumpData[1];
|
ULONG DumpData[1];
|
||||||
} IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET;
|
} IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET;
|
||||||
|
|
||||||
typedef struct _ERROR_LOG_MESSAGE
|
|
||||||
{
|
|
||||||
PIO_ERROR_LOG_PACKET Packet;
|
|
||||||
LIST_ENTRY ListEntry;
|
|
||||||
} IO_ERROR_LOG_MESSAGE, *PIO_ERROR_LOG_MESSAGE;
|
|
||||||
|
|
||||||
/* GLOBALS *******************************************************************/
|
|
||||||
|
|
||||||
static HANDLE ErrorLogPortHandle;
|
|
||||||
static HANDLE ErrorLogThreadHandle;
|
|
||||||
static PEPORT ErrorLogPort;
|
|
||||||
|
|
||||||
static LIST_ENTRY ErrorLogListHead;
|
|
||||||
static KSPIN_LOCK ErrorLogListLock;
|
|
||||||
static KSEMAPHORE ErrorLogSemaphore;
|
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
static VOID IoSendErrorLogEntry(PIO_ERROR_LOG_PACKET Packet)
|
|
||||||
{
|
|
||||||
LPCMESSAGE Message;
|
|
||||||
ULONG Size;
|
|
||||||
ULONG i;
|
|
||||||
|
|
||||||
Size = sizeof(IO_ERROR_LOG_PACKET) +
|
|
||||||
(Packet->DumpDataSize * sizeof(UCHAR));
|
|
||||||
|
|
||||||
for (i=0; i<((Size % MAX_MESSAGE_DATA) - 1); i++)
|
|
||||||
{
|
|
||||||
Message.ActualMessageLength = MAX_MESSAGE_DATA;
|
|
||||||
Message.TotalMessageLength = sizeof(LPCMESSAGE);
|
|
||||||
Message.MessageType = i;
|
|
||||||
memcpy(Message.MessageData, (PVOID)Packet, MAX_MESSAGE_DATA);
|
|
||||||
LpcRequestPort(ErrorLogPort, &Message);
|
|
||||||
}
|
|
||||||
Message.ActualMessageLength = MAX_MESSAGE_DATA;
|
|
||||||
Message.TotalMessageLength = sizeof(LPCMESSAGE);
|
|
||||||
Message.MessageType = i;
|
|
||||||
memcpy(Message.MessageData, (PVOID)Packet, Size % MAX_MESSAGE_DATA);
|
|
||||||
LpcRequestPort(ErrorLogPort, &Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS IoErrorLogThreadMain(PVOID Context)
|
|
||||||
{
|
|
||||||
NTSTATUS Status;
|
|
||||||
LPCMESSAGE ConnectMsg;
|
|
||||||
HANDLE PortHandle;
|
|
||||||
PIO_ERROR_LOG_MESSAGE Message;
|
|
||||||
KIRQL oldIrql;
|
|
||||||
PLIST_ENTRY ListEntry;
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
Status = NtListenPort(ErrorLogPortHandle, &ConnectMsg);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = NtAcceptConnectPort(&PortHandle,
|
|
||||||
ErrorLogPortHandle,
|
|
||||||
NULL,
|
|
||||||
1,
|
|
||||||
0,
|
|
||||||
NULL);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = NtCompleteConnectPort(PortHandle);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = ObReferenceObjectByHandle(PortHandle,
|
|
||||||
PORT_ALL_ACCESS,
|
|
||||||
ExPortType,
|
|
||||||
UserMode,
|
|
||||||
(PVOID*)&ErrorLogPort,
|
|
||||||
NULL);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
ZwClose(PortHandle);
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
ZwClose(PortHandle);
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
|
|
||||||
KeWaitForSingleObject(&ErrorLogSemaphore,
|
|
||||||
UserRequest,
|
|
||||||
KernelMode,
|
|
||||||
FALSE,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
KeAcquireSpinLock(&ErrorLogListLock, &oldIrql);
|
|
||||||
|
|
||||||
ListEntry = RemoveHeadList(&ErrorLogListHead);
|
|
||||||
|
|
||||||
KeReleaseSpinLock(&ErrorLogListLock, oldIrql);
|
|
||||||
|
|
||||||
Message = CONTAINING_RECORD(ListEntry,
|
|
||||||
IO_ERROR_LOG_MESSAGE,
|
|
||||||
ListEntry);
|
|
||||||
|
|
||||||
IoSendErrorLogEntry(Message->Packet);
|
|
||||||
|
|
||||||
ExFreePool(Message->Packet);
|
|
||||||
ExFreePool(Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS IoInitErrorLog(VOID)
|
NTSTATUS IoInitErrorLog(VOID)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
||||||
UNICODE_STRING PortName;
|
|
||||||
CLIENT_ID Cid;
|
|
||||||
|
|
||||||
InitializeListHead(&ErrorLogListHead);
|
|
||||||
KeInitializeSpinLock(&ErrorLogListLock);
|
|
||||||
|
|
||||||
KeInitializeSemaphore(&ErrorLogSemaphore,
|
|
||||||
0,
|
|
||||||
500);
|
|
||||||
|
|
||||||
RtlInitUnicodeString(&PortName, L"\\ErrorLogPort");
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
|
||||||
&PortName,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
Status = NtCreatePort(&ErrorLogPortHandle,
|
|
||||||
&ObjectAttributes,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = PsCreateSystemThread(ErrorLogThreadHandle,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
&Cid,
|
|
||||||
IoErrorLogThreadMain,
|
|
||||||
NULL);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PVOID STDCALL IoAllocateErrorLogEntry(PVOID IoObject, UCHAR EntrySize)
|
PVOID STDCALL IoAllocateErrorLogEntry(PVOID IoObject, UCHAR EntrySize)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
|
@ -206,22 +50,6 @@ PVOID STDCALL IoAllocateErrorLogEntry(PVOID IoObject, UCHAR EntrySize)
|
||||||
|
|
||||||
VOID STDCALL IoWriteErrorLogEntry(PVOID ElEntry)
|
VOID STDCALL IoWriteErrorLogEntry(PVOID ElEntry)
|
||||||
{
|
{
|
||||||
KIRQL oldIrql;
|
|
||||||
PIO_ERROR_LOG_MESSAGE Message;
|
|
||||||
|
|
||||||
Message = ExAllocatePool(NonPagedPool, sizeof(IO_ERROR_LOG_MESSAGE));
|
|
||||||
Message->Packet = (PIO_ERROR_LOG_PACKET)ElEntry;
|
|
||||||
|
|
||||||
KeAcquireSpinLock(&ErrorLogListLock, &oldIrql);
|
|
||||||
|
|
||||||
InsertTailList(&ErrorLogListHead, &Message->ListEntry);
|
|
||||||
|
|
||||||
KeReleaseSemaphore(&ErrorLogSemaphore,
|
|
||||||
IO_NO_INCREMENT,
|
|
||||||
1,
|
|
||||||
FALSE);
|
|
||||||
|
|
||||||
KeReleaseSpinLock(&ErrorLogListLock, oldIrql);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: section.c,v 1.27 2000/04/02 13:32:41 ea Exp $
|
/* $Id: section.c,v 1.28 2000/04/03 21:54:39 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -27,6 +27,45 @@ POBJECT_TYPE EXPORTED MmSectionObjectType = NULL;
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
VOID MmSetPageEntrySection(PSECTION_OBJECT Section,
|
||||||
|
ULONG Offset,
|
||||||
|
PVOID Entry)
|
||||||
|
{
|
||||||
|
PSECTION_PAGE_TABLE Table;
|
||||||
|
ULONG DirectoryOffset;
|
||||||
|
ULONG TableOffset;
|
||||||
|
|
||||||
|
DirectoryOffset = PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(Offset);
|
||||||
|
Table = Section->PageDirectory.PageTables[DirectoryOffset];
|
||||||
|
if (Table == NULL)
|
||||||
|
{
|
||||||
|
Table =
|
||||||
|
Section->PageDirectory.PageTables[DirectoryOffset] =
|
||||||
|
ExAllocatePool(NonPagedPool, sizeof(SECTION_PAGE_TABLE));
|
||||||
|
}
|
||||||
|
TableOffset = PAGE_TO_SECTION_PAGE_TABLE_OFFSET(Offset);
|
||||||
|
Table->Pages[TableOffset] = Entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
PVOID MmGetPageEntrySection(PSECTION_OBJECT Section,
|
||||||
|
ULONG Offset)
|
||||||
|
{
|
||||||
|
PSECTION_PAGE_TABLE Table;
|
||||||
|
PVOID Entry;
|
||||||
|
ULONG DirectoryOffset;
|
||||||
|
ULONG TableOffset;
|
||||||
|
|
||||||
|
DirectoryOffset = PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(Offset);
|
||||||
|
Table = Section->PageDirectory.PageTables[DirectoryOffset];
|
||||||
|
if (Table == NULL)
|
||||||
|
{
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
TableOffset = PAGE_TO_SECTION_PAGE_TABLE_OFFSET(Offset);
|
||||||
|
Entry = Table->Pages[TableOffset];
|
||||||
|
return(Entry);
|
||||||
|
}
|
||||||
|
|
||||||
PVOID MiTryToSharePageInSection(PSECTION_OBJECT Section,
|
PVOID MiTryToSharePageInSection(PSECTION_OBJECT Section,
|
||||||
ULONG Offset)
|
ULONG Offset)
|
||||||
{
|
{
|
||||||
|
@ -72,6 +111,14 @@ PVOID MiTryToSharePageInSection(PSECTION_OBJECT Section,
|
||||||
|
|
||||||
VOID MmpDeleteSection(PVOID ObjectBody)
|
VOID MmpDeleteSection(PVOID ObjectBody)
|
||||||
{
|
{
|
||||||
|
DPRINT1("MmpDeleteSection(ObjectBody %x)\n", ObjectBody);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID MmpCloseSection(PVOID ObjectBody,
|
||||||
|
ULONG HandleCount)
|
||||||
|
{
|
||||||
|
DPRINT1("MmpCloseSection(OB %x, HC %d) RC %d\n",
|
||||||
|
ObjectBody, HandleCount, ObGetReferenceCount(ObjectBody));
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS MmpCreateSection(PVOID ObjectBody,
|
NTSTATUS MmpCreateSection(PVOID ObjectBody,
|
||||||
|
@ -111,10 +158,10 @@ NTSTATUS MmpCreateSection(PVOID ObjectBody,
|
||||||
|
|
||||||
NTSTATUS MmInitSectionImplementation(VOID)
|
NTSTATUS MmInitSectionImplementation(VOID)
|
||||||
{
|
{
|
||||||
ANSI_STRING AnsiString;
|
|
||||||
|
|
||||||
MmSectionObjectType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE));
|
MmSectionObjectType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE));
|
||||||
|
|
||||||
|
RtlInitUnicodeString(&MmSectionObjectType->TypeName, L"Section");
|
||||||
|
|
||||||
MmSectionObjectType->TotalObjects = 0;
|
MmSectionObjectType->TotalObjects = 0;
|
||||||
MmSectionObjectType->TotalHandles = 0;
|
MmSectionObjectType->TotalHandles = 0;
|
||||||
MmSectionObjectType->MaxObjects = ULONG_MAX;
|
MmSectionObjectType->MaxObjects = ULONG_MAX;
|
||||||
|
@ -123,7 +170,7 @@ NTSTATUS MmInitSectionImplementation(VOID)
|
||||||
MmSectionObjectType->NonpagedPoolCharge = sizeof(SECTION_OBJECT);
|
MmSectionObjectType->NonpagedPoolCharge = sizeof(SECTION_OBJECT);
|
||||||
MmSectionObjectType->Dump = NULL;
|
MmSectionObjectType->Dump = NULL;
|
||||||
MmSectionObjectType->Open = NULL;
|
MmSectionObjectType->Open = NULL;
|
||||||
MmSectionObjectType->Close = NULL;
|
MmSectionObjectType->Close = MmpCloseSection;
|
||||||
MmSectionObjectType->Delete = MmpDeleteSection;
|
MmSectionObjectType->Delete = MmpDeleteSection;
|
||||||
MmSectionObjectType->Parse = NULL;
|
MmSectionObjectType->Parse = NULL;
|
||||||
MmSectionObjectType->Security = NULL;
|
MmSectionObjectType->Security = NULL;
|
||||||
|
@ -131,9 +178,6 @@ NTSTATUS MmInitSectionImplementation(VOID)
|
||||||
MmSectionObjectType->OkayToClose = NULL;
|
MmSectionObjectType->OkayToClose = NULL;
|
||||||
MmSectionObjectType->Create = MmpCreateSection;
|
MmSectionObjectType->Create = MmpCreateSection;
|
||||||
|
|
||||||
RtlInitAnsiString(&AnsiString,"Section");
|
|
||||||
RtlAnsiStringToUnicodeString(&MmSectionObjectType->TypeName,
|
|
||||||
&AnsiString,TRUE);
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,6 +492,10 @@ NTSTATUS STDCALL MmUnmapViewOfSection(PEPROCESS Process,
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
|
|
||||||
Section = MemoryArea->Data.SectionData.Section;
|
Section = MemoryArea->Data.SectionData.Section;
|
||||||
|
|
||||||
|
DPRINT1("MmUnmapViewOfSection(Section %x) SectionRC %d\n",
|
||||||
|
Section, ObGetReferenceCount(Section));
|
||||||
|
|
||||||
KeAcquireSpinLock(&Section->ViewListLock, &oldIrql);
|
KeAcquireSpinLock(&Section->ViewListLock, &oldIrql);
|
||||||
RemoveEntryList(&MemoryArea->Data.SectionData.ViewListEntry);
|
RemoveEntryList(&MemoryArea->Data.SectionData.ViewListEntry);
|
||||||
KeReleaseSpinLock(&Section->ViewListLock, oldIrql);
|
KeReleaseSpinLock(&Section->ViewListLock, oldIrql);
|
||||||
|
|
|
@ -1,23 +1,14 @@
|
||||||
/* $Id: port.c,v 1.17 2000/01/26 10:07:28 dwelch Exp $
|
/* $Id: port.c,v 1.18 2000/04/03 21:54:39 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/nt/port.c
|
* FILE: ntoskrnl/nt/port.c
|
||||||
* PURPOSE: Communication mechanism (like Mach?)
|
* PURPOSE: Communication mechanism
|
||||||
* PROGRAMMER: David Welch (welch@cwcom.net)
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* NOTES ********************************************************************
|
|
||||||
*
|
|
||||||
* This is a very rough implementation, not compatible with mach or nt
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
@ -37,7 +28,9 @@
|
||||||
#define EPORT_WAIT_FOR_ACCEPT (2)
|
#define EPORT_WAIT_FOR_ACCEPT (2)
|
||||||
#define EPORT_WAIT_FOR_COMPLETE_SRV (3)
|
#define EPORT_WAIT_FOR_COMPLETE_SRV (3)
|
||||||
#define EPORT_WAIT_FOR_COMPLETE_CLT (4)
|
#define EPORT_WAIT_FOR_COMPLETE_CLT (4)
|
||||||
#define EPORT_CONNECTED (5)
|
#define EPORT_CONNECTED_CLIENT (5)
|
||||||
|
#define EPORT_CONNECTED_SERVER (6)
|
||||||
|
#define EPORT_DISCONNECTED (7)
|
||||||
|
|
||||||
struct _EPORT;
|
struct _EPORT;
|
||||||
|
|
||||||
|
@ -45,7 +38,8 @@ typedef struct _QUEUEDMESSAGE
|
||||||
{
|
{
|
||||||
struct _EPORT* Sender;
|
struct _EPORT* Sender;
|
||||||
LIST_ENTRY QueueListEntry;
|
LIST_ENTRY QueueListEntry;
|
||||||
LPCMESSAGE Message;
|
LPC_MESSAGE Message;
|
||||||
|
UCHAR MessageData[MAX_MESSAGE_DATA];
|
||||||
} QUEUEDMESSAGE, *PQUEUEDMESSAGE;
|
} QUEUEDMESSAGE, *PQUEUEDMESSAGE;
|
||||||
|
|
||||||
/* GLOBALS *******************************************************************/
|
/* GLOBALS *******************************************************************/
|
||||||
|
@ -92,7 +86,7 @@ PQUEUEDMESSAGE EiDequeueConnectMessagePort(PEPORT Port)
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS EiReplyOrRequestPort(PEPORT Port,
|
NTSTATUS EiReplyOrRequestPort(PEPORT Port,
|
||||||
PLPCMESSAGE LpcReply,
|
PLPC_MESSAGE LpcReply,
|
||||||
ULONG MessageType,
|
ULONG MessageType,
|
||||||
PEPORT Sender)
|
PEPORT Sender)
|
||||||
{
|
{
|
||||||
|
@ -104,11 +98,11 @@ NTSTATUS EiReplyOrRequestPort(PEPORT Port,
|
||||||
|
|
||||||
if (LpcReply != NULL)
|
if (LpcReply != NULL)
|
||||||
{
|
{
|
||||||
memcpy(&MessageReply->Message, LpcReply, sizeof(LPCMESSAGE));
|
memcpy(&MessageReply->Message, LpcReply, LpcReply->MessageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageReply->Message.ClientProcessId = (DWORD)PsGetCurrentProcessId();
|
MessageReply->Message.Cid.UniqueProcess = PsGetCurrentProcessId();
|
||||||
MessageReply->Message.ClientThreadId = (DWORD)PsGetCurrentThreadId();
|
MessageReply->Message.Cid.UniqueThread = PsGetCurrentThreadId();
|
||||||
MessageReply->Message.MessageType = MessageType;
|
MessageReply->Message.MessageType = MessageType;
|
||||||
MessageReply->Message.MessageId = InterlockedIncrement(&EiNextLpcMessageId);
|
MessageReply->Message.MessageId = InterlockedIncrement(&EiNextLpcMessageId);
|
||||||
|
|
||||||
|
@ -119,9 +113,51 @@ NTSTATUS EiReplyOrRequestPort(PEPORT Port,
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID NiClosePort(PVOID ObjectBody,
|
||||||
|
ULONG HandleCount)
|
||||||
|
{
|
||||||
|
PEPORT Port = (PEPORT)ObjectBody;
|
||||||
|
LPC_MESSAGE Message;
|
||||||
|
|
||||||
|
// DPRINT1("NiClosePort(ObjectBody %x, HandleCount %d) RefCount %d\n",
|
||||||
|
// ObjectBody, HandleCount, ObGetReferenceCount(Port));
|
||||||
|
|
||||||
|
if (HandleCount == 0 &&
|
||||||
|
Port->State == EPORT_CONNECTED_CLIENT &&
|
||||||
|
ObGetReferenceCount(Port) == 2)
|
||||||
|
{
|
||||||
|
// DPRINT1("All handles closed to client port\n");
|
||||||
|
|
||||||
|
Message.MessageSize = sizeof(LPC_MESSAGE);
|
||||||
|
Message.DataSize = 0;
|
||||||
|
|
||||||
|
EiReplyOrRequestPort(Port->OtherPort,
|
||||||
|
&Message,
|
||||||
|
LPC_PORT_CLOSED,
|
||||||
|
Port);
|
||||||
|
KeSetEvent(&Port->OtherPort->Event, IO_NO_INCREMENT, FALSE);
|
||||||
|
|
||||||
|
Port->OtherPort->OtherPort = NULL;
|
||||||
|
Port->OtherPort->State = EPORT_DISCONNECTED;
|
||||||
|
ObDereferenceObject(Port);
|
||||||
|
}
|
||||||
|
if (HandleCount == 0 &&
|
||||||
|
Port->State == EPORT_CONNECTED_SERVER &&
|
||||||
|
ObGetReferenceCount(Port) == 2)
|
||||||
|
{
|
||||||
|
// DPRINT("All handles closed to server\n");
|
||||||
|
|
||||||
|
Port->OtherPort->OtherPort = NULL;
|
||||||
|
Port->OtherPort->State = EPORT_DISCONNECTED;
|
||||||
|
ObDereferenceObject(Port->OtherPort);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VOID NiDeletePort(PVOID ObjectBody)
|
VOID NiDeletePort(PVOID ObjectBody)
|
||||||
{
|
{
|
||||||
|
// PEPORT Port = (PEPORT)ObjectBody;
|
||||||
|
|
||||||
|
// DPRINT1("Deleting port %x\n", Port);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS NiCreatePort(PVOID ObjectBody,
|
NTSTATUS NiCreatePort(PVOID ObjectBody,
|
||||||
|
@ -170,7 +206,7 @@ NTSTATUS NiInitPort(VOID)
|
||||||
ExPortType->NonpagedPoolCharge = sizeof(EPORT);
|
ExPortType->NonpagedPoolCharge = sizeof(EPORT);
|
||||||
ExPortType->Dump = NULL;
|
ExPortType->Dump = NULL;
|
||||||
ExPortType->Open = NULL;
|
ExPortType->Open = NULL;
|
||||||
ExPortType->Close = NULL;
|
ExPortType->Close = NiClosePort;
|
||||||
ExPortType->Delete = NiDeletePort;
|
ExPortType->Delete = NiDeletePort;
|
||||||
ExPortType->Parse = NULL;
|
ExPortType->Parse = NULL;
|
||||||
ExPortType->Security = NULL;
|
ExPortType->Security = NULL;
|
||||||
|
@ -191,6 +227,7 @@ static NTSTATUS NiInitializePort(PEPORT Port)
|
||||||
Port->OtherPort = NULL;
|
Port->OtherPort = NULL;
|
||||||
Port->QueueLength = 0;
|
Port->QueueLength = 0;
|
||||||
Port->ConnectQueueLength = 0;
|
Port->ConnectQueueLength = 0;
|
||||||
|
Port->State = EPORT_INACTIVE;
|
||||||
InitializeListHead(&Port->QueueListHead);
|
InitializeListHead(&Port->QueueListHead);
|
||||||
InitializeListHead(&Port->ConnectQueueListHead);
|
InitializeListHead(&Port->ConnectQueueListHead);
|
||||||
|
|
||||||
|
@ -201,7 +238,7 @@ NTSTATUS STDCALL NtCreatePort(PHANDLE PortHandle,
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes,
|
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
ULONG MaxConnectInfoLength,
|
ULONG MaxConnectInfoLength,
|
||||||
ULONG MaxDataLength,
|
ULONG MaxDataLength,
|
||||||
ULONG Unknown1)
|
ULONG Reserved)
|
||||||
{
|
{
|
||||||
PEPORT Port;
|
PEPORT Port;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -221,17 +258,19 @@ NTSTATUS STDCALL NtCreatePort(PHANDLE PortHandle,
|
||||||
Port->MaxConnectInfoLength = 260;
|
Port->MaxConnectInfoLength = 260;
|
||||||
Port->MaxDataLength = 328;
|
Port->MaxDataLength = 328;
|
||||||
|
|
||||||
|
ObDereferenceObject(Port);
|
||||||
|
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtConnectPort (OUT PHANDLE ConnectedPort,
|
NTSTATUS STDCALL NtConnectPort (PHANDLE ConnectedPort,
|
||||||
IN PUNICODE_STRING PortName,
|
PUNICODE_STRING PortName,
|
||||||
IN PVOID Unknown1,
|
PSECURITY_QUALITY_OF_SERVICE Qos,
|
||||||
IN PLPCSECTIONINFO SectionInfo,
|
PLPC_SECTION_WRITE WriteMap,
|
||||||
IN PLPCSECTIONMAPINFO MapInfo,
|
PLPC_SECTION_READ ReadMap,
|
||||||
IN PVOID Unknown2,
|
PULONG MaxMessageSize,
|
||||||
IN PVOID ConnectInfo,
|
PVOID ConnectInfo,
|
||||||
IN PULONG uConnectInfoLength)
|
PULONG UserConnectInfoLength)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Connect to a named port and wait for the other side to
|
* FUNCTION: Connect to a named port and wait for the other side to
|
||||||
* accept the connection
|
* accept the connection
|
||||||
|
@ -241,7 +280,7 @@ NTSTATUS STDCALL NtConnectPort (OUT PHANDLE ConnectedPort,
|
||||||
PEPORT NamedPort;
|
PEPORT NamedPort;
|
||||||
PEPORT OurPort;
|
PEPORT OurPort;
|
||||||
HANDLE OurPortHandle;
|
HANDLE OurPortHandle;
|
||||||
LPCMESSAGE Request;
|
PLPC_MESSAGE Request;
|
||||||
PQUEUEDMESSAGE Reply;
|
PQUEUEDMESSAGE Reply;
|
||||||
ULONG ConnectInfoLength;
|
ULONG ConnectInfoLength;
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
|
@ -252,7 +291,9 @@ NTSTATUS STDCALL NtConnectPort (OUT PHANDLE ConnectedPort,
|
||||||
/*
|
/*
|
||||||
* Copy in user parameters
|
* Copy in user parameters
|
||||||
*/
|
*/
|
||||||
memcpy(&ConnectInfoLength, uConnectInfoLength, sizeof(*uConnectInfoLength));
|
memcpy(&ConnectInfoLength,
|
||||||
|
UserConnectInfoLength,
|
||||||
|
sizeof(*UserConnectInfoLength));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get access to the port
|
* Get access to the port
|
||||||
|
@ -285,12 +326,15 @@ NTSTATUS STDCALL NtConnectPort (OUT PHANDLE ConnectedPort,
|
||||||
*/
|
*/
|
||||||
DPRINT("Creating request message\n");
|
DPRINT("Creating request message\n");
|
||||||
|
|
||||||
Request.ActualMessageLength = ConnectInfoLength;
|
Request = ExAllocatePool(NonPagedPool,
|
||||||
Request.TotalMessageLength = sizeof(LPCMESSAGE) + ConnectInfoLength;
|
sizeof(LPC_MESSAGE) + ConnectInfoLength);
|
||||||
Request.SharedSectionSize = 0;
|
|
||||||
|
Request->DataSize = ConnectInfoLength;
|
||||||
|
Request->MessageSize = sizeof(LPC_MESSAGE) + ConnectInfoLength;
|
||||||
|
Request->SharedSectionSize = 0;
|
||||||
if (ConnectInfo != NULL && ConnectInfoLength > 0)
|
if (ConnectInfo != NULL && ConnectInfoLength > 0)
|
||||||
{
|
{
|
||||||
memcpy(Request.MessageData, ConnectInfo, ConnectInfoLength);
|
memcpy((PVOID)(Request + 1), ConnectInfo, ConnectInfoLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -298,7 +342,7 @@ NTSTATUS STDCALL NtConnectPort (OUT PHANDLE ConnectedPort,
|
||||||
*/
|
*/
|
||||||
DPRINT("Queuing message\n");
|
DPRINT("Queuing message\n");
|
||||||
|
|
||||||
EiReplyOrRequestPort(NamedPort, &Request, LPC_CONNECTION_REQUEST, OurPort);
|
EiReplyOrRequestPort(NamedPort, Request, LPC_CONNECTION_REQUEST, OurPort);
|
||||||
KeSetEvent(&NamedPort->Event, IO_NO_INCREMENT, FALSE);
|
KeSetEvent(&NamedPort->Event, IO_NO_INCREMENT, FALSE);
|
||||||
|
|
||||||
DPRINT("Waiting for connection completion\n");
|
DPRINT("Waiting for connection completion\n");
|
||||||
|
@ -316,19 +360,25 @@ NTSTATUS STDCALL NtConnectPort (OUT PHANDLE ConnectedPort,
|
||||||
KeAcquireSpinLock(&OurPort->Lock, &oldIrql);
|
KeAcquireSpinLock(&OurPort->Lock, &oldIrql);
|
||||||
Reply = EiDequeueMessagePort(OurPort);
|
Reply = EiDequeueMessagePort(OurPort);
|
||||||
KeReleaseSpinLock(&OurPort->Lock, oldIrql);
|
KeReleaseSpinLock(&OurPort->Lock, oldIrql);
|
||||||
memcpy(ConnectInfo, Reply->Message.MessageData,
|
memcpy(ConnectInfo,
|
||||||
Reply->Message.ActualMessageLength);
|
Reply->MessageData,
|
||||||
*uConnectInfoLength = Reply->Message.ActualMessageLength;
|
Reply->Message.DataSize);
|
||||||
|
*UserConnectInfoLength = Reply->Message.DataSize;
|
||||||
|
|
||||||
if (Reply->Message.MessageType == LPC_CONNECTION_REFUSED)
|
if (Reply->Message.MessageType == LPC_CONNECTION_REFUSED)
|
||||||
{
|
{
|
||||||
|
ObDereferenceObject(NamedPort);
|
||||||
|
ObDereferenceObject(OurPort);
|
||||||
ZwClose(OurPortHandle);
|
ZwClose(OurPortHandle);
|
||||||
|
ExFreePool(Request);
|
||||||
ExFreePool(Reply);
|
ExFreePool(Reply);
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
|
|
||||||
*ConnectedPort = OurPortHandle;
|
OurPort->State = EPORT_CONNECTED_CLIENT;
|
||||||
|
*ConnectedPort = OurPortHandle;
|
||||||
ExFreePool(Reply);
|
ExFreePool(Reply);
|
||||||
|
ExFreePool(Request);
|
||||||
|
|
||||||
DPRINT("Exited successfully\n");
|
DPRINT("Exited successfully\n");
|
||||||
|
|
||||||
|
@ -338,10 +388,10 @@ NTSTATUS STDCALL NtConnectPort (OUT PHANDLE ConnectedPort,
|
||||||
|
|
||||||
NTSTATUS STDCALL NtAcceptConnectPort (PHANDLE ServerPortHandle,
|
NTSTATUS STDCALL NtAcceptConnectPort (PHANDLE ServerPortHandle,
|
||||||
HANDLE NamedPortHandle,
|
HANDLE NamedPortHandle,
|
||||||
PLPCMESSAGE LpcMessage,
|
PLPC_MESSAGE LpcMessage,
|
||||||
ULONG AcceptIt,
|
BOOLEAN AcceptIt,
|
||||||
ULONG Unknown2,
|
PLPC_SECTION_WRITE WriteMap,
|
||||||
PLPCSECTIONMAPINFO MapInfo)
|
PLPC_SECTION_READ ReadMap)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PEPORT NamedPort;
|
PEPORT NamedPort;
|
||||||
|
@ -386,7 +436,8 @@ NTSTATUS STDCALL NtAcceptConnectPort (PHANDLE ServerPortHandle,
|
||||||
LPC_CONNECTION_REFUSED,
|
LPC_CONNECTION_REFUSED,
|
||||||
NamedPort);
|
NamedPort);
|
||||||
KeSetEvent(&ConnectionRequest->Sender->Event, IO_NO_INCREMENT, FALSE);
|
KeSetEvent(&ConnectionRequest->Sender->Event, IO_NO_INCREMENT, FALSE);
|
||||||
ExFreePool(ConnectionRequest);
|
ObDereferenceObject(ConnectionRequest->Sender);
|
||||||
|
ExFreePool(ConnectionRequest);
|
||||||
ObDereferenceObject(NamedPort);
|
ObDereferenceObject(NamedPort);
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -402,6 +453,7 @@ NTSTATUS STDCALL NtAcceptConnectPort (PHANDLE ServerPortHandle,
|
||||||
OurPort);
|
OurPort);
|
||||||
ExFreePool(ConnectionRequest);
|
ExFreePool(ConnectionRequest);
|
||||||
|
|
||||||
|
ObDereferenceObject(OurPort);
|
||||||
ObDereferenceObject(NamedPort);
|
ObDereferenceObject(NamedPort);
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
|
@ -428,20 +480,22 @@ NTSTATUS STDCALL NtCompleteConnectPort (HANDLE PortHandle)
|
||||||
|
|
||||||
KeSetEvent(&OurPort->OtherPort->Event, IO_NO_INCREMENT, FALSE);
|
KeSetEvent(&OurPort->OtherPort->Event, IO_NO_INCREMENT, FALSE);
|
||||||
|
|
||||||
|
OurPort->State = EPORT_CONNECTED_SERVER;
|
||||||
|
|
||||||
ObDereferenceObject(OurPort);
|
ObDereferenceObject(OurPort);
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtImpersonateClientOfPort (IN HANDLE PortHandle,
|
NTSTATUS STDCALL NtImpersonateClientOfPort (HANDLE PortHandle,
|
||||||
IN PLPCMESSAGE ClientMessage)
|
PLPC_MESSAGE ClientMessage)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL NtListenPort (IN HANDLE PortHandle,
|
NTSTATUS STDCALL NtListenPort (IN HANDLE PortHandle,
|
||||||
IN PLPCMESSAGE ConnectMsg)
|
IN PLPC_MESSAGE ConnectMsg)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Listen on a named port and wait for a connection attempt
|
* FUNCTION: Listen on a named port and wait for a connection attempt
|
||||||
*/
|
*/
|
||||||
|
@ -466,17 +520,17 @@ NTSTATUS STDCALL NtListenPort (IN HANDLE PortHandle,
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL NtQueryInformationPort (IN HANDLE PortHandle,
|
NTSTATUS STDCALL NtQueryInformationPort (IN HANDLE PortHandle,
|
||||||
IN CINT PortInformationClass, /* guess */
|
IN CINT PortInformationClass,
|
||||||
OUT PVOID PortInformation, /* guess */
|
OUT PVOID PortInformation,
|
||||||
IN ULONG PortInformationLength, /* guess */
|
IN ULONG PortInformationLength,
|
||||||
OUT PULONG ReturnLength /* guess */)
|
OUT PULONG ReturnLength)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL NtReplyPort (IN HANDLE PortHandle,
|
NTSTATUS STDCALL NtReplyPort (IN HANDLE PortHandle,
|
||||||
IN PLPCMESSAGE LpcReply)
|
IN PLPC_MESSAGE LpcReply)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PEPORT Port;
|
PEPORT Port;
|
||||||
|
@ -507,10 +561,10 @@ NTSTATUS STDCALL NtReplyPort (IN HANDLE PortHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL NtReplyWaitReceivePort (IN HANDLE PortHandle,
|
NTSTATUS STDCALL NtReplyWaitReceivePort (HANDLE PortHandle,
|
||||||
PVOID Unknown,
|
PULONG PortId,
|
||||||
IN PLPCMESSAGE LpcReply,
|
PLPC_MESSAGE LpcReply,
|
||||||
OUT PLPCMESSAGE LpcMessage)
|
PLPC_MESSAGE LpcMessage)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PEPORT Port;
|
PEPORT Port;
|
||||||
|
@ -566,7 +620,7 @@ NTSTATUS STDCALL NtReplyWaitReceivePort (IN HANDLE PortHandle,
|
||||||
*/
|
*/
|
||||||
KeAcquireSpinLock(&Port->Lock, &oldIrql);
|
KeAcquireSpinLock(&Port->Lock, &oldIrql);
|
||||||
Request = EiDequeueMessagePort(Port);
|
Request = EiDequeueMessagePort(Port);
|
||||||
memcpy(LpcMessage, &Request->Message, sizeof(*LpcMessage));
|
memcpy(LpcMessage, &Request->Message, Request->Message.MessageSize);
|
||||||
if (Request->Message.MessageType == LPC_CONNECTION_REQUEST)
|
if (Request->Message.MessageType == LPC_CONNECTION_REQUEST)
|
||||||
{
|
{
|
||||||
EiEnqueueConnectMessagePort(Port, Request);
|
EiEnqueueConnectMessagePort(Port, Request);
|
||||||
|
@ -585,8 +639,23 @@ NTSTATUS STDCALL NtReplyWaitReceivePort (IN HANDLE PortHandle,
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL LpcSendTerminationPort(PEPORT Port,
|
||||||
|
TIME CreationTime)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
LPC_TERMINATION_MESSAGE Msg;
|
||||||
|
|
||||||
|
Msg.CreationTime = CreationTime;
|
||||||
|
Status = EiReplyOrRequestPort(Port,
|
||||||
|
&Msg.Header,
|
||||||
|
LPC_DATAGRAM,
|
||||||
|
NULL);
|
||||||
|
KeSetEvent(&Port->Event, IO_NO_INCREMENT, FALSE);
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL LpcRequestPort(PEPORT Port,
|
NTSTATUS STDCALL LpcRequestPort(PEPORT Port,
|
||||||
PLPCMESSAGE LpcMessage)
|
PLPC_MESSAGE LpcMessage)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
@ -602,7 +671,7 @@ NTSTATUS STDCALL LpcRequestPort(PEPORT Port,
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtRequestPort (IN HANDLE PortHandle,
|
NTSTATUS STDCALL NtRequestPort (IN HANDLE PortHandle,
|
||||||
IN PLPCMESSAGE LpcMessage /* guess */)
|
IN PLPC_MESSAGE LpcMessage)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PEPORT Port;
|
PEPORT Port;
|
||||||
|
@ -630,8 +699,8 @@ NTSTATUS STDCALL NtRequestPort (IN HANDLE PortHandle,
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL NtRequestWaitReplyPort(IN HANDLE PortHandle,
|
NTSTATUS STDCALL NtRequestWaitReplyPort(IN HANDLE PortHandle,
|
||||||
PLPCMESSAGE LpcRequest,
|
PLPC_MESSAGE LpcRequest,
|
||||||
PLPCMESSAGE LpcReply)
|
PLPC_MESSAGE LpcReply)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PEPORT Port;
|
PEPORT Port;
|
||||||
|
@ -661,6 +730,7 @@ NTSTATUS STDCALL NtRequestWaitReplyPort(IN HANDLE PortHandle,
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
DbgPrint("Enqueue failed\n");
|
||||||
ObDereferenceObject(Port);
|
ObDereferenceObject(Port);
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
@ -680,70 +750,38 @@ NTSTATUS STDCALL NtRequestWaitReplyPort(IN HANDLE PortHandle,
|
||||||
KeAcquireSpinLock(&Port->Lock, &oldIrql);
|
KeAcquireSpinLock(&Port->Lock, &oldIrql);
|
||||||
Message = EiDequeueMessagePort(Port);
|
Message = EiDequeueMessagePort(Port);
|
||||||
KeReleaseSpinLock(&Port->Lock, oldIrql);
|
KeReleaseSpinLock(&Port->Lock, oldIrql);
|
||||||
memcpy(LpcReply, &Message->Message, sizeof(*LpcReply));
|
DPRINT("Message->Message.MessageSize %d\n",
|
||||||
|
Message->Message.MessageSize);
|
||||||
|
memcpy(LpcReply, &Message->Message, Message->Message.MessageSize);
|
||||||
ExFreePool(Message);
|
ExFreePool(Message);
|
||||||
|
|
||||||
|
ObDereferenceObject(Port);
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtReplyWaitReplyPort(PVOID a, PVOID b)
|
NTSTATUS STDCALL NtReplyWaitReplyPort(HANDLE PortHandle,
|
||||||
|
PLPC_MESSAGE ReplyMessage)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
NTSTATUS STDCALL NtReadRequestData (HANDLE PortHandle,
|
||||||
* NAME SYSTEM
|
PLPC_MESSAGE Message,
|
||||||
* NtReadRequestData NOT EXPORTED
|
ULONG Index,
|
||||||
*
|
PVOID Buffer,
|
||||||
* DESCRIPTION
|
ULONG BufferLength,
|
||||||
* Probably used only for FastLPC, to read data from the
|
PULONG Returnlength)
|
||||||
* recipient's address space directly.
|
|
||||||
*
|
|
||||||
* ARGUMENTS
|
|
||||||
*
|
|
||||||
* RETURN VALUE
|
|
||||||
*
|
|
||||||
* NOTE
|
|
||||||
* The number of arguments is the same as in NT's.
|
|
||||||
*
|
|
||||||
* REVISIONS
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
NTSTATUS STDCALL NtReadRequestData (DWORD a0,
|
|
||||||
DWORD a1,
|
|
||||||
DWORD a2,
|
|
||||||
DWORD a3,
|
|
||||||
DWORD a4,
|
|
||||||
DWORD a5)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL NtWriteRequestData (HANDLE PortHandle,
|
||||||
/**********************************************************************
|
PLPC_MESSAGE Message,
|
||||||
* NAME SYSTEM
|
ULONG Index,
|
||||||
* NtWriteRequestData NOT EXPORTED
|
PVOID Buffer,
|
||||||
*
|
ULONG BufferLength,
|
||||||
* DESCRIPTION
|
PULONG ReturnLength)
|
||||||
* Probably used only for FastLPC, to write data in the
|
|
||||||
* recipient's address space directly.
|
|
||||||
*
|
|
||||||
* ARGUMENTS
|
|
||||||
*
|
|
||||||
* RETURN VALUE
|
|
||||||
*
|
|
||||||
* NOTE
|
|
||||||
* The number of arguments is the same as in NT's.
|
|
||||||
*
|
|
||||||
* REVISIONS
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
NTSTATUS STDCALL NtWriteRequestData (DWORD a0,
|
|
||||||
DWORD a1,
|
|
||||||
DWORD a2,
|
|
||||||
DWORD a3,
|
|
||||||
DWORD a4,
|
|
||||||
DWORD a5)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: handle.c,v 1.19 2000/03/26 22:00:09 dwelch Exp $
|
/* $Id: handle.c,v 1.20 2000/04/03 21:54:40 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -464,8 +464,8 @@ NTSTATUS ObReferenceObjectByHandle(HANDLE Handle,
|
||||||
ASSERT_IRQL(PASSIVE_LEVEL);
|
ASSERT_IRQL(PASSIVE_LEVEL);
|
||||||
|
|
||||||
DPRINT("ObReferenceObjectByHandle(Handle %x, DesiredAccess %x, "
|
DPRINT("ObReferenceObjectByHandle(Handle %x, DesiredAccess %x, "
|
||||||
"ObjectType %x, AccessMode %d, Object %x)\n",Handle,DesiredAccess,
|
"ObjectType %x, AccessMode %d, Object %x)\n",Handle,DesiredAccess,
|
||||||
ObjectType,AccessMode,Object);
|
ObjectType,AccessMode,Object);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -474,6 +474,8 @@ NTSTATUS ObReferenceObjectByHandle(HANDLE Handle,
|
||||||
if (Handle == NtCurrentProcess() &&
|
if (Handle == NtCurrentProcess() &&
|
||||||
(ObjectType == PsProcessType || ObjectType == NULL))
|
(ObjectType == PsProcessType || ObjectType == NULL))
|
||||||
{
|
{
|
||||||
|
DPRINT("Reference from %x\n", ((PULONG)&Handle)[-1]);
|
||||||
|
|
||||||
ObReferenceObjectByPointer(PsGetCurrentProcess(),
|
ObReferenceObjectByPointer(PsGetCurrentProcess(),
|
||||||
PROCESS_ALL_ACCESS,
|
PROCESS_ALL_ACCESS,
|
||||||
PsProcessType,
|
PsProcessType,
|
||||||
|
@ -531,6 +533,11 @@ NTSTATUS ObReferenceObjectByHandle(HANDLE Handle,
|
||||||
return(STATUS_OBJECT_TYPE_MISMATCH);
|
return(STATUS_OBJECT_TYPE_MISMATCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ObjectHeader->ObjectType == PsProcessType)
|
||||||
|
{
|
||||||
|
DPRINT("Reference from %x\n", ((PULONG)&Handle)[-1]);
|
||||||
|
}
|
||||||
|
|
||||||
if (!(GrantedAccess & DesiredAccess) &&
|
if (!(GrantedAccess & DesiredAccess) &&
|
||||||
!((~GrantedAccess) & DesiredAccess))
|
!((~GrantedAccess) & DesiredAccess))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: object.c,v 1.21 2000/02/20 22:52:49 ea Exp $
|
/* $Id: object.c,v 1.22 2000/04/03 21:54:40 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -334,24 +334,20 @@ ULONG ObGetHandleCount(PVOID ObjectBody)
|
||||||
* RETURN VALUE
|
* RETURN VALUE
|
||||||
* The current value of the reference counter.
|
* The current value of the reference counter.
|
||||||
*/
|
*/
|
||||||
ULONG
|
ULONG FASTCALL ObfReferenceObject(PVOID ObjectBody)
|
||||||
FASTCALL
|
|
||||||
ObfReferenceObject (PVOID ObjectBody)
|
|
||||||
{
|
{
|
||||||
POBJECT_HEADER Header = BODY_TO_HEADER(ObjectBody);
|
POBJECT_HEADER Header = BODY_TO_HEADER(ObjectBody);
|
||||||
ULONG ReferenceCount;
|
ULONG ReferenceCount;
|
||||||
|
|
||||||
ReferenceCount = ++ Header->RefCount;
|
|
||||||
|
|
||||||
ObPerformRetentionChecks (Header);
|
ReferenceCount = Header->RefCount++;
|
||||||
|
|
||||||
return (ReferenceCount);
|
ObPerformRetentionChecks (Header);
|
||||||
|
|
||||||
|
return(ReferenceCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID FASTCALL ObfDereferenceObject (PVOID ObjectBody)
|
||||||
FASTCALL
|
|
||||||
ObfDereferenceObject (PVOID ObjectBody)
|
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Decrements a given object's reference count and performs
|
* FUNCTION: Decrements a given object's reference count and performs
|
||||||
* retention checks
|
* retention checks
|
||||||
|
@ -384,11 +380,19 @@ ObfDereferenceObject (PVOID ObjectBody)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID STDCALL ObDereferenceObject (PVOID ObjectBody)
|
||||||
STDCALL
|
|
||||||
ObDereferenceObject (PVOID ObjectBody)
|
|
||||||
{
|
{
|
||||||
ObfDereferenceObject (ObjectBody);
|
POBJECT_HEADER Header = BODY_TO_HEADER(ObjectBody);
|
||||||
|
extern POBJECT_TYPE PsProcessType;
|
||||||
|
|
||||||
|
if (Header->ObjectType == PsProcessType)
|
||||||
|
{
|
||||||
|
DPRINT("Deref p 0x%x with refcount %d type %x ",
|
||||||
|
ObjectBody, Header->RefCount, PsProcessType);
|
||||||
|
DPRINT("eip %x\n", ((PULONG)&ObjectBody)[-1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
ObfDereferenceObject (ObjectBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: create.c,v 1.12 2000/03/22 18:35:57 dwelch Exp $
|
/* $Id: create.c,v 1.13 2000/04/03 21:54:40 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -368,14 +368,13 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
|
||||||
KeInitializeDpc(&Thread->Tcb.TimerDpc, PiTimeoutThread, Thread);
|
KeInitializeDpc(&Thread->Tcb.TimerDpc, PiTimeoutThread, Thread);
|
||||||
Thread->Tcb.WaitBlockList = NULL;
|
Thread->Tcb.WaitBlockList = NULL;
|
||||||
InsertTailList(&Thread->ThreadsProcess->Pcb.ThreadListHead,
|
InsertTailList(&Thread->ThreadsProcess->Pcb.ThreadListHead,
|
||||||
&Thread->Tcb.ProcessThreadListEntry );
|
&Thread->Tcb.ProcessThreadListEntry);
|
||||||
// DPRINT1("Inserting %x into process %x list\n",
|
InitializeListHead(&Thread->TerminationPortList);
|
||||||
// Thread, Thread->ThreadsProcess);
|
|
||||||
KeInitializeDispatcherHeader(&Thread->Tcb.DispatcherHeader,
|
KeInitializeDispatcherHeader(&Thread->Tcb.DispatcherHeader,
|
||||||
InternalThreadType,
|
InternalThreadType,
|
||||||
sizeof(ETHREAD),
|
sizeof(ETHREAD),
|
||||||
FALSE);
|
FALSE);
|
||||||
|
KeInitializeSpinLock(&Thread->ActiveTimerListLock);
|
||||||
InitializeListHead(&Thread->IrpList);
|
InitializeListHead(&Thread->IrpList);
|
||||||
Thread->Cid.UniqueThread = (HANDLE)InterlockedIncrement(
|
Thread->Cid.UniqueThread = (HANDLE)InterlockedIncrement(
|
||||||
&PiNextThreadUniqueId);
|
&PiNextThreadUniqueId);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <internal/ke.h>
|
#include <internal/ke.h>
|
||||||
#include <internal/mm.h>
|
#include <internal/mm.h>
|
||||||
#include <internal/ob.h>
|
#include <internal/ob.h>
|
||||||
|
#include <internal/port.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
@ -170,8 +171,8 @@ VOID PsTerminateOtherThread(PETHREAD Thread, NTSTATUS ExitStatus)
|
||||||
NTSTATUS STDCALL PiTerminateProcess(PEPROCESS Process,
|
NTSTATUS STDCALL PiTerminateProcess(PEPROCESS Process,
|
||||||
NTSTATUS ExitStatus)
|
NTSTATUS ExitStatus)
|
||||||
{
|
{
|
||||||
DPRINT("PiTerminateProcess(Process %x, ExitStatus %x)\n",
|
DPRINT1("PiTerminateProcess(Process %x, ExitStatus %x) RC %d\n",
|
||||||
Process, ExitStatus);
|
Process, ExitStatus, ObGetReferenceCount(Process));
|
||||||
|
|
||||||
if (Process->Pcb.ProcessState == PROCESS_STATE_TERMINATED)
|
if (Process->Pcb.ProcessState == PROCESS_STATE_TERMINATED)
|
||||||
{
|
{
|
||||||
|
@ -185,6 +186,7 @@ NTSTATUS STDCALL PiTerminateProcess(PEPROCESS Process,
|
||||||
Process->Pcb.DispatcherHeader.SignalState = TRUE;
|
Process->Pcb.DispatcherHeader.SignalState = TRUE;
|
||||||
KeDispatcherObjectWake(&Process->Pcb.DispatcherHeader);
|
KeDispatcherObjectWake(&Process->Pcb.DispatcherHeader);
|
||||||
KeReleaseDispatcherDatabaseLock(FALSE);
|
KeReleaseDispatcherDatabaseLock(FALSE);
|
||||||
|
DPRINT("RC %d\n", ObGetReferenceCount(Process));
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,8 +264,53 @@ NTSTATUS PsTerminateSystemThread(NTSTATUS ExitStatus)
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL NtCallTerminatePorts(PETHREAD Thread)
|
||||||
NTSTATUS STDCALL NtRegisterThreadTerminatePort(HANDLE TerminationPort)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
KIRQL oldIrql;
|
||||||
|
PLIST_ENTRY current_entry;
|
||||||
|
PEPORT_TERMINATION_REQUEST current;
|
||||||
|
|
||||||
|
KeAcquireSpinLock(&Thread->ActiveTimerListLock, &oldIrql);
|
||||||
|
while ((current_entry = RemoveHeadList(&Thread->TerminationPortList)) !=
|
||||||
|
&Thread->TerminationPortList);
|
||||||
|
{
|
||||||
|
current = CONTAINING_RECORD(current_entry,
|
||||||
|
EPORT_TERMINATION_REQUEST,
|
||||||
|
ThreadListEntry);
|
||||||
|
KeReleaseSpinLock(&Thread->ActiveTimerListLock, oldIrql);
|
||||||
|
LpcSendTerminationPort(current->Port,
|
||||||
|
Thread->CreateTime);
|
||||||
|
KeAcquireSpinLock(&Thread->ActiveTimerListLock, &oldIrql);
|
||||||
|
}
|
||||||
|
KeReleaseSpinLock(&Thread->ActiveTimerListLock, oldIrql);
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL NtRegisterThreadTerminatePort(HANDLE TerminationPortHandle)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
PEPORT_TERMINATION_REQUEST Request;
|
||||||
|
PEPORT TerminationPort;
|
||||||
|
KIRQL oldIrql;
|
||||||
|
PETHREAD Thread;
|
||||||
|
|
||||||
|
Status = ObReferenceObjectByHandle(TerminationPortHandle,
|
||||||
|
PORT_ALL_ACCESS,
|
||||||
|
ExPortType,
|
||||||
|
UserMode,
|
||||||
|
(PVOID*)&TerminationPort,
|
||||||
|
NULL);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
Request = ExAllocatePool(NonPagedPool, sizeof(Request));
|
||||||
|
Request->Port = TerminationPort;
|
||||||
|
Thread = PsGetCurrentThread();
|
||||||
|
KeAcquireSpinLock(&Thread->ActiveTimerListLock, &oldIrql);
|
||||||
|
InsertTailList(&Thread->TerminationPortList, &Request->ThreadListEntry);
|
||||||
|
KeReleaseSpinLock(&Thread->ActiveTimerListLock, oldIrql);
|
||||||
|
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,7 +186,7 @@ VOID PiDeleteProcess(PVOID ObjectBody)
|
||||||
{
|
{
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
|
|
||||||
DPRINT("PiDeleteProcess(ObjectBody %x)\n",ObjectBody);
|
DPRINT1("PiDeleteProcess(ObjectBody %x)\n",ObjectBody);
|
||||||
|
|
||||||
KeAcquireSpinLock(&PsProcessListLock, &oldIrql);
|
KeAcquireSpinLock(&PsProcessListLock, &oldIrql);
|
||||||
RemoveEntryList(&((PEPROCESS)ObjectBody)->Pcb.ProcessListEntry);
|
RemoveEntryList(&((PEPROCESS)ObjectBody)->Pcb.ProcessListEntry);
|
||||||
|
|
|
@ -25,31 +25,31 @@ VOID CsrInitProcessData(VOID);
|
||||||
|
|
||||||
NTSTATUS CsrCreateProcess (PCSRSS_PROCESS_DATA ProcessData,
|
NTSTATUS CsrCreateProcess (PCSRSS_PROCESS_DATA ProcessData,
|
||||||
PCSRSS_CREATE_PROCESS_REQUEST Request,
|
PCSRSS_CREATE_PROCESS_REQUEST Request,
|
||||||
PLPCMESSAGE* Reply);
|
PCSRSS_API_REPLY Reply);
|
||||||
|
|
||||||
NTSTATUS CsrTerminateProcess(PCSRSS_PROCESS_DATA ProcessData,
|
NTSTATUS CsrTerminateProcess(PCSRSS_PROCESS_DATA ProcessData,
|
||||||
PCSRSS_API_REQUEST LpcMessage,
|
PCSRSS_API_REQUEST LpcMessage,
|
||||||
PLPCMESSAGE* Reply);
|
PCSRSS_API_REPLY Reply);
|
||||||
|
|
||||||
NTSTATUS CsrWriteConsole(PCSRSS_PROCESS_DATA ProcessData,
|
NTSTATUS CsrWriteConsole(PCSRSS_PROCESS_DATA ProcessData,
|
||||||
PCSRSS_API_REQUEST LpcMessage,
|
PCSRSS_API_REQUEST LpcMessage,
|
||||||
PLPCMESSAGE* Reply);
|
PCSRSS_API_REPLY Reply);
|
||||||
|
|
||||||
NTSTATUS CsrAllocConsole(PCSRSS_PROCESS_DATA ProcessData,
|
NTSTATUS CsrAllocConsole(PCSRSS_PROCESS_DATA ProcessData,
|
||||||
PCSRSS_API_REQUEST LpcMessage,
|
PCSRSS_API_REQUEST LpcMessage,
|
||||||
PLPCMESSAGE* Reply);
|
PCSRSS_API_REPLY Reply);
|
||||||
|
|
||||||
NTSTATUS CsrFreeConsole(PCSRSS_PROCESS_DATA ProcessData,
|
NTSTATUS CsrFreeConsole(PCSRSS_PROCESS_DATA ProcessData,
|
||||||
PCSRSS_API_REQUEST LpcMessage,
|
PCSRSS_API_REQUEST LpcMessage,
|
||||||
PLPCMESSAGE* Reply);
|
PCSRSS_API_REPLY Reply);
|
||||||
|
|
||||||
NTSTATUS CsrReadConsole(PCSRSS_PROCESS_DATA ProcessData,
|
NTSTATUS CsrReadConsole(PCSRSS_PROCESS_DATA ProcessData,
|
||||||
PCSRSS_API_REQUEST LpcMessage,
|
PCSRSS_API_REQUEST LpcMessage,
|
||||||
PLPCMESSAGE* Reply);
|
PCSRSS_API_REPLY Reply);
|
||||||
|
|
||||||
NTSTATUS CsrConnectProcess(PCSRSS_PROCESS_DATA ProcessData,
|
NTSTATUS CsrConnectProcess(PCSRSS_PROCESS_DATA ProcessData,
|
||||||
PCSRSS_API_REQUEST Request,
|
PCSRSS_API_REQUEST Request,
|
||||||
PLPCMESSAGE* Reply);
|
PCSRSS_API_REPLY Reply);
|
||||||
|
|
||||||
/* print.c */
|
/* print.c */
|
||||||
VOID DisplayString(LPCWSTR lpwString);
|
VOID DisplayString(LPCWSTR lpwString);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: conio.c,v 1.3 2000/03/22 18:35:59 dwelch Exp $
|
/* $Id: conio.c,v 1.4 2000/04/03 21:54:41 dwelch Exp $
|
||||||
*
|
*
|
||||||
* reactos/subsys/csrss/api/conio.c
|
* reactos/subsys/csrss/api/conio.c
|
||||||
*
|
*
|
||||||
|
@ -23,53 +23,40 @@ static HANDLE KeyboardDeviceHandle;
|
||||||
|
|
||||||
NTSTATUS CsrAllocConsole(PCSRSS_PROCESS_DATA ProcessData,
|
NTSTATUS CsrAllocConsole(PCSRSS_PROCESS_DATA ProcessData,
|
||||||
PCSRSS_API_REQUEST LpcMessage,
|
PCSRSS_API_REQUEST LpcMessage,
|
||||||
PLPCMESSAGE* LpcReply)
|
PCSRSS_API_REPLY LpcReply)
|
||||||
{
|
{
|
||||||
PCSRSS_API_REPLY Reply;
|
LpcReply->Header.MessageSize = sizeof(CSRSS_API_REPLY);
|
||||||
|
LpcReply->Header.DataSize = sizeof(CSRSS_API_REPLY) -
|
||||||
(*LpcReply) = RtlAllocateHeap(CsrssApiHeap,
|
sizeof(LPC_MESSAGE_HEADER);
|
||||||
HEAP_ZERO_MEMORY,
|
|
||||||
sizeof(LPCMESSAGE));
|
|
||||||
(*LpcReply)->ActualMessageLength = sizeof(CSRSS_API_REPLY);
|
|
||||||
(*LpcReply)->TotalMessageLength = sizeof(LPCMESSAGE);
|
|
||||||
Reply = (PCSRSS_API_REPLY)((*LpcReply)->MessageData);
|
|
||||||
|
|
||||||
Reply->Status = STATUS_NOT_IMPLEMENTED;
|
LpcReply->Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
return(STATUS_NOT_IMPLEMENTED);
|
return(STATUS_NOT_IMPLEMENTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS CsrFreeConsole(PCSRSS_PROCESS_DATA ProcessData,
|
NTSTATUS CsrFreeConsole(PCSRSS_PROCESS_DATA ProcessData,
|
||||||
PCSRSS_API_REQUEST LpcMessage,
|
PCSRSS_API_REQUEST LpcMessage,
|
||||||
PLPCMESSAGE* LpcReply)
|
PCSRSS_API_REPLY LpcReply)
|
||||||
{
|
{
|
||||||
PCSRSS_API_REPLY Reply;
|
LpcReply->Header.MessageSize = sizeof(CSRSS_API_REPLY);
|
||||||
|
LpcReply->Header.DataSize = sizeof(CSRSS_API_REPLY) -
|
||||||
(*LpcReply) = RtlAllocateHeap(CsrssApiHeap,
|
sizeof(LPC_MESSAGE_HEADER);
|
||||||
HEAP_ZERO_MEMORY,
|
|
||||||
sizeof(LPCMESSAGE));
|
|
||||||
(*LpcReply)->ActualMessageLength = sizeof(CSRSS_API_REPLY);
|
|
||||||
(*LpcReply)->TotalMessageLength = sizeof(LPCMESSAGE);
|
|
||||||
Reply = (PCSRSS_API_REPLY)((*LpcReply)->MessageData);
|
|
||||||
|
|
||||||
Reply->Status = STATUS_NOT_IMPLEMENTED;
|
LpcReply->Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
return(STATUS_NOT_IMPLEMENTED);
|
return(STATUS_NOT_IMPLEMENTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS CsrReadConsole(PCSRSS_PROCESS_DATA ProcessData,
|
NTSTATUS CsrReadConsole(PCSRSS_PROCESS_DATA ProcessData,
|
||||||
PCSRSS_API_REQUEST LpcMessage,
|
PCSRSS_API_REQUEST LpcMessage,
|
||||||
PLPCMESSAGE* LpcReply)
|
PCSRSS_API_REPLY LpcReply)
|
||||||
{
|
{
|
||||||
KEY_EVENT_RECORD KeyEventRecord;
|
KEY_EVENT_RECORD KeyEventRecord;
|
||||||
BOOL stat = TRUE;
|
|
||||||
PCHAR Buffer;
|
PCHAR Buffer;
|
||||||
DWORD Result;
|
|
||||||
int i;
|
int i;
|
||||||
ULONG nNumberOfCharsToRead;
|
ULONG nNumberOfCharsToRead;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
IO_STATUS_BLOCK Iosb;
|
IO_STATUS_BLOCK Iosb;
|
||||||
PCSRSS_API_REPLY Reply;
|
|
||||||
|
|
||||||
// DbgPrint("CSR: CsrReadConsole()\n");
|
// DbgPrint("CSR: CsrReadConsole()\n");
|
||||||
|
|
||||||
|
@ -78,14 +65,11 @@ NTSTATUS CsrReadConsole(PCSRSS_PROCESS_DATA ProcessData,
|
||||||
|
|
||||||
// DbgPrint("CSR: NrCharactersToRead %d\n", nNumberOfCharsToRead);
|
// DbgPrint("CSR: NrCharactersToRead %d\n", nNumberOfCharsToRead);
|
||||||
|
|
||||||
(*LpcReply) = RtlAllocateHeap(CsrssApiHeap,
|
LpcReply->Header.MessageSize = sizeof(CSRSS_API_REPLY) +
|
||||||
HEAP_ZERO_MEMORY,
|
|
||||||
sizeof(LPCMESSAGE));
|
|
||||||
(*LpcReply)->ActualMessageLength = sizeof(CSRSS_API_REPLY) +
|
|
||||||
nNumberOfCharsToRead;
|
nNumberOfCharsToRead;
|
||||||
(*LpcReply)->TotalMessageLength = sizeof(LPCMESSAGE);
|
LpcReply->Header.DataSize = LpcReply->Header.MessageSize -
|
||||||
Reply = (PCSRSS_API_REPLY)((*LpcReply)->MessageData);
|
sizeof(LPC_MESSAGE_HEADER);
|
||||||
Buffer = Reply->Data.ReadConsoleReply.Buffer;
|
Buffer = LpcReply->Data.ReadConsoleReply.Buffer;
|
||||||
|
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
|
@ -104,35 +88,31 @@ NTSTATUS CsrReadConsole(PCSRSS_PROCESS_DATA ProcessData,
|
||||||
0);
|
0);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DbgPrint("CSR: Read failed, bailing\n");
|
// DbgPrint("CSR: Read failed, bailing\n");
|
||||||
}
|
}
|
||||||
if (KeyEventRecord.bKeyDown && KeyEventRecord.uChar.AsciiChar != 0)
|
if (KeyEventRecord.bKeyDown && KeyEventRecord.uChar.AsciiChar != 0)
|
||||||
{
|
{
|
||||||
Buffer[i] = KeyEventRecord.uChar.AsciiChar;
|
Buffer[i] = KeyEventRecord.uChar.AsciiChar;
|
||||||
//DbgPrint("CSR: Read '%c'\n", Buffer[i]);
|
// DbgPrint("CSR: Read '%c'\n", Buffer[i]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reply->Data.ReadConsoleReply.NrCharactersRead = i;
|
LpcReply->Data.ReadConsoleReply.NrCharactersRead = i;
|
||||||
Reply->Status = Status;
|
LpcReply->Status = Status;
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS CsrWriteConsole(PCSRSS_PROCESS_DATA ProcessData,
|
NTSTATUS CsrWriteConsole(PCSRSS_PROCESS_DATA ProcessData,
|
||||||
PCSRSS_API_REQUEST Message,
|
PCSRSS_API_REQUEST Message,
|
||||||
PLPCMESSAGE* LpcReply)
|
PCSRSS_API_REPLY LpcReply)
|
||||||
{
|
{
|
||||||
IO_STATUS_BLOCK Iosb;
|
IO_STATUS_BLOCK Iosb;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PCSRSS_API_REPLY Reply;
|
|
||||||
|
|
||||||
(*LpcReply) = RtlAllocateHeap(CsrssApiHeap,
|
LpcReply->Header.MessageSize = sizeof(CSRSS_API_REPLY);
|
||||||
HEAP_ZERO_MEMORY,
|
LpcReply->Header.DataSize = sizeof(CSRSS_API_REPLY) -
|
||||||
sizeof(LPCMESSAGE));
|
sizeof(LPC_MESSAGE_HEADER);
|
||||||
(*LpcReply)->ActualMessageLength = sizeof(CSRSS_API_REPLY);
|
|
||||||
(*LpcReply)->TotalMessageLength = sizeof(LPCMESSAGE);
|
|
||||||
Reply = (PCSRSS_API_REPLY)((*LpcReply)->MessageData);
|
|
||||||
|
|
||||||
// DbgPrint("CSR: CsrWriteConsole()\n");
|
// DbgPrint("CSR: CsrWriteConsole()\n");
|
||||||
// DbgPrint("CSR: ConsoleDeviceHandle %x\n", ConsoleDeviceHandle);
|
// DbgPrint("CSR: ConsoleDeviceHandle %x\n", ConsoleDeviceHandle);
|
||||||
|
@ -155,8 +135,8 @@ NTSTATUS CsrWriteConsole(PCSRSS_PROCESS_DATA ProcessData,
|
||||||
// DbgPrint("CSR: Write failed\n");
|
// DbgPrint("CSR: Write failed\n");
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
Reply->Data.WriteConsoleReply.NrCharactersWritten = Iosb.Information;
|
LpcReply->Data.WriteConsoleReply.NrCharactersWritten = Iosb.Information;
|
||||||
Reply->Status = STATUS_SUCCESS;
|
LpcReply->Status = STATUS_SUCCESS;
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +187,6 @@ VOID CsrInitConsoleSupport(VOID)
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DbgPrint("CSR: Failed to open keyboard. Expect problems.\n");
|
DbgPrint("CSR: Failed to open keyboard. Expect problems.\n");
|
||||||
for(;;);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DbgPrint("CSR: KeyboardDeviceHandle %x\n", KeyboardDeviceHandle);
|
DbgPrint("CSR: KeyboardDeviceHandle %x\n", KeyboardDeviceHandle);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: process.c,v 1.6 2000/03/22 18:36:00 dwelch Exp $
|
/* $Id: process.c,v 1.7 2000/04/03 21:54:41 dwelch Exp $
|
||||||
*
|
*
|
||||||
* reactos/subsys/csrss/api/process.c
|
* reactos/subsys/csrss/api/process.c
|
||||||
*
|
*
|
||||||
|
@ -60,24 +60,20 @@ PCSRSS_PROCESS_DATA CsrGetProcessData(ULONG ProcessId)
|
||||||
return(ProcessData[i]);
|
return(ProcessData[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DbgPrint("CSR: CsrGetProcessData() failed\n");
|
// DbgPrint("CSR: CsrGetProcessData() failed\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS CsrCreateProcess (PCSRSS_PROCESS_DATA ProcessData,
|
NTSTATUS CsrCreateProcess (PCSRSS_PROCESS_DATA ProcessData,
|
||||||
PCSRSS_CREATE_PROCESS_REQUEST Request,
|
PCSRSS_CREATE_PROCESS_REQUEST Request,
|
||||||
PLPCMESSAGE* LpcReply)
|
PCSRSS_API_REPLY Reply)
|
||||||
{
|
{
|
||||||
PCSRSS_PROCESS_DATA NewProcessData;
|
PCSRSS_PROCESS_DATA NewProcessData;
|
||||||
PCSRSS_API_REPLY Reply;
|
|
||||||
|
|
||||||
(*LpcReply) = RtlAllocateHeap(CsrssApiHeap,
|
Reply->Header.DataSize = sizeof(CSRSS_API_REPLY) -
|
||||||
HEAP_ZERO_MEMORY,
|
sizeof(LPC_MESSAGE_HEADER);
|
||||||
sizeof(LPCMESSAGE));
|
Reply->Header.MessageSize = sizeof(CSRSS_API_REPLY);
|
||||||
(*LpcReply)->ActualMessageLength = sizeof(CSRSS_API_REPLY);
|
|
||||||
(*LpcReply)->TotalMessageLength = sizeof(LPCMESSAGE);
|
|
||||||
Reply = (PCSRSS_API_REPLY)((*LpcReply)->MessageData);
|
|
||||||
|
|
||||||
NewProcessData = CsrGetProcessData(Request->NewProcessId);
|
NewProcessData = CsrGetProcessData(Request->NewProcessId);
|
||||||
|
|
||||||
|
@ -111,25 +107,21 @@ NTSTATUS CsrCreateProcess (PCSRSS_PROCESS_DATA ProcessData,
|
||||||
&Reply->Data.CreateProcessReply.ConsoleHandle,
|
&Reply->Data.CreateProcessReply.ConsoleHandle,
|
||||||
NewProcessData->Console);
|
NewProcessData->Console);
|
||||||
|
|
||||||
DbgPrint("CSR: ConsoleHandle %x\n",
|
// DbgPrint("CSR: ConsoleHandle %x\n",
|
||||||
Reply->Data.CreateProcessReply.ConsoleHandle);
|
// Reply->Data.CreateProcessReply.ConsoleHandle);
|
||||||
DisplayString(L"CSR: Did CreateProcess successfully\n");
|
// DisplayString(L"CSR: Did CreateProcess successfully\n");
|
||||||
|
// DbgPrint("Reply->Header.MessageSize %d\n", Reply->Header.MessageSize);
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS CsrTerminateProcess(PCSRSS_PROCESS_DATA ProcessData,
|
NTSTATUS CsrTerminateProcess(PCSRSS_PROCESS_DATA ProcessData,
|
||||||
PCSRSS_API_REQUEST LpcMessage,
|
PCSRSS_API_REQUEST LpcMessage,
|
||||||
PLPCMESSAGE* LpcReply)
|
PCSRSS_API_REPLY Reply)
|
||||||
{
|
{
|
||||||
PCSRSS_API_REPLY Reply;
|
Reply->Header.MessageSize = sizeof(CSRSS_API_REPLY)
|
||||||
|
- sizeof(LPC_MESSAGE_HEADER);
|
||||||
(*LpcReply) = (PLPCMESSAGE)RtlAllocateHeap(CsrssApiHeap,
|
Reply->Header.DataSize = sizeof(CSRSS_API_REPLY);
|
||||||
HEAP_ZERO_MEMORY,
|
|
||||||
sizeof(LPCMESSAGE));
|
|
||||||
(*LpcReply)->ActualMessageLength = sizeof(CSRSS_API_REPLY);
|
|
||||||
(*LpcReply)->TotalMessageLength = sizeof(LPCMESSAGE);
|
|
||||||
Reply = (PCSRSS_API_REPLY)((*LpcReply)->MessageData);
|
|
||||||
|
|
||||||
Reply->Status = STATUS_NOT_IMPLEMENTED;
|
Reply->Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
@ -138,16 +130,11 @@ NTSTATUS CsrTerminateProcess(PCSRSS_PROCESS_DATA ProcessData,
|
||||||
|
|
||||||
NTSTATUS CsrConnectProcess(PCSRSS_PROCESS_DATA ProcessData,
|
NTSTATUS CsrConnectProcess(PCSRSS_PROCESS_DATA ProcessData,
|
||||||
PCSRSS_API_REQUEST Request,
|
PCSRSS_API_REQUEST Request,
|
||||||
PLPCMESSAGE* LpcReply)
|
PCSRSS_API_REPLY Reply)
|
||||||
{
|
{
|
||||||
PCSRSS_API_REPLY Reply;
|
Reply->Header.MessageSize = sizeof(CSRSS_API_REPLY);
|
||||||
|
Reply->Header.DataSize = sizeof(CSRSS_API_REPLY) -
|
||||||
(*LpcReply) = RtlAllocateHeap(CsrssApiHeap,
|
sizeof(LPC_MESSAGE_HEADER);
|
||||||
HEAP_ZERO_MEMORY,
|
|
||||||
sizeof(LPCMESSAGE));
|
|
||||||
(*LpcReply)->ActualMessageLength = sizeof(CSRSS_API_REPLY);
|
|
||||||
(*LpcReply)->TotalMessageLength = sizeof(LPCMESSAGE);
|
|
||||||
Reply = (PCSRSS_API_REPLY)((*LpcReply)->MessageData);
|
|
||||||
|
|
||||||
Reply->Status = STATUS_SUCCESS;
|
Reply->Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: wapi.c,v 1.5 2000/03/22 18:36:00 dwelch Exp $
|
/* $Id: wapi.c,v 1.6 2000/04/03 21:54:41 dwelch Exp $
|
||||||
*
|
*
|
||||||
* reactos/subsys/csrss/api/wapi.c
|
* reactos/subsys/csrss/api/wapi.c
|
||||||
*
|
*
|
||||||
|
@ -25,36 +25,37 @@ HANDLE CsrssApiHeap;
|
||||||
static void Thread_Api2(HANDLE ServerPort)
|
static void Thread_Api2(HANDLE ServerPort)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PLPCMESSAGE LpcReply;
|
LPC_MAX_MESSAGE LpcReply;
|
||||||
LPCMESSAGE LpcRequest;
|
LPC_MAX_MESSAGE LpcRequest;
|
||||||
PCSRSS_API_REQUEST Request;
|
PCSRSS_API_REQUEST Request;
|
||||||
PCSRSS_PROCESS_DATA ProcessData;
|
PCSRSS_PROCESS_DATA ProcessData;
|
||||||
PCSRSS_API_REPLY Reply;
|
PCSRSS_API_REPLY Reply;
|
||||||
|
|
||||||
LpcReply = NULL;
|
Reply = NULL;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
Status = NtReplyWaitReceivePort(ServerPort,
|
Status = NtReplyWaitReceivePort(ServerPort,
|
||||||
0,
|
0,
|
||||||
LpcReply,
|
&Reply->Header,
|
||||||
&LpcRequest);
|
&LpcRequest.Header);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DisplayString(L"CSR: NtReplyWaitReceivePort failed\n");
|
DisplayString(L"CSR: NtReplyWaitReceivePort failed\n");
|
||||||
}
|
}
|
||||||
if (LpcReply != NULL)
|
|
||||||
|
if (LpcRequest.Header.MessageType == LPC_PORT_CLOSED)
|
||||||
{
|
{
|
||||||
RtlFreeHeap(CsrssApiHeap,
|
// DbgPrint("Client closed port\n");
|
||||||
0,
|
NtClose(ServerPort);
|
||||||
LpcReply);
|
NtTerminateThread(NtCurrentThread(), STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
Request = (PCSRSS_API_REQUEST)LpcRequest.MessageData;
|
Request = (PCSRSS_API_REQUEST)&LpcRequest;
|
||||||
LpcReply = NULL;
|
Reply = (PCSRSS_API_REPLY)&LpcReply;
|
||||||
Reply = NULL;
|
|
||||||
|
|
||||||
ProcessData = CsrGetProcessData(LpcRequest.ClientProcessId);
|
ProcessData = CsrGetProcessData(
|
||||||
|
(ULONG)LpcRequest.Header.Cid.UniqueProcess);
|
||||||
|
|
||||||
// DisplayString(L"CSR: Received request\n");
|
// DisplayString(L"CSR: Received request\n");
|
||||||
|
|
||||||
|
@ -63,58 +64,51 @@ static void Thread_Api2(HANDLE ServerPort)
|
||||||
case CSRSS_CREATE_PROCESS:
|
case CSRSS_CREATE_PROCESS:
|
||||||
Status = CsrCreateProcess(ProcessData,
|
Status = CsrCreateProcess(ProcessData,
|
||||||
&Request->Data.CreateProcessRequest,
|
&Request->Data.CreateProcessRequest,
|
||||||
&LpcReply);
|
Reply);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CSRSS_TERMINATE_PROCESS:
|
case CSRSS_TERMINATE_PROCESS:
|
||||||
Status = CsrTerminateProcess(ProcessData,
|
Status = CsrTerminateProcess(ProcessData,
|
||||||
Request,
|
Request,
|
||||||
&LpcReply);
|
Reply);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CSRSS_WRITE_CONSOLE:
|
case CSRSS_WRITE_CONSOLE:
|
||||||
Status = CsrWriteConsole(ProcessData,
|
Status = CsrWriteConsole(ProcessData,
|
||||||
Request,
|
Request,
|
||||||
&LpcReply);
|
Reply);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CSRSS_READ_CONSOLE:
|
case CSRSS_READ_CONSOLE:
|
||||||
Status = CsrReadConsole(ProcessData,
|
Status = CsrReadConsole(ProcessData,
|
||||||
Request,
|
Request,
|
||||||
&LpcReply);
|
Reply);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CSRSS_ALLOC_CONSOLE:
|
case CSRSS_ALLOC_CONSOLE:
|
||||||
Status = CsrAllocConsole(ProcessData,
|
Status = CsrAllocConsole(ProcessData,
|
||||||
Request,
|
Request,
|
||||||
&LpcReply);
|
Reply);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CSRSS_FREE_CONSOLE:
|
case CSRSS_FREE_CONSOLE:
|
||||||
Status = CsrFreeConsole(ProcessData,
|
Status = CsrFreeConsole(ProcessData,
|
||||||
Request,
|
Request,
|
||||||
&LpcReply);
|
Reply);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CSRSS_CONNECT_PROCESS:
|
case CSRSS_CONNECT_PROCESS:
|
||||||
Status = CsrConnectProcess(ProcessData,
|
Status = CsrConnectProcess(ProcessData,
|
||||||
Request,
|
Request,
|
||||||
&LpcReply);
|
Reply);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
LpcReply = RtlAllocateHeap(CsrssApiHeap,
|
Reply->Header.DataSize = sizeof(CSRSS_API_REPLY) -
|
||||||
HEAP_ZERO_MEMORY,
|
sizeof(LPC_MESSAGE_HEADER);
|
||||||
sizeof(LPCMESSAGE));
|
Reply->Header.MessageSize = sizeof(CSRSS_API_REPLY);
|
||||||
Reply = (PCSRSS_API_REPLY)(LpcReply->MessageData);
|
|
||||||
Reply->Status = STATUS_NOT_IMPLEMENTED;
|
Reply->Status = STATUS_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
Reply = (PCSRSS_API_REPLY)(LpcReply->MessageData);
|
|
||||||
if (Reply->Status == STATUS_SUCCESS)
|
|
||||||
{
|
|
||||||
// DisplayString(L"CSR: Returning STATUS_SUCCESS\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,8 +123,9 @@ static void Thread_Api2(HANDLE ServerPort)
|
||||||
void Thread_Api(PVOID PortHandle)
|
void Thread_Api(PVOID PortHandle)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
LPCMESSAGE Request;
|
LPC_MAX_MESSAGE Request;
|
||||||
HANDLE ServerPort;
|
HANDLE ServerPort;
|
||||||
|
HANDLE ServerThread;
|
||||||
|
|
||||||
CsrssApiHeap = RtlCreateHeap(HEAP_GROWABLE,
|
CsrssApiHeap = RtlCreateHeap(HEAP_GROWABLE,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -149,7 +144,7 @@ void Thread_Api(PVOID PortHandle)
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
Status = NtListenPort(PortHandle, &Request);
|
Status = NtListenPort(PortHandle, &Request.Header);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DisplayString(L"CSR: NtListenPort() failed\n");
|
DisplayString(L"CSR: NtListenPort() failed\n");
|
||||||
|
@ -183,7 +178,7 @@ void Thread_Api(PVOID PortHandle)
|
||||||
NULL,
|
NULL,
|
||||||
(PTHREAD_START_ROUTINE)Thread_Api2,
|
(PTHREAD_START_ROUTINE)Thread_Api2,
|
||||||
ServerPort,
|
ServerPort,
|
||||||
NULL,
|
&ServerThread,
|
||||||
NULL);
|
NULL);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
@ -191,6 +186,7 @@ void Thread_Api(PVOID PortHandle)
|
||||||
NtClose(ServerPort);
|
NtClose(ServerPort);
|
||||||
NtTerminateThread(NtCurrentThread(), Status);
|
NtTerminateThread(NtCurrentThread(), Status);
|
||||||
}
|
}
|
||||||
|
NtClose(ServerThread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: init.c,v 1.16 2000/03/22 18:36:00 dwelch Exp $
|
/* $Id: init.c,v 1.17 2000/04/03 21:54:41 dwelch Exp $
|
||||||
*
|
*
|
||||||
* init.c - Session Manager initialization
|
* init.c - Session Manager initialization
|
||||||
*
|
*
|
||||||
|
@ -28,6 +28,7 @@
|
||||||
*/
|
*/
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <ntdll/rtl.h>
|
#include <ntdll/rtl.h>
|
||||||
|
#include <napi/lpc.h>
|
||||||
|
|
||||||
#include "smss.h"
|
#include "smss.h"
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: smapi.c,v 1.3 1999/12/28 16:25:21 ekohl Exp $
|
/* $Id: smapi.c,v 1.4 2000/04/03 21:54:42 dwelch Exp $
|
||||||
*
|
*
|
||||||
* Reactos Session Manager
|
* Reactos Session Manager
|
||||||
*
|
*
|
||||||
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
#include <napi/lpc.h>
|
||||||
|
|
||||||
#include "smss.h"
|
#include "smss.h"
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ SmApiThread (HANDLE Port)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG Unknown;
|
ULONG Unknown;
|
||||||
PLPCMESSAGE Reply = NULL;
|
PLPC_MESSAGE Reply = NULL;
|
||||||
LPCMESSAGE Message;
|
LPC_MESSAGE Message;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
DisplayString (L"SmApiThread: running\n");
|
DisplayString (L"SmApiThread: running\n");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue