From 37dced97251b90e6b0003a2def5959748293b4af Mon Sep 17 00:00:00 2001 From: Hartmut Birr Date: Sun, 28 Aug 2005 11:58:06 +0000 Subject: [PATCH] Allocated the message reply buffer according to the size of the message. svn path=/trunk/; revision=17581 --- reactos/ntoskrnl/include/internal/port.h | 1 - reactos/ntoskrnl/lpc/reply.c | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/reactos/ntoskrnl/include/internal/port.h b/reactos/ntoskrnl/include/internal/port.h index 9e2c51dc87c..a859eff532c 100644 --- a/reactos/ntoskrnl/include/internal/port.h +++ b/reactos/ntoskrnl/include/internal/port.h @@ -88,7 +88,6 @@ typedef struct _QUEUEDMESSAGE PEPORT Sender; LIST_ENTRY QueueListEntry; PORT_MESSAGE Message; - UCHAR MessageData[0x130]; /* FIXME: HACK */ } QUEUEDMESSAGE, *PQUEUEDMESSAGE; typedef struct _LPC_DBG_MESSAGE diff --git a/reactos/ntoskrnl/lpc/reply.c b/reactos/ntoskrnl/lpc/reply.c index 7ebda68a6a6..ae42bb28c44 100644 --- a/reactos/ntoskrnl/lpc/reply.c +++ b/reactos/ntoskrnl/lpc/reply.c @@ -37,19 +37,30 @@ EiReplyOrRequestPort (IN PEPORT Port, { 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 > 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->u1.s1.TotalLength); + 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();