PLPCP_MESSAGE Message;
PLPCP_PORT_OBJECT ConnectionPort = NULL;
PLPCP_CONNECTION_MESSAGE ConnectMessage;
+ PLPCP_NONPAGED_PORT_QUEUE MessageQueue;
+
PAGED_CODE();
LPCTRACE(LPC_CLOSE_DEBUG, "Port: %p. Flags: %lx\n", Port, Port->Flags);
if (Port->MsgQueue.Semaphore)
{
/* Use the semaphore to find the port queue and free it */
- ExFreePool(CONTAINING_RECORD(Port->MsgQueue.Semaphore,
- LPCP_NONPAGED_PORT_QUEUE,
- Semaphore));
+ MessageQueue = CONTAINING_RECORD(Port->MsgQueue.Semaphore,
+ LPCP_NONPAGED_PORT_QUEUE,
+ Semaphore);
+ ExFreePoolWithTag(MessageQueue, 'troP');
}
}
}
IN ULONG SystemHandleCount)
{
PLPCP_PORT_OBJECT Port = (PLPCP_PORT_OBJECT)Object;
+
LPCTRACE(LPC_CLOSE_DEBUG, "Port: %p. Flags: %lx\n", Port, Port->Flags);
/* Only Server-side Connection Ports need clean up*/
PLIST_ENTRY ListHead, NextEntry;
HANDLE Pid;
CLIENT_DIED_MSG ClientDiedMsg;
- Timeout.QuadPart = -1000000;
+
PAGED_CODE();
LPCTRACE(LPC_CLOSE_DEBUG, "Port: %p. Flags: %lx\n", Port, Port->Flags);
+ Timeout.QuadPart = -1000000;
+
/* Check if this is a communication port */
if ((Port->Flags & LPCP_PORT_TYPE_MASK) == LPCP_COMMUNICATION_PORT)
{
for (;;)
{
/* Send the message */
- if (LpcRequestPort(Port,
- &ClientDiedMsg.h) != STATUS_NO_MEMORY) break;
+ if (LpcRequestPort(Port, &ClientDiedMsg.h) != STATUS_NO_MEMORY)
+ break;
/* Wait until trying again */
KeDelayExecutionThread(KernelMode, FALSE, &Timeout);
/* Dereference the object unless it's the same port */
if (ConnectionPort != Port) ObDereferenceObject(ConnectionPort);
+
+ /* Check if this is a connection port with a server process */
+ if (((Port->Flags & LPCP_PORT_TYPE_MASK) == LPCP_CONNECTION_PORT) &&
+ (ConnectionPort->ServerProcess))
+ {
+ /* Dereference the server process */
+ ObDereferenceObject(ConnectionPort->ServerProcess);
+ ConnectionPort->ServerProcess = NULL;
+ }
}
else
{
KeReleaseGuardedMutex(&LpcpLock);
}
- /* Check if this is a connection port with a server process*/
- if (((Port->Flags & LPCP_PORT_TYPE_MASK) == LPCP_CONNECTION_PORT) &&
- (ConnectionPort->ServerProcess))
- {
- /* Dereference the server process */
- ObDereferenceObject(ConnectionPort->ServerProcess);
- ConnectionPort->ServerProcess = NULL;
- }
-
/* Free client security */
LpcpFreePortClientSecurity(Port);
LPCTRACE(LPC_CLOSE_DEBUG, "Port: %p deleted\n", Port);