From 7bfcc9b94cfb8309cf496a59042a6a8a8e2d1f7a Mon Sep 17 00:00:00 2001 From: Emanuele Aliberti Date: Mon, 29 Jan 2001 00:13:22 +0000 Subject: [PATCH] Stubs for some new LPC functions (w2k). Added some base checking in NtCreatePort's parameters. svn path=/trunk/; revision=1581 --- reactos/ntoskrnl/lpc/connect.c | 39 ++++++++++- reactos/ntoskrnl/lpc/create.c | 124 +++++++++++++++++++++++++++++++-- reactos/ntoskrnl/lpc/reply.c | 66 ++++++++++++++---- 3 files changed, 212 insertions(+), 17 deletions(-) diff --git a/reactos/ntoskrnl/lpc/connect.c b/reactos/ntoskrnl/lpc/connect.c index b8eb952d405..abce66241ac 100644 --- a/reactos/ntoskrnl/lpc/connect.c +++ b/reactos/ntoskrnl/lpc/connect.c @@ -1,4 +1,4 @@ -/* $Id: connect.c,v 1.3 2001/01/18 15:00:09 dwelch Exp $ +/* $Id: connect.c,v 1.4 2001/01/29 00:13:21 ea Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -248,5 +248,42 @@ NtAcceptConnectPort (PHANDLE ServerPortHandle, return (STATUS_SUCCESS); } +/********************************************************************** + * NAME EXPORTED + * NtSecureConnectPort@36 + * + * DESCRIPTION + * Connect to a named port and wait for the other side to + * accept the connection. Possibly verify that the server + * matches the ServerSid (trusted server). + * Present in w2k+. + * + * ARGUMENTS + * ConnectedPort + * PortName + * Qos + * WriteMap + * ServerSid + * ReadMap + * MaxMessageSize + * ConnectInfo + * UserConnectInfoLength + * + * RETURN VALUE + * + */ +NTSTATUS STDCALL +NtSecureConnectPort (OUT PHANDLE ConnectedPort, + IN PUNICODE_STRING PortName, + IN PSECURITY_QUALITY_OF_SERVICE Qos, + IN OUT PLPC_SECTION_WRITE WriteMap OPTIONAL, + IN PSID ServerSid OPTIONAL, + IN OUT PLPC_SECTION_READ ReadMap OPTIONAL, + OUT PULONG MaxMessageSize OPTIONAL, + IN OUT PVOID ConnectInfo OPTIONAL, + IN OUT PULONG UserConnectInfoLength OPTIONAL) +{ + return (STATUS_NOT_IMPLEMENTED); +} /* EOF */ diff --git a/reactos/ntoskrnl/lpc/create.c b/reactos/ntoskrnl/lpc/create.c index 1ffb5fc1d51..504e5174ded 100644 --- a/reactos/ntoskrnl/lpc/create.c +++ b/reactos/ntoskrnl/lpc/create.c @@ -1,4 +1,4 @@ -/* $Id: create.c,v 1.2 2000/10/22 16:36:51 ekohl Exp $ +/* $Id: create.c,v 1.3 2001/01/29 00:13:22 ea Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -19,6 +19,45 @@ #define NDEBUG #include +static +NTSTATUS STDCALL VerifyCreateParameters ( + IN PHANDLE PortHandle, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN ULONG MaxConnectInfoLength, + IN ULONG MaxDataLength, + IN ULONG Reserved + ) +{ + if (NULL == PortHandle) + { + return (STATUS_INVALID_PARAMETER_1); + } + if (NULL == ObjectAttributes) + { + return (STATUS_INVALID_PARAMETER_2); + } + if ( (ObjectAttributes->Attributes & OBJ_OPENLINK) + || (ObjectAttributes->Attributes & OBJ_OPENIF) + || (ObjectAttributes->Attributes & OBJ_EXCLUSIVE) + || (ObjectAttributes->Attributes & OBJ_PERMANENT) + || (ObjectAttributes->Attributes & OBJ_INHERIT) +// || (ObjectAttributes->Attributes & OBJ_KERNEL_HANDLE) + ) + { + return (STATUS_INVALID_PORT_ATTRIBUTES); + } + if (MaxConnectInfoLength > 0x104) /* FIXME: use a macro! */ + { + return (STATUS_INVALID_PARAMETER_3); + } + if (MaxDataLength > 0x148) /* FIXME: use a macro! */ + { + return (STATUS_INVALID_PARAMETER_4); + } + /* FIXME: some checking is done also on Reserved */ + return (STATUS_SUCCESS); +} + NTSTATUS NiCreatePort ( @@ -62,6 +101,22 @@ NiCreatePort ( } +/********************************************************************** + * NAME EXPORTED + * NtCreatePort@20 + * + * DESCRIPTION + * + * ARGUMENTS + * PortHandle, + * ObjectAttributes, + * MaxConnectInfoLength, + * MaxDataLength, + * Reserved + * + * RETURN VALUE + * + */ EXPORTED NTSTATUS STDCALL @@ -77,7 +132,20 @@ NtCreatePort ( NTSTATUS Status; DPRINT("NtCreatePort() Name %x\n", ObjectAttributes->ObjectName->Buffer); - + + /* Verify parameters */ + Status = VerifyCreateParameters ( + PortHandle, + ObjectAttributes, + MaxConnectInfoLength, + MaxDataLength, + Reserved + ); + if (STATUS_SUCCESS != Status) + { + return (Status); + } + /* Ask Ob to create the object */ Port = ObCreateObject ( PortHandle, PORT_ALL_ACCESS, @@ -90,13 +158,61 @@ NtCreatePort ( } Status = NiInitializePort (Port); - Port->MaxConnectInfoLength = 260; - Port->MaxDataLength = 328; + Port->MaxConnectInfoLength = 260; /* FIXME: use a macro! */ + Port->MaxDataLength = 328; /* FIXME: use a macro! */ ObDereferenceObject (Port); return (Status); } +/********************************************************************** + * NAME EXPORTED + * NtCreateWaitablePort@20 + * + * DESCRIPTION + * Waitable ports can be connected to with NtSecureConnectPort. + * No port interface can be used with waitable ports but + * NtReplyWaitReceivePort and NtReplyWaitReceivePortEx. + * Present only in w2k+. + * + * ARGUMENTS + * PortHandle, + * ObjectAttributes, + * MaxConnectInfoLength, + * MaxDataLength, + * Reserved + * + * RETURN VALUE + * + */ +EXPORTED +NTSTATUS +STDCALL +NtCreateWaitablePort ( + OUT PHANDLE PortHandle, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN ULONG MaxConnectInfoLength, + IN ULONG MaxDataLength, + IN ULONG Reserved + ) +{ + NTSTATUS Status; + + /* Verify parameters */ + Status = VerifyCreateParameters ( + PortHandle, + ObjectAttributes, + MaxConnectInfoLength, + MaxDataLength, + Reserved + ); + if (STATUS_SUCCESS != Status) + { + return (Status); + } + /* TODO */ + return (STATUS_NOT_IMPLEMENTED); +} /* EOF */ diff --git a/reactos/ntoskrnl/lpc/reply.c b/reactos/ntoskrnl/lpc/reply.c index 70b7a7d14c9..5875ce9fa10 100644 --- a/reactos/ntoskrnl/lpc/reply.c +++ b/reactos/ntoskrnl/lpc/reply.c @@ -1,4 +1,4 @@ -/* $Id: reply.c,v 1.4 2001/01/18 15:00:09 dwelch Exp $ +/* $Id: reply.c,v 1.5 2001/01/29 00:13:22 ea Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -115,10 +115,18 @@ NtReplyPort (IN HANDLE PortHandle, /********************************************************************** * NAME EXPORTED - * + * NtReplyWaitReceivePortEx + * * DESCRIPTION - * + * Can be used with waitable ports. + * Present only in w2k+. + * * ARGUMENTS + * PortHandle + * PortId + * LpcReply + * LpcMessage + * Timeout * * RETURN VALUE * @@ -126,17 +134,18 @@ NtReplyPort (IN HANDLE PortHandle, * */ NTSTATUS STDCALL -NtReplyWaitReceivePort (HANDLE PortHandle, - PULONG PortId, - PLPC_MESSAGE LpcReply, - PLPC_MESSAGE LpcMessage) +NtReplyWaitReceivePortEx(IN HANDLE PortHandle, + OUT PULONG PortId, + IN PLPC_MESSAGE LpcReply, + OUT PLPC_MESSAGE LpcMessage, + IN PLARGE_INTEGER Timeout) { NTSTATUS Status; PEPORT Port; KIRQL oldIrql; PQUEUEDMESSAGE Request; - DPRINT("NtReplyWaitReceivePort(PortHandle %x, LpcReply %x, " + DPRINT("NtReplyWaitReceivePortEx(PortHandle %x, LpcReply %x, " "LpcMessage %x)\n", PortHandle, LpcReply, LpcMessage); Status = ObReferenceObjectByHandle(PortHandle, @@ -147,7 +156,7 @@ NtReplyWaitReceivePort (HANDLE PortHandle, NULL); if (!NT_SUCCESS(Status)) { - DPRINT1("NtReplyWaitReceivePort() = %x\n", Status); + DPRINT1("NtReplyWaitReceivePortEx() = %x\n", Status); return(Status); } @@ -155,7 +164,7 @@ NtReplyWaitReceivePort (HANDLE PortHandle, Port->State != EPORT_CONNECTED_SERVER && LpcReply != NULL) { - DPRINT1("NtReplyWaitReceivePort() = %x (State was %x)\n", + DPRINT1("NtReplyWaitReceivePortEx() = %x (State was %x)\n", STATUS_PORT_DISCONNECTED, Port->State); return(STATUS_PORT_DISCONNECTED); } @@ -174,7 +183,7 @@ NtReplyWaitReceivePort (HANDLE PortHandle, if (!NT_SUCCESS(Status)) { ObDereferenceObject(Port); - DPRINT1("NtReplyWaitReceivePort() = %x\n", Status); + DPRINT1("NtReplyWaitReceivePortEx() = %x\n", Status); return(Status); } } @@ -191,7 +200,7 @@ NtReplyWaitReceivePort (HANDLE PortHandle, NULL); if (!NT_SUCCESS(Status)) { - DPRINT1("NtReplyWaitReceivePort() = %x\n", Status); + DPRINT1("NtReplyWaitReceivePortEx() = %x\n", Status); return(Status); } @@ -232,6 +241,39 @@ NtReplyWaitReceivePort (HANDLE PortHandle, } +/********************************************************************** + * NAME EXPORTED + * NtReplyWaitReceivePort + * + * DESCRIPTION + * Can be used with waitable ports. + * + * ARGUMENTS + * PortHandle + * PortId + * LpcReply + * LpcMessage + * + * RETURN VALUE + * + * REVISIONS + * + */ +NTSTATUS STDCALL +NtReplyWaitReceivePort (IN HANDLE PortHandle, + OUT PULONG PortId, + IN PLPC_MESSAGE LpcReply, + OUT PLPC_MESSAGE LpcMessage) +{ + return NtReplyWaitReceivePortEx ( + PortHandle, + PortId, + LpcReply, + LpcMessage, + NULL + ); +} + /********************************************************************** * NAME *