*/
NTSTATUS STDCALL
EiReplyOrRequestPort (IN PEPORT Port,
- IN PLPC_MESSAGE LpcReply,
+ IN PPORT_MESSAGE LpcReply,
IN ULONG MessageType,
IN PEPORT Sender)
{
KIRQL oldIrql;
PQUEUEDMESSAGE MessageReply;
+ ULONG Size;
if (Port == NULL)
{
KEBUGCHECK(0);
}
- MessageReply = ExAllocatePoolWithTag(NonPagedPool, sizeof(QUEUEDMESSAGE),
+ Size = sizeof(QUEUEDMESSAGE);
+ if (LpcReply && LpcReply->u1.s1.TotalLength > (CSHORT)sizeof(PORT_MESSAGE))
+ {
+ Size += LpcReply->u1.s1.TotalLength - sizeof(PORT_MESSAGE);
+ }
+ MessageReply = ExAllocatePoolWithTag(NonPagedPool, Size,
TAG_LPC_MESSAGE);
MessageReply->Sender = Sender;
if (LpcReply != NULL)
{
- memcpy(&MessageReply->Message, LpcReply, LpcReply->MessageSize);
+ memcpy(&MessageReply->Message, LpcReply, LpcReply->u1.s1.TotalLength);
+ }
+ else
+ {
+ MessageReply->Message.u1.s1.TotalLength = sizeof(PORT_MESSAGE);
+ MessageReply->Message.u1.s1.DataLength = 0;
}
MessageReply->Message.ClientId.UniqueProcess = PsGetCurrentProcessId();
MessageReply->Message.ClientId.UniqueThread = PsGetCurrentThreadId();
- MessageReply->Message.MessageType = MessageType;
+ MessageReply->Message.u2.s2.Type = MessageType;
MessageReply->Message.MessageId = InterlockedIncrementUL(&LpcpNextMessageId);
KeAcquireSpinLock(&Port->Lock, &oldIrql);
*/
NTSTATUS STDCALL
NtReplyPort (IN HANDLE PortHandle,
- IN PLPC_MESSAGE LpcReply)
+ IN PPORT_MESSAGE LpcReply)
{
NTSTATUS Status;
PEPORT Port;
* REVISIONS
*/
NTSTATUS STDCALL
-NtReplyWaitReceivePortEx(IN HANDLE PortHandle,
- OUT PULONG PortId,
- IN PLPC_MESSAGE LpcReply,
- OUT PLPC_MESSAGE LpcMessage,
- IN PLARGE_INTEGER Timeout)
+NtReplyWaitReceivePortEx(IN HANDLE PortHandle,
+ OUT PVOID *PortContext OPTIONAL,
+ IN PPORT_MESSAGE ReplyMessage OPTIONAL,
+ OUT PPORT_MESSAGE ReceiveMessage,
+ IN PLARGE_INTEGER Timeout OPTIONAL)
{
PEPORT Port;
KIRQL oldIrql;
PreviousMode = ExGetPreviousMode();
DPRINT("NtReplyWaitReceivePortEx(PortHandle %x, LpcReply %x, "
- "LpcMessage %x)\n", PortHandle, LpcReply, LpcMessage);
+ "LpcMessage %x)\n", PortHandle, ReplyMessage, ReceiveMessage);
if (PreviousMode != KernelMode)
{
_SEH_TRY
{
- ProbeForWrite(LpcMessage,
- sizeof(LPC_MESSAGE),
+ ProbeForWrite(ReceiveMessage,
+ sizeof(PORT_MESSAGE),
1);
}
_SEH_HANDLE
/*
* Send the reply, only if port is connected
*/
- if (LpcReply != NULL && !Disconnected)
+ if (ReplyMessage != NULL && !Disconnected)
{
Status = EiReplyOrRequestPort(Port->OtherPort,
- LpcReply,
+ ReplyMessage,
LPC_REPLY,
Port);
KeReleaseSemaphore(&Port->OtherPort->Semaphore, IO_NO_INCREMENT, 1,
Request = EiDequeueMessagePort(Port);
KeReleaseSpinLock(&Port->Lock, oldIrql);
- if (Request->Message.MessageType == LPC_CONNECTION_REQUEST)
+ if (Request == NULL)
+ {
+ ObDereferenceObject(Port);
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ if (Request->Message.u2.s2.Type == LPC_CONNECTION_REQUEST)
{
- LPC_MESSAGE Header;
+ PORT_MESSAGE Header;
PEPORT_CONNECT_REQUEST_MESSAGE CRequest;
CRequest = (PEPORT_CONNECT_REQUEST_MESSAGE)&Request->Message;
- memcpy(&Header, &Request->Message, sizeof(LPC_MESSAGE));
- Header.DataSize = CRequest->ConnectDataLength;
- Header.MessageSize = Header.DataSize + sizeof(LPC_MESSAGE);
+ memcpy(&Header, &Request->Message, sizeof(PORT_MESSAGE));
+ Header.u1.s1.DataLength = CRequest->ConnectDataLength;
+ Header.u1.s1.TotalLength = Header.u1.s1.DataLength + sizeof(PORT_MESSAGE);
if (PreviousMode != KernelMode)
{
_SEH_TRY
{
- ProbeForWrite((PVOID)(LpcMessage + 1),
+ ProbeForWrite((PVOID)(ReceiveMessage + 1),
CRequest->ConnectDataLength,
1);
- RtlCopyMemory(LpcMessage,
+ RtlCopyMemory(ReceiveMessage,
&Header,
- sizeof(LPC_MESSAGE));
- RtlCopyMemory((PVOID)(LpcMessage + 1),
+ sizeof(PORT_MESSAGE));
+ RtlCopyMemory((PVOID)(ReceiveMessage + 1),
CRequest->ConnectData,
CRequest->ConnectDataLength);
}
}
else
{
- RtlCopyMemory(LpcMessage,
+ RtlCopyMemory(ReceiveMessage,
&Header,
- sizeof(LPC_MESSAGE));
- RtlCopyMemory((PVOID)(LpcMessage + 1),
+ sizeof(PORT_MESSAGE));
+ RtlCopyMemory((PVOID)(ReceiveMessage + 1),
CRequest->ConnectData,
CRequest->ConnectDataLength);
}
{
_SEH_TRY
{
- ProbeForWrite(LpcMessage,
- Request->Message.MessageSize,
+ ProbeForWrite(ReceiveMessage,
+ Request->Message.u1.s1.TotalLength,
1);
- RtlCopyMemory(LpcMessage,
+ RtlCopyMemory(ReceiveMessage,
&Request->Message,
- Request->Message.MessageSize);
+ Request->Message.u1.s1.TotalLength);
}
_SEH_HANDLE
{
}
else
{
- RtlCopyMemory(LpcMessage,
+ RtlCopyMemory(ReceiveMessage,
&Request->Message,
- Request->Message.MessageSize);
+ Request->Message.u1.s1.TotalLength);
}
}
if (!NT_SUCCESS(Status))
ObDereferenceObject(Port);
return(Status);
}
- if (Request->Message.MessageType == LPC_CONNECTION_REQUEST)
+ if (Request->Message.u2.s2.Type == LPC_CONNECTION_REQUEST)
{
KeAcquireSpinLock(&Port->Lock, &oldIrql);
EiEnqueueConnectMessagePort(Port, Request);
* REVISIONS
*/
NTSTATUS STDCALL
-NtReplyWaitReceivePort (IN HANDLE PortHandle,
- OUT PULONG PortId,
- IN PLPC_MESSAGE LpcReply,
- OUT PLPC_MESSAGE LpcMessage)
+NtReplyWaitReceivePort(IN HANDLE PortHandle,
+ OUT PVOID *PortContext OPTIONAL,
+ IN PPORT_MESSAGE ReplyMessage OPTIONAL,
+ OUT PPORT_MESSAGE ReceiveMessage)
{
- return(NtReplyWaitReceivePortEx (PortHandle,
- PortId,
- LpcReply,
- LpcMessage,
- NULL));
+ return NtReplyWaitReceivePortEx(PortHandle,
+ PortContext,
+ ReplyMessage,
+ ReceiveMessage,
+ NULL);
}
/**********************************************************************
*/
NTSTATUS STDCALL
NtReplyWaitReplyPort (HANDLE PortHandle,
- PLPC_MESSAGE ReplyMessage)
+ PPORT_MESSAGE ReplyMessage)
{
UNIMPLEMENTED;
return(STATUS_NOT_IMPLEMENTED);
STDCALL
LpcRequestWaitReplyPort (
IN PEPORT Port,
- IN PLPC_MESSAGE LpcMessageRequest,
- OUT PLPC_MESSAGE LpcMessageReply
+ IN PPORT_MESSAGE LpcMessageRequest,
+ OUT PPORT_MESSAGE LpcMessageReply
)
{
UNIMPLEMENTED;