Index: ntoskrnl/lpc/close.c =================================================================== --- ntoskrnl/lpc/close.c (Revision 56356) +++ ntoskrnl/lpc/close.c (Arbeitskopie) @@ -424,11 +424,21 @@ } } + /* 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; + } + /* Release the lock */ KeReleaseGuardedMutex(&LpcpLock); /* Dereference the object unless it's the same port */ if (ConnectionPort != Port) ObDereferenceObject(ConnectionPort); + } else { @@ -436,15 +446,6 @@ 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);