mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 17:14:41 +00:00
Fix for issue with closing non-existent or already closed handle
svn path=/trunk/; revision=1165
This commit is contained in:
parent
06784b2b11
commit
279b8390a0
3 changed files with 39 additions and 19 deletions
|
@ -1,3 +1,5 @@
|
|||
27/5/00: Fixed issue with closing non-existent or already closed handle
|
||||
|
||||
26/1/99: ZwCreateProcess now maps ntdll rather than the user-mode code
|
||||
|
||||
9/6/99: Implemented ZwOpenProcess
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: startup.c,v 1.24 2000/05/25 15:51:16 ekohl Exp $
|
||||
/* $Id: startup.c,v 1.25 2000/05/27 12:48:59 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -18,7 +18,7 @@
|
|||
#include <csrss/csrss.h>
|
||||
#include <ntdll/csr.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#define NDEBUG
|
||||
#include <ntdll/ntdll.h>
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: handle.c,v 1.21 2000/05/09 21:30:06 ekohl Exp $
|
||||
/* $Id: handle.c,v 1.22 2000/05/27 12:48:59 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -336,21 +336,35 @@ PVOID ObDeleteHandle(PEPROCESS Process, HANDLE Handle)
|
|||
KeAcquireSpinLock(&HandleTable->ListLock, &oldIrql);
|
||||
|
||||
Rep = ObpGetObjectByHandle(HandleTable, Handle);
|
||||
ObjectBody = Rep->ObjectBody;
|
||||
Header = BODY_TO_HEADER(ObjectBody);
|
||||
BODY_TO_HEADER(ObjectBody)->HandleCount--;
|
||||
ObReferenceObjectByPointer(ObjectBody,
|
||||
GENERIC_ALL,
|
||||
NULL,
|
||||
UserMode);
|
||||
Rep->ObjectBody = NULL;
|
||||
|
||||
KeReleaseSpinLock(&HandleTable->ListLock, oldIrql);
|
||||
|
||||
if ((Header->ObjectType != NULL) &&
|
||||
(Header->ObjectType->Close != NULL))
|
||||
if (Rep == NULL)
|
||||
{
|
||||
Header->ObjectType->Close(ObjectBody, Header->HandleCount);
|
||||
KeReleaseSpinLock(&HandleTable->ListLock, oldIrql);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
ObjectBody = Rep->ObjectBody;
|
||||
DPRINT("ObjectBody %x\n", ObjectBody);
|
||||
if (ObjectBody != NULL)
|
||||
{
|
||||
Header = BODY_TO_HEADER(ObjectBody);
|
||||
BODY_TO_HEADER(ObjectBody)->HandleCount--;
|
||||
ObReferenceObjectByPointer(ObjectBody,
|
||||
GENERIC_ALL,
|
||||
NULL,
|
||||
UserMode);
|
||||
Rep->ObjectBody = NULL;
|
||||
|
||||
KeReleaseSpinLock(&HandleTable->ListLock, oldIrql);
|
||||
|
||||
if ((Header->ObjectType != NULL) &&
|
||||
(Header->ObjectType->Close != NULL))
|
||||
{
|
||||
Header->ObjectType->Close(ObjectBody, Header->HandleCount);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
KeReleaseSpinLock(&HandleTable->ListLock, oldIrql);
|
||||
}
|
||||
|
||||
DPRINT("Finished ObDeleteHandle()\n");
|
||||
|
@ -576,13 +590,17 @@ NTSTATUS STDCALL NtClose(HANDLE Handle)
|
|||
DPRINT("NtClose(Handle %x)\n",Handle);
|
||||
|
||||
ObjectBody = ObDeleteHandle(PsGetCurrentProcess(), Handle);
|
||||
|
||||
if (ObjectBody == NULL)
|
||||
{
|
||||
return(STATUS_HANDLES_CLOSED);
|
||||
}
|
||||
|
||||
Header = BODY_TO_HEADER(ObjectBody);
|
||||
|
||||
DPRINT("Dereferencing %x\n", ObjectBody);
|
||||
ObDereferenceObject(ObjectBody);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue